From 2ec787362c2c326fd7060be6a73b064efada7c05 Mon Sep 17 00:00:00 2001 From: iOptimizeThings Date: Tue, 19 May 2026 22:24:59 -0700 Subject: [PATCH] sycl: fix performance regression by caching getenv --- ggml/src/ggml-sycl/common.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-sycl/common.cpp b/ggml/src/ggml-sycl/common.cpp index ae08abad81b..8e807743685 100644 --- a/ggml/src/ggml-sycl/common.cpp +++ b/ggml/src/ggml-sycl/common.cpp @@ -86,7 +86,8 @@ int64_t downsample_sycl_global_range(int64_t accumulate_block_num, int64_t block #ifdef GGML_SYCL_SUPPORT_LEVEL_ZERO static bool ggml_sycl_use_level_zero_device_alloc(sycl::queue &q) { - return ggml_sycl_get_env("GGML_SYCL_ENABLE_LEVEL_ZERO", 1) && + static const int enable_level_zero = ggml_sycl_get_env("GGML_SYCL_ENABLE_LEVEL_ZERO", 1); + return enable_level_zero && q.get_device().is_gpu() && q.get_backend() == sycl::backend::ext_oneapi_level_zero; }