From 0825ba2fcab3ed720b85748572e53ca05ad29f1d Mon Sep 17 00:00:00 2001 From: slaren Date: Sun, 3 Nov 2024 16:28:22 +0100 Subject: [PATCH] revert synchronization change to ggml_init --- ggml/src/ggml.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 3be67c9b4..7dc3340a1 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -1402,25 +1402,26 @@ static inline bool ggml_can_repeat_rows(const struct ggml_tensor * t0, const str //////////////////////////////////////////////////////////////////////////////// struct ggml_context * ggml_init(struct ggml_init_params params) { - static volatile bool is_first_call = false; - if (!is_first_call) { - ggml_critical_section_start(); - if (!is_first_call) { - // initialize time system (required on Windows) - ggml_time_init(); + static bool is_first_call = false; - for (int i = 0; i < (1 << 16); ++i) { - union { - uint16_t u16; - ggml_fp16_t fp16; - } u = {i}; - ggml_table_f32_f16[i] = GGML_COMPUTE_FP16_TO_FP32(u.fp16); - } - is_first_call = true; + ggml_critical_section_start(); + + if (!is_first_call) { + // initialize time system (required on Windows) + ggml_time_init(); + + for (int i = 0; i < (1 << 16); ++i) { + union { + uint16_t u16; + ggml_fp16_t fp16; + } u = {i}; + ggml_table_f32_f16[i] = GGML_COMPUTE_FP16_TO_FP32(u.fp16); } - ggml_critical_section_end(); + is_first_call = true; } + ggml_critical_section_end(); + struct ggml_context * ctx = GGML_MALLOC(sizeof(struct ggml_context)); // allow to call ggml_init with 0 size