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

[DO NOT MERGE] remove duplicate pixels #37359

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
57c2e1a
add layer and filter qual
VinInn Mar 11, 2022
e082b5d
on cpu as well
VinInn Mar 11, 2022
3ac8d85
Make both ME1a and ME1b LCT (A/CLCT) sorted into ring 1.
sifuluo Mar 11, 2022
145e293
Merge pull request #37217 from sifuluo/backport12_3
cmsbuild Mar 12, 2022
f9667d9
Merge pull request #37205 from cms-tsg-storm/HLTmigrationTo1230pre6
cmsbuild Mar 12, 2022
907510d
use z as hit id
VinInn Mar 12, 2022
d02578e
introduce real data unit test for pede
mmusich Mar 11, 2022
d30ceca
Bugfix for Strips O2O
tvami Mar 13, 2022
5a61538
Merge pull request #37206 from cms-tsg-storm/UpdateTSGandRelvalGTsFor…
cmsbuild Mar 14, 2022
ebad739
Merge pull request #37235 from mmusich/O2OFix_12_3_X
cmsbuild Mar 14, 2022
ece73a0
Merge pull request #37213 from quark2/GEM-onlineDQMForLumiBasedPlots-…
cmsbuild Mar 14, 2022
e9ca208
Merge pull request #37223 from francescobrivio/alca-tkStatusDCS_12_3_X
cmsbuild Mar 15, 2022
7693016
Merge pull request #37226 from mmusich/addMillePedeTestingSetup_12_3_X
cmsbuild Mar 16, 2022
01e4ab9
Merged DumpTK from repository VinInn with cms-merge-topic
VinInn Mar 16, 2022
ac99b70
detect dup pixels
VinInn Mar 16, 2022
9541733
avoid reading outside buffer
VinInn Mar 16, 2022
4d72974
reproduce CPU
VinInn Mar 18, 2022
f7bb5b6
Merged DupPix from repository VinInn with cms-merge-topic
VinInn Mar 18, 2022
8c0bf85
remove tk dump
VinInn Mar 21, 2022
6e6fcba
Merged DupPix from repository VinInn with cms-merge-topic
VinInn Mar 21, 2022
e09788b
remove all duplicates
VinInn Mar 21, 2022
5cd32ba
add protections
VinInn Mar 22, 2022
ac1dd01
Merged DupPix from repository VinInn with cms-merge-topic
VinInn Mar 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion DataFormats/SiPixelDigi/interface/SiPixelDigiConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ namespace sipixelconstants {
inline constexpr uint32_t getRow(uint32_t ww) { return ((ww >> ROW_shift) & ROW_mask); }
inline constexpr uint32_t getDCol(uint32_t ww) { return ((ww >> DCOL_shift) & DCOL_mask); }
inline constexpr uint32_t getPxId(uint32_t ww) { return ((ww >> PXID_shift) & PXID_mask); }
} // namespace functions
inline constexpr uint32_t removeADC(uint32_t ww) {
return (ww >> ADC_bits);
} // ADC_shift ==0: let's keep it simple
} // namespace functions
} // namespace sipixelconstants

