#if defined(_MSC_VER) || defined(__MINGW32__)
static int64_t timer_freq, timer_start;
-void ggml_time_init(void) {
+static BOOL CALLBACK ggml_time_init_once(PINIT_ONCE once, PVOID param, PVOID *ctx) {
+ UNUSED(once);
+ UNUSED(param);
+ UNUSED(ctx);
+
LARGE_INTEGER t;
QueryPerformanceFrequency(&t);
timer_freq = t.QuadPart;
// We subtract the program start time to reduce the likelihood of that happening.
QueryPerformanceCounter(&t);
timer_start = t.QuadPart;
+
+ return TRUE;
+}
+void ggml_time_init(void) {
+ static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
+ InitOnceExecuteOnce(&once, ggml_time_init_once, NULL, NULL);
}
int64_t ggml_time_ms(void) {
LARGE_INTEGER t;