Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort/Radix cosim failed #13

Open
xushuoxiang opened this issue Feb 29, 2024 · 0 comments
Open

Sort/Radix cosim failed #13

xushuoxiang opened this issue Feb 29, 2024 · 0 comments

Comments

@xushuoxiang
Copy link

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];
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant