diff options
author | slaren <slarengh@gmail.com> | 2024-01-29 09:05:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 10:05:13 +0200 |
commit | fbe7dfa53caff0a7e830b676e6e949917a5c71b4 (patch) | |
tree | d035bf7c1897ec32c8e033985d589aef79cc2620 /ggml-opencl.cpp | |
parent | 172ac82629815d038702b049070f4c8c02662da5 (diff) |
ggml : add max buffer sizes to opencl and metal backends (#5181)
Diffstat (limited to 'ggml-opencl.cpp')
-rw-r--r-- | ggml-opencl.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ggml-opencl.cpp b/ggml-opencl.cpp index d4066353..797bee66 100644 --- a/ggml-opencl.cpp +++ b/ggml-opencl.cpp @@ -2125,6 +2125,15 @@ static size_t ggml_backend_opencl_buffer_type_get_alignment(ggml_backend_buffer_ GGML_UNUSED(buffer_type); } +static size_t ggml_backend_opencl_buffer_type_get_max_size(ggml_backend_buffer_type_t buffer_type) { + static size_t max_size = -1; + if (max_size == (size_t)-1) { + ggml_cl_init(); + clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(size_t), &max_size, NULL); + } + return max_size; +} + static bool ggml_backend_opencl_buffer_type_supports_backend(ggml_backend_buffer_type_t buffer_type, ggml_backend_t backend) { //return ggml_backend_is_opencl(backend); // opencl must be used through the cpu backend return ggml_backend_is_cpu(backend); @@ -2136,7 +2145,7 @@ static ggml_backend_buffer_type_i ggml_backend_opencl_buffer_type_interface = { /* .get_name = */ ggml_backend_opencl_buffer_type_name, /* .alloc_buffer = */ ggml_backend_opencl_buffer_type_alloc_buffer, /* .get_alignment = */ ggml_backend_opencl_buffer_type_get_alignment, - /* .get_max_size = */ NULL, // TODO: return from device info + /* .get_max_size = */ ggml_backend_opencl_buffer_type_get_max_size, /* .get_alloc_size = */ NULL, /* .supports_backend = */ ggml_backend_opencl_buffer_type_supports_backend, /* .is_host = */ NULL, |