Browse Source

More alignment fixes for 32-byte AVX

rdb 9 years ago
parent
commit
cf105f276c

+ 2 - 2
dtool/src/dtoolbase/deletedBufferChain.cxx

@@ -71,7 +71,7 @@ allocate(size_t size, TypeHandle type_handle) {
 
 
   // Allocate memory, and make sure the object starts at the proper alignment.
   // Allocate memory, and make sure the object starts at the proper alignment.
   void *mem = NeverFreeMemory::alloc(alloc_size);
   void *mem = NeverFreeMemory::alloc(alloc_size);
-  intptr_t pad = ((intptr_t)flag_reserved_bytes - (intptr_t)mem) % MemoryHook::get_memory_alignment();
+  intptr_t pad = (-(intptr_t)flag_reserved_bytes - (intptr_t)mem) % MemoryHook::get_memory_alignment();
   obj = (ObjectNode *)((uintptr_t)mem + pad);
   obj = (ObjectNode *)((uintptr_t)mem + pad);
 
 
 #ifdef USE_DELETEDCHAINFLAG
 #ifdef USE_DELETEDCHAINFLAG
@@ -80,7 +80,7 @@ allocate(size_t size, TypeHandle type_handle) {
 
 
   void *ptr = node_to_buffer(obj);
   void *ptr = node_to_buffer(obj);
 
 
-#ifdef _DEBUG
+#ifndef NDEBUG
   assert(((uintptr_t)ptr % MemoryHook::get_memory_alignment()) == 0);
   assert(((uintptr_t)ptr % MemoryHook::get_memory_alignment()) == 0);
 #endif
 #endif
 
 

+ 5 - 0
dtool/src/dtoolbase/dtoolbase.h

@@ -339,21 +339,26 @@ typedef struct _object PyObject;
 #define ALIGN_4BYTE
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE
 #define ALIGN_8BYTE
 #define ALIGN_16BYTE
 #define ALIGN_16BYTE
+#define ALIGN_32BYTE
 #define ALIGN_64BYTE
 #define ALIGN_64BYTE
 #elif defined(_MSC_VER)
 #elif defined(_MSC_VER)
 #define ALIGN_4BYTE __declspec(align(4))
 #define ALIGN_4BYTE __declspec(align(4))
 #define ALIGN_8BYTE __declspec(align(8))
 #define ALIGN_8BYTE __declspec(align(8))
 #define ALIGN_16BYTE __declspec(align(16))
 #define ALIGN_16BYTE __declspec(align(16))
+#define ALIGN_32BYTE __declspec(align(32))
 #define ALIGN_64BYTE __declspec(align(64))
 #define ALIGN_64BYTE __declspec(align(64))
 #elif defined(__GNUC__)
 #elif defined(__GNUC__)
 #define ALIGN_4BYTE __attribute__ ((aligned (4)))
 #define ALIGN_4BYTE __attribute__ ((aligned (4)))
 #define ALIGN_8BYTE __attribute__ ((aligned (8)))
 #define ALIGN_8BYTE __attribute__ ((aligned (8)))
 #define ALIGN_16BYTE __attribute__ ((aligned (16)))
 #define ALIGN_16BYTE __attribute__ ((aligned (16)))
+#define ALIGN_32BYTE __attribute__ ((aligned (32)))
 #define ALIGN_64BYTE __attribute__ ((aligned (64)))
 #define ALIGN_64BYTE __attribute__ ((aligned (64)))
 #else
 #else
 #define ALIGN_4BYTE
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE
 #define ALIGN_8BYTE
 #define ALIGN_16BYTE
 #define ALIGN_16BYTE
+#define ALIGN_32BYTE
+#define ALIGN_64BYTE
 #endif
 #endif
 
 
 // Do we need to implement memory-alignment enforcement within the MemoryHook
 // Do we need to implement memory-alignment enforcement within the MemoryHook

+ 3 - 1
panda/src/linmath/lsimpleMatrix.h

@@ -58,7 +58,9 @@ private:
 #endif  // HAVE_EIGEN
 #endif  // HAVE_EIGEN
 
 
 // This is as good a place as any to define this alignment macro.
 // This is as good a place as any to define this alignment macro.
-#ifdef LINMATH_ALIGN
+#if defined(LINMATH_ALIGN) && defined(HAVE_EIGEN) && defined(__AVX__)
+#define ALIGN_LINMATH ALIGN_32BYTE
+#elif defined(LINMATH_ALIGN)
 #define ALIGN_LINMATH ALIGN_16BYTE
 #define ALIGN_LINMATH ALIGN_16BYTE
 #else
 #else
 #define ALIGN_LINMATH
 #define ALIGN_LINMATH