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

Add SYCL tests for CCA code #630

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions tests/sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ traccc_add_test(
test_barrier.sycl
test_mutex.sycl
test_unique_lock.sycl
test_cca.sycl

LINK_LIBRARIES
GTest::gtest_main
Expand Down
69 changes: 69 additions & 0 deletions tests/sycl/test_cca.sycl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#include <gtest/gtest.h>

#include <CL/sycl.hpp>
#include <functional>
#include <vecmem/memory/host_memory_resource.hpp>
#include <vecmem/memory/sycl/device_memory_resource.hpp>
#include <vecmem/utils/sycl/async_copy.hpp>

#include "tests/cca_test.hpp"
#include "traccc/sycl/clusterization/clusterization_algorithm.hpp"

namespace {

cca_function_t f = [](const traccc::cell_collection_types::host& cells,
const traccc::cell_module_collection_types::host&
modules) {
std::map<traccc::geometry_id, vecmem::vector<traccc::measurement>> result;

vecmem::host_memory_resource host_mr;
cl::sycl::queue queue;
vecmem::sycl::device_memory_resource device_mr;
vecmem::sycl::async_copy copy{&queue};

traccc::sycl::clusterization_algorithm cc({device_mr}, copy, &queue, 1024);

traccc::cell_collection_types::buffer cells_buffer{
static_cast<traccc::cell_collection_types::buffer::size_type>(
cells.size()),
device_mr};
copy.setup(cells_buffer);
copy(vecmem::get_data(cells), cells_buffer)->ignore();

traccc::cell_module_collection_types::buffer modules_buffer{
static_cast<traccc::cell_module_collection_types::buffer::size_type>(
modules.size()),
device_mr};
copy.setup(modules_buffer);
copy(vecmem::get_data(modules), modules_buffer)->ignore();

auto measurements_buffer = cc(cells_buffer, modules_buffer);
traccc::measurement_collection_types::host measurements{&host_mr};
copy(measurements_buffer, measurements)->wait();

for (std::size_t i = 0; i < measurements.size(); i++) {
result[modules.at(measurements.at(i).module_link).surface_link.value()]
.push_back(measurements.at(i));
}

return result;
};
} // namespace

TEST_P(ConnectedComponentAnalysisTests, Run) {
test_connected_component_analysis(GetParam());
}

INSTANTIATE_TEST_SUITE_P(
SYCLFastSvAlgorithm, ConnectedComponentAnalysisTests,
::testing::Combine(
::testing::Values(f),
::testing::ValuesIn(ConnectedComponentAnalysisTests::get_test_files())),
ConnectedComponentAnalysisTests::get_test_name);
Loading