Merge pull request #3666 from SChernykh/dev
Better detection of aligned malloc functions
This commit is contained in:
commit
a18fa269a6
2 changed files with 43 additions and 6 deletions
|
@ -1,4 +1,12 @@
|
|||
if (WITH_RANDOMX)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
|
||||
|
||||
if(HAVE_POSIX_MEMALIGN)
|
||||
add_definitions(/DHAVE_POSIX_MEMALIGN)
|
||||
endif()
|
||||
|
||||
add_definitions(/DXMRIG_ALGO_RANDOMX)
|
||||
set(WITH_ARGON2 ON)
|
||||
|
||||
|
|
|
@ -200,7 +200,18 @@ typedef union{
|
|||
int i32[4];
|
||||
} vec_u;
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
inline void* rx_aligned_alloc(size_t size, size_t align) {
|
||||
void* p;
|
||||
if (posix_memalign(&p, align, size) == 0)
|
||||
return p;
|
||||
|
||||
return 0;
|
||||
};
|
||||
#else
|
||||
# define rx_aligned_alloc(a, b) malloc(a)
|
||||
#endif
|
||||
|
||||
#define rx_aligned_free(a) free(a)
|
||||
#define rx_prefetch_nta(x)
|
||||
#define rx_prefetch_t0(x)
|
||||
|
@ -392,7 +403,7 @@ FORCE_INLINE rx_vec_f128 rx_cvt_packed_int_vec_f128(const void* addr) {
|
|||
typedef uint8x16_t rx_vec_i128;
|
||||
typedef float64x2_t rx_vec_f128;
|
||||
|
||||
#if !defined(XMRIG_OS_WIN) // FIXME
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
inline void* rx_aligned_alloc(size_t size, size_t align) {
|
||||
void* p;
|
||||
if (posix_memalign(&p, align, size) == 0)
|
||||
|
@ -400,11 +411,14 @@ inline void* rx_aligned_alloc(size_t size, size_t align) {
|
|||
|
||||
return 0;
|
||||
};
|
||||
# define rx_aligned_free(a) free(a)
|
||||
#elif defined(_MSC_VER)
|
||||
# define rx_aligned_alloc(a, b) _aligned_malloc(a, b)
|
||||
# define rx_aligned_free(a) _aligned_free(a)
|
||||
#else
|
||||
# define rx_aligned_alloc(a, b) malloc(a)
|
||||
#endif
|
||||
|
||||
# define rx_aligned_free(a) free(a)
|
||||
#endif
|
||||
|
||||
inline void rx_prefetch_nta(void* ptr) {
|
||||
asm volatile ("prfm pldl1strm, [%0]\n" : : "r" (ptr));
|
||||
|
@ -546,8 +560,23 @@ typedef union {
|
|||
rx_vec_i128 i;
|
||||
} rx_vec_f128;
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
inline void* rx_aligned_alloc(size_t size, size_t align) {
|
||||
void* p;
|
||||
if (posix_memalign(&p, align, size) == 0)
|
||||
return p;
|
||||
|
||||
return 0;
|
||||
};
|
||||
# define rx_aligned_free(a) free(a)
|
||||
#elif defined(_MSC_VER)
|
||||
# define rx_aligned_alloc(a, b) _aligned_malloc(a, b)
|
||||
# define rx_aligned_free(a) _aligned_free(a)
|
||||
#else
|
||||
# define rx_aligned_alloc(a, b) malloc(a)
|
||||
# define rx_aligned_free(a) free(a)
|
||||
#endif
|
||||
|
||||
#define rx_prefetch_nta(x)
|
||||
#define rx_prefetch_t0(x)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue