@@ -723,17 +723,9 @@ GPUd() void GPUTPCGMMerger::MergeBorderTracks<1>(int32_t nBlocks, int32_t nThrea
723723
724724 if (iThread == 0 ) {
725725 if (iBlock == 0 ) {
726- #ifdef GPUCA_DETERMINISTIC_MODE
727- GPUCommonAlgorithm::sortDeviceDynamic (range1, range1 + N1, [](const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b) { return (a.fMin != b.fMin ) ? (a.fMin < b.fMin ) : (a.fId < b.fId ); });
728- #else
729- GPUCommonAlgorithm::sortDeviceDynamic (range1, range1 + N1, [](const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b) { return a.fMin < b.fMin ; });
730- #endif
726+ GPUCommonAlgorithm::sortDeviceDynamic (range1, range1 + N1, [](const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b) { return GPUCA_DETERMINISTIC_CODE ((a.fMin != b.fMin ) ? (a.fMin < b.fMin ) : (a.fId < b.fId ), a.fMin < b.fMin ); });
731727 } else if (iBlock == 1 ) {
732- #ifdef GPUCA_DETERMINISTIC_MODE
733- GPUCommonAlgorithm::sortDeviceDynamic (range2, range2 + N2, [](const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b) { return (a.fMax != b.fMax ) ? (a.fMax < b.fMax ) : (a.fId < b.fId ); });
734- #else
735- GPUCommonAlgorithm::sortDeviceDynamic (range2, range2 + N2, [](const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b) { return a.fMax < b.fMax ; });
736- #endif
728+ GPUCommonAlgorithm::sortDeviceDynamic (range2, range2 + N2, [](const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b) { return GPUCA_DETERMINISTIC_CODE ((a.fMax != b.fMax ) ? (a.fMax < b.fMax ) : (a.fId < b.fId ), a.fMax < b.fMax ); });
737729 }
738730 }
739731#else
@@ -749,21 +741,13 @@ namespace // anonymous
749741struct MergeBorderTracks_compMax {
750742 GPUd () bool operator ()(const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b)
751743 {
752- #ifdef GPUCA_DETERMINISTIC_MODE
753- return (a.fMax != b.fMax ) ? (a.fMax < b.fMax ) : (a.fId < b.fId );
754- #else
755- return a.fMax < b.fMax ;
756- #endif
744+ return GPUCA_DETERMINISTIC_CODE ((a.fMax != b.fMax ) ? (a.fMax < b.fMax ) : (a.fId < b.fId ), a.fMax < b.fMax );
757745 }
758746};
759747struct MergeBorderTracks_compMin {
760748 GPUd () bool operator ()(const GPUTPCGMBorderRange& a, const GPUTPCGMBorderRange& b)
761749 {
762- #ifdef GPUCA_DETERMINISTIC_MODE
763- return (a.fMin != b.fMin ) ? (a.fMin < b.fMin ) : (a.fId < b.fId );
764- #else
765- return a.fMin < b.fMin ;
766- #endif
750+ return GPUCA_DETERMINISTIC_CODE ((a.fMin != b.fMin ) ? (a.fMin < b.fMin ) : (a.fId < b.fId ), a.fMin < b.fMin );
767751 }
768752};
769753} // anonymous namespace
@@ -904,11 +888,7 @@ GPUd() void GPUTPCGMMerger::MergeBorderTracks<2>(int32_t nBlocks, int32_t nThrea
904888
905889 mTrackLinks [b1.TrackID ()] = iBest2;
906890 if (mergeMode > 0 ) {
907- #ifdef GPUCA_DETERMINISTIC_MODE
908- CAMath::AtomicMax (&mTrackLinks [iBest2], b1.TrackID ());
909- #else
910- mTrackLinks [iBest2] = b1.TrackID ();
911- #endif
891+ GPUCA_DETERMINISTIC_CODE (CAMath::AtomicMax (&mTrackLinks [iBest2], b1.TrackID ()), mTrackLinks [iBest2] = b1.TrackID ());
912892 }
913893 }
914894 // GPUInfo("STAT: sectors %d, %d: all %d merged %d", iSector1, iSector2, statAll, statMerged);
@@ -1467,14 +1447,7 @@ struct GPUTPCGMMerger_CompareClusterIdsLooper {
14671447 if (a1.row != b1.row ) {
14681448 return ((a1.row > b1.row ) ^ ((a.leg - leg) & 1 ) ^ outwards);
14691449 }
1470- #ifdef GPUCA_DETERMINISTIC_MODE
1471- if (a1.id != b1.id ) {
1472- return (a1.id > b1.id );
1473- }
1474- return aa > bb;
1475- #else
1476- return a1.id > b1.id ;
1477- #endif
1450+ return GPUCA_DETERMINISTIC_CODE ((a1.id != b1.id ) ? (a1.id > b1.id ) : (aa > bb), a1.id > b1.id );
14781451 }
14791452};
14801453
@@ -1488,14 +1461,7 @@ struct GPUTPCGMMerger_CompareClusterIds {
14881461 if (a.row != b.row ) {
14891462 return (a.row > b.row );
14901463 }
1491- #ifdef GPUCA_DETERMINISTIC_MODE
1492- if (a.id != b.id ) {
1493- return (a.id > b.id );
1494- }
1495- return aa > bb;
1496- #else
1497- return (a.id > b.id );
1498- #endif
1464+ return GPUCA_DETERMINISTIC_CODE ((a.id != b.id ) ? (a.id > b.id ) : (aa > bb), a.id > b.id );
14991465 }
15001466};
15011467} // anonymous namespace
@@ -1567,20 +1533,20 @@ GPUd() void GPUTPCGMMerger::CollectMergedTracks(int32_t nBlocks, int32_t nThread
15671533 // unpack and sort clusters
15681534 if (nParts > 1 && leg == 0 ) {
15691535 GPUCommonAlgorithm::sort (trackParts, trackParts + nParts, [](const GPUTPCGMSectorTrack* a, const GPUTPCGMSectorTrack* b) {
1570- #ifdef GPUCA_DETERMINISTIC_MODE
1571- if (a->X () != b->X ()) {
1536+ GPUCA_DETERMINISTIC_CODE ( // clang-format off
1537+ if (a->X () != b->X ()) {
1538+ return (a->X () > b->X ());
1539+ }
1540+ if (a->Y () != b->Y ()) {
1541+ return (a->Y () > b->Y ());
1542+ }
1543+ if (a->Z () != b->Z ()) {
1544+ return (a->Z () > b->Z ());
1545+ }
1546+ return a->QPt () > b->QPt ();
1547+ , // !GPUCA_DETERMINISTIC_CODE
15721548 return (a->X () > b->X ());
1573- }
1574- if (a->Y () != b->Y ()) {
1575- return (a->Y () > b->Y ());
1576- }
1577- if (a->Z () != b->Z ()) {
1578- return (a->Z () > b->Z ());
1579- }
1580- return a->QPt () > b->QPt ();
1581- #else
1582- return (a->X () > b->X ());
1583- #endif
1549+ ) // clang-format on
15841550 });
15851551 }
15861552
@@ -1832,20 +1798,18 @@ struct GPUTPCGMMergerSortTracks_comp {
18321798 if (a.Legs () != b.Legs ()) {
18331799 return a.Legs () > b.Legs ();
18341800 }
1835- #ifdef GPUCA_DETERMINISTIC_MODE
1836- if (a.NClusters () != b.NClusters ()) {
1801+ GPUCA_DETERMINISTIC_CODE ( // clang-format off
1802+ if (a.NClusters () != b.NClusters ()) {
1803+ return a.NClusters () > b.NClusters ();
1804+ } if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1805+ return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1806+ } if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1807+ return a.GetParam ().GetY () > b.GetParam ().GetY ();
1808+ }
1809+ return aa > bb;
1810+ , // !GPUCA_DETERMINISTIC_CODE
18371811 return a.NClusters () > b.NClusters ();
1838- }
1839- if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1840- return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1841- }
1842- if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1843- return a.GetParam ().GetY () > b.GetParam ().GetY ();
1844- }
1845- return aa > bb;
1846- #else
1847- return a.NClusters () > b.NClusters ();
1848- #endif
1812+ ) // clang-format on
18491813 }
18501814};
18511815
@@ -1856,17 +1820,16 @@ struct GPUTPCGMMergerSortTracksQPt_comp {
18561820 {
18571821 const GPUTPCGMMergedTrack& GPUrestrict () a = mCmp [aa];
18581822 const GPUTPCGMMergedTrack& GPUrestrict () b = mCmp [bb];
1859- #ifdef GPUCA_DETERMINISTIC_MODE
1860- if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1823+ GPUCA_DETERMINISTIC_CODE ( // clang-format off
1824+ if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1825+ return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1826+ } if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1827+ return a.GetParam ().GetY () > b.GetParam ().GetY ();
1828+ }
1829+ return a.GetParam ().GetZ () > b.GetParam ().GetZ ();
1830+ , // !GPUCA_DETERMINISTIC_CODE
18611831 return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1862- }
1863- if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1864- return a.GetParam ().GetY () > b.GetParam ().GetY ();
1865- }
1866- return a.GetParam ().GetZ () > b.GetParam ().GetZ ();
1867- #else
1868- return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1869- #endif
1832+ ) // clang-format on
18701833 }
18711834};
18721835} // anonymous namespace
@@ -1901,20 +1864,18 @@ GPUd() void GPUTPCGMMerger::SortTracks(int32_t nBlocks, int32_t nThreads, int32_
19011864 if (a.Legs () != b.Legs ()) {
19021865 return a.Legs () > b.Legs ();
19031866 }
1904- #ifdef GPUCA_DETERMINISTIC_MODE
1905- if (a.NClusters () != b.NClusters ()) {
1867+ GPUCA_DETERMINISTIC_CODE ( // clang-format off
1868+ if (a.NClusters () != b.NClusters ()) {
1869+ return a.NClusters () > b.NClusters ();
1870+ } if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1871+ return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1872+ } if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1873+ return a.GetParam ().GetY () > b.GetParam ().GetY ();
1874+ }
1875+ return aa > bb;
1876+ , // !GPUCA_DETERMINISTIC_CODE
19061877 return a.NClusters () > b.NClusters ();
1907- }
1908- if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1909- return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1910- }
1911- if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1912- return a.GetParam ().GetY () > b.GetParam ().GetY ();
1913- }
1914- return aa > bb;
1915- #else
1916- return a.NClusters () > b.NClusters ();
1917- #endif
1878+ ) // clang-format on
19181879 };
19191880
19201881 GPUCommonAlgorithm::sortDeviceDynamic (mTrackOrderProcess , mTrackOrderProcess + mMemory ->nOutputTracks , comp);
@@ -1931,17 +1892,16 @@ GPUd() void GPUTPCGMMerger::SortTracksQPt(int32_t nBlocks, int32_t nThreads, int
19311892 auto comp = [cmp = mOutputTracks ](const int32_t aa, const int32_t bb) {
19321893 const GPUTPCGMMergedTrack& GPUrestrict () a = cmp[aa];
19331894 const GPUTPCGMMergedTrack& GPUrestrict () b = cmp[bb];
1934- #ifdef GPUCA_DETERMINISTIC_MODE
1935- if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1895+ GPUCA_DETERMINISTIC_CODE ( // clang-format off
1896+ if (CAMath::Abs (a.GetParam ().GetQPt ()) != CAMath::Abs (b.GetParam ().GetQPt ())) {
1897+ return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1898+ } if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1899+ return a.GetParam ().GetY () > b.GetParam ().GetY ();
1900+ }
1901+ return a.GetParam ().GetZ () > b.GetParam ().GetZ ();
1902+ , // !GPUCA_DETERMINISTIC_CODE
19361903 return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1937- }
1938- if (a.GetParam ().GetY () != b.GetParam ().GetY ()) {
1939- return a.GetParam ().GetY () > b.GetParam ().GetY ();
1940- }
1941- return a.GetParam ().GetZ () > b.GetParam ().GetZ ();
1942- #else
1943- return CAMath::Abs (a.GetParam ().GetQPt ()) > CAMath::Abs (b.GetParam ().GetQPt ());
1944- #endif
1904+ ) // clang-format on
19451905 };
19461906
19471907 GPUCommonAlgorithm::sortDeviceDynamic (mTrackSort , mTrackSort + mMemory ->nOutputTracks , comp);
0 commit comments