Skip to content

Commit

Permalink
Add JLSE CMake preset and a few small fixes (#1611)
Browse files Browse the repository at this point in the history
* Work around maybe-uninitialized warning:

In file included from /soft/compilers/gcc/12.2.0/x86_64-suse-linux/include/c++/12.2.0/string:40,
                 from /home/alund/celeritas_project/celeritas/src/corecel/io/Label.hh:12,
                 from /home/alund/celeritas_project/celeritas/test/corecel/io/Label.test.cc:7:
In static member function ‘static constexpr int std::char_traits<char>::compare(const char_type*, const char_type*, std::size_t)’,
    inlined from ‘int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /soft/compilers/gcc/12.2.0/x86_64-suse-linux/include/c++/12.2.0/bits/basic_string.h:3148:32,
    inlined from ‘bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]’ at /soft/compilers/gcc/12.2.0/x86_64-suse-linux/include/c++/12.2.0/bits/basic_string.h:3694:27,
    inlined from ‘bool celeritas::operator<(const Label&, const Label&)’ at /home/alund/celeritas_project/celeritas/src/corecel/io/Label.hh:98:17,
    inlined from ‘bool celeritas::operator<(const Label&, const Label&)’ at /home/alund/celeritas_project/celeritas/src/corecel/io/Label.hh:92:13,
    inlined from ‘virtual void celeritas::test::LabelTest_ordering_Test::TestBody()’ at /home/alund/celeritas_project/celeritas/test/corecel/io/Label.test.cc:28:5:
/soft/compilers/gcc/12.2.0/x86_64-suse-linux/include/c++/12.2.0/bits/char_traits.h:385:32: error: ‘*(const unsigned char*)((char*)&<unnamed> + offsetof(celeritas::Label, celeritas::Label::ext.std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::<unnamed>))’ may be used uninitialized [-Werror=maybe-uninitialized]
  385 |         return __builtin_memcmp(__s1, __s2, __n);
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /home/alund/spack/var/spack/environments/celeritas/.spack-env/view/include/gtest/gtest-printers.h:122,
                 from /home/alund/spack/var/spack/environments/celeritas/.spack-env/view/include/gtest/gtest-matchers.h:49,
                 from /home/alund/spack/var/spack/environments/celeritas/.spack-env/view/include/gtest/internal/gtest-death-test-internal.h:47,
                 from /home/alund/spack/var/spack/environments/celeritas/.spack-env/view/include/gtest/gtest-death-test.h:43,
                 from /home/alund/spack/var/spack/environments/celeritas/.spack-env/view/include/gtest/gtest.h:64,
                 from /home/alund/celeritas_project/celeritas/test/Test.hh:12,
                 from /home/alund/celeritas_project/celeritas/test/celeritas_test.hh:16,
                 from /home/alund/celeritas_project/celeritas/test/corecel/io/Label.test.cc:9:
/home/alund/celeritas_project/celeritas/test/corecel/io/Label.test.cc: In member function ‘virtual void celeritas::test::LabelTest_ordering_Test::TestBody()’:
/home/alund/celeritas_project/celeritas/test/corecel/io/Label.test.cc:28:50: note: ‘<anonymous>’ declared here
   28 |     EXPECT_FALSE(Label("a", "2") < Label("a", "1"));
      |                                                  ^

* Fix broken links

* Fix and test NormalDistribution copy constructor

* Add JLSE cmake preset

* Address feedback
  • Loading branch information
amandalund authored Feb 5, 2025
1 parent 168ddc9 commit b607c51
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Then see the "Downstream usage as a library" section of the [installation
documentation][install] for how to use Celeritas in your application or framework.

[spack-start]: https://spack.readthedocs.io/en/latest/getting_started.html
[install]: https://celeritas-project.github.io/celeritas/user/introduction/installation.html
[install]: https://celeritas-project.github.io/celeritas/user/usage/installation.html

# Installation for developers

Expand Down Expand Up @@ -141,7 +141,7 @@ The full set of configurations is viewable on CI platform [GitHub Actions][gha])
Compatibility fixes that do not cause newer versions to fail are welcome.

[spack]: https://github.com/spack/spack
[install]: https://celeritas-project.github.io/celeritas/user/introduction/installation.html
[install]: https://celeritas-project.github.io/celeritas/user/usage/installation.html
[gha]: https://github.com/celeritas-project/celeritas/actions

