Skip to content

Commit 08d35fa

Browse files
committed
Added the standart clusterization tests for HIP.
1 parent f896ada commit 08d35fa

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed

tests/hip/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
# TRACCC library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2024 CERN for the benefit of the ACTS project
3+
# (c) 2024-2025 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

7+
# Enable the HIP language.
78
enable_language(HIP)
9+
10+
# Use the HIP runtime library.
11+
find_package(HIPToolkit REQUIRED)
12+
813
traccc_add_test(
914
hip
1015
# Define the sources for the test.
1116
test_thrust.hip
17+
test_cca.cpp
1218
LINK_LIBRARIES
19+
HIP::hiprt
1320
rocthrust
1421
GTest::gtest_main
1522
vecmem::core
1623
vecmem::hip
24+
traccc::core
25+
traccc::device_common
26+
traccc::hip
27+
traccc_tests_common
1728
)
1829

1930
set_target_properties( traccc_test_hip PROPERTIES

tests/hip/test_cca.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2022-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#include <gtest/gtest.h>
9+
10+
#include <functional>
11+
#include <vecmem/memory/hip/device_memory_resource.hpp>
12+
#include <vecmem/memory/host_memory_resource.hpp>
13+
#include <vecmem/utils/hip/async_copy.hpp>
14+
15+
#include "tests/cca_test.hpp"
16+
#include "traccc/clusterization/clustering_config.hpp"
17+
#include "traccc/clusterization/device/tags.hpp"
18+
#include "traccc/geometry/silicon_detector_description.hpp"
19+
#include "traccc/hip/clusterization/clusterization_algorithm.hpp"
20+
#include "traccc/hip/utils/stream.hpp"
21+
22+
namespace {
23+
vecmem::host_memory_resource host_mr;
24+
25+
cca_function_t get_f_with(traccc::clustering_config cfg) {
26+
return [cfg](const traccc::edm::silicon_cell_collection::host& cells,
27+
const traccc::silicon_detector_description::host& dd)
28+
-> std::pair<std::map<traccc::geometry_id,
29+
traccc::edm::measurement_collection<
30+
traccc::default_algebra>::host>,
31+
traccc::edm::silicon_cluster_collection::host> {
32+
std::map<traccc::geometry_id, traccc::edm::measurement_collection<
33+
traccc::default_algebra>::host>
34+
geom_to_meas_map;
35+
36+
traccc::hip::stream stream;
37+
vecmem::hip::device_memory_resource device_mr;
38+
vecmem::hip::async_copy copy{stream.hipStream()};
39+
40+
traccc::hip::clusterization_algorithm cc({device_mr, &host_mr}, copy,
41+
stream, cfg);
42+
43+
traccc::silicon_detector_description::buffer dd_buffer{
44+
static_cast<
45+
traccc::silicon_detector_description::buffer::size_type>(
46+
dd.size()),
47+
device_mr};
48+
copy.setup(dd_buffer)->ignore();
49+
copy(vecmem::get_data(dd), dd_buffer,
50+
vecmem::copy::type::host_to_device)
51+
->ignore();
52+
53+
traccc::edm::silicon_cell_collection::buffer cells_buffer{
54+
static_cast<
55+
traccc::edm::silicon_cell_collection::buffer::size_type>(
56+
cells.size()),
57+
device_mr};
58+
copy.setup(cells_buffer)->wait();
59+
copy(vecmem::get_data(cells), cells_buffer)->wait();
60+
61+
auto [measurements_buffer, cluster_buffer] =
62+
cc(cells_buffer, dd_buffer,
63+
traccc::device::clustering_keep_disjoint_set{});
64+
traccc::edm::measurement_collection<traccc::default_algebra>::host
65+
measurements{host_mr};
66+
copy(measurements_buffer, measurements)->wait();
67+
68+
traccc::edm::silicon_cluster_collection::host clusters{host_mr};
69+
copy(cluster_buffer, clusters)->wait();
70+
71+
for (std::size_t i = 0; i < measurements.size(); i++) {
72+
if (geom_to_meas_map.contains(
73+
measurements.at(i).surface_link().value()) == false) {
74+
geom_to_meas_map.insert(
75+
{measurements.at(i).surface_link().value(),
76+
traccc::edm::measurement_collection<
77+
traccc::default_algebra>::host{host_mr}});
78+
}
79+
geom_to_meas_map.at(measurements.at(i).surface_link().value())
80+
.push_back(measurements.at(i));
81+
}
82+
83+
return {std::move(geom_to_meas_map), std::move(clusters)};
84+
};
85+
}
86+
} // namespace
87+
88+
TEST_P(ConnectedComponentAnalysisTests, Run) {
89+
test_connected_component_analysis(GetParam());
90+
}
91+
92+
INSTANTIATE_TEST_SUITE_P(
93+
HIPFastSvAlgorithm, ConnectedComponentAnalysisTests,
94+
::testing::Combine(
95+
::testing::Values(get_f_with(default_ccl_test_config())),
96+
::testing::ValuesIn(ConnectedComponentAnalysisTests::get_test_files())),
97+
ConnectedComponentAnalysisTests::get_test_name);
98+
99+
INSTANTIATE_TEST_SUITE_P(
100+
HIPFastSvAlgorithmWithScratch, ConnectedComponentAnalysisTests,
101+
::testing::Combine(
102+
::testing::Values(get_f_with(tiny_ccl_test_config())),
103+
::testing::ValuesIn(
104+
ConnectedComponentAnalysisTests::get_test_files_short())),
105+
ConnectedComponentAnalysisTests::get_test_name);

0 commit comments

Comments
 (0)