From a67dbcc538516a9bc63429b0b359685758f7bcec Mon Sep 17 00:00:00 2001 From: Max Krasnyansky Date: Mon, 27 May 2024 21:29:58 -0700 Subject: [PATCH] threadpool: fix compiler errors for android and x64 builds --- ggml.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ggml.c b/ggml.c index e67bd148a..463b40f32 100644 --- a/ggml.c +++ b/ggml.c @@ -19402,6 +19402,9 @@ static bool __thread_priority(int32_t prio) { #else // posix? +#ifndef __USE_GNU +#define __USE_GNU +#endif #include static bool __thread_affinity(const bool * mask) { @@ -19473,17 +19476,16 @@ static bool __thread_priority(int32_t prio) { #endif -#ifdef __aarch64__ - +#if defined(__aarch64__) && ( defined(__clang__) || defined(__GNUC__) ) static inline void __cpu_relax(void) { __asm__ volatile("yield" ::: "memory"); } - -#else - +#elif defined(__x86_64__) static inline void __cpu_relax(void) { - __asm__ volatile("rep; nop" ::: "memory"); + _mm_pause(); } +#else +static inline void __cpu_relax(void) {;} #endif static void __cpumask_next(const bool * global_mask, bool * local_mask, bool strict, int32_t* iter) {