breagen / MachSuite

Benchmarks for Accelerator Design and Customized Architectures
http://www.eecs.harvard.edu/~reagen/papers/machsuite.pdf
Other
114 stars 47 forks source link

Sort/Radix cosim failed #13

Open xushuoxiang opened 7 months ago

xushuoxiang commented 7 months ago

We utilized the VitisHLS 2020.2 tool for cosimulation and observed discrepancies in the cosimulation results of the Sort/Radix example (the direction we use is sort_dir). Following thorough debugging and analysis, we identified that the VitisHLS tool might have overlooked the read-after-write correlation between the local_scan and last_step_scan functions, resulting in premature updating of the value of bucket[0]. The ultimate successful solution involved explicitly incorporating the dependency of bucket[0]. We temporarily stored the value of bucket[0] at the conclusion of the hist execution and restored it at the onset of the local_scan execution. Some of the codes we modified are as follows:

void hist(int bucket[BUCKETSIZE], int a[SIZE], int exp)
{
    int blockID, i, bucket_indx, a_indx;
    blockID = 0;
    hist_1 : for (blockID=0; blockID<NUMOFBLOCKS; blockID++) {
        hist_2 : for(i=0; i<4; i++) {
            a_indx = blockID * ELEMENTSPERBLOCK + i;
            bucket_indx = ((a[a_indx] >> exp) & 0x3)*NUMOFBLOCKS + blockID + 1;
            bucket[bucket_indx]++;
        }
    }
    lastval=bucket[0];
}

void local_scan(int bucket[BUCKETSIZE])
{
    int radixID, i, bucket_indx;
    bucket[0]=lastval;
    local_1 : for (radixID=0; radixID<SCAN_RADIX; radixID++) {
        local_2 : for (i=1; i<SCAN_BLOCK; i++){
            bucket_indx = radixID*SCAN_BLOCK + i;
            bucket[bucket_indx] += bucket[bucket_indx-1];
        }
    }
}