File indexing completed on 2025-01-18 10:13:52
0001
0002
0003
0004 #ifndef VECGEOM_BASE_GLOBAL_H_
0005 #define VECGEOM_BASE_GLOBAL_H_
0006
0007 #if __cplusplus < 201103L
0008 #error VecGeom requires compiler and library support for the ISO C++ 2011 standard.
0009 #endif
0010
0011 #include "VecGeom/base/Config.h"
0012
0013 #ifdef VECGEOM_FLOAT_PRECISION
0014 #define VECCORE_SINGLE_PRECISION
0015 using Precision = float;
0016 #else
0017 using Precision = double;
0018 #endif
0019
0020 #include <VecCore/VecCore>
0021
0022 #include "VecGeom/base/Config.h"
0023 #include "VecGeom/base/Cuda.h"
0024 #include "VecGeom/base/Math.h"
0025 #include <type_traits>
0026
0027 using uint = unsigned int;
0028 using NavIndex_t = unsigned int;
0029
0030 #define VECGEOM
0031
0032 #ifdef __INTEL_COMPILER
0033
0034 #define VECGEOM_INTEL
0035 #define VECGEOM_FORCE_INLINE inline
0036 #ifndef VECCORE_CUDA
0037 #define VECGEOM_ALIGNED __attribute__((aligned(64)))
0038 #endif
0039 #else
0040 #if (defined(__GNUC__) || defined(__GNUG__) || defined(__clang__)) && !defined(__NO_INLINE__) && \
0041 !defined(VECGEOM_NOINLINE)
0042 #define VECGEOM_FORCE_INLINE inline __attribute__((always_inline))
0043 #ifndef VECCORE_CUDA
0044 #define VECGEOM_ALIGNED __attribute__((aligned(64)))
0045 #endif
0046 #else
0047
0048 #define VECGEOM_FORCE_INLINE inline
0049 #ifndef VECCORE_CUDA
0050 #define VECGEOM_ALIGNED
0051 #endif
0052 #endif
0053 #endif
0054
0055
0056 #define VECGEOM_CONSTEXPR constexpr
0057 #define VECGEOM_CONSTEXPR_RETURN constexpr
0058
0059
0060 #ifdef VECCORE_CUDA_DEVICE_COMPILATION
0061
0062 #define VECGEOM_GLOBAL static __constant__ const
0063 #define VECGEOM_CLASS_GLOBAL static const
0064 #else
0065 #define VECGEOM_GLOBAL static constexpr
0066 #define VECGEOM_CLASS_GLOBAL static constexpr
0067 #endif
0068
0069 namespace vecgeom {
0070 inline namespace VECGEOM_IMPL_NAMESPACE {
0071 enum EnumInside {
0072 eInside = 1,
0073 kInside = eInside,
0074 eSurface = 2,
0075 kSurface = eSurface,
0076 eOutside = 3,
0077 kOutside = eOutside,
0078 };
0079
0080 using Inside_t = int;
0081
0082 VECGEOM_GLOBAL int kAlignmentBoundary = 32;
0083
0084 namespace EInside {
0085 VECGEOM_GLOBAL vecgeom::Inside_t kInside = 1;
0086 VECGEOM_GLOBAL vecgeom::Inside_t kSurface = 2;
0087 VECGEOM_GLOBAL vecgeom::Inside_t kOutside = 3;
0088 }
0089
0090 namespace details {
0091 template <typename DataType, typename Target>
0092 struct UseIfSameType {
0093 VECCORE_ATT_HOST_DEVICE
0094 static Target const *Get(DataType *) { return nullptr; }
0095 };
0096 template <typename DataType>
0097 struct UseIfSameType<DataType, DataType> {
0098 VECCORE_ATT_HOST_DEVICE
0099 static DataType const *Get(DataType *ptr) { return ptr; }
0100 };
0101 }
0102
0103
0104 #define VECGEOM_MAXDAUGHTERS 2000
0105 #define VECGEOM_MAXFACETS 20000
0106
0107
0108
0109 #if defined(VECGEOM_VC) && !defined(VECCORE_CUDA)
0110 using VectorBackend = vecCore::backend::VcVectorT<Precision>;
0111 #else
0112 using VectorBackend = vecCore::backend::ScalarT<Precision>;
0113 #endif
0114 using ScalarBackend = vecCore::backend::ScalarT<Precision>;
0115
0116
0117 namespace {
0118
0119 template <typename T>
0120 VECGEOM_FORCE_INLINE
0121 VECCORE_ATT_HOST_DEVICE
0122 bool ToBool(T )
0123 {
0124 return false;
0125 }
0126 #pragma GCC diagnostic push
0127 #pragma GCC diagnostic ignored "-Wunused-function"
0128 template <>
0129 VECGEOM_FORCE_INLINE
0130 VECCORE_ATT_HOST_DEVICE
0131 bool ToBool<bool>(bool mask)
0132 {
0133 return mask;
0134 #pragma GCC diagnostic pop
0135 }
0136 }
0137
0138
0139
0140
0141
0142 #define vecCore__MaskedAssignFunc(Dest, Mask, FuncCallExpr) \
0143 { \
0144 if (vecCore::VectorSize<typename std::remove_reference<decltype(Dest)>::type>() == 1) { \
0145 if (vecgeom::ToBool(Mask)) Dest = FuncCallExpr; \
0146 } else { \
0147 vecCore::MaskedAssign(Dest, Mask, FuncCallExpr); \
0148 } \
0149 }
0150
0151 }
0152
0153
0154 template <typename T>
0155 VECGEOM_FORCE_INLINE
0156 VECCORE_ATT_HOST_DEVICE
0157 T InfinityLength() noexcept
0158 {
0159 return vecCore::NumericLimits<T>::Max();
0160 }
0161
0162
0163 template <typename T>
0164 VECGEOM_FORCE_INLINE
0165 VECCORE_ATT_HOST_DEVICE
0166 T NonZeroAbs(T const &x)
0167 {
0168 return Abs(x) + T(1.0e-30);
0169 }
0170
0171 template <typename T>
0172 VECGEOM_FORCE_INLINE
0173 VECCORE_ATT_HOST_DEVICE
0174 T NonZero(T const &x)
0175 {
0176 return x + CopySign(T(1.0e-30), x);
0177 }
0178
0179 }
0180
0181 #endif