File indexing completed on 2026-05-27 07:24:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/definitions/algebra.hpp"
0011 #include "detray/utils/ranges.hpp"
0012
0013
0014 #include "transform_store_cuda_kernel.hpp"
0015
0016
0017 #include <vecmem/memory/cuda/managed_memory_resource.hpp>
0018
0019
0020 #include <gtest/gtest.h>
0021
0022
0023 #include <climits>
0024
0025 using namespace detray;
0026
0027 TEST(transform_store_cuda, transform_store) {
0028
0029 vecmem::cuda::managed_memory_resource mng_mr;
0030
0031 host_transform_store_t static_store(mng_mr);
0032 typename host_transform_store_t::context_type ctx0{};
0033 typename host_transform_store_t::context_type ctx1{};
0034
0035 ASSERT_TRUE(static_store.empty(ctx0));
0036
0037 ASSERT_EQ(static_store.size(ctx0), 0u);
0038
0039 point3 t0{1.f, 2.f, 3.f};
0040 point3 z0{4.f, 2.f, 3.f};
0041 point3 x0{1.f, 0.f, 3.f};
0042 transform3 tf0{t0, z0, x0};
0043 static_store.push_back(tf0, ctx0);
0044 ASSERT_EQ(static_store.size(ctx0), 1u);
0045
0046 point3 t1{1.f, 1.f, 2.f};
0047 point3 z1{1.f, 0.f, 0.f};
0048 point3 x1{0.f, 0.f, 2.f};
0049 transform3 tf1{t1, z1, x1};
0050 static_store.push_back(tf1, ctx1);
0051 ASSERT_EQ(static_store.size(ctx1), 2u);
0052
0053 point3 t2{2.f, 2.f, 5.f};
0054 point3 z2{0.f, 0.f, 0.f};
0055 point3 x2{1.f, 2.f, 3.f};
0056 transform3 tf2{t2, z2, x2};
0057 static_store.push_back(std::move(tf2), ctx0);
0058 ASSERT_EQ(static_store.size(ctx0), 3u);
0059
0060 point3 t3{2.f, 0.f, 5.f};
0061 point3 z3{1.f, 2.f, 3.f};
0062 point3 x3{0.f, 0.f, 0.f};
0063 transform3 tf3{t3, z3, x3};
0064 static_store.emplace_back(ctx0, std::move(t3));
0065 ASSERT_EQ(static_store.size(ctx0), 4u);
0066
0067 static_store.emplace_back(ctx0);
0068 ASSERT_EQ(static_store.size(ctx0), 5u);
0069
0070
0071 dindex n_transforms = static_store.size(ctx0);
0072
0073
0074 vecmem::vector<point3> input(&mng_mr);
0075 for (unsigned int i = 0u; i < n_transforms; i++) {
0076 input.push_back({static_cast<scalar>(i), static_cast<scalar>(i + 1u),
0077 static_cast<scalar>(i + 2u)});
0078 }
0079
0080
0081 std::vector<point3> output_host;
0082
0083 auto range = detray::ranges::subrange(static_store.get(ctx0),
0084 dindex_range{0u, n_transforms});
0085 std::size_t count{0u};
0086 for (const auto& tf : range) {
0087 auto output = tf.point_to_global(input[count]);
0088 output_host.push_back(output);
0089 count++;
0090 }
0091
0092
0093 vecmem::vector<point3> output_device(n_transforms, &mng_mr);
0094
0095 auto input_data = vecmem::get_data(input);
0096 auto output_data = vecmem::get_data(output_device);
0097 auto static_store_data = get_data(static_store);
0098 transform_test(input_data, static_store_data, output_data,
0099 static_store.size());
0100
0101
0102 for (unsigned int i = 0u; i < n_transforms; i++) {
0103 ASSERT_EQ(output_host[i], output_device[i]);
0104 }
0105 }