Skip to content

Commit b619f1b

Browse files
author
Vakho Tsulaia
committed
TMP commit
Extra checks and printouts
1 parent d704197 commit b619f1b

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

tests/unit_tests/device/cuda/detector_cuda.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,31 @@ TEST(detector_cuda, detector_alignment) {
130130
// and shift them by the same translation
131131
typename detector_host_t::transform_container tf_store_aligned_host;
132132

133-
point3 shift{.100000f * unit<scalar>::mm, .200000f * unit<scalar>::mm,
134-
.300000f * unit<scalar>::mm};
133+
point3 shift{.1f * unit<scalar>::mm, .2f * unit<scalar>::mm,
134+
.3f * unit<scalar>::mm};
135135

136136
tf_store_aligned_host.reserve(
137137
det_host.transform_store().size(),
138138
typename decltype(det_host)::transform_container::context_type{});
139139

140140
for (const auto& tf : det_host.transform_store()) {
141-
point3 shifted = tf.translation() + shift;
141+
point3 shifted{tf.translation()[0] + shift[0],
142+
tf.translation()[1] + shift[1],
143+
tf.translation()[2] + shift[2]};
142144
tf_store_aligned_host.push_back(
143145
transform_t{shifted, tf.x(), tf.y(), tf.z()});
144146
}
145147

148+
std::cout << "Comparing translations STEP1" << std::endl;
149+
typename decltype(det_host)::transform_container::context_type ctx{};
150+
for (unsigned int i = 0u; i < 20; i++) {
151+
auto trstatic = det_host.transform_store().at(i,ctx).translation();
152+
auto traligned = tf_store_aligned_host.at(i,ctx).translation();
153+
auto trdiff = traligned - trstatic;
154+
EXPECT_POINT3_NEAR(trdiff, shift, 1e-6);
155+
}
156+
157+
146158
// copy the vector of aligned transforms to the device
147159
// again, use synchronous copy and fixed size buffers
148160
auto tf_buff_aligned =
@@ -173,10 +185,11 @@ TEST(detector_cuda, detector_alignment) {
173185
surfacexf_data_static, surfacexf_data_aligned);
174186

175187
// check that the relevant transforms have been properly shifted
176-
for (unsigned int i = 0u; i < surfacexf_device_static.size(); i++) {
188+
std::cout << "Comparing translations STEP3" << std::endl;
189+
for (unsigned int i = 0u; i < 20; i++) {
177190
auto translation_static = surfacexf_device_static[i].translation();
178191
auto translation_aligned = surfacexf_device_aligned[i].translation();
179192
auto translation_diff = translation_aligned - translation_static;
180-
EXPECT_POINT3_NEAR(translation_diff, shift, 1e-5);
193+
EXPECT_POINT3_NEAR(translation_diff, shift, 1e-6);
181194
}
182195
}

tests/unit_tests/device/cuda/detector_cuda_kernel.cu

+20
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ __global__ void detector_alignment_test_kernel(
128128
vecmem::device_vector<transform_t> surfacexf_device_aligned(
129129
surfacexf_data_aligned);
130130

131+
printf("Comparing translations STEP2\n");
132+
for (unsigned int i = 0u; i < 20; i++) {
133+
const auto sf = tracking_surface{det_device_static,
134+
det_device_static.surfaces()[i]};
135+
auto trstat = sf.transform(ctx).translation();
136+
const auto af = tracking_surface{det_device_aligned,
137+
det_device_aligned.surfaces()[i]};
138+
auto tralig = af.transform(ctx).translation();
139+
if(fabs(tralig[0]-trstat[0]-.1f)>1e-6
140+
|| fabs(tralig[1]-trstat[1]-.2f)>1e-6
141+
|| fabs(tralig[2]-trstat[2]-.3f)>1e-6) {
142+
printf("[%f,%f,%f] - [%f,%f,%f] = [%f,%f,%f]\n",
143+
tralig[0],tralig[1],tralig[2],
144+
trstat[0],trstat[1],trstat[2],
145+
fabs(tralig[0]-trstat[0]),
146+
fabs(tralig[1]-trstat[1]),
147+
fabs(tralig[2]-trstat[2]));
148+
}
149+
150+
}
131151
// copy surface transforms into relevant vectors
132152
for (unsigned int i = 0u; i < det_device_static.surfaces().size(); i++) {
133153
const auto sf = tracking_surface{det_device_static,

0 commit comments

Comments
 (0)