@@ -3053,15 +3053,15 @@ static_assert(sizeof(struct ggml_tensor)%GGML_MEM_ALIGN == 0, "ggml_tensor size
3053
3053
3054
3054
// Helpers for polling loops
3055
3055
#if defined(__aarch64__) && ( defined(__clang__) || defined(__GNUC__) )
3056
- static inline void __cpu_relax (void) {
3056
+ static inline void ggml_thread_cpu_relax (void) {
3057
3057
__asm__ volatile("yield" ::: "memory");
3058
3058
}
3059
3059
#elif defined(__x86_64__)
3060
- static inline void __cpu_relax (void) {
3060
+ static inline void ggml_thread_cpu_relax (void) {
3061
3061
_mm_pause();
3062
3062
}
3063
3063
#else
3064
- static inline void __cpu_relax (void) {;}
3064
+ static inline void ggml_thread_cpu_relax (void) {;}
3065
3065
#endif
3066
3066
3067
3067
//
@@ -3140,7 +3140,7 @@ static void ggml_barrier(struct ggml_compute_threadpool * threadpool) {
3140
3140
if (atomic_load_explicit(n_barrier_passed, memory_order_relaxed) != passed_old) {
3141
3141
return;
3142
3142
}
3143
- __cpu_relax ();
3143
+ ggml_thread_cpu_relax ();
3144
3144
}
3145
3145
}
3146
3146
}
@@ -18667,7 +18667,7 @@ enum {
18667
18667
#include "windows.h"
18668
18668
18669
18669
// TODO: support > 64 CPUs
18670
- static bool __thread_affinity (bool * mask) {
18670
+ static bool ggml_thread_apply_affinity (bool * mask) {
18671
18671
HANDLE h = GetCurrentThread();
18672
18672
uint64_t bitmask = 0ULL;
18673
18673
@@ -18701,7 +18701,7 @@ static bool __thread_affinity(bool * mask) {
18701
18701
return m != 0;
18702
18702
}
18703
18703
18704
- static bool __process_priority (int32_t prio) {
18704
+ static bool ggml_thread_apply_process_priority (int32_t prio) {
18705
18705
DWORD p = NORMAL_PRIORITY_CLASS;
18706
18706
18707
18707
switch (prio) {
@@ -18714,7 +18714,7 @@ static bool __process_priority(int32_t prio) {
18714
18714
return SetPriorityClass(GetCurrentProcess(), p);
18715
18715
}
18716
18716
18717
- static bool __thread_priority (int32_t prio) {
18717
+ static bool ggml_thread_apply_thread_priority (int32_t prio) {
18718
18718
DWORD p = NORMAL_PRIORITY_CLASS;
18719
18719
18720
18720
switch (prio) {
@@ -18732,12 +18732,12 @@ static bool __thread_priority(int32_t prio) {
18732
18732
#include <sys/types.h>
18733
18733
#include <sys/resource.h>
18734
18734
18735
- static bool __thread_affinity (const bool * mask) {
18735
+ static bool ggml_thread_apply_affinity (const bool * mask) {
18736
18736
UNUSED(mask);
18737
18737
return true;
18738
18738
}
18739
18739
18740
- static bool __process_priority (int32_t prio) {
18740
+ static bool ggml_thread_apply_process_prio (int32_t prio) {
18741
18741
int32_t p = 0;
18742
18742
18743
18743
switch (prio) {
@@ -18751,14 +18751,14 @@ static bool __process_priority(int32_t prio) {
18751
18751
return r != -1;
18752
18752
}
18753
18753
18754
- static bool __thread_priority (int32_t prio) {
18754
+ static bool ggml_thread_apply_thread_priority (int32_t prio) {
18755
18755
UNUSED(prio);
18756
18756
return true;
18757
18757
}
18758
18758
18759
18759
#else // posix?
18760
18760
18761
- static bool __thread_affinity (const bool * mask) {
18761
+ static bool ggml_thread_apply_affinity (const bool * mask) {
18762
18762
cpu_set_t cpuset;
18763
18763
int32_t err;
18764
18764
@@ -18787,7 +18787,7 @@ static bool __thread_affinity(const bool * mask) {
18787
18787
return true;
18788
18788
}
18789
18789
18790
- static bool __process_priority (int32_t prio) {
18790
+ static bool ggml_thread_apply_process_prio (int32_t prio) {
18791
18791
struct sched_param p;
18792
18792
int32_t policy = SCHED_OTHER;
18793
18793
@@ -18807,7 +18807,7 @@ static bool __process_priority(int32_t prio) {
18807
18807
return true;
18808
18808
}
18809
18809
18810
- static bool __thread_priority (int32_t prio) {
18810
+ static bool ggml_thread_apply_thread_priority (int32_t prio) {
18811
18811
struct sched_param p;
18812
18812
int32_t policy = SCHED_OTHER;
18813
18813
switch (prio) {
@@ -18828,7 +18828,7 @@ static bool __thread_priority(int32_t prio) {
18828
18828
18829
18829
#endif
18830
18830
18831
- static void __cpumask_next (const bool * global_mask, bool * local_mask, bool strict, int32_t* iter) {
18831
+ static void ggml_thread_cpumask_next (const bool * global_mask, bool * local_mask, bool strict, int32_t* iter) {
18832
18832
if (!global_mask) {
18833
18833
memset(local_mask, 1, GGML_MAX_N_THREADS);
18834
18834
return;
@@ -19160,7 +19160,7 @@ static inline bool ggml_graph_compute_poll_for_work(struct ggml_compute_state *
19160
19160
19161
19161
for (uint64_t i=0; !ggml_graph_compute_ready(state) && i<n_rounds; i++) {
19162
19162
// No new work. Keep polling.
19163
- __cpu_relax ();
19163
+ ggml_thread_cpu_relax ();
19164
19164
}
19165
19165
19166
19166
return state->pending;
@@ -19188,9 +19188,9 @@ static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
19188
19188
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
19189
19189
struct ggml_compute_threadpool * threadpool = state->threadpool;
19190
19190
19191
- __thread_priority (threadpool->prio);
19191
+ ggml_thread_apply_thread_priority (threadpool->prio);
19192
19192
if (state->mask_specified)
19193
- __thread_affinity (state->cpumask);
19193
+ ggml_thread_apply_affinity (state->cpumask);
19194
19194
19195
19195
while (true) {
19196
19196
// Check if we need to sleep
@@ -19306,8 +19306,8 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
19306
19306
#else // Not using OPENMP
19307
19307
int32_t cpumask_iter = 0;
19308
19308
19309
- __process_priority (tpp->prio);
19310
- __thread_priority (tpp->prio);
19309
+ ggml_thread_apply_process_prio (tpp->prio);
19310
+ ggml_thread_apply_thread_priority (tpp->prio);
19311
19311
19312
19312
for (int j = 0; j < tpp->n_threads; j++) {
19313
19313
workers[j] = (struct ggml_compute_state) {
@@ -19320,7 +19320,7 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
19320
19320
};
19321
19321
19322
19322
if (tpp->mask_specified) {
19323
- __cpumask_next (tpp->cpumask, workers[j].cpumask, tpp->strict_cpu, &cpumask_iter);
19323
+ ggml_thread_cpumask_next (tpp->cpumask, workers[j].cpumask, tpp->strict_cpu, &cpumask_iter);
19324
19324
}
19325
19325
19326
19326
// Spin threads for all secondary workers
@@ -19408,7 +19408,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19408
19408
#else
19409
19409
// Update main thread affinity to match the current threadpool
19410
19410
if (threadpool->workers[0].mask_specified) {
19411
- __thread_affinity (threadpool->workers[0].cpumask);
19411
+ ggml_thread_apply_affinity (threadpool->workers[0].cpumask);
19412
19412
}
19413
19413
19414
19414
// Kick all threads to start the new graph
0 commit comments