#endif // DataFormats_SiPixelDigi_interface_SiPixelDigiConstants
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ namespace pixelgpudetails {
//if (threadIdx.x==0) printf("Event: %u blockIdx.x: %u start: %u end: %u\n", eventno, blockIdx.x, begin, end);

int32_t first = threadIdx.x + blockIdx.x * blockDim.x;
int32_t lastWord = wordCounter - 1;
for (int32_t iloop = first, nend = wordCounter; iloop < nend; iloop += blockDim.x * gridDim.x) {
auto gIndex = iloop;
xx[gIndex] = 0;
Expand Down Expand Up @@ -440,6 +441,16 @@ namespace pixelgpudetails {
}
}

// remove duplicate pixels (for the time being keep second to reproduce current CPU behaviour)
Copy link
Contributor Author

@VinInn VinInn Mar 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip if following is "duplicate"

auto noADC = sipixelconstants::removeADC(ww);
// auto noADCm1 = sipixelconstants::removeADC(gIndex==0 ? 0 : word[gIndex-1]);
auto noADCp1 = sipixelconstants::removeADC(gIndex == lastWord ? 0 : word[gIndex + 1]);
if (noADC == noADCp1) {
// auto globalPix = frameConversion(barrel, side, layer, rocIdInDetUnit, localPix);
// printf("dup pix at %d %d %d\n",detId.moduleId,globalPix.row,globalPix.col);
continue;
}

pixelgpudetails::Pixel globalPix = frameConversion(barrel, side, layer, rocIdInDetUnit, localPix);
xx[gIndex] = globalPix.row; // origin shifting by 1 0-159
yy[gIndex] = globalPix.col; // origin shifting by 1 0-415
Expand Down Expand Up @@ -656,7 +667,8 @@ namespace pixelgpudetails {
std::cout << "CUDA findClus kernel launch with " << blocks << " blocks of " << threadsPerBlock << " threads\n";
#endif

findClus<false><<<blocks, threadsPerBlock, 0, stream>>>(digis_d.view().moduleInd(),
findClus<false><<<blocks, threadsPerBlock, 0, stream>>>(digis_d.view().rawIdArr(),
digis_d.view().moduleInd(),
digis_d.view().xx(),
digis_d.view().yy(),
clusters_d.moduleStart(),
Expand Down Expand Up @@ -763,7 +775,8 @@ namespace pixelgpudetails {
threadsPerBlock = 256;
blocks = phase2PixelTopology::numberOfModules;

findClus<true><<<blocks, threadsPerBlock, 0, stream>>>(digis_d.view().moduleInd(),
findClus<true><<<blocks, threadsPerBlock, 0, stream>>>(digis_d.view().rawIdArr(),
digis_d.view().moduleInd(),
digis_d.view().xx(),
digis_d.view().yy(),
clusters_d.moduleStart(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace gpuClustering {
auto endModule = moduleStart[0];
for (auto module = firstModule; module < endModule; module += gridDim.x) {
auto firstPixel = moduleStart[1 + module];
while (id[firstPixel] == invalidModuleId)
++firstPixel; // could be duplicates!
auto thisModuleId = id[firstPixel];
assert(thisModuleId < nMaxModules);
assert(thisModuleId == moduleId[module]);
Expand Down
30 changes: 29 additions & 1 deletion RecoLocalTracker/SiPixelClusterizer/plugins/gpuClustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace gpuClustering {
}

template <bool isPhase2>
__global__ void findClus(uint16_t const* __restrict__ id, // module id of each pixel
__global__ void findClus(uint32_t* __restrict__ rawIdArr,
uint16_t* __restrict__ id, // module id of each pixel
uint16_t const* __restrict__ x, // local coordinates of each pixel
uint16_t const* __restrict__ y, //
uint32_t const* __restrict__ moduleStart, // index of the first pixel of each module
Expand Down Expand Up @@ -103,6 +104,14 @@ namespace gpuClustering {
printf("too many pixels in module %d: %d > %d\n", thisModuleId, msize - firstPixel, maxPixInModule);
msize = maxPixInModule + firstPixel;
}
/*
/// dump
if (thisModuleId==1) {
printf ("dump for mod 1\n");
for (int k = int(firstPixel); k< msize; ++k) printf ("%d %d\n",x[k],y[k]);
printf ("end dump for mod 1\n");
}
*/
}

__syncthreads();
Expand All @@ -114,6 +123,24 @@ namespace gpuClustering {
__syncthreads();
#endif

// remove duplicate
if (msize > 1)
for (int i = first; i < msize - 1; i += blockDim.x) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full combinatorics in one module to search for duplicates

if (id[i] == invalidModuleId) // skip invalid pixels
continue;
for (int j = i + 1; j < msize; ++j) {
if (id[j] == invalidModuleId) // skip invalid pixels
continue;
if (y[i] == y[j] && x[i] == x[j]) {
// printf("found dup %d %d %d %d %d\n",i,j,id[i],x[i], y[i]);
id[i] = invalidModuleId;
rawIdArr[i] = 0;
break;
}
}
}
__syncthreads();

// fill histo
for (int i = first; i < msize; i += blockDim.x) {
if (id[i] == invalidModuleId) // skip invalid pixels
Expand Down Expand Up @@ -204,6 +231,7 @@ namespace gpuClustering {
continue;
auto l = nnn[k]++;
assert(l < maxNeighbours);
// if (l>=5) printf("too many Neighbours! %d %d %d\n",thisModuleId, x[i], y[i]);
nn[k][l] = *p;
}
}
Expand Down
14 changes: 12 additions & 2 deletions RecoLocalTracker/SiPixelClusterizer/test/gpuClustering_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ int main(void) {
constexpr SiPixelClusterThresholds clusterThresholds(kSiPixelClusterThresholdsDefaultPhase1);

// these in reality are already on GPU
auto h_raw = std::make_unique<uint32_t[]>(numElements);
auto h_id = std::make_unique<uint16_t[]>(numElements);
auto h_x = std::make_unique<uint16_t[]>(numElements);
auto h_y = std::make_unique<uint16_t[]>(numElements);
auto h_adc = std::make_unique<uint16_t[]>(numElements);
auto h_clus = std::make_unique<int[]>(numElements);

#ifdef __CUDACC__
auto d_raw = cms::cuda::make_device_unique<uint32_t[]>(numElements, nullptr);
auto d_id = cms::cuda::make_device_unique<uint16_t[]>(numElements, nullptr);
auto d_x = cms::cuda::make_device_unique<uint16_t[]>(numElements, nullptr);
auto d_y = cms::cuda::make_device_unique<uint16_t[]>(numElements, nullptr);
Expand Down Expand Up @@ -265,6 +267,7 @@ int main(void) {

cms::cuda::launch(findClus<false>,
{blocksPerGrid, threadsPerBlock},
d_raw.get(),
d_id.get(),
d_x.get(),
d_y.get(),
Expand Down Expand Up @@ -305,8 +308,15 @@ int main(void) {
h_moduleStart[0] = nModules;
countModules<false>(h_id.get(), h_moduleStart.get(), h_clus.get(), n);
memset(h_clusInModule.get(), 0, maxNumModules * sizeof(uint32_t));
findClus<false>(
h_id.get(), h_x.get(), h_y.get(), h_moduleStart.get(), h_clusInModule.get(), h_moduleId.get(), h_clus.get(), n);
findClus<false>(h_raw.get(),
h_id.get(),
h_x.get(),
h_y.get(),
h_moduleStart.get(),
h_clusInModule.get(),
h_moduleId.get(),
h_clus.get(),
n);

nModules = h_moduleStart[0];
auto nclus = h_clusInModule.get();
Expand Down