From 93f8d471c1f69898f0807bff6c9b9bd2fecc06e9 Mon Sep 17 00:00:00 2001 From: Albert Jin Date: Sun, 5 May 2024 23:15:49 +0800 Subject: [PATCH 1/2] opencl alignment size should be converted from bits to bytes Reference: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_DEVICE_MEM_BASE_ADDR_ALIGN > Alignment requirement (in bits) for sub-buffer offsets. --- ggml-opencl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ggml-opencl.cpp b/ggml-opencl.cpp index b3f8b7eaf0a3b..031edb4cd8bf7 100644 --- a/ggml-opencl.cpp +++ b/ggml-opencl.cpp @@ -2119,6 +2119,7 @@ static size_t ggml_backend_opencl_buffer_type_get_alignment(ggml_backend_buffer_ if (alignment == (cl_uint)-1) { ggml_cl_init(); clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(cl_uint), &alignment, NULL); + alignment >>= 3; } return alignment; From 0e968fac53f8f8e3fc70b6dc5120c1aa5b938c0e Mon Sep 17 00:00:00 2001 From: Albert Jin Date: Thu, 9 May 2024 10:44:34 +0800 Subject: [PATCH 2/2] Update ggml-opencl.cpp for readability using division instead of shift Co-authored-by: Jared Van Bortel --- ggml-opencl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml-opencl.cpp b/ggml-opencl.cpp index 031edb4cd8bf7..880a14958cec5 100644 --- a/ggml-opencl.cpp +++ b/ggml-opencl.cpp @@ -2119,7 +2119,7 @@ static size_t ggml_backend_opencl_buffer_type_get_alignment(ggml_backend_buffer_ if (alignment == (cl_uint)-1) { ggml_cl_init(); clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(cl_uint), &alignment, NULL); - alignment >>= 3; + alignment /= 8; // bits to bytes } return alignment;