Skip to content

Commit

Permalink
Disable cuda tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
beomki-yeo committed Oct 18, 2023
1 parent 8aead89 commit 0e2a257
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ using detector_device_t = detector<toy_metadata, device_container_types>;

// These types are identical in host and device code for all bfield types
using transform3 = typename detector_host_t::transform3;
using point3 = typename detector_host_t::point3;
using vector3_t = typename transform3::vector3;
using point3_t = typename transform3::point3;
using matrix_operator = standard_matrix_operator<scalar>;
using track_t = free_track_parameters<transform3>;
using free_matrix = typename track_t::covariance_type;
Expand Down Expand Up @@ -227,7 +227,7 @@ inline void compare_propagation_results(
const vector3_t &device_pos = device_positions[i][j];

auto relative_error =
static_cast<point3>(1. / host_pl * (host_pos - device_pos));
static_cast<point3_t>(1. / host_pl * (host_pos - device_pos));

ASSERT_NEAR(getter::norm(relative_error), 0.f, is_close);
}
Expand Down
28 changes: 18 additions & 10 deletions tests/unit_tests/device/sycl/propagator.sycl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

// Project include(s)
#include "detray/detectors/create_toy_geometry.hpp"
#include "propagator_sycl_kernel.hpp"

// Vecmem include(s)
Expand Down Expand Up @@ -34,6 +35,9 @@ class SyclPropConstBFieldMng : public ::testing::TestWithParam<vector3_t> {};

