// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include #ifdef JFJOCH_USE_CUDA #include #include #include #include #include "../common/CUDAWrapper.h" #include "../image_analysis/scale_merge/PairSortGPU.h" // The device sort against std::sort, with many repeated first and second values (so both keys decide) // and whole duplicate pairs. TEST_CASE("SortPairsGPU: the order std::sort leaves", "[PairSortGPU]") { if (get_gpu_count() == 0) { WARN("No CUDA GPU present. Skipping SortPairsGPU"); return; } std::mt19937 rng(5); std::uniform_int_distribution coarse(0, 200); std::exponential_distribution fine(1.0); std::vector> v(500000); for (auto &p : v) p = {coarse(rng) * 0.37, coarse(rng) % 3 ? fine(rng) : 0.5 * coarse(rng)}; for (size_t i = 0; i < 1000; ++i) v[v.size() - 1 - i] = v[i]; auto host = v; std::sort(host.begin(), host.end()); SortPairsGPU(v); CHECK(v == host); } #endif