|
4 | 4 | #define FF_OPENCL_MODULE_NAME "OpenCL" |
5 | 5 | #define FF_OPENCL_NUM_FORMAT_ARGS 3 |
6 | 6 |
|
7 | | -#ifdef FF_HAVE_OPENCL |
| 7 | +#if defined(FF_HAVE_OPENCL) || defined(__APPLE__) |
8 | 8 | #include "common/library.h" |
9 | 9 | #include "common/parsing.h" |
10 | 10 | #include <string.h> |
11 | 11 |
|
12 | 12 | #define CL_TARGET_OPENCL_VERSION 100 |
13 | 13 | #ifdef __APPLE__ |
14 | | -#include <OpenCL/cl.h> |
| 14 | + #include <OpenCL/cl.h> |
15 | 15 | #else |
16 | | -#include <CL/cl.h> |
| 16 | + #include <CL/cl.h> |
17 | 17 | #endif |
18 | 18 |
|
19 | 19 | typedef struct OpenCLData |
@@ -75,36 +75,43 @@ static const char* openCLHandelData(FFinstance* instance, OpenCLData* data) |
75 | 75 | return NULL; |
76 | 76 | } |
77 | 77 |
|
| 78 | +#endif // FF_HAVE_OPENCL || __APPLE__ |
| 79 | + |
| 80 | +#ifdef FF_HAVE_OPENCL |
| 81 | + |
78 | 82 | static const char* printOpenCL(FFinstance* instance) |
79 | 83 | { |
80 | 84 | OpenCLData data; |
81 | 85 |
|
82 | | - #ifdef __APPLE__ |
83 | | - data.ffclGetPlatformIDs = clGetPlatformIDs; |
84 | | - data.ffclGetDeviceIDs = clGetDeviceIDs; |
85 | | - data.ffclGetDeviceInfo = clGetDeviceInfo; |
86 | | - #else |
87 | | - FF_LIBRARY_LOAD(opencl, instance->config.libOpenCL, "dlopen libOpenCL.so failed", "libOpenCL.so", 1); |
88 | | - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetPlatformIDs); |
89 | | - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceIDs); |
90 | | - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceInfo); |
91 | | - #endif |
| 86 | + FF_LIBRARY_LOAD(opencl, instance->config.libOpenCL, "dlopen libOpenCL.so failed", "libOpenCL.so", 1); |
| 87 | + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetPlatformIDs); |
| 88 | + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceIDs); |
| 89 | + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceInfo); |
92 | 90 |
|
93 | 91 | const char* error = openCLHandelData(instance, &data); |
| 92 | + dlclose(opencl); |
| 93 | + return error; |
| 94 | +} |
94 | 95 |
|
95 | | - #ifndef __APPLE__ |
96 | | - dlclose(opencl); |
97 | | - #endif |
| 96 | +#elif __APPLE__ // FF_HAVE_OPENCL |
98 | 97 |
|
99 | | - return error; |
| 98 | +static const char* printOpenCL(FFinstance* instance) |
| 99 | +{ |
| 100 | + OpenCLData data; |
| 101 | + data.ffclGetPlatformIDs = clGetPlatformIDs; |
| 102 | + data.ffclGetDeviceIDs = clGetDeviceIDs; |
| 103 | + data.ffclGetDeviceInfo = clGetDeviceInfo; |
| 104 | + |
| 105 | + return openCLHandelData(instance, &data); |
100 | 106 | } |
101 | | -#endif |
| 107 | + |
| 108 | +#endif // __APPLE__ |
102 | 109 |
|
103 | 110 | void ffPrintOpenCL(FFinstance* instance) |
104 | 111 | { |
105 | 112 | const char* error; |
106 | 113 |
|
107 | | - #ifdef FF_HAVE_OPENCL |
| 114 | + #if defined(FF_HAVE_OPENCL) || defined(__APPLE__) |
108 | 115 | error = printOpenCL(instance); |
109 | 116 | #else |
110 | 117 | error = "Fastfetch was build without OpenCL support"; |
|
0 commit comments