File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,24 @@ static void *huge_malloc(BLASLONG size){
74
74
75
75
#endif
76
76
77
+ /* Benchmarks should allocate with cacheline (often 64 bytes) alignment
78
+ to avoid unreliable results. This technique, storing the allocated
79
+ pointer value just before the aligned memory, doesn't require
80
+ C11's aligned_alloc for compatibility with older compilers. */
81
+ static void * aligned_alloc_cacheline (size_t n )
82
+ {
83
+ void * p = malloc ((size_t )(void * ) + n + L1_DATA_LINESIZE - 1 );
84
+ if (p ) {
85
+ void * * newp = (void * * )
86
+ (((uintptr_t )p + L1_DATA_LINESIZE ) & (uintptr_t )- L1_DATA_LINESIZE );
87
+ newp [-1 ] = p ;
88
+ p = newp ;
89
+ }
90
+ return p ;
91
+ }
92
+ #define malloc aligned_alloc_cacheline
93
+ #define free (p ) free((p) ? ((void **)(p))[-1] : (p))
94
+
77
95
#if defined(__WIN32__ ) || defined(__WIN64__ ) || !defined(_POSIX_TIMERS )
78
96
struct timeval start , stop ;
79
97
#elif defined(__APPLE__ )
You can’t perform that action at this time.
0 commit comments