diff options
author | Howard Su <howard0su@gmail.com> | 2023-05-29 01:09:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-28 20:09:56 +0300 |
commit | ca74884f6625b15ef69832f07fc60fe00db5f90c (patch) | |
tree | 42d8130cddce8ac3e441fabe64d9dd35f73af8e9 /ggml-opencl.cpp | |
parent | a6704643b62243bc4b6bbcd727d63d44e01a1002 (diff) |
opencl : use strstr to check if fp16 supported (#1611)
* Use strstr to check if fp16 supported
* Ensure ext_buffer is null terminated
Diffstat (limited to 'ggml-opencl.cpp')
-rw-r--r-- | ggml-opencl.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/ggml-opencl.cpp b/ggml-opencl.cpp index 667f55e..8f2e5fb 100644 --- a/ggml-opencl.cpp +++ b/ggml-opencl.cpp @@ -469,16 +469,11 @@ void ggml_cl_init(void) { size_t ext_str_size; clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, 0, NULL, &ext_str_size); - char* ext_buffer = (char*) malloc(sizeof(char) * ext_str_size); + char *ext_buffer = (char *)alloca(ext_str_size + 1); clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, ext_str_size, ext_buffer, NULL); + ext_buffer[ext_str_size] = '\0'; // ensure it is null terminated // Check if ext_buffer contains cl_khr_fp16 - for (size_t i = 0; i < ext_str_size - 12; i++) { - if (memcmp(ext_buffer + i, "cl_khr_fp16", 11) == 0) { - fp16_support = true; - break; - } - } - free(ext_buffer); + fp16_support = strstr(ext_buffer, "cl_khr_fp16") != NULL; fprintf(stderr, "ggml_opencl: device FP16 support: %s\n", fp16_support ? "true" : "false"); cl_context_properties properties[] = { |