Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate header naming convention #1325

Merged
merged 32 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3988cd9
use inline constexpr
esseivaju Jul 15, 2024
81f6ede
refactor header extension to hh
esseivaju Jul 16, 2024
16c661d
update clang-format
esseivaju Jul 18, 2024
d946d70
move version header to corecel, keep older header for compatibility
esseivaju Jul 18, 2024
6efb2a7
add missing macro
esseivaju Jul 18, 2024
07b4fd7
add warning message
esseivaju Jul 18, 2024
d58d87a
create C++ version of config/version headers, keep old header for com…
esseivaju Jul 18, 2024
d33dba5
use new version of headers
esseivaju Jul 18, 2024
afe200e
rename device_runtime_api.h
esseivaju Jul 18, 2024
5610f53
case-sensitive sort to preserve directory order
esseivaju Jul 18, 2024
5bcd101
cleanup duplicate
esseivaju Jul 18, 2024
48506e5
sort headers
esseivaju Jul 19, 2024
da4b21f
gcc version check and doc
esseivaju Jul 19, 2024
1e29e37
Merge branch 'develop' into inline-const
esseivaju Jul 19, 2024
e5257e5
update include
esseivaju Jul 19, 2024
3c6220e
gcc-friendly syntax
esseivaju Jul 19, 2024
524103e
rename device_runtime_api.hh to CamelCase
esseivaju Jul 20, 2024
d608da8
keep device_runtime_api.h for compatibility
esseivaju Jul 20, 2024
9e66b49
Update doxygen
esseivaju Jul 20, 2024
9480c58
Merge branch 'develop' into inline-const
esseivaju Jul 25, 2024
a5eb109
move configure_file
esseivaju Jul 25, 2024
654fc54
error if using the wrong standard
esseivaju Jul 25, 2024
0661141
remove compat strings
esseivaju Jul 25, 2024
132e448
keep warning message
esseivaju Jul 25, 2024
c1b1421
Combine corecel/Config and corecel/sys/Config
esseivaju Jul 25, 2024
c19cf26
update includes
esseivaju Jul 25, 2024
4a884cc
update device_runtime_api.h
esseivaju Jul 25, 2024
637c25c
remove celeritas_*.h rule
esseivaju Jul 25, 2024
0c06937
Rename symbol
esseivaju Jul 25, 2024
adbb96b
add doc
esseivaju Jul 25, 2024
cc86a18
run clang-format
esseivaju Jul 25, 2024
32ae942
Merge branch 'develop' into inline-const
sethrj Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
Expand Down Expand Up @@ -71,44 +71,45 @@ IncludeCategories:
- Regex: '^<.+>$'
Priority: 1
SortPriority: 2
# Special group for config/version headers as they might be needed before other headers
- Regex: '^"celeritas_[a-z_]+\.h"'
Priority: 2
SortPriority: 3
- Regex: '^"corecel/device_runtime_api\.h"$'
- Regex: '^"corecel/(Config|Version|DeviceRuntimeApi)\.hh"$'
sethrj marked this conversation as resolved.
Show resolved Hide resolved
Priority: 2
SortPriority: 3
- Regex: '^"corecel/'
Priority: 2
Priority: 3
SortPriority: 5
CaseSensitive: true
- Regex: '^"geocel/'
Priority: 2
Priority: 3
SortPriority: 6
CaseSensitive: true
- Regex: '^"orange/'
Priority: 2
Priority: 3
SortPriority: 7
CaseSensitive: true
- Regex: '^"celeritas/'
Priority: 2
Priority: 3
SortPriority: 8
CaseSensitive: true
- Regex: '^"accel/'
Priority: 2
Priority: 3
SortPriority: 9
CaseSensitive: true
- Regex: '^"[^/]+"'
Priority: 5
Priority: 6
SortPriority: 11
- Regex: '^"detail/'
Priority: 6
Priority: 7
SortPriority: 13
- Regex: '"(^gtest/|TestBase|\.test\.hh|celeritas_test\.hh)'
Priority: 7
Priority: 8
CaseSensitive: true
SortPriority: 14
- Regex: '.*'
Priority: 5
Priority: 6
SortPriority: 12 # higher than detail, lower than no-slash
IncludeIsMainRegex: '(\.[^.]+)?$'
IncludeIsMainSourceRegex: '(\.cu|\.t\.hh)$' # Allow CU/template files as main
Expand Down Expand Up @@ -138,7 +139,7 @@ PenaltyReturnTypeOnItsOwnLine: 10
PointerAlignment: Left
QualifierAlignment: Right
ReflowComments: true
SortIncludes: true
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
Expand All @@ -155,7 +156,7 @@ SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: c++17
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand Down
3 changes: 2 additions & 1 deletion app/celer-export-geant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <vector>
#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/io/Logger.hh"
#include "corecel/sys/MpiCommunicator.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/celer-g4/RootIO.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <G4ThreadLocalSingleton.hh>
#include <G4Types.hh>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "celeritas/io/EventData.hh"

