Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:51

0001 /// \file AlignedBase.h
0002 /// \author Johannes de Fine Licht (johannes.definelicht@cern.ch)
0003 
0004 #ifndef VECGEOM_BASE_ALIGNEDBASE_H_
0005 #define VECGEOM_BASE_ALIGNEDBASE_H_
0006 
0007 #include "VecGeom/base/Global.h"
0008 #ifdef VECGEOM_VC
0009 #include <Vc/Vc>
0010 #endif
0011 
0012 namespace vecgeom {
0013 
0014 VECGEOM_DEVICE_FORWARD_DECLARE(class AlignedBase;);
0015 VECGEOM_DEVICE_DECLARE_CONV(class, AlignedBase);
0016 
0017 inline namespace VECGEOM_IMPL_NAMESPACE {
0018 
0019 #ifdef VECGEOM_VC
0020 // unfortunately the version macros have changed in Vc over time
0021 // so I am checking which one exist
0022 #ifdef Vc_VERSION_NUMBER
0023 #if Vc_VERSION_NUMBER >= Vc_VERSION_CHECK(0, 99, 71) & Vc_VERSION_NUMBER < Vc_VERSION_CHECK(1, 0, 0)
0024 class AlignedBase : public Vc::VectorAlignedBase<Vc::Vector<double>> {
0025 #else
0026 class AlignedBase : public Vc::VectorAlignedBase {
0027 #endif
0028 #endif
0029 #ifdef VC_VERSION_NUMBER
0030 #if VC_VERSION_NUMBER >= VC_VERSION_CHECK(0, 99, 72)
0031   class AlignedBase : public Vc::VectorAlignedBase<Vc::Vector<double>> {
0032 #else
0033   class AlignedBase : public Vc::VectorAlignedBase {
0034 #endif
0035 #endif
0036   public:
0037     virtual ~AlignedBase() {}
0038   };
0039 #elif !defined(VECCORE_CUDA)
0040 class AlignedBase {
0041 
0042 public:
0043   VECGEOM_FORCE_INLINE
0044   void *operator new(size_t size) { return vecCore::AlignedAlloc(kAlignmentBoundary, size); }
0045 
0046   VECGEOM_FORCE_INLINE
0047   void *operator new(size_t, void *p) { return p; }
0048 
0049   VECGEOM_FORCE_INLINE
0050   void *operator new[](size_t size) { return vecCore::AlignedAlloc(kAlignmentBoundary, size); }
0051 
0052   VECGEOM_FORCE_INLINE
0053   void *operator new[](size_t, void *p) { return p; }
0054 
0055   VECGEOM_FORCE_INLINE
0056   void operator delete(void *ptr, size_t) { vecCore::AlignedFree(ptr); }
0057 
0058   VECGEOM_FORCE_INLINE
0059   void operator delete(void *, void *) {}
0060 
0061   VECGEOM_FORCE_INLINE
0062   void operator delete[](void *ptr, size_t) { vecCore::AlignedFree(ptr); }
0063 
0064   VECGEOM_FORCE_INLINE
0065   void operator delete[](void *, void *) {}
0066 };
0067 #else
0068 class AlignedBase {
0069 };
0070 #endif
0071 }
0072 } // End global namespace
0073 
0074 #endif // VECGEOM_BASE_ALIGNEDBASE_H_