Skip to content

Commit 673f95b

Browse files
committed
restore use of GGML_PRINT_DEBUG in ggml-cpu.c
1 parent bf95fff commit 673f95b

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

ggml/src/ggml-cpu.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ void ggml_numa_init(enum ggml_numa_strategy numa_flag) {
23322332
// set numa scheme
23332333
g_state.numa.numa_strategy = numa_flag;
23342334

2335-
GGML_LOG_DEBUG("numa strategy %u\n",g_state.numa.numa_strategy);
2335+
GGML_PRINT_DEBUG("numa strategy %u\n",g_state.numa.numa_strategy);
23362336

23372337
g_state.numa.cpuset = ggml_get_numa_affinity();
23382338

@@ -2352,7 +2352,7 @@ void ggml_numa_init(enum ggml_numa_strategy numa_flag) {
23522352
++g_state.numa.total_cpus;
23532353
}
23542354

2355-
GGML_LOG_DEBUG("found %u numa nodes, %u CPUs\n", g_state.numa.n_nodes, g_state.numa.total_cpus);
2355+
GGML_PRINT_DEBUG("found %u numa nodes, %u CPUs\n", g_state.numa.n_nodes, g_state.numa.total_cpus);
23562356

23572357
// figure out which node we're on
23582358
uint current_cpu;
@@ -2372,21 +2372,21 @@ void ggml_numa_init(enum ggml_numa_strategy numa_flag) {
23722372
return;
23732373
}
23742374

2375-
GGML_LOG_DEBUG("found our process on numa node %u, CPU %u\n", g_state.numa.current_node, current_cpu);
2375+
GGML_PRINT_DEBUG("found our process on numa node %u, CPU %u\n", g_state.numa.current_node, current_cpu);
23762376

23772377
for (uint32_t n = 0; n < g_state.numa.n_nodes; ++n) {
23782378
struct ggml_numa_node * node = &g_state.numa.nodes[n];
2379-
GGML_LOG_DEBUG("CPUs on node %u:", n);
2379+
GGML_PRINT_DEBUG("CPUs on node %u:", n);
23802380
node->n_cpus = 0;
23812381
for (uint32_t c = 0; c < g_state.numa.total_cpus; ++c) {
23822382
rv = snprintf(path, sizeof(path), "/sys/devices/system/node/node%u/cpu%u", n, c);
23832383
GGML_ASSERT(rv > 0 && (unsigned)rv < sizeof(path));
23842384
if (stat(path, &st) == 0) {
23852385
node->cpus[node->n_cpus++] = c;
2386-
GGML_LOG_DEBUG(" %u", c);
2386+
GGML_PRINT_DEBUG(" %u", c);
23872387
}
23882388
}
2389-
GGML_LOG_DEBUG("\n");
2389+
GGML_PRINT_DEBUG("\n");
23902390
}
23912391

23922392
if (ggml_is_numa()) {
@@ -12953,7 +12953,7 @@ static bool ggml_thread_apply_affinity(const bool * mask) {
1295312953

1295412954
for (uint32_t i = 0; i < GGML_MAX_N_THREADS; i++) {
1295512955
if (mask[i]) {
12956-
GGML_LOG_DEBUG("Thread %lx: adding %d to cpuset\n", pthread_self(), i);
12956+
GGML_PRINT_DEBUG("Thread %lx: adding %d to cpuset\n", pthread_self(), i);
1295712957
CPU_SET(i, &cpuset);
1295812958
}
1295912959
}
@@ -13075,13 +13075,13 @@ void ggml_threadpool_free(struct ggml_threadpool* threadpool) {
1307513075
#ifndef GGML_USE_OPENMP
1307613076
// pause/resume must be called under mutex
1307713077
static void ggml_threadpool_pause_locked(struct ggml_threadpool * threadpool) {
13078-
GGML_LOG_DEBUG("Pausing threadpool\n");
13078+
GGML_PRINT_DEBUG("Pausing threadpool\n");
1307913079
threadpool->pause = true;
1308013080
ggml_cond_broadcast(&threadpool->cond);
1308113081
}
1308213082

1308313083
static void ggml_threadpool_resume_locked(struct ggml_threadpool * threadpool) {
13084-
GGML_LOG_DEBUG("Resuming threadpool\n");
13084+
GGML_PRINT_DEBUG("Resuming threadpool\n");
1308513085
threadpool->pause = false;
1308613086
ggml_cond_broadcast(&threadpool->cond);
1308713087
}
@@ -13117,7 +13117,7 @@ struct ggml_cplan ggml_graph_plan(
1311713117
struct ggml_threadpool * threadpool) {
1311813118

1311913119
if (threadpool == NULL) {
13120-
//GGML_LOG_DEBUG("Threadpool is not specified. Will create a disposable threadpool : n_threads %d\n", n_threads);
13120+
//GGML_PRINT_DEBUG("Threadpool is not specified. Will create a disposable threadpool : n_threads %d\n", n_threads);
1312113121
}
1312213122
if (n_threads <= 0) {
1312313123
n_threads = threadpool ? threadpool->n_threads_max : GGML_DEFAULT_N_THREADS;
@@ -13392,7 +13392,7 @@ static inline bool ggml_graph_compute_check_for_work(struct ggml_compute_state *
1339213392
ggml_mutex_lock_shared(&threadpool->mutex);
1339313393
while (!ggml_graph_compute_thread_ready(state)) {
1339413394
// No new work. Wait for the signal.
13395-
GGML_LOG_DEBUG("thread #%d waiting for work (sleeping)\n", state->ith);
13395+
GGML_PRINT_DEBUG("thread #%d waiting for work (sleeping)\n", state->ith);
1339613396
ggml_cond_wait(&threadpool->cond, &threadpool->mutex);
1339713397
}
1339813398
ggml_mutex_unlock_shared(&threadpool->mutex);
@@ -13412,12 +13412,12 @@ static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
1341213412
while (true) {
1341313413
// Check if we need to sleep
1341413414
while (threadpool->pause) {
13415-
GGML_LOG_DEBUG("thread #%d inside pause loop\n", state->ith);
13415+
GGML_PRINT_DEBUG("thread #%d inside pause loop\n", state->ith);
1341613416
ggml_mutex_lock_shared(&threadpool->mutex);
1341713417
if (threadpool->pause) {
1341813418
ggml_cond_wait(&threadpool->cond, &threadpool->mutex);
1341913419
}
13420-
GGML_LOG_DEBUG("thread #%d resuming after wait\n", state->ith);
13420+
GGML_PRINT_DEBUG("thread #%d resuming after wait\n", state->ith);
1342113421
ggml_mutex_unlock_shared(&threadpool->mutex);
1342213422
}
1342313423

@@ -13445,7 +13445,7 @@ static void ggml_graph_compute_kickoff(struct ggml_threadpool * threadpool, int
1344513445

1344613446
ggml_mutex_lock(&threadpool->mutex);
1344713447

13448-
GGML_LOG_DEBUG("threadpool: n_threads_cur %d n_threads %d\n", threadpool->n_threads_cur, n_threads);
13448+
GGML_PRINT_DEBUG("threadpool: n_threads_cur %d n_threads %d\n", threadpool->n_threads_cur, n_threads);
1344913449

1345013450
// Update the number of active threads
1345113451
atomic_store_explicit(&threadpool->n_threads_cur, n_threads, memory_order_relaxed);
@@ -13579,7 +13579,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
1357913579
bool disposable_threadpool = false;
1358013580

1358113581
if (threadpool == NULL) {
13582-
//GGML_LOG_DEBUG("Threadpool is not specified. Will create a disposable threadpool : n_threads %d\n", n_threads);
13582+
//GGML_PRINT_DEBUG("Threadpool is not specified. Will create a disposable threadpool : n_threads %d\n", n_threads);
1358313583
disposable_threadpool = true;
1358413584

1358513585
struct ggml_threadpool_params ttp = ggml_threadpool_params_default(n_threads);
@@ -13701,7 +13701,7 @@ void ggml_cpu_init(void) {
1370113701

1370213702
//const uint64_t t_end = ggml_time_us(); UNUSED(t_end);
1370313703

13704-
//GGML_LOG_DEBUG("%s: GELU, Quick GELU, SILU and EXP tables initialized in %f ms\n", __func__, (t_end - t_start)/1000.0);
13704+
//GGML_PRINT_DEBUG("%s: GELU, Quick GELU, SILU and EXP tables initialized in %f ms\n", __func__, (t_end - t_start)/1000.0);
1370513705
}
1370613706

1370713707
#if defined(__ARM_ARCH)

ggml/src/ggml-impl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ void ggml_log_callback_default(enum ggml_log_level level, const char * text, voi
6666
#define GGML_LOG_DEBUG(...) ggml_log_internal(GGML_LOG_LEVEL_DEBUG, __VA_ARGS__)
6767
#define GGML_LOG_CONT(...) ggml_log_internal(GGML_LOG_LEVEL_CONT , __VA_ARGS__)
6868

69+
#define GGML_DEBUG 0
70+
71+
#if (GGML_DEBUG >= 1)
72+
#define GGML_PRINT_DEBUG(...) GGML_LOG_DEBUG(__VA_ARGS__)
73+
#else
74+
#define GGML_PRINT_DEBUG(...)
75+
#endif
76+
77+
#if (GGML_DEBUG >= 5)
78+
#define GGML_PRINT_DEBUG_5(...) GGML_LOG_DEBUG(__VA_ARGS__)
79+
#else
80+
#define GGML_PRINT_DEBUG_5(...)
81+
#endif
82+
83+
#if (GGML_DEBUG >= 10)
84+
#define GGML_PRINT_DEBUG_10(...) GGML_LOG_DEBUG(__VA_ARGS__)
85+
#else
86+
#define GGML_PRINT_DEBUG_10(...)
87+
#endif
88+
6989
// tensor params
7090

7191
static void ggml_set_op_params(struct ggml_tensor * tensor, const void * params, size_t params_size) {

ggml/src/ggml.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ void ggml_abort(const char * file, int line, const char * fmt, ...) {
164164
abort();
165165
}
166166

167-
#define GGML_DEBUG 0
168-
169167
//
170168
// logging
171169
//
@@ -210,24 +208,6 @@ void ggml_log_callback_default(enum ggml_log_level level, const char * text, voi
210208
fflush(stderr);
211209
}
212210

213-
#if (GGML_DEBUG >= 1)
214-
#define GGML_PRINT_DEBUG(...) GGML_LOG_DEBUG(__VA_ARGS__)
215-
#else
216-
#define GGML_PRINT_DEBUG(...)
217-
#endif
218-
219-
#if (GGML_DEBUG >= 5)
220-
#define GGML_PRINT_DEBUG_5(...) GGML_LOG_DEBUG(__VA_ARGS__)
221-
#else
222-
#define GGML_PRINT_DEBUG_5(...)
223-
#endif
224-
225-
#if (GGML_DEBUG >= 10)
226-
#define GGML_PRINT_DEBUG_10(...) GGML_LOG_DEBUG(__VA_ARGS__)
227-
#else
228-
#define GGML_PRINT_DEBUG_10(...)
229-
#endif
230-
231211
//
232212
// end of logging block
233213
//

0 commit comments

Comments
 (0)