Skip to content

Commit

Permalink
mem_tg: fix support for more than 8 memory channels
Browse files Browse the repository at this point in the history
The sizeof() operator returns the size of an object or type in bytes,
not bits. Instead of calculating the number of bits using, e.g.,
CHAR_BIT * sizeof(), hard-code 64 since it is close to the declaration.

This is a prerequisite for HBM support with up to 32 channels.

Link: #3137
Fixes: 7bf96dc ("mem_tg test multichannel")
Signed-off-by: Peter Colberg <[email protected]>
  • Loading branch information
pcolberg committed Jul 19, 2024
1 parent 5b22807 commit b79e041
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/mem_tg/tg_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ class tg_test : public test_command
int num_channels = 0;
if ((tg_exe_->mem_ch_[0]).find("all") == 0) {
uint64_t mem_capability = tg_exe_->read64(MEM_TG_CTRL);
channels = new int[sizeof(uint64_t)]; // size should be same as mem_capability
for (uint32_t i = 0; i < sizeof(uint64_t); i++) { // number of iterations should be same as mem_capability
channels = new int[64]; // size should be same as mem_capability
for (uint32_t i = 0; i < 64; i++) { // number of iterations should be same as mem_capability
if ((mem_capability & (1ULL << i)) != 0) {
channels[num_channels] = i;
num_channels += 1;
Expand Down

0 comments on commit b79e041

Please sign in to comment.