Skip to content

Commit c238a92

Browse files
committed
Resolve the race condition.
1 parent d7ff256 commit c238a92

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/popsift/common/excl_blk_prefix_sum.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,15 @@ class Block
132132
_mapping_writer.set( ebs, self, cell );
133133
}
134134

135+
// Wait to update loop_total until everyone is done.
136+
__syncthreads();
135137
if( threadIdx.y == 0 && threadIdx.x == 31 ) {
136138
loop_total += ibs;
137139
}
138-
__syncthreads();
139140
}
140141

141-
// if( threadIdx.y == 0 && threadIdx.x == 31 )
142-
if( threadIdx.y == 0 )
142+
if( threadIdx.y == 0 && threadIdx.x == 31 )
143143
{
144-
loop_total = popsift::shuffle( loop_total, 31 );
145144
_total_writer.set( loop_total );
146145
}
147146
}

0 commit comments

Comments
 (0)