Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:24

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2023 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Projection include(s).
0009 #include "traccc/edm/container.hpp"
0010 
0011 // VecMem include(s).
0012 #include <vecmem/memory/host_memory_resource.hpp>
0013 
0014 // Google test include(s).
0015 #include <gtest/gtest.h>
0016 
0017 TEST(ContainerCopy, HostToHost) {
0018   using test_container_types = traccc::container_types<int, int>;
0019 
0020   // Memory resources used by the application.
0021   vecmem::host_memory_resource host_mr;
0022 
0023   // Create a host container
0024   test_container_types::host host_orig{&host_mr};
0025 
0026   // Fill the host container
0027   for (int i = 0; i < 3; ++i) {
0028     host_orig.push_back(i,
0029                         test_container_types::host::vector_type<int>{i, i + 1});
0030   }
0031 
0032   // Copy the container to the host buffer, and back.
0033   auto host_buffer = traccc::get_data(host_orig);
0034   test_container_types::device host_copy{host_buffer};
0035 
0036   // Check the copied container
0037   ASSERT_EQ(host_copy.size(), 3u);
0038   const auto& host_headers = host_copy.get_headers();
0039   ASSERT_EQ(host_headers.size(), 3u);
0040   ASSERT_EQ(host_headers[0], 0);
0041   ASSERT_EQ(host_headers[1], 1);
0042   ASSERT_EQ(host_headers[2], 2);
0043 
0044   const auto& host_items = host_copy.get_items();
0045   ASSERT_EQ(host_items.size(), 3u);
0046   ASSERT_EQ(host_items[0].size(), 2u);
0047   ASSERT_EQ(host_items[0][0], 0);
0048   ASSERT_EQ(host_items[0][1], 1);
0049   ASSERT_EQ(host_items[1].size(), 2u);
0050   ASSERT_EQ(host_items[1][0], 1);
0051   ASSERT_EQ(host_items[1][1], 2);
0052   ASSERT_EQ(host_items[2].size(), 2u);
0053   ASSERT_EQ(host_items[2][0], 2);
0054   ASSERT_EQ(host_items[2][1], 3);
0055 }