TEST_P(SyclPropConstBFieldMng, propagator) {

// Detector configuration
toy_det_config toy_cfg{};

// Creating SYCL queue object
::sycl::queue q(handle_async_error);
std::cout << "Running constant bfield propagation on device (mng mem): "
Expand All @@ -43,20 +47,25 @@ TEST_P(SyclPropConstBFieldMng, propagator) {
vecmem::sycl::shared_memory_resource shared_mr;

// Set the magnetic field
const vector3 B = GetParam();
const vector3_t B = GetParam();
auto field = bfield::create_const_field(B);

// Create the toy geometry
toy_cfg.bfield_vec(B);
auto [det, names] = create_toy_geometry(shared_mr, toy_cfg);

run_propagation_test<bfield::const_bknd_t>(
&shared_mr, &q, det, detray::get_data<bfield::const_bknd_t>(det));
auto det_view = detray::get_data(det);

run_propagation_test<bfield::const_bknd_t>(&shared_mr, &q, det, det_view,
field);
}

class SyclPropConstBFieldCpy : public ::testing::TestWithParam<vector3_t> {};

TEST_P(SyclPropConstBFieldCpy, propagator) {

// Detector configuration
toy_det_config toy_cfg{};

// Creating SYCL queue object
::sycl::queue q(handle_async_error);
std::cout << "Running constant bfield propagation on device (cpy): "
Expand All @@ -71,17 +80,16 @@ TEST_P(SyclPropConstBFieldCpy, propagator) {
vecmem::sycl::copy sycl_cpy(q_wrapper);

// Set the magnetic field
const vector3 B = GetParam();
const vector3_t B = GetParam();
auto field = bfield::create_const_field(B);

// Create the toy geometry
toy_cfg.bfield_vec(B);
auto [det, names] = create_toy_geometry(host_mr, toy_cfg);

auto det_buff =
detray::get_buffer<bfield::const_bknd_t>(det, dev_mr, sycl_cpy);
auto det_buff = detray::get_buffer(det, dev_mr, sycl_cpy);

run_propagation_test<bfield::const_bknd_t>(&shared_mr, &q, det,
detray::get_data(det_buff));
run_propagation_test<bfield::const_bknd_t>(
&shared_mr, &q, det, detray::get_data(det_buff), field);
}

INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation1, SyclPropConstBFieldMng,
Expand Down
11 changes: 6 additions & 5 deletions tests/unit_tests/device/sycl/propagator_kernel.sycl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ void propagator_test(

reinterpret_cast<::sycl::queue*>(queue.queue())
->submit([&](::sycl::handler& h) {
h.parallel_for(ndrange, [det_data, tracks_data, candidates_data,
path_lengths_data, positions_data,
jac_transports_data](
h.parallel_for(ndrange, [det_data, field_data, tracks_data,
candidates_data, path_lengths_data,
positions_data, jac_transports_data](
::sycl::nd_item<1> item) {
detector_device_t dev_det(det_data);

Expand All @@ -43,7 +43,8 @@ void propagator_test(
candidates(candidates_data);
vecmem::jagged_device_vector<scalar> path_lengths(
path_lengths_data);
vecmem::jagged_device_vector<vector3> positions(positions_data);
vecmem::jagged_device_vector<vector3_t> positions(
positions_data);
vecmem::jagged_device_vector<free_matrix> jac_transports(
jac_transports_data);

Expand Down Expand Up @@ -93,7 +94,7 @@ void propagator_test(
}

/// Explicit instantiation for a constant magnetic field
template void propagator_test<bfield::const_bknd_t>(
template void propagator_test<bfield::const_bknd_t, detector_host_t>(
detector_host_t::view_type, covfie::field_view<bfield::const_bknd_t>,
vecmem::data::vector_view<track_t>&,
vecmem::data::jagged_vector_view<intersection_t<detector_host_t>>&,
Expand Down
28 changes: 14 additions & 14 deletions tutorials/src/device/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ enable_language(CUDA)
include(detray-compiler-options-cuda)

# Examples using the array algebra plugin.
detray_add_tutorial( detector_construction_cuda
"detector_construction.cpp"
"detector_construction.hpp"
"detector_construction.cu"
LINK_LIBRARIES vecmem::cuda detray::core_array covfie::core
detray::tutorial detray::utils)
target_compile_definitions(detray_tutorial_detector_construction_cuda PRIVATE array=array)
#detray_add_tutorial( detector_construction_cuda
# "detector_construction.cpp"
# "detector_construction.hpp"
# "detector_construction.cu"
# LINK_LIBRARIES vecmem::cuda detray::core_array covfie::core
# detray::tutorial detray::utils)
#target_compile_definitions(detray_tutorial_detector_construction_cuda PRIVATE array=array)

detray_add_tutorial( propagation_cuda
"propagation.cpp"
"propagation.hpp"
"propagation_kernel.cu"
LINK_LIBRARIES vecmem::cuda detray::core_array covfie::core covfie::cuda
detray::tutorial detray::utils)
target_compile_definitions(detray_tutorial_propagation_cuda PRIVATE array=array)
#detray_add_tutorial( propagation_cuda
# "propagation.cpp"
# "propagation.hpp"
# "propagation_kernel.cu"
# LINK_LIBRARIES vecmem::cuda detray::core_array covfie::core covfie::cuda
# detray::tutorial detray::utils)
#target_compile_definitions(detray_tutorial_propagation_cuda PRIVATE array=array)
11 changes: 2 additions & 9 deletions tutorials/src/device/cuda/propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@ int main() {
// VecMem memory resource(s)
vecmem::cuda::managed_memory_resource mng_mr;

// Set the magnetic field

// Define the name of the input file: use detray unittest data in this case
const std::string field_file = !std::getenv("DETRAY_BFIELD_FILE")
? ""
: std::getenv("DETRAY_BFIELD_FILE");
detray::tutorial::field_host_t bfield =
detray::io::read_bfield<detray::bfield::inhom_field_t>(field_file);

// Get the magnetic field
auto bfield = detray::bfield::create_inhom_field();
// Create the toy geometry
detray::toy_det_config toy_cfg{};
auto [det, names] = detray::create_toy_geometry(mng_mr, toy_cfg);
Expand Down

0 comments on commit 0e2a257

Please sign in to comment.