Expand Down
3 changes: 2 additions & 1 deletion app/celer-g4/RunAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <G4RunManager.hh>
#include <G4StateManager.hh>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/Macros.hh"
#include "corecel/io/Logger.hh"
Expand Down
5 changes: 3 additions & 2 deletions app/celer-g4/celer-g4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@

#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "celeritas_version.h"
#include "corecel/Config.hh"
#include "corecel/Version.hh"

#include "corecel/Assert.hh"
#include "corecel/Macros.hh"
#include "corecel/io/ExceptionOutput.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/celer-geo/Runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//---------------------------------------------------------------------------//
#include "Runner.hh"

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/io/StringUtils.hh"
#include "corecel/sys/Device.hh"
#include "corecel/sys/Stopwatch.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/celer-geo/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//---------------------------------------------------------------------------//
#pragma once

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Types.hh"
#include "geocel/g4/GeantGeoTraits.hh"
#include "geocel/vg/VecgeomGeoTraits.hh"
Expand Down
5 changes: 3 additions & 2 deletions app/celer-geo/celer-geo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include <vector>
#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "celeritas_version.h"
#include "corecel/Config.hh"
#include "corecel/Version.hh"

#include "corecel/io/ExceptionOutput.hh"
#include "corecel/io/Logger.hh"
#include "corecel/io/Repr.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/celer-sim/RootOutput.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//---------------------------------------------------------------------------//
#pragma once

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"

namespace celeritas
Expand Down
3 changes: 2 additions & 1 deletion app/celer-sim/RunnerInput.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//---------------------------------------------------------------------------//
#pragma once

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Macros.hh"
#include "corecel/Types.hh"
#include "corecel/io/Label.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/celer-sim/RunnerInputIO.json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <string>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/cont/ArrayIO.json.hh"
#include "corecel/io/JsonUtils.json.hh"
#include "corecel/io/LabelIO.json.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/celer-sim/RunnerOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <utility>
#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/cont/Range.hh"
#include "corecel/io/JsonPimpl.hh"
Expand Down
7 changes: 4 additions & 3 deletions app/celer-sim/celer-sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "celeritas_version.h"
#include "corecel/device_runtime_api.h"
#include "corecel/Config.hh"
#include "corecel/DeviceRuntimeApi.hh"
#include "corecel/Version.hh"

#include "corecel/io/BuildOutput.hh"
#include "corecel/io/ExceptionOutput.hh"
#include "corecel/io/Logger.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/demo-geo-check/GCheckKernel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <memory>
#include <vector>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/Macros.hh"
#include "corecel/Types.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/demo-geo-check/demo-geo-check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <vector>
#include <nlohmann/json.hpp>

#include "celeritas_cmake_strings.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/Types.hh"
#include "corecel/cont/ArrayIO.json.hh"
Expand Down
2 changes: 1 addition & 1 deletion app/demo-interactor/KNDemoKernel.thrust.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <thrust/device_ptr.h>
#include <thrust/reduce.h>

#include "corecel/device_runtime_api.h"
#include "corecel/DeviceRuntimeApi.hh"

