Skip to content

Commit

Permalink
Additional syncthreads and replace break with continue.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomreis committed Jul 28, 2023
1 parent 6bd38ad commit 45ce573
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions EventFilter/EcalRawToDigi/plugins/UnpackGPU.cu
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ namespace ecal {
for (uint32_t ich = 0; ich < nchannels; ich += NTHREADS) {
auto const i_to_access = ich + threadIdx.x;
if (i_to_access == 0) {
ch_with_bad_block = 999999;
ch_with_bad_block = std::numeric_limits<uint32_t>::max();
}

uint64_t wdata;
uint8_t stripid;
uint8_t xtalid;

// threads must be inside the range (no break here because of __syncthreads() afterwards)
if (i_to_access < nchannels) {
if (i_to_access < nchannels && i_to_access < ch_with_bad_block) {
// inc the channel's counter and get the pos where to store
wdata = current_tower_block[1 + i_to_access * 3];
stripid = wdata & 0x7;
Expand All @@ -299,7 +299,7 @@ namespace ecal {
}
if (i_to_access > 0) {
// check if the stripid has increased or that the xtalid has increased from the previous data word. If not something is wrong and the rest of the block is skipped.
auto const prev_i_to_access = ich + threadIdx.x - 1;
auto const prev_i_to_access = i_to_access - 1;
auto const prevwdata = current_tower_block[1 + prev_i_to_access * 3];
uint8_t const laststripid = prevwdata & 0x7;
uint8_t const lastxtalid = (prevwdata >> 4) & 0x7;
Expand All @@ -309,16 +309,18 @@ namespace ecal {
}
}

__syncthreads();

// check if this thread has the lowest bad block
if (bad_block) {
if (bad_block && i_to_access < ch_with_bad_block) {
atomicMin(&ch_with_bad_block, i_to_access);
}

__syncthreads();

// threads outside of the range or bad block detected in this thread or one working on a lower block -> leave the loop
// threads outside of the range or bad block detected in this thread or one working on a lower block -> stop this loop iteration here
if (i_to_access >= nchannels || i_to_access >= ch_with_bad_block) {
break;
continue;
}

ElectronicsIdGPU eid{fed2dcc(fed), ttid, stripid, xtalid};
Expand Down

0 comments on commit 45ce573

Please sign in to comment.