Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into cling-sincospi
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Jan 25, 2024
2 parents 7ea4b02 + c942e57 commit acef5b5
Show file tree
Hide file tree
Showing 43 changed files with 1,410 additions and 156 deletions.
34 changes: 34 additions & 0 deletions .jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@ pipeline {
stages {
stage('Build') {
parallel {
stage('rocm-ndebug-orange') {
agent {
docker {
image 'celeritas/ci-centos7-rocm5:2022-12-14.2'
label 'AMD_Radeon_Instinct_MI100 && rocm-docker'
args '--device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined'
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm ndebug-orange'
}
post {
always {
xunit reduceLog: false, tools:[CTest(deleteOutputFiles: true, failIfNotNew: true, pattern: 'build/Testing/**/*.xml', skipNoTestFiles: false, stopProcessingIfError: true)]
}
}
}
stage('rocm-ndebug-orange-float') {
agent {
docker {
image 'celeritas/ci-centos7-rocm5:2022-12-14.2'
label 'AMD_Radeon_Instinct_MI100 && rocm-docker'
args '--device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined'
}
}
steps {
sh 'entrypoint-shell ./scripts/ci/run-ci.sh centos-rocm ndebug-orange-float'
}
post {
always {
xunit reduceLog: false, tools:[CTest(deleteOutputFiles: true, failIfNotNew: true, pattern: 'build/Testing/**/*.xml', skipNoTestFiles: false, stopProcessingIfError: true)]
}
}
}
stage('cuda-debug-orange') {
agent {
docker {
Expand Down
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,18 @@ elseif(CELERITAS_USE_HIP)
set(CELERITAS_HAVE_ROCTX ON)
target_link_libraries(celeritas_device_toolkit INTERFACE ${ROCTX_LIBRARY})
endif()
# TODO: downstream libs don't link against correct HIP dependencies when using
# static libraries
if(NOT BUILD_SHARED_LIBS)
# Downstream libs don't link against correct HIP dependencies when using
# static libraries, and even though the code below propagates the library
# names (-lamdhip64) CMake fails to include the link directories
# (/opt/rocm/lib)
target_link_libraries(celeritas_device_toolkit
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_HIP_IMPLICIT_LINK_LIBRARIES}>"
)
target_link_directories(celeritas_device_toolkit
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_HIP_IMPLICIT_LINK_DIRECTORIES}>"
)
endif()
endif()

install(TARGETS celeritas_device_toolkit
Expand Down Expand Up @@ -610,6 +620,12 @@ message(WARNING \"The Celeritas version was not detected during configuration.
provenance data in output results.\")
")
endif()

if(CELERITAS_USE_HIP AND NOT BUILD_SHARED_LIBS)
# See celeritas_device_toolkit above
install(CODE "
message(WARNING \"CMake may not be able to correctly propagate implicit HIP
libraries: downstream executables may fail to link.\")
")
endif()

#----------------------------------------------------------------------------#
1 change: 0 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"hidden": true,
"description": "Build with optimizations and without debug assertions",
"cacheVariables": {
"BUILD_SHARED_LIBS":{"type": "BOOL", "value": "OFF"},
"CELERITAS_DEBUG": {"type": "BOOL", "value": "OFF"},
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "Release"},
"CMAKE_CUDA_FLAGS_RELEASE": "-O3 -DNDEBUG",
Expand Down
2 changes: 1 addition & 1 deletion example/accel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(CeleritasAccelExample VERSION 0.0.1 LANGUAGES CXX)
cmake_policy(VERSION 3.12...3.22)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
find_package(Celeritas 0.4 REQUIRED)
find_package(Celeritas 0.5 REQUIRED)
find_package(Geant4 REQUIRED)

if(NOT CELERITAS_USE_Geant4 OR CELERITAS_CORE_GEO STREQUAL "ORANGE")
Expand Down
2 changes: 1 addition & 1 deletion example/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(CeleritasMinimalExample VERSION 0.0.1 LANGUAGES CXX)
cmake_policy(VERSION 3.12...3.22)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
find_package(Celeritas 0.4 REQUIRED)
find_package(Celeritas 0.5 REQUIRED)

add_executable(minimal minimal.cc)

Expand Down
1 change: 1 addition & 0 deletions interface/celeritas.i
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace celeritas
%celer_rename_to_cstring(vector_type, ImportPhysicsVectorType);
%celer_rename_to_cstring(process_type, ImportProcessType);
%celer_rename_to_cstring(process_class, ImportProcessClass);
%celer_rename_to_cstring(material_state, ImportMaterialState);
%celer_rename_to_cstring(model, ImportModelClass);
%rename(process_class_to_geant_name) to_geant_name(ImportProcessClass);
%rename(model_to_geant_name) to_geant_name(ImportModelClass);
Expand Down
2 changes: 1 addition & 1 deletion scripts/cmake-presets/ci-ubuntu-cuda.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"description": "Build with release ORANGE",
"inherits": [".ndebug", "base"],
"cacheVariables": {
"BUILD_SHARED_LIBS": {"type": "BOOL", "value": "OFF"},
"CELERITAS_USE_ROOT": {"type": "BOOL", "value": "OFF"}
}
},
Expand All @@ -82,7 +83,6 @@
"description": "Build release with vecgeom for testing *only* demos",
"inherits": [".ndebug", ".vecgeom", "base"],
"cacheVariables": {
"BUILD_SHARED_LIBS": {"type": "BOOL", "value": "ON"},
"BUILD_TESTING": {"type": "BOOL", "value": "ON"},
"CELERITAS_BUILD_DEMOS": {"type": "BOOL", "value": "ON"},
"CELERITAS_BUILD_TESTS": {"type": "BOOL", "value": "OFF"}
Expand Down
17 changes: 10 additions & 7 deletions src/celeritas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ list(APPEND SOURCES
grid/ValueGridInserter.cc
grid/VectorUtils.cc
io/AtomicRelaxationReader.cc
io/ImportMaterial.cc
io/ImportModel.cc
io/ImportPhysicsTable.cc
io/ImportPhysicsVector.cc
Expand Down Expand Up @@ -245,13 +246,15 @@ if(CELERITAS_USE_VecGeom)
ext/VecgeomParams.surface.cu
)
endif()
endif()

if(CELERITAS_USE_VecGeom AND CELERITAS_USE_CUDA)
# This needs to be public because its might be needed
# to resolve the symbols generate by the `nvcc -dlink` of
# one of the executable.
list(APPEND PUBLIC_DEPS VecGeom::vecgeom)
if(CELERITAS_USE_CUDA)
# This needs to be public because its might be needed
# to resolve the symbols generate by the `nvcc -dlink` of
# one of the executable.
list(APPEND PUBLIC_DEPS VecGeom::vecgeom)
elseif(VecGeom_CUDA_FOUND)
# VecGeom is built with CUDA but Celeritas is not
list(APPEND PRIVATE_DEPS VecGeom::vecgeomcuda)
endif()
endif()

if(CELERITAS_CORE_GEO STREQUAL "VecGeom")
Expand Down
31 changes: 31 additions & 0 deletions src/celeritas/Types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,40 @@
#include "Types.hh"

#include "corecel/io/EnumStringMapper.hh"
#include "corecel/io/StringEnumMapper.hh"

#include "UnitTypes.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to a unit system.
*/
char const* to_cstring(UnitSystem value)
{
static_assert(static_cast<int>(UnitSystem::cgs) == CELERITAS_UNITS_CGS);
static_assert(static_cast<int>(UnitSystem::si) == CELERITAS_UNITS_SI);
static_assert(static_cast<int>(UnitSystem::clhep) == CELERITAS_UNITS_CLHEP);
static_assert(static_cast<int>(UnitSystem::native) == CELERITAS_UNITS);

static EnumStringMapper<UnitSystem> const to_cstring_impl{
"none", "cgs", "si", "clhep"};
return to_cstring_impl(value);
}

//---------------------------------------------------------------------------//
/*!
* Get a unit system corresponding to a string value.
*/
UnitSystem to_unit_system(std::string const& s)
{
static auto const from_string
= StringEnumMapper<UnitSystem>::from_cstring_func(to_cstring,
"unit system");
return from_string(s);
}

//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to a state of matter.
Expand Down
22 changes: 19 additions & 3 deletions src/celeritas/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <cstdint>

#include "celeritas_config.h"
// IWYU pragma: begin_exports
#include "corecel/Assert.hh"
#include "corecel/Macros.hh"
Expand Down Expand Up @@ -37,9 +38,6 @@ using EventId = OpaqueId<struct Event_>;
//! Opaque index to IsotopeRecord in a vector
using IsotopeId = OpaqueId<struct IsotopeRecord>;

//! Opaque index to MaterialRecord in a vector: represents a material ID
using MaterialId = OpaqueId<struct MaterialRecord>;

//! Opaque index of model in the list of physics processes
using ModelId = OpaqueId<class Model>;

Expand Down Expand Up @@ -79,6 +77,18 @@ using SubshellId = OpaqueId<struct Subshell_>;

//---------------------------------------------------------------------------//
// ENUMERATIONS
//---------------------------------------------------------------------------//
//! Unit system used by Celeritas
enum class UnitSystem
{
none, //!< Invalid unit system
cgs, //!< Gaussian CGS
si, //!< International System
clhep, //!< Geant4 native
size_,
native = CELERITAS_UNITS, //!< Compile time selected system
};

//---------------------------------------------------------------------------//
//! Interpolation type
enum class Interp
Expand Down Expand Up @@ -171,6 +181,12 @@ struct StepLimit
// HELPER FUNCTIONS (HOST)
//---------------------------------------------------------------------------//

// Get a string corresponding to a unit system
char const* to_cstring(UnitSystem);

// Get a unit system corresponding to a string
UnitSystem to_unit_system(std::string const& s);

// Get a string corresponding to a material state
char const* to_cstring(MatterState);

Expand Down
53 changes: 44 additions & 9 deletions src/celeritas/UnitTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
//---------------------------------------------------------------------------//
#pragma once

#include <utility>

#include "celeritas_config.h"
#include "corecel/math/UnitUtils.hh"

#include "Constants.hh"
#include "Types.hh"
#include "Units.hh"

namespace celeritas
Expand Down Expand Up @@ -251,43 +254,75 @@ struct LogMev
//---------------------------------------------------------------------------//

//! Traits class for units
template<int>
struct UnitTraits;
template<UnitSystem>
struct UnitSystemTraits;

//! CGS unit traits
template<>
struct UnitTraits<CELERITAS_UNITS_CGS>
struct UnitSystemTraits<UnitSystem::cgs>
{
using Length = Centimeter;
using Mass = Gram;
using Time = Second;
using BField = Gauss; //!< Magnetic flux density

static char const* label() { return "cgs"; }
};

//! SI unit traits
template<>
struct UnitTraits<CELERITAS_UNITS_SI>
struct UnitSystemTraits<UnitSystem::si>
{
using Length = Meter;
using Mass = Kilogram;
using Time = Second;
using BField = Tesla;

static char const* label() { return "si"; }
};

//! CLHEP unit traits
template<>
struct UnitTraits<CELERITAS_UNITS_CLHEP>
struct UnitSystemTraits<UnitSystem::clhep>
{
using Length = Millimeter;
using Mass = ClhepUnitMass;
using Time = Nanosecond;
using BField = ClhepUnitBField;

static char const* label() { return "clhep"; }
};

using CgsTraits = UnitTraits<CELERITAS_UNITS_CGS>;
using SiTraits = UnitTraits<CELERITAS_UNITS_SI>;
using ClhepTraits = UnitTraits<CELERITAS_UNITS_CLHEP>;
using NativeTraits = UnitTraits<CELERITAS_UNITS>;
using CgsTraits = UnitSystemTraits<UnitSystem::cgs>;
using SiTraits = UnitSystemTraits<UnitSystem::si>;
using ClhepTraits = UnitSystemTraits<UnitSystem::clhep>;
using NativeTraits = UnitSystemTraits<UnitSystem::native>;

//---------------------------------------------------------------------------//
/*!
* Expand a macro to a switch statement over all possible unit system types.
*
* This is *not* a \c CELER_FUNCTION because unit conversion should be done
* only during preprocessing on the CPU.
*/
template<class F>
constexpr decltype(auto) visit_unit_system(F&& func, UnitSystem sys)
{
#define CELER_US_VISIT_CASE(TYPE) \
case UnitSystem::TYPE: \
return std::forward<F>(func)(UnitSystemTraits<UnitSystem::TYPE>{});

switch (sys)
{
CELER_US_VISIT_CASE(cgs);
CELER_US_VISIT_CASE(si);
CELER_US_VISIT_CASE(clhep);
default:
CELER_ASSERT_UNREACHABLE();
}

#undef CELER_US_VISIT_CASE
}

//---------------------------------------------------------------------------//
} // namespace units
Expand Down
8 changes: 0 additions & 8 deletions src/celeritas/ext/GeantImporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ std::vector<ImportElement> import_elements()
element.name = g4element->GetName();
element.atomic_number = g4element->GetZ();
element.atomic_mass = g4element->GetAtomicMassAmu();
element.radiation_length_tsai = g4element->GetfRadTsai() / (g / cm2);
element.coulomb_factor = g4element->GetfCoulomb();

// Despite the function name, this is *NOT* a vector, it's an array
double* const g4rel_abundance = g4element->GetRelativeAbundanceVector();
Expand Down Expand Up @@ -407,13 +405,8 @@ import_materials(GeantImporter::DataSelection::Flags particle_flags)
material.name = g4material->GetName();
material.state = to_material_state(g4material->GetState());
material.temperature = g4material->GetTemperature(); // [K]
material.density = g4material->GetDensity() / (g / cm3);
material.electron_density = g4material->GetTotNbOfElectPerVolume()
/ (1. / cm3);
material.number_density = g4material->GetTotNbOfAtomsPerVolume()
/ (1. / cm3);
material.radiation_length = g4material->GetRadlen() / cm;
material.nuclear_int_length = g4material->GetNuclearInterLength() / cm;

// Populate material production cut values
for (auto const& idx_convert : cut_converters)
Expand All @@ -439,7 +432,6 @@ import_materials(GeantImporter::DataSelection::Flags particle_flags)

ImportMatElemComponent elem_comp;
elem_comp.element_id = g4element->GetIndex();
elem_comp.mass_fraction = g4material->GetFractionVector()[j];
double elem_num_density = g4material->GetVecNbOfAtomsPerVolume()[j]
/ (1. / cm3);
elem_comp.number_fraction = elem_num_density
Expand Down
7 changes: 4 additions & 3 deletions src/celeritas/field/RZMapFieldInput.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ namespace celeritas
* The magnetic field is discretized at nodes on an R-Z grid, and each point
* the field vector is approximated by a 2-D vector in R-Z. The input units of
* this field are in *NATIVE UNITS* (cm/gauss when CGS). An optional \c _units
* field in the input can specify whether the input is in tesla or native
* units, with allowable values of "T", "tesla", "gauss", or "native".
* field in the input can specify whether the input is in SI or CGS
* units, with allowable values of "si", "cgs", or "clhep". The native CLHEP
* unit strength is 1000*tesla.
*
* The field values are all indexed with R having stride 1: [Z][R]
*/
Expand All @@ -35,8 +36,8 @@ struct RZMapFieldInput
unsigned int num_grid_z{};
unsigned int num_grid_r{};
double min_z{}; //!< Lower z coordinate [len]
double min_r{}; //!< Lower r coordinate [len]
double max_z{}; //!< Last z coordinate [len]
double min_r{}; //!< Lower r coordinate [len]
double max_r{}; //!< Last r coordinate [len]
std::vector<double> field_z; //!< Flattened Z field component [bfield]
std::vector<double> field_r; //!< Flattened R field component [bfield]
Expand Down
Loading

0 comments on commit acef5b5

Please sign in to comment.