@@ -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
}
@@ -18654,7 +18654,7 @@ enum {
18654
18654
#include "windows.h"
18655
18655
18656
18656
// TODO: support > 64 CPUs
18657
- static bool __thread_affinity (bool * mask) {
18657
+ static bool ggml_thread_apply_affinity (bool * mask) {
18658
18658
HANDLE h = GetCurrentThread();
18659
18659
uint64_t bitmask = 0ULL;
18660
18660
@@ -18688,7 +18688,7 @@ static bool __thread_affinity(bool * mask) {
18688
18688
return m != 0;
18689
18689
}
18690
18690
18691
- static bool __process_priority (int32_t prio) {
18691
+ static bool ggml_thread_apply_process_priority (int32_t prio) {
18692
18692
DWORD p = NORMAL_PRIORITY_CLASS;
18693
18693
18694
18694
switch (prio) {
@@ -18701,7 +18701,7 @@ static bool __process_priority(int32_t prio) {
18701
18701
return SetPriorityClass(GetCurrentProcess(), p);
18702
18702
}
18703
18703
18704
- static bool __thread_priority (int32_t prio) {
18704
+ static bool ggml_thread_apply_thread_priority (int32_t prio) {
18705
18705
DWORD p = NORMAL_PRIORITY_CLASS;
18706
18706
18707
18707
switch (prio) {
@@ -18719,12 +18719,12 @@ static bool __thread_priority(int32_t prio) {
18719
18719
#include <sys/types.h>
18720
18720
#include <sys/resource.h>
18721
18721
18722
- static bool __thread_affinity (const bool * mask) {
18722
+ static bool ggml_thread_apply_affinity (const bool * mask) {
18723
18723
UNUSED(mask);
18724
18724
return true;
18725
18725
}
18726
18726
18727
- static bool __process_priority (int32_t prio) {
18727
+ static bool ggml_thread_apply_process_prio (int32_t prio) {
18728
18728
int32_t p = 0;
18729
18729
18730
18730
switch (prio) {
@@ -18738,14 +18738,14 @@ static bool __process_priority(int32_t prio) {
18738
18738
return r != -1;
18739
18739
}
18740
18740
18741
- static bool __thread_priority (int32_t prio) {
18741
+ static bool ggml_thread_apply_thread_priority (int32_t prio) {
18742
18742
UNUSED(prio);
18743
18743
return true;
18744
18744
}
18745
18745
18746
18746
#else // posix?
18747
18747
18748
- static bool __thread_affinity (const bool * mask) {
18748
+ static bool ggml_thread_apply_affinity (const bool * mask) {
18749
18749
cpu_set_t cpuset;
18750
18750
int32_t err;
18751
18751
@@ -18774,7 +18774,7 @@ static bool __thread_affinity(const bool * mask) {
18774
18774
return true;
18775
18775
}
18776
18776
18777
- static bool __process_priority (int32_t prio) {
18777
+ static bool ggml_thread_apply_process_prio (int32_t prio) {
18778
18778
struct sched_param p;
18779
18779
int32_t policy = SCHED_OTHER;
18780
18780
@@ -18794,7 +18794,7 @@ static bool __process_priority(int32_t prio) {
18794
18794
return true;
18795
18795
}
18796
18796
18797
- static bool __thread_priority (int32_t prio) {
18797
+ static bool ggml_thread_apply_thread_priority (int32_t prio) {
18798
18798
struct sched_param p;
18799
18799
int32_t policy = SCHED_OTHER;
18800
18800
switch (prio) {
@@ -18815,7 +18815,7 @@ static bool __thread_priority(int32_t prio) {
18815
18815
18816
18816
#endif
18817
18817
18818
- static void __cpumask_next (const bool * global_mask, bool * local_mask, bool strict, int32_t* iter) {
18818
+ static void ggml_thread_cpumask_next (const bool * global_mask, bool * local_mask, bool strict, int32_t* iter) {
18819
18819
if (!global_mask) {
18820
18820
memset(local_mask, 1, GGML_MAX_N_THREADS);
18821
18821
return;
@@ -19147,7 +19147,7 @@ static inline bool ggml_graph_compute_poll_for_work(struct ggml_compute_state *
19147
19147
19148
19148
for (uint64_t i=0; !ggml_graph_compute_ready(state) && i<n_rounds; i++) {
19149
19149
// No new work. Keep polling.
19150
- __cpu_relax ();
19150
+ ggml_thread_cpu_relax ();
19151
19151
}
19152
19152
19153
19153
return state->pending;
@@ -19175,9 +19175,9 @@ static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
19175
19175
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
19176
19176
struct ggml_compute_threadpool * threadpool = state->threadpool;
19177
19177
19178
- __thread_priority (threadpool->prio);
19178
+ ggml_thread_apply_thread_priority (threadpool->prio);
19179
19179
if (state->mask_specified)
19180
- __thread_affinity (state->cpumask);
19180
+ ggml_thread_apply_affinity (state->cpumask);
19181
19181
19182
19182
while (true) {
19183
19183
// Check if we need to sleep
@@ -19293,8 +19293,8 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
19293
19293
#else // Not using OPENMP
19294
19294
int32_t cpumask_iter = 0;
19295
19295
19296
- __process_priority (tpp->prio);
19297
- __thread_priority (tpp->prio);
19296
+ ggml_thread_apply_process_prio (tpp->prio);
19297
+ ggml_thread_apply_thread_priority (tpp->prio);
19298
19298
19299
19299
for (int j = 0; j < tpp->n_threads; j++) {
19300
19300
workers[j] = (struct ggml_compute_state) {
@@ -19307,7 +19307,7 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
19307
19307
};
19308
19308
19309
19309
if (tpp->mask_specified) {
19310
- __cpumask_next (tpp->cpumask, workers[j].cpumask, tpp->strict_cpu, &cpumask_iter);
19310
+ ggml_thread_cpumask_next (tpp->cpumask, workers[j].cpumask, tpp->strict_cpu, &cpumask_iter);
19311
19311
}
19312
19312
19313
19313
// Spin threads for all secondary workers
@@ -19395,7 +19395,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19395
19395
#else
19396
19396
// Update main thread affinity to match the current threadpool
19397
19397
if (threadpool->workers[0].mask_specified) {
19398
- __thread_affinity (threadpool->workers[0].cpumask);
19398
+ ggml_thread_apply_affinity (threadpool->workers[0].cpumask);
19399
19399
}
19400
19400
19401
19401
// Kick all threads to start the new graph
0 commit comments