@@ -69,6 +69,12 @@ struct ggml_cl_version {
69
69
cl_uint minor = 0 ;
70
70
};
71
71
72
+ struct ggml_cl_compiler_version {
73
+ int major = -1 ;
74
+ int minor = -1 ;
75
+ int patch = -1 ;
76
+ };
77
+
72
78
// Parses a version string of form "XX.YY ". On an error returns ggml_cl_version with all zeroes.
73
79
static ggml_cl_version parse_cl_version (std::string_view str) {
74
80
size_t major_str_begin = 0 ;
@@ -173,24 +179,28 @@ static ADRENO_GPU_GEN get_adreno_gpu_gen(const char *device_name) {
173
179
return ADRENO_GPU_GEN::ADRENO_UNKNOWN;
174
180
}
175
181
176
- static int get_adreno_cl_compiler_version (const char *driver_version) {
182
+ static ggml_cl_compiler_version get_adreno_cl_compiler_version (const char *driver_version) {
177
183
std::string driver_ver_str (driver_version);
178
184
size_t compiler_ver_pos = driver_ver_str.find (" E031" );
179
185
size_t compiler_ver_len = 13 ;
180
- size_t compiler_ver_offset = 5 ;
186
+ size_t compiler_major_offset = 5 ;
187
+ size_t compiler_minor_offset = 8 ;
188
+ size_t compiler_patch_offset = 11 ;
181
189
182
190
if (compiler_ver_pos == std::string::npos) {
183
191
compiler_ver_pos = driver_ver_str.find (" DX" );
184
192
if (compiler_ver_pos == std::string::npos) {
185
- return - 1 ;
193
+ return {} ;
186
194
}
187
195
compiler_ver_len = 11 ;
188
- compiler_ver_offset = 3 ;
196
+ compiler_major_offset = 3 ;
189
197
}
190
198
191
199
std::string compiler_ver_str = driver_ver_str.substr (compiler_ver_pos, compiler_ver_len);
192
- std::string major_ver_str = compiler_ver_str.substr (compiler_ver_offset, 2 );
193
- return std::atoi (major_ver_str.c_str ());
200
+ int major = std::atoi (compiler_ver_str.substr (compiler_major_offset, 2 ).c_str ());
201
+ int minor = std::atoi (compiler_ver_str.substr (compiler_minor_offset, 2 ).c_str ());
202
+ int patch = std::atoi (compiler_ver_str.substr (compiler_patch_offset, 2 ).c_str ());
203
+ return { major, minor, patch };
194
204
}
195
205
196
206
// backend device context
@@ -216,6 +226,7 @@ struct ggml_backend_opencl_context {
216
226
size_t max_alloc_size;
217
227
bool fp16_support;
218
228
bool has_vector_subgroup_broadcast;
229
+ ggml_cl_compiler_version adreno_cl_compiler_version;
219
230
220
231
int adreno_wave_size;
221
232
@@ -1308,9 +1319,10 @@ static ggml_backend_opencl_context * ggml_cl2_init(ggml_backend_dev_t dev) {
1308
1319
GGML_LOG_INFO (" ggml_opencl: OpenCL driver: %s\n " , driver_version);
1309
1320
backend_ctx->driver_version = driver_version;
1310
1321
1311
- int adreno_cl_compiler_version = get_adreno_cl_compiler_version (driver_version);
1322
+ backend_ctx-> adreno_cl_compiler_version = get_adreno_cl_compiler_version (driver_version);
1312
1323
backend_ctx->has_vector_subgroup_broadcast =
1313
- adreno_cl_compiler_version >= 47 || adreno_cl_compiler_version == 17 ;
1324
+ backend_ctx->adreno_cl_compiler_version .major >= 47 ||
1325
+ backend_ctx->adreno_cl_compiler_version .major == 17 ;
1314
1326
GGML_LOG_INFO (" ggml_opencl: vector subgroup broadcast support: %s\n " ,
1315
1327
backend_ctx->has_vector_subgroup_broadcast ? " true" : " false" );
1316
1328
0 commit comments