HIP icon indicating copy to clipboard operation
HIP copied to clipboard

updates to shared memory variable not seen by all threads

Open markdewing opened this issue 4 years ago • 2 comments

Around line 190 in tmpRadixSort5.h, there is an update to shared variable ibs, which is the control variable in a while loop. It appears the update to ibs is not seen by all threads.

Using ibs - either by printing it out, or by assigning it to another shared variable - will fix the problem, and the program runs correctly.

     __shared__ int ibs;
     __shared__ int ibs2;
     ...
      ibs = size - 1;
     __syncthreads();
     while (__syncthreads_and(ibs>0)) {

     ...

      if (threadIdx.x == 0) {
        ibs -= sb;
        // uncomment the next line to fix the hang or error
        //ibs2 = ibs;
      }
      __syncthreads();
  }  

More info in Readme. Build command in "compile.sh" reproduce_sync_failure.tar.gz

markdewing avatar Jul 02 '21 15:07 markdewing

One thread may be needed to update ibs.

// broadcast
if (threadIdx.x == 0) ibs = size - 1;

zjin-lcf avatar Sep 10 '21 02:09 zjin-lcf

Does marking ibs volatile help?

Oblomov avatar Dec 16 '21 09:12 Oblomov

@markdewing Can we go ahead and close this ticket? Thanks!

ppanchad-amd avatar Mar 22 '24 19:03 ppanchad-amd