# Development
Expand All @@ -152,7 +152,7 @@ details on coding in Celeritas, and [the administration guidelines][administrati

[contributing-guidelines]: https://celeritas-project.github.io/celeritas/user/development/contributing.html
[development-guidelines]: https://celeritas-project.github.io/celeritas/user/development/coding.html
[administration-guidelines]: https://celeritas-project.github.io/celeritas/user/appendix/administration.html
[administration-guidelines]: https://celeritas-project.github.io/celeritas/user/development/administration.html

# Directory structure

Expand Down
1 change: 1 addition & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cd "$(dirname $0)"/..
SYSTEM_NAME=${LMOD_SYSTEM_NAME}
if [ -z "${SYSTEM_NAME}" ]; then
SYSTEM_NAME=${HOSTNAME%%.*}
SYSTEM_NAME=${SYSTEM_NAME%%login*}
fi

# Link user presets for this system if they don't exist
Expand Down
117 changes: 117 additions & 0 deletions scripts/cmake-presets/jlse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"version": 3,
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
"configurePresets": [
{
"name": ".base",
"hidden": true,
"inherits": ["full"],
"binaryDir": "${sourceDir}/build-${presetName}",
"generator": "Ninja",
"cacheVariables": {
"BUILD_SHARED_LIBS": {"type": "BOOL", "value": "ON"},
"CELERITAS_BUILD_DOCS": {"type": "BOOL", "value": "OFF"},
"CELERITAS_USE_OpenMP": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_Geant4": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_HepMC3": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_CUDA": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_HIP": {"type": "BOOL", "value": "OFF"},
"CELERITAS_USE_MPI": {"type": "BOOL", "value": "OFF"},
"CELERITAS_USE_ROOT": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "ON"},
"CMAKE_CXX_FLAGS": "-Wall -Wextra -pedantic -Werror",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_CXX_EXTENSIONS": {"type": "BOOL", "value": "OFF"},
"CMAKE_CUDA_FLAGS": "-Werror all-warnings",
"CMAKE_CUDA_ARCHITECTURES": "70;80;90",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install-${presetName}",
"CMAKE_EXPORT_COMPILE_COMMANDS": {"type": "BOOL", "value": "ON"}
}
},
{
"name": "base",
"displayName": "JLSE default options (CUDA, VecGeom)",
"inherits": [".base"],
"binaryDir": "${sourceDir}/build"
},
{
"name": "release",
"displayName": "Build with optimizations and disable debug assertions",
"inherits": [".base", ".ndebug"],
"binaryDir": "${sourceDir}/build-release"
},
{
"name": "reldeb",
"displayName": "Build with basic optimizations and debug assertions",
"inherits": [".base", ".reldeb"],
"binaryDir": "${sourceDir}/build-reldeb",
"cacheVariables": {
"CELERITAS_DEVICE_DEBUG":{"type": "BOOL", "value": "ON"}
}
},
{
"name": "debug",
"displayName": "Build with debug assertions",
"inherits": [".base", ".debug"],
"binaryDir": "${sourceDir}/build-debug",
"cacheVariables": {
"CELERITAS_DEVICE_DEBUG":{"type": "BOOL", "value": "ON"}
}
},
{
"name": "release-orange",
"displayName": "Build with optimizations and disable VecGeom and debug assertions",
"inherits": [".base", "release"],
"binaryDir": "${sourceDir}/build-release-orange",
"cacheVariables": {
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "OFF"}
}
},
{
"name": "reldeb-orange",
"displayName": "Build with debug assertions and disable VecGeom",
"inherits": [".base", "reldeb"],
"binaryDir": "${sourceDir}/build-reldeb-orange",
"cacheVariables": {
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "OFF"}
}
},
{
"name": "float",
"displayName": "Build with single precision and disable VecGeom",
"inherits": ["reldeb-orange"],
"binaryDir": "${sourceDir}/build-float",
"cacheVariables": {
"CELERITAS_REAL_TYPE": "float"
}
}
],
"buildPresets": [
{
"name": "base",
"configurePreset": "base",
"jobs": 8,
"nativeToolOptions": ["-k0"]
},
{"name": "release", "configurePreset": "release", "inherits": "base"},
{"name": "reldeb", "configurePreset": "reldeb", "inherits": "base"},
{"name": "debug", "configurePreset": "debug", "inherits": "base"},
{"name": "release-orange", "configurePreset": "release-orange", "inherits": "base"},
{"name": "reldeb-orange", "configurePreset": "reldeb-orange", "inherits": "base"},
{"name": "float", "configurePreset": "float", "inherits": "base"}
],
"testPresets": [
{
"name": "base",
"configurePreset": "base",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": false, "jobs": 8}
},
{"name": "release", "configurePreset": "release", "inherits": "base"},
{"name": "reldeb", "configurePreset": "reldeb", "inherits": "base"},
{"name": "debug", "configurePreset": "debug", "inherits": "base"},
{"name": "release-orange", "configurePreset": "release-orange", "inherits": "base"},
{"name": "reldeb-orange", "configurePreset": "reldeb-orange", "inherits": "base"},
{"name": "float", "configurePreset": "float", "inherits": "base"}
]
}
2 changes: 1 addition & 1 deletion src/celeritas/random/distribution/NormalDistribution.hh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ NormalDistribution<RealType>::NormalDistribution(real_type mean,
template<class RealType>
CELER_FUNCTION
NormalDistribution<RealType>::NormalDistribution(NormalDistribution const& other)
: mean_{other.mean}, stddev_{other.stddev}
: mean_{other.mean_}, stddev_{other.stddev_}
{
}

Expand Down
9 changes: 2 additions & 7 deletions src/corecel/io/Label.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <functional>
#include <iosfwd>
#include <string>
#include <tuple>
#include <utility>

#include "corecel/Config.hh"
Expand Down Expand Up @@ -91,13 +92,7 @@ inline bool operator!=(Label const& lhs, Label const& rhs)
//! Less-than comparison for sorting
inline bool operator<(Label const& lhs, Label const& rhs)
{
if (lhs.name < rhs.name)
return true;
else if (lhs.name > rhs.name)
return false;
if (lhs.ext < rhs.ext)
return true;
return false;
return std::tie(lhs.name, lhs.ext) < std::tie(rhs.name, rhs.ext);
}

//---------------------------------------------------------------------------//
Expand Down
13 changes: 13 additions & 0 deletions test/celeritas/random/distribution/NormalDistribution.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ TEST(NormalDistributionTest, move)
EXPECT_DOUBLE_EQ(4 * samples[1], sample_normal(rng));
}

TEST(NormalDistributionTest, copy)
{
DiagnosticRngEngine<std::mt19937> rng;
NormalDistribution<double> sample{4, 0.5};

// Initialize with parameters but not spare values
NormalDistribution<double> sample_copy{sample};

auto orig = sample(rng);
rng = {};
EXPECT_DOUBLE_EQ(orig, sample_copy(rng));
}

//---------------------------------------------------------------------------//
} // namespace test
} // namespace celeritas

0 comments on commit b607c51

Please sign in to comment.