]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/MemoryAssignmentHelpers.h
bug fix: reconstruction crash when the output buffer size exceed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / MemoryAssignmentHelpers.h
index 4d162c58f6278acb4ea870ea53b04958a6dd809a..5fe6692ff86bf05e00eaa66d06b929a373d20d5a 100644 (file)
 #ifndef MEMORYASSIGNMENTHELPERS_H
 #define MEMORYASSIGNMENTHELPERS_H
 
+#ifndef assert
 #include <assert.h>
+#endif //!assert
 
 template<unsigned int X>
-static inline void AlignTo( char *&mem )
+GPUhd() static inline void AlignTo( char *&mem )
 {
   STATIC_ASSERT( ( X & ( X - 1 ) ) == 0, X_needs_to_be_a_multiple_of_2 );
-  const int offset = reinterpret_cast<unsigned long>( mem ) & ( X - 1 );
+  const int offset = reinterpret_cast<unsigned long long>( mem ) & ( X - 1 );
   if ( offset > 0 ) {
     mem += ( X - offset );
   }
@@ -31,7 +33,7 @@ static inline void AlignTo( char *&mem )
 }
 
 template<unsigned int X>
-static inline unsigned int NextMultipleOf( unsigned int value )
+GPUhd() static inline unsigned int NextMultipleOf( unsigned int value )
 {
   STATIC_ASSERT( ( X & ( X - 1 ) ) == 0, X_needs_to_be_a_multiple_of_2 );
   const int offset = value & ( X - 1 );
@@ -56,7 +58,7 @@ template<typename T, unsigned int Alignment> static inline T *AssignMemory( char
   return AssignMemory<T, Alignment>( mem, stride * count );
 }
 
-template<typename T, unsigned int Alignment> static T *_assignMemory( char *&mem, unsigned int size )
+template<typename T, unsigned int Alignment> GPUhd() static T *_assignMemory( char *&mem, unsigned int size )
 {
   STATIC_ASSERT( ( Alignment & ( Alignment - 1 ) ) == 0, Alignment_needs_to_be_a_multiple_of_2 );
   AlignTo<Alignment>( mem );
@@ -65,7 +67,7 @@ template<typename T, unsigned int Alignment> static T *_assignMemory( char *&mem
   return r;
 }
 
-template<typename T> static inline void AssignMemory( T *&dst, char *&mem, int count )
+template<typename T> GPUhd() static inline void AssignMemory( T *&dst, char *&mem, int count )
 {
   dst = _assignMemory < T, ( sizeof( T ) & ( sizeof( T ) - 1 ) ) == 0 && sizeof( T ) <= 16 ? sizeof( T ) : sizeof( void * ) > ( mem, count );
 }