Skip to content

Commit

Permalink
Split benchmarks and svgtools and make new library for valudation uti…
Browse files Browse the repository at this point in the history
…ls (#834)

This splits the validation utils off from the other test utils, so that the svgtools dependency is contained with the tools that actually need them. For example, the detray benchmarks and any client code that just wants to use the tesbed detectors, does not have to build actsvg at all anymore
  • Loading branch information
niermann999 authored Oct 14, 2024
1 parent 4747191 commit 16d8679
Show file tree
Hide file tree
Showing 52 changed files with 78 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
cd build
source ${GITHUB_WORKSPACE}/.github/ci_setup.sh ${{ matrix.PLATFORM.NAME }}
ctest --output-on-failure
- name: Unit Test
- name: Unit Tests
if: "matrix.BUILD_TYPE == 'Debug'"
run: |
cd build
Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ option( DETRAY_BUILD_CUDA "Build the CUDA sources included in detray"
${DETRAY_BUILD_CUDA_DEFAULT} )
cmake_dependent_option(DETRAY_BUILD_HOST "Build the host sources included in detray" ON "DETRAY_BUILD_CUDA OR DETRAY_BUILD_SYCL" ON)
option( DETRAY_BUILD_TEST_UTILS "Build the test utility library of Detray" OFF )
option( DETRAY_BUILD_VALIDATION_TOOLS "Build the validation tools of Detray" OFF )
option( DETRAY_BUILD_UNITTESTS "Build the unit tests of Detray" OFF )
option( DETRAY_BUILD_INTEGRATIONTESTS "Build the integration tests of Detray"
OFF )
Expand Down Expand Up @@ -90,13 +91,19 @@ if ( BUILD_TESTING AND (DETRAY_BUILD_UNITTESTS OR DETRAY_BUILD_INTEGRATIONTESTS)
set( DETRAY_BUILD_TESTING ON )
endif()

# Test utilities are needed for tests, tutorials and benchmarks
if ( DETRAY_BUILD_TESTING OR DETRAY_BUILD_BENCHMARKS OR DETRAY_BUILD_TUTORIALS )
# Validation utilities are needed for integration tests and tutorials
if ( DETRAY_BUILD_TESTING OR DETRAY_BUILD_TUTORIALS )
set( DETRAY_BUILD_VALIDATION_TOOLS ON )
endif()

# Test utilities are needed for validation utilities and benchmarks
if ( DETRAY_BUILD_TESTING OR DETRAY_BUILD_VALIDATION_TOOLS
OR DETRAY_BUILD_BENCHMARKS )
set( DETRAY_BUILD_TEST_UTILS ON )
endif()

# Svg display is needed for the test utilities
if ( DETRAY_BUILD_TEST_UTILS )
# Svg display is needed for the validation utilities
if ( DETRAY_BUILD_VALIDATION_TOOLS )
set( DETRAY_SVG_DISPLAY ON )
endif()

Expand Down
38 changes: 26 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,32 @@ include_directories( SYSTEM $<TARGET_PROPERTY:dfelibs::dfelibs,INTERFACE_INCLUDE

# Set up a test library, which can be used by downstream projects without
# building the detray unit and integration
file( GLOB _detray_test_utils_headers
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"include/detray/test/utils/*.hpp"
"include/detray/test/utils/detectors/*.hpp"
"include/detray/test/utils/detectors/factories/*.hpp"
"include/detray/test/utils/simulation/event_generator/*.hpp"
"include/detray/test/utils/simulation/*.hpp" )

detray_add_library( detray_test_utils test_utils ${_detray_test_headers} )
target_link_libraries( detray_test_utils INTERFACE vecmem::core detray::core detray::detectors detray::csv_io detray::svgtools )

unset( _detray_test_utils_headers )
if ( DETRAY_BUILD_TEST_UTILS )
file( GLOB _detray_test_utils_headers
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"include/detray/test/utils/*.hpp"
"include/detray/test/utils/detectors/*.hpp"
"include/detray/test/utils/detectors/factories/*.hpp"
"include/detray/test/utils/simulation/event_generator/*.hpp"
"include/detray/test/utils/simulation/*.hpp" )

detray_add_library( detray_test_utils test_utils ${_detray_test_utils_headers} )
target_link_libraries( detray_test_utils INTERFACE vecmem::core detray::core detray::detectors )

unset( _detray_test_utils_headers )
endif()

# Build extended validation tools
if ( DETRAY_BUILD_VALIDATION_TOOLS )
file( GLOB _detray_validation_headers
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"include/detray/test/validation/*.hpp" )

detray_add_library( detray_validation_utils validation_utils ${_detray_validation_headers} )
target_link_libraries( detray_validation_utils INTERFACE vecmem::core detray::core detray::test_utils detray::csv_io detray::svgtools )

unset( _detray_validation_headers )
endif()

# Build the common (host and device) test library (mostly for integration tests)
if( DETRAY_BUILD_TESTING )
Expand Down
2 changes: 1 addition & 1 deletion tests/include/detray/test/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ add_library( detray_test_cpu INTERFACE "detector_consistency.hpp"

add_library( detray::test_cpu ALIAS detray_test_cpu )

target_link_libraries( detray_test_cpu INTERFACE vecmem::core detray::core_array detray::test_common detray::test_utils )
target_link_libraries( detray_test_cpu INTERFACE vecmem::core detray::core_array detray::test_common detray::validation_utils )
4 changes: 2 additions & 2 deletions tests/include/detray/test/cpu/detector_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include "detray/test/common/detail/whiteboard.hpp"
#include "detray/test/common/detector_scan_config.hpp"
#include "detray/test/common/fixture_base.hpp"
#include "detray/test/utils/detector_scan_utils.hpp"
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/test/utils/types.hpp"
#include "detray/test/validation/detector_scan_utils.hpp"
#include "detray/test/validation/detector_scanner.hpp"

// System include(s)
#include <iostream>
Expand Down
4 changes: 2 additions & 2 deletions tests/include/detray/test/cpu/material_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
// Detray test include(s)
#include "detray/test/common/detail/whiteboard.hpp"
#include "detray/test/common/fixture_base.hpp"
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/material_validation_utils.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/test/utils/types.hpp"
#include "detray/test/validation/detector_scanner.hpp"
#include "detray/test/validation/material_validation_utils.hpp"

// System include(s)
#include <ios>
Expand Down
2 changes: 1 addition & 1 deletion tests/include/detray/test/cpu/material_validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// Detray test include(s)
#include "detray/test/common/fixture_base.hpp"
#include "detray/test/common/material_validation_config.hpp"
#include "detray/test/utils/material_validation_utils.hpp"
#include "detray/test/validation/material_validation_utils.hpp"

// Vecmem include(s)
#include <vecmem/memory/host_memory_resource.hpp>
Expand Down
6 changes: 3 additions & 3 deletions tests/include/detray/test/cpu/navigation_validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// Detray test include(s)
#include "detray/test/common/fixture_base.hpp"
#include "detray/test/common/navigation_validation_config.hpp"
#include "detray/test/utils/detector_scan_utils.hpp"
#include "detray/test/utils/material_validation_utils.hpp"
#include "detray/test/utils/navigation_validation_utils.hpp"
#include "detray/test/validation/detector_scan_utils.hpp"
#include "detray/test/validation/material_validation_utils.hpp"
#include "detray/test/validation/navigation_validation_utils.hpp"

// System include(s)
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion tests/include/detray/test/device/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ add_library( detray_test_cuda STATIC "material_validation.hpp"

add_library( detray::test_cuda ALIAS detray_test_cuda )

target_link_libraries( detray_test_cuda PUBLIC vecmem::cuda covfie::cuda detray::core_array detray::test_device detray::test_cpu detray::test_utils )
target_link_libraries( detray_test_cuda PUBLIC vecmem::cuda covfie::cuda detray::core_array detray::test_device detray::test_cpu detray::validation_utils )
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "detray/test/common/fixture_base.hpp"
#include "detray/test/common/material_validation_config.hpp"
#include "detray/test/cpu/material_validation.hpp"
#include "detray/test/utils/material_validation_utils.hpp"
#include "detray/test/validation/material_validation_utils.hpp"

// Vecmem include(s)
#include <vecmem/memory/cuda/device_memory_resource.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
// Detray test include(s)
#include "detray/test/common/fixture_base.hpp"
#include "detray/test/common/navigation_validation_config.hpp"
#include "detray/test/utils/detector_scan_utils.hpp"
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/inspectors.hpp"
#include "detray/test/utils/material_validation_utils.hpp"
#include "detray/test/utils/navigation_validation_utils.hpp"
#include "detray/test/validation/detector_scan_utils.hpp"
#include "detray/test/validation/detector_scanner.hpp"
#include "detray/test/validation/material_validation_utils.hpp"
#include "detray/test/validation/navigation_validation_utils.hpp"

// Vecmem include(s)
#include <vecmem/memory/cuda/device_memory_resource.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/include/detray/test/device/propagator_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Detray test include(s)
#include "detray/test/utils/inspectors.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/test/utils/step_tracer.hpp"
#include "detray/test/validation/step_tracer.hpp"

// Vecmem include(s)
#include <vecmem/memory/memory_resource.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "detray/plugins/svgtools/illustrator.hpp"

// Detray test include(s)
#include "detray/test/utils/svg_display.hpp"
#include "detray/test/validation/svg_display.hpp"

// System include(s)
#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

// Detray test include(s)
#include "detray/test/utils/inspectors.hpp"
#include "detray/test/utils/material_validation_utils.hpp"
#include "detray/test/utils/step_tracer.hpp"
#include "detray/test/validation/material_validation_utils.hpp"
#include "detray/test/validation/step_tracer.hpp"

// System include(s)
#include <algorithm>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 10 additions & 7 deletions tests/scripts/run_jacobian_validation.sh → .../tools/scripts/run_jacobian_validation.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#
# Mozilla Public License Version 2.0

# Absolute path of detray git root directory
root_dir="$(git rev-parse --show-toplevel)"

# Number of threads
n_threads=1

Expand Down Expand Up @@ -240,28 +243,28 @@ cd ${output_dir}
if [ "$skip_first_phase" = false ] && [ "$skip_second_phase" = false ]; then

# Run rk_tolerance_comparision.C
root -q '../../../tests/validation/root/rk_tolerance_comparison.C+O('${log10_min_rk_tol}','${log10_max_rk_tol}')'
root -q "$root_dir"'/tests/tools/root/rk_tolerance_comparison.C+O('${log10_min_rk_tol}','${log10_max_rk_tol}')'

# Run jacobian_histogram.C
root -q -l '../../../tests/validation/root/jacobian_histogram.C+O('${log10_min_rk_tol}')'
root -q -l "$root_dir"'/tests/tools/root/jacobian_histogram.C+O('${log10_min_rk_tol}')'

# Run jacobian_comparison.C
root -q -l ../../../tests/validation/root/jacobian_comparison.C+O
root -q -l "$root_dir"/tests/tools/root/jacobian_comparison.C+O

# Run covariance_validation.C
root -q -l ../../../tests/validation/root/covariance_validation.C+O
root -q -l "$root_dir"/tests/tools/root/covariance_validation.C+O

elif [ "$skip_first_phase" = true ] && [ "$skip_second_phase" = false ]; then

# Run covariance_validation.C
root ../../../tests/validation/root/covariance_validation.C+O
root "$root_dir"/tests/tools/root/covariance_validation.C+O

elif [ "$skip_first_phase" = false ] && [ "$skip_second_phase" = true ]; then

# Run rk_tolerance_comparision.C
root '../../../tests/validation/root/rk_tolerance_comparison.C+O('${log10_min_rk_tol}','${log10_max_rk_tol}')'
root "$root_dir"'/tests/tools/root/rk_tolerance_comparison.C+O('${log10_min_rk_tol}','${log10_max_rk_tol}')'

# Run jacobian_histogram.C
root '../../../tests/validation/root/jacobian_histogram.C+O('${log10_min_rk_tol}')'
root "$root_dir"'/tests/tools/root/jacobian_histogram.C+O('${log10_min_rk_tol}')'

fi
2 changes: 1 addition & 1 deletion tests/unit_tests/cpu/simulation/detector_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Project include(s).
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/validation/detector_scanner.hpp"

#include "detray/definitions/units.hpp"
#include "detray/navigation/detail/trajectories.hpp"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/svgtools/intersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include "detray/plugins/svgtools/writer.hpp"

// Detray test include(s)
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/detectors/build_toy_detector.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/test/utils/svg_display.hpp"
#include "detray/test/validation/detector_scanner.hpp"
#include "detray/test/validation/svg_display.hpp"
#include "detray/tracks/tracks.hpp"

// Vecmem include(s)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/svgtools/trajectories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "detray/plugins/svgtools/writer.hpp"

// Detray test include(s)
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/detectors/build_toy_detector.hpp"
#include "detray/test/utils/svg_display.hpp"
#include "detray/test/validation/detector_scanner.hpp"
#include "detray/test/validation/svg_display.hpp"

// Vecmem include(s)
#include <vecmem/memory/host_memory_resource.hpp>
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/svgtools/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "detray/plugins/svgtools/writer.hpp"

// Detray test include(s)
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/detectors/build_toy_detector.hpp"
#include "detray/test/utils/svg_display.hpp"
#include "detray/test/validation/detector_scanner.hpp"
#include "detray/test/validation/svg_display.hpp"

// Vecmem include(s)
#include <vecmem/memory/host_memory_resource.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tutorials/src/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ foreach(file ${source_files})
detray_add_tutorial( ${file_name}
${file}
LINK_LIBRARIES detray::core_array covfie::core vecmem::core detray::io
detray::tutorial detray::test_utils )
detray::tutorial detray::validation_utils )
endforeach()
4 changes: 2 additions & 2 deletions tutorials/src/cpu/detector/detector_ray_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// Project include(s)
#include "detray/navigation/detail/ray.hpp"
#include "detray/navigation/volume_graph.hpp"
#include "detray/test/utils/detector_scan_utils.hpp"
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/detectors/build_toy_detector.hpp"
#include "detray/test/utils/hash_tree.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/test/validation/detector_scan_utils.hpp"
#include "detray/test/validation/detector_scanner.hpp"

// Example linear algebra plugin: std::array
#include "detray/tutorial/types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tutorials/src/cpu/propagation/navigation_inspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include "detray/propagator/actor_chain.hpp"
#include "detray/propagator/line_stepper.hpp"
#include "detray/propagator/propagator.hpp"
#include "detray/test/utils/detector_scanner.hpp"
#include "detray/test/utils/detectors/build_toy_detector.hpp"
#include "detray/test/utils/inspectors.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/test/validation/detector_scanner.hpp"
#include "detray/tracks/tracks.hpp"

// Example linear algebra plugin: std::array
Expand Down

0 comments on commit 16d8679

Please sign in to comment.