LLM inference in C/C++
C++ ggml
sycl : fix the B70 mem allocate error when >19.3GB (#28953)
Neo Zhangc9a5eeeb34ab
diff --git a/ggml/src/ggml-sycl/ggml-sycl.cpp b/ggml/src/ggml-sycl/ggml-sycl.cppindex 46b1f21590..b24664a0b9 100644--- a/ggml/src/ggml-sycl/ggml-sycl.cpp+++ b/ggml/src/ggml-sycl/ggml-sycl.cpp@@ -1011,12 +1011,25 @@ static size_t ggml_backend_sycl_buffer_type_get_alignment(ggml_backend_buffer_tyGGML_UNUSED(buft);}+bool is_bmg_g31_arch(int device) {+ return ggml_sycl_info().devices[device].hw_info.arch == gpu_arch::intel_gpu_bmg_g31;+}+static size_t ggml_backend_sycl_buffer_type_get_max_size(ggml_backend_buffer_type_t buft) {size_t max_alloc_size = dpct::get_current_device().get_max_mem_alloc_size();if (g_ggml_sycl_host_pinned_mem_2g) {return std::min(max_alloc_size, (size_t) 2LL*1024*1024*1024);} else {+ ggml_backend_sycl_buffer_type_context * ctx = (ggml_backend_sycl_buffer_type_context *)buft->context;+ int device = ctx->device;+ if(is_bmg_g31_arch(device)) {+ //Todo, it's workaround for BMG-G31, which has a known issue with large allocations.+ //The max alloc size is reduced to 60% of the reported max alloc size.+ //remove it after https://github.com/intel/compute-runtime/issues/998 is fixed.+ max_alloc_size = max_alloc_size*0.6;+ }return max_alloc_size;+}GGML_UNUSED(buft);}