diff --git a/examples/llava/minicpmv-cli.cpp b/examples/llava/minicpmv-cli.cpp index 379fc295f..f500ea5b9 100644 --- a/examples/llava/minicpmv-cli.cpp +++ b/examples/llava/minicpmv-cli.cpp @@ -180,7 +180,7 @@ static const char * sample(struct llama_sampling_context * ctx_sampling, static struct llava_context * minicpmv_init(gpt_params * params, const std::string & fname, int &n_past){ auto ctx_clip = clip_init_context(params); - auto embeds = llava_image_embed_make_with_filename(ctx_clip, params->n_threads, fname.c_str()); + auto embeds = llava_image_embed_make_with_filename(ctx_clip, params->cpuparams.n_threads, fname.c_str()); if (!embeds) { std::cerr << "error: failed to load image " << fname << ". Terminating\n\n"; return NULL; diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 989b5d692..3dbc1244c 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -18861,7 +18861,6 @@ void ggml_release_threadpool(struct ggml_compute_threadpool* threadpool) { if (!threadpool->disposable) { ggml_mutex_lock(&threadpool->mutex); } - threadpool->n_threads_cur = n_threads; threadpool->stop = true; threadpool->pause = false; if (!threadpool->disposable) { @@ -19154,21 +19153,27 @@ static thread_ret_t ggml_graph_compute_thread(void * data) { static bool ggml_graph_compute_check_for_work(struct ggml_compute_state * state) { struct ggml_compute_threadpool * threadpool = state->threadpool; - do { - if (threadpool->poll) { - while (!threadpool->new_work && !threadpool->stop && !threadpool->pause) { - // No new work. Yield and keep polling. - __cpu_relax(); - } - } else { - ggml_mutex_lock_shared(&threadpool->mutex); - while (!threadpool->new_work && !threadpool->stop && !threadpool->pause) { - // No new work. Wait for the signal. - ggml_cond_wait(&threadpool->cond, &threadpool->mutex); - } - ggml_mutex_unlock_shared(&threadpool->mutex); + if (threadpool->poll) { + while (!((threadpool->new_work && state->ith < threadpool->n_threads_cur) || + threadpool->stop || + threadpool->pause + ) + ) { + // No new work. Yield and keep polling. + __cpu_relax(); } - } while (state->ith >= threadpool->n_threads_cur); + } else { + ggml_mutex_lock_shared(&threadpool->mutex); + while (!((threadpool->new_work && state->ith < threadpool->n_threads_cur) || + threadpool->stop || + threadpool->pause + ) + ) { + // No new work. Wait for the signal. + ggml_cond_wait(&threadpool->cond, &threadpool->mutex); + } + ggml_mutex_unlock_shared(&threadpool->mutex); + } return threadpool->new_work; }