namespace celeritas
{
Expand Down
3 changes: 2 additions & 1 deletion app/demo-interactor/demo-interactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <vector>
#include <nlohmann/json.hpp>

#include "celeritas_version.h"
#include "corecel/Version.hh"

#include "corecel/io/Logger.hh"
#include "corecel/sys/Device.hh"
#include "corecel/sys/DeviceIO.json.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/demo-interactor/host-demo-interactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <vector>
#include <nlohmann/json.hpp>

#include "celeritas_version.h"
#include "corecel/Version.hh"

#include "corecel/Assert.hh"
#include "corecel/io/Logger.hh"
#include "corecel/sys/Device.hh"
Expand Down
3 changes: 2 additions & 1 deletion app/orange-update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <vector>
#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/io/Logger.hh"
#include "corecel/sys/MpiCommunicator.hh"
Expand Down
2 changes: 2 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ set(_DOXYGEN_EXTRA_SOURCE
"${PROJECT_BINARY_DIR}/include/celeritas_config.h"
"${PROJECT_BINARY_DIR}/include/celeritas_cmake_strings.h"
"${PROJECT_BINARY_DIR}/include/celeritas_version.h"
"${PROJECT_BINARY_DIR}/include/corecel/Version.hh"
"${PROJECT_BINARY_DIR}/include/corecel/Config.hh"
)
if((CELERITAS_DEBUG AND CELERITAS_BUILD_TESTS)
OR CELERITAS_DOXYGEN_BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion doc/appendix/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ such as
``cudaMalloc`` does *not* have to be compiled with NVCC. Instead, it only has to
be linked against the CUDA runtime library and include ``cuda_runtime_api.h``.
The platform-agnostic Celeritas include file to use is
``corecel/device_runtime_api.h``.
``corecel/DeviceRuntimeApi.hh``.
Note that VecGeom compiles differently when run
through NVCC (macro magic puts much of the code in a different namespace) so
its inclusion must be very carefully managed.
Expand Down
13 changes: 8 additions & 5 deletions doc/main/api/corecel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ primarily pertaining to GPU abstractions.
Configuration
-------------

The ``celeritas_config.h`` configure file contains all-caps definitions of the
The ``corecel/Config.hh`` configure file contains all-caps definitions of the
CMake configuration options as 0/1 defines so they can be used with ``if
constexpr`` and other C++ expressions. The ``celeritas_cmake_strings.h``
defines static C strings with configuration options such as key dependent
library versions. Finally, ``celeritas_version.h`` defines version numbers as
a preprocessor definition, a set of integers, and a descriptive string.
constexpr`` and other C++ expressions. In addition, it defines static C strings
with configuration options such as key dependent library versions.
Finally, ``corecel/Version.hh`` defines version numbers as preprocessor definition,
a set of integers, and a descriptive string. ``celeritas_version.h``,
``celeritas_cmake_strings.h``, ``celeritas_sys_config.h``, ``celeritas_config.h``
and ``corecel/device_runtime_api.h`` are deprecated and kept as aliases for
backward-compatibility. They may be removed in an upcoming major version.

.. doxygendefine:: CELERITAS_VERSION
.. doxygenvariable:: celeritas_version
Expand Down
10 changes: 4 additions & 6 deletions interface/celeritas.i
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
// CONFIG FILE
//---------------------------------------------------------------------------//
%{
#include "celeritas_version.h"
#include "celeritas_config.h"
#include "celeritas_cmake_strings.h"
#include "corecel/Config.hh"
#include "corecel/Version.hh"
%}

%include "celeritas_version.h"
%include "celeritas_config.h"
%include "celeritas_cmake_strings.h"
%include "corecel/Config.hh"
%include "corecel/Version.hh"

//---------------------------------------------------------------------------//
// ASSERTIONS
Expand Down
6 changes: 3 additions & 3 deletions scripts/dev/celeritas-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class {name}Test : public ::celeritas::test::Test
TEST_HEADER_FILE = '''
#pragma once

#include "celeritas_config.h"
#include "corecel/Assert.hh"
#include "corecel/Config.hh"
#include "corecel/Macros.hh"
#include "corecel/Types.hh"

Expand Down Expand Up @@ -240,8 +240,8 @@ class {name}Test : public ::celeritas::test::Test
TEST_CODE_FILE = '''\
#include "{name}.test.hh"

#include "corecel/device_runtime_api.h"
#include "corecel/Types.h"
#include "corecel/DeviceRuntimeApi.hh"
#include "corecel/Types.hh"
#include "corecel/sys/KernelParamCalculator.device.hh"
#include "corecel/sys/Device.hh"

Expand Down
2 changes: 1 addition & 1 deletion scripts/dev/run-iwyu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi
OUTFILE=$(mktemp)
iwyu_tool.py -p $1 -- \
-Xiwyu --no_fwd_decls \
-Xiwyu --keep="*device_runtime_api*" \
-Xiwyu --keep="*DeviceRuntimeApi*" \
-Xiwyu --keep="*.json.hh*" \
-Xiwyu --transitive_includes_only \
-Xiwyu --mapping_file="${SCRIPT_DIR}/iwyu-apple-clang.imp" \
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ foreach(_var BUILD_TYPE HOSTNAME REAL_TYPE UNITS OPENMP CORE_GEO CORE_RNG)
set(_var "CELERITAS_${_var}")
string(TOLOWER "${_var}" _lower)
string(APPEND CELERITAS_CMAKE_STRINGS
"static const char ${_lower}[] = \"${${_var}}\";\n"
"inline constexpr char ${_lower}[] = \"${${_var}}\";\n"
)
endforeach()

Expand All @@ -64,7 +64,7 @@ foreach(_var CLHEP_VERSION Geant4_VERSION VecGeom_VERSION)
endif()
set(_value "${${_var}}")
string(APPEND CELERITAS_CMAKE_STRINGS
"static const char celeritas_${_lower}[] = \"${_value}\";\n"
"inline constexpr char celeritas_${_lower}[] = \"${_value}\";\n"
)
endforeach()
celeritas_configure_file("celeritas_cmake_strings.h.in" "celeritas_cmake_strings.h" @ONLY)
Expand Down
3 changes: 2 additions & 1 deletion src/accel/ExceptionConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <string>
#include <G4Exception.hh>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/Assert.hh"
#include "corecel/Macros.hh"
#include "corecel/OpaqueIdIO.hh"
Expand Down
3 changes: 2 additions & 1 deletion src/accel/GeantSimpleCalo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <nlohmann/json.hpp>

#include "celeritas_config.h"
#include "corecel/Config.hh"

#include "corecel/cont/Range.hh"
#include "corecel/io/JsonPimpl.hh"
#include "corecel/io/LabelIO.json.hh"
Expand Down
Loading
Loading