diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index eea39e2489..0e867e7e7f 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -150,7 +150,7 @@ jobs: platform-release: "${{ env.platform }}:${{ matrix.release }}" run: | # install this repo - CXX="${{ matrix.CXX }}" CXXFLAGS="${{ matrix.CXXFLAGS }}" cmake --warn-uninitialized -B build -S . -DCMAKE_INSTALL_PREFIX=install -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DUSE_ASAN=${{matrix.USE_ASAN}} -DUSE_TSAN=${{matrix.USE_TSAN}} -DUSE_UBSAN=${{matrix.USE_UBSAN}} + CXX="${{ matrix.CXX }}" CXXFLAGS="${{ matrix.CXXFLAGS }}" cmake --warn-uninitialized -B build -S . -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=24 -DCMAKE_UNITY_BUILD_UNIQUE_ID=UNITY_BUILD_UNIQUE_ID -DCMAKE_INSTALL_PREFIX=install -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DUSE_ASAN=${{matrix.USE_ASAN}} -DUSE_TSAN=${{matrix.USE_TSAN}} -DUSE_UBSAN=${{matrix.USE_UBSAN}} cmake --build build -j $(getconf _NPROCESSORS_ONLN) --target install ccache --show-stats --verbose ccache --evict-older-than 7d diff --git a/src/algorithms/calorimetry/CalorimeterIslandCluster.cc b/src/algorithms/calorimetry/CalorimeterIslandCluster.cc index 0c85a4c5ff..cd7d4f26a4 100644 --- a/src/algorithms/calorimetry/CalorimeterIslandCluster.cc +++ b/src/algorithms/calorimetry/CalorimeterIslandCluster.cc @@ -34,10 +34,6 @@ using namespace edm4eic; namespace eicrecon { -template struct multilambda : L... { - using L::operator()...; - constexpr multilambda(L... lambda) : L(std::move(lambda))... {} -}; static double Phi_mpi_pi(double phi) { return std::remainder(phi, 2 * M_PI); } diff --git a/src/algorithms/calorimetry/CalorimeterIslandCluster.h b/src/algorithms/calorimetry/CalorimeterIslandCluster.h index c79e0eb380..72630e4d16 100644 --- a/src/algorithms/calorimetry/CalorimeterIslandCluster.h +++ b/src/algorithms/calorimetry/CalorimeterIslandCluster.h @@ -70,6 +70,11 @@ class CalorimeterIslandCluster : public CalorimeterIslandClusterAlgorithm, dd4hep::IDDescriptor m_idSpec; private: + template struct multilambda : L... { + using L::operator()...; + constexpr multilambda(L... lambda) : L(std::move(lambda))... {} + }; + // grouping function with Breadth-First Search void bfs_group(const edm4eic::CalorimeterHitCollection& hits, std::set& group, std::size_t idx, std::vector& visits) const; diff --git a/src/algorithms/calorimetry/ImagingTopoCluster.cc b/src/algorithms/calorimetry/ImagingTopoCluster.cc index 8031c7c6a6..8be5689ee7 100644 --- a/src/algorithms/calorimetry/ImagingTopoCluster.cc +++ b/src/algorithms/calorimetry/ImagingTopoCluster.cc @@ -37,10 +37,6 @@ #include "algorithms/calorimetry/ImagingTopoClusterConfig.h" namespace eicrecon { -template struct multilambda : L... { - using L::operator()...; - constexpr multilambda(L... lambda) : L(std::move(lambda))... {} -}; void ImagingTopoCluster::init() { diff --git a/src/algorithms/calorimetry/ImagingTopoCluster.h b/src/algorithms/calorimetry/ImagingTopoCluster.h index 1d7d30aae9..cd9cd20efd 100644 --- a/src/algorithms/calorimetry/ImagingTopoCluster.h +++ b/src/algorithms/calorimetry/ImagingTopoCluster.h @@ -69,6 +69,11 @@ class ImagingTopoCluster : public ImagingTopoClusterAlgorithm, void process(const Input& input, const Output& output) const final; private: + template struct multilambda : L... { + using L::operator()...; + constexpr multilambda(L... lambda) : L(std::move(lambda))... {} + }; + // helper function to group hits bool is_neighbour(const edm4eic::CalorimeterHit& h1, const edm4eic::CalorimeterHit& h2) const; diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 130ad0da8d..5cab55ac3d 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -15,25 +15,37 @@ namespace eicrecon { -static std::string print_shape(const std::vector& v) { - std::stringstream ss(""); - for (std::size_t i = 0; i < v.size() - 1; i++) { - ss << v[i] << "x"; - } - ss << v[v.size() - 1]; - return ss.str(); -} +#ifndef UNITY_BUILD_UNIQUE_ID +#define UNITY_BUILD_UNIQUE_ID +#endif -template -Ort::Value vec_to_tensor(std::vector& data, const std::vector& shape) { - Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, - OrtMemType::OrtMemTypeDefault); - auto tensor = - Ort::Value::CreateTensor(mem_info, data.data(), data.size(), shape.data(), shape.size()); - return tensor; -} +namespace { + namespace UNITY_BUILD_UNIQUE_ID { + + static std::string print_shape(const std::vector& v) { + std::stringstream ss(""); + for (std::size_t i = 0; i < v.size() - 1; i++) { + ss << v[i] << "x"; + } + ss << v[v.size() - 1]; + return ss.str(); + } + + template + Ort::Value vec_to_tensor(std::vector& data, const std::vector& shape) { + Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, + OrtMemType::OrtMemTypeDefault); + auto tensor = Ort::Value::CreateTensor(mem_info, data.data(), data.size(), shape.data(), + shape.size()); + return tensor; + } + + } // namespace UNITY_BUILD_UNIQUE_ID +} // namespace void InclusiveKinematicsML::init() { + using namespace UNITY_BUILD_UNIQUE_ID; + // onnxruntime setup m_env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, "inclusive-kinematics-ml"); Ort::SessionOptions session_options; @@ -89,6 +101,8 @@ void InclusiveKinematicsML::init() { void InclusiveKinematicsML::process(const InclusiveKinematicsML::Input& input, const InclusiveKinematicsML::Output& output) const { + using namespace UNITY_BUILD_UNIQUE_ID; + const auto [electron, da] = input; auto [ml] = output; diff --git a/src/algorithms/onnx/ONNXInference.cc b/src/algorithms/onnx/ONNXInference.cc index 4ed841325a..b40c43c5c1 100644 --- a/src/algorithms/onnx/ONNXInference.cc +++ b/src/algorithms/onnx/ONNXInference.cc @@ -18,42 +18,54 @@ namespace eicrecon { -static std::string print_shape(const std::vector& v) { - std::stringstream ss(""); - for (std::size_t i = 0; i < v.size() - 1; i++) { - ss << v[i] << " x "; - } - ss << v[v.size() - 1]; - return ss.str(); -} +#ifndef UNITY_BUILD_UNIQUE_ID +#define UNITY_BUILD_UNIQUE_ID +#endif -static bool check_shape_consistency(const std::vector& shape1, - const std::vector& shape2) { - if (shape2.size() != shape1.size()) { - return false; - } - for (std::size_t ix = 0; ix < shape1.size(); ix++) { - if ((shape1[ix] != -1) && (shape2[ix] != -1) && (shape1[ix] != shape2[ix])) { - return false; +namespace { + namespace UNITY_BUILD_UNIQUE_ID { + + static std::string print_shape(const std::vector& v) { + std::stringstream ss(""); + for (std::size_t i = 0; i < v.size() - 1; i++) { + ss << v[i] << " x "; + } + ss << v[v.size() - 1]; + return ss.str(); } - } - return true; -} -template -static Ort::Value iters_to_tensor(typename std::vector::const_iterator data_begin, - typename std::vector::const_iterator data_end, - std::vector::const_iterator shape_begin, - std::vector::const_iterator shape_end) { - Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, - OrtMemType::OrtMemTypeDefault); - auto tensor = - Ort::Value::CreateTensor(mem_info, const_cast(&*data_begin), data_end - data_begin, - &*shape_begin, shape_end - shape_begin); - return tensor; -} + static bool check_shape_consistency(const std::vector& shape1, + const std::vector& shape2) { + if (shape2.size() != shape1.size()) { + return false; + } + for (std::size_t ix = 0; ix < shape1.size(); ix++) { + if ((shape1[ix] != -1) && (shape2[ix] != -1) && (shape1[ix] != shape2[ix])) { + return false; + } + } + return true; + } + + template + static Ort::Value iters_to_tensor(typename std::vector::const_iterator data_begin, + typename std::vector::const_iterator data_end, + std::vector::const_iterator shape_begin, + std::vector::const_iterator shape_end) { + Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, + OrtMemType::OrtMemTypeDefault); + auto tensor = + Ort::Value::CreateTensor(mem_info, const_cast(&*data_begin), data_end - data_begin, + &*shape_begin, shape_end - shape_begin); + return tensor; + } + + } // namespace UNITY_BUILD_UNIQUE_ID +} // namespace void ONNXInference::init() { + using namespace UNITY_BUILD_UNIQUE_ID; + // onnxruntime setup m_env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, name().data()); Ort::SessionOptions session_options; @@ -106,6 +118,8 @@ void ONNXInference::init() { void ONNXInference::process(const ONNXInference::Input& input, const ONNXInference::Output& output) const { + using namespace UNITY_BUILD_UNIQUE_ID; + const auto [in_tensors] = input; auto [out_tensors] = output;