Use strstr to check if fp16 supported

This commit is contained in:
Howard Su 2023-05-27 20:13:49 +08:00
parent 93618031c7
commit 6c5c79a2a3

View file

@ -469,16 +469,10 @@ void ggml_cl_init(void) {
size_t ext_str_size; size_t ext_str_size;
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, 0, NULL, &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);
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, ext_str_size, ext_buffer, NULL); clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, ext_str_size, ext_buffer, NULL);
// Check if ext_buffer contains cl_khr_fp16 // Check if ext_buffer contains cl_khr_fp16
for (size_t i = 0; i < ext_str_size - 12; i++) { fp16_support = strstr(ext_buffer, "cl_khr_fp16") != NULL;
if (memcmp(ext_buffer + i, "cl_khr_fp16", 11) == 0) {
fp16_support = true;
break;
}
}
free(ext_buffer);
fprintf(stderr, "ggml_opencl: device FP16 support: %s\n", fp16_support ? "true" : "false"); fprintf(stderr, "ggml_opencl: device FP16 support: %s\n", fp16_support ? "true" : "false");
cl_context_properties properties[] = { cl_context_properties properties[] = {