diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index cee9a629f9910e0674adcb5885eed4252d55b11b..c65a8e0584ebbc61063bea2187babb1755e876da 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -1,6 +1,6 @@ set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/simd + ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_CURRENT_SOURCE_DIR}/pars ${CMAKE_CURRENT_SOURCE_DIR}/data ) @@ -13,7 +13,7 @@ add_library(CaCore SHARED ${SRCS}) target_include_directories(CaCore PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/data - ${CMAKE_CURRENT_SOURCE_DIR}/simd + ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_CURRENT_SOURCE_DIR}/pars ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -25,7 +25,7 @@ target_link_libraries(CaCore ) install(TARGETS CaCore DESTINATION lib) -install(DIRECTORY simd TYPE INCLUDE FILES_MATCHING PATTERN "*.h") +install(DIRECTORY utils TYPE INCLUDE FILES_MATCHING PATTERN "*.h") install(DIRECTORY data TYPE INCLUDE FILES_MATCHING PATTERN "*.h") install(DIRECTORY pars TYPE INCLUDE FILES_MATCHING PATTERN "*.h") @@ -33,9 +33,9 @@ install( FILES data/CaTrack.h pars/CaConstants.h - simd/CaSimd.h - simd/CaSimdVc.h - simd/CaSimdPseudo.h + utils/CaSimd.h + utils/CaSimdVc.h + utils/CaSimdPseudo.h DESTINATION include/ ) diff --git a/algo/ca/core/simd/CaSimdVc.h b/algo/ca/core/simd/CaSimdVc.h deleted file mode 100644 index f807e12d02db3f5b608733f5cfa45e55dccf6e10..0000000000000000000000000000000000000000 --- a/algo/ca/core/simd/CaSimdVc.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2010-2014 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer], Maksym Zyzak */ - -#ifndef Ca_CaSimdVc_H -#define Ca_CaSimdVc_H - -#include "Vc/Vc" - -namespace cbm::algo::ca -{ - - typedef Vc::float_v fvec; - //typedef Vc::double_v fvec; - //typedef Vc::Vector<float, Vc::VectorAbi::Scalar> fvec; - //typedef Vc::SimdArray<float, 4> fvec; - - typedef fvec::EntryType fscal; - typedef fvec::MaskType fmask; - -#define _fvecalignment __attribute__((aligned(Vc::VectorAlignment))) - -} // namespace cbm::algo::ca - -#endif diff --git a/algo/ca/core/simd/CaSimd.h b/algo/ca/core/utils/CaSimd.h similarity index 100% rename from algo/ca/core/simd/CaSimd.h rename to algo/ca/core/utils/CaSimd.h diff --git a/algo/ca/core/simd/CaSimdPseudo.h b/algo/ca/core/utils/CaSimdPseudo.h similarity index 97% rename from algo/ca/core/simd/CaSimdPseudo.h rename to algo/ca/core/utils/CaSimdPseudo.h index 3e876001ee8b65863c58ee546644c5a0a44c6330..74f64da5afcd7d01aba7fcd850d8fa2c1b22a0e1 100644 --- a/algo/ca/core/simd/CaSimdPseudo.h +++ b/algo/ca/core/utils/CaSimdPseudo.h @@ -7,6 +7,7 @@ #include <iomanip> #include <iostream> +#include <boost/serialization/access.hpp> #include <cmath> @@ -138,6 +139,16 @@ namespace cbm::algo::ca } } + /// Serialization block + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive& ar, const unsigned int) + { + for (size_t i = 0; i < size(); ++i) { + ar& v[i]; + } + } + static fvec One() { return fvec(1.); } static fvec Zero() { return fvec(0.); } diff --git a/algo/ca/core/utils/CaSimdVc.h b/algo/ca/core/utils/CaSimdVc.h new file mode 100644 index 0000000000000000000000000000000000000000..668622c655b05d69cb67846380d0b8c70c618d4d --- /dev/null +++ b/algo/ca/core/utils/CaSimdVc.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2010-2014 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt + SPDX-License-Identifier: GPL-3.0-only + Authors: Igor Kulakov [committer], Maksym Zyzak */ + +#ifndef Ca_CaSimdVc_H +#define Ca_CaSimdVc_H + +#include "Vc/Vc" +#include <boost/serialization/access.hpp> +#include <boost/serialization/array.hpp> +#include <boost/serialization/split_free.hpp> + +namespace cbm::algo::ca +{ + typedef Vc::float_v fvec; + //typedef Vc::double_v fvec; + //typedef Vc::Vector<float, Vc::VectorAbi::Scalar> fvec; + //typedef Vc::SimdArray<float, 4> fvec; + + typedef fvec::EntryType fscal; + typedef fvec::MaskType fmask; + +#define _fvecalignment __attribute__((aligned(Vc::VectorAlignment))) +} // namespace cbm::algo::ca + +/// \brief Serializer for SIMD vectors +namespace boost::serialization +{ + template<class Archive> + void save(Archive& ar, const cbm::algo::ca::fvec& vect, unsigned int) + { + std::array<cbm::algo::ca::fscal, cbm::algo::ca::fvec::size()> buffer; + for (size_t i = 0; i < cbm::algo::ca::fvec::size(); ++i) { buffer[i] = vect[i]; } + ar << buffer; + } + + template<class Archive> + void load(Archive& ar, cbm::algo::ca::fvec& vect, unsigned int) + { + std::array<cbm::algo::ca::fscal, cbm::algo::ca::fvec::size()> buffer; + ar >> buffer; + for (size_t i = 0; i < cbm::algo::ca::fvec::size(); ++i) { + vect[i] = buffer[i]; + } + } + + template<class Archive> + void serialize(Archive& ar, cbm::algo::ca::fvec& vect, const unsigned int version) + { + split_free(ar, vect, version); + } +} + + +#endif diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index c91ad51763a53b9d94f25d03c7d143fe6f6e2902..d30f029ba0d8dc843e2213ac31ee9741731f00bf 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -213,7 +213,6 @@ install(FILES CbmL1Counters.h L1Algo/L1ObjectInitController.h #L1Algo/L1Constants.h L1Algo/L1Utils.h - L1Algo/L1SimdSerializer.h L1Algo/L1TrackPar.h utils/CbmCaIdealHitProducer.h utils/CbmCaIdealHitProducerDet.h diff --git a/reco/L1/L1Algo/L1BaseStationInfo.h b/reco/L1/L1Algo/L1BaseStationInfo.h index a23cbb5e7a3c6b39ee0886a54a63c3270d672ef1..cba776b6b40675f4e4df3d3bcb0a0d67d4b13812 100644 --- a/reco/L1/L1Algo/L1BaseStationInfo.h +++ b/reco/L1/L1Algo/L1BaseStationInfo.h @@ -18,6 +18,7 @@ // L1 Core #include "L1ObjectInitController.h" #include "L1Station.h" +#include "L1Material.h" // C++ std #include <bitset> #include <functional> diff --git a/reco/L1/L1Algo/L1Field.h b/reco/L1/L1Algo/L1Field.h index 353933a0211251401e2aa1a63e58a666b034d846..dc66cb30a6275244f42dc11a951471fa9af9fc57 100644 --- a/reco/L1/L1Algo/L1Field.h +++ b/reco/L1/L1Algo/L1Field.h @@ -8,8 +8,8 @@ #include <string> #include "CaConstants.h" -#include "L1Def.h" -#include "L1SimdSerializer.h" +#include "CaSimd.h" +#include <boost/serialization/access.hpp> class L1TrackPar; diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index 6322a03ddb6da55efe946ef1cef367a968eaa31d..1a0f5e9fa2103ce1b4853441ab399e0f6b5e67dc 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -26,6 +26,7 @@ #include "L1Parameters.h" #include "L1Utils.h" #include "L1Vector.h" +#include "CaSimd.h" class L1ConfigRW; class L1Algo; diff --git a/reco/L1/L1Algo/L1Material.h b/reco/L1/L1Algo/L1Material.h index 5c3ef784bb1d831d1f404b86f389d80c3ee13d6a..d060c37790214b0460ea2bd322a5ee72e27ec8bc 100644 --- a/reco/L1/L1Algo/L1Material.h +++ b/reco/L1/L1Algo/L1Material.h @@ -13,8 +13,7 @@ #include <vector> #include "CaConstants.h" -#include "L1Def.h" -#include "L1SimdSerializer.h" +#include "CaSimd.h" using namespace cbm::algo::ca; diff --git a/reco/L1/L1Algo/L1SimdSerializer.h b/reco/L1/L1Algo/L1SimdSerializer.h deleted file mode 100644 index 79505b8125c82cdb2dc305b433ae486c6194c592..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1SimdSerializer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/// \file L1SimdSerializer.h -/// \brief External serialization for SIMD vector -/// \since 02.09.2022 -/// \author S.Zharko <s.zharko@gsi.de> - -#ifndef L1SimdSerializer_h -#define L1SimdSerializer_h 1 - -#include <boost/serialization/access.hpp> -#include <boost/serialization/split_free.hpp> - -#include "CaSimd.h" -/// This header defines functionality for saving and loading SIMDized vectors. At the moment, only the first element of -/// the vector can be saved, and the loaded vector will be horizontally equal. -/// -namespace boost -{ - namespace serialization - { - template<class Archive> - void save(Archive& ar, const cbm::algo::ca::fvec& vect, unsigned int) - { - ar << vect[0]; - } - - template<class Archive> - void load(Archive& ar, cbm::algo::ca::fvec& vect, unsigned int) - { - cbm::algo::ca::fscal buffer; - ar >> buffer; - for (size_t i = 0; i < cbm::algo::ca::fvec::size(); ++i) { - vect[i] = buffer; - } - } - - template<class Archive> - void serialize(Archive& ar, cbm::algo::ca::fvec& vect, const unsigned int version) - { - split_free(ar, vect, version); - } - } // namespace serialization -} // namespace boost - -#endif // L1SimdSerializer_h diff --git a/reco/L1/L1Algo/L1Station.h b/reco/L1/L1Algo/L1Station.h index b5b04cb559b5808c9ffaf2440ff51fc18b8bbc8b..62389f9d51b7a3c62721dda0c8cf842690e1639f 100644 --- a/reco/L1/L1Algo/L1Station.h +++ b/reco/L1/L1Algo/L1Station.h @@ -10,11 +10,8 @@ #include "CaConstants.h" #include "L1Field.h" -#include "L1Material.h" -#include "L1SimdSerializer.h" -#include "L1UMeasurementInfo.h" +#include "CaSimd.h" #include "L1Utils.h" -#include "L1XYMeasurementInfo.h" /// Structure L1Station /// Contains a set of geometry parameters for a particular station @@ -24,7 +21,7 @@ public: // TODO: SZh 12.05.2022: Rewrite type into L1DetectorID, change detector indexing scheme // TODO: SZh 12.05.2022: Provide getters to stations - int type = cbm::algo::ca::constants::undef::Int; + int type = cbm::algo::ca::constants::undef::Int; // ? Detector type? int timeInfo = cbm::algo::ca::constants::undef::Int; ///< flag: if time information can be used int fieldStatus = cbm::algo::ca::constants::undef::Int; ///< flag: 1 - station is INSIDE the field, 0 - station is OUTSIDE the field diff --git a/reco/L1/L1Algo/L1UMeasurementInfo.h b/reco/L1/L1Algo/L1UMeasurementInfo.h index 7390e4af7450c781c8dc15fba5fcc8b33d26d809..0a42c8e79401de83d7cf78bab2d57bab0f9cfbf4 100644 --- a/reco/L1/L1Algo/L1UMeasurementInfo.h +++ b/reco/L1/L1Algo/L1UMeasurementInfo.h @@ -8,8 +8,8 @@ #include <string> #include "CaConstants.h" +#include "CaSimd.h" #include "L1Def.h" -#include "L1SimdSerializer.h" #include "L1Utils.h" class L1UMeasurementInfo { diff --git a/reco/L1/L1Algo/L1XYMeasurementInfo.h b/reco/L1/L1Algo/L1XYMeasurementInfo.h index 6580a59ae03cb54813f2be42fdb665c15234e8ea..34781242d2153f8ba24fabb990c33ed246093718 100644 --- a/reco/L1/L1Algo/L1XYMeasurementInfo.h +++ b/reco/L1/L1Algo/L1XYMeasurementInfo.h @@ -8,8 +8,8 @@ #include <string> #include "CaConstants.h" +#include "CaSimd.h" #include "L1Def.h" -#include "L1SimdSerializer.h" using namespace cbm::algo::ca; diff --git a/reco/L1/catools/CaToolsMCTrack.h b/reco/L1/catools/CaToolsMCTrack.h index 6b55029a0ec8f30dc917c9d158ce8769bb9d4591..1b50bb7f1b6e15a2c1d4b235ae3f2dd5f3061ade 100644 --- a/reco/L1/catools/CaToolsMCTrack.h +++ b/reco/L1/catools/CaToolsMCTrack.h @@ -154,7 +154,7 @@ namespace ca::tools int GetPdgCode() const { return fPdgCode; } /// Gets azimuthal angle [rad] - double GetPhi() const { return TMath::ATan2(-fMom[1], -fMom[0]); } + double GetPhi() const { return std::atan2(fMom[1], fMom[0]); } /// Gets a reference to associated point indexes const auto& GetPointIndexes() const { return fvPointIndexes; } diff --git a/reco/littrack/parallel/CMakeLists.txt b/reco/littrack/parallel/CMakeLists.txt index 4acecba75edfe33430f0c276a1eaaa91f1a6534c..48d06d4bc17da5859c829593bd9a7570f9324e28 100644 --- a/reco/littrack/parallel/CMakeLists.txt +++ b/reco/littrack/parallel/CMakeLists.txt @@ -2,7 +2,7 @@ set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} - ${CBMROOT_SOURCE_DIR}/algo/ca/core/simd + ${CBMROOT_SOURCE_DIR}/algo/ca/core/utils )