Skip to content

Commit 2268c27

Browse files
opencl: fix compiler warnings with GCC and Clang
Still getting the warning about clCreateCmdQueue being obsolete. Will fix that separately.
1 parent 1c4e4d5 commit 2268c27

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

ggml/src/ggml-opencl/ggml-opencl.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#define CL_TARGET_OPENCL_VERSION 220
22

33
// suppress warnings in CL headers for GCC and Clang
4-
#pragma GCC diagnostic ignored "-Wgnu-anonymous-struct"
54
#pragma GCC diagnostic ignored "-Woverlength-strings"
5+
#ifdef __clang__
6+
#pragma GCC diagnostic ignored "-Wgnu-anonymous-struct"
7+
#endif
68

79
#include "ggml-opencl.h"
810
#include "ggml-backend.h"
@@ -1163,9 +1165,7 @@ static void * ggml_backend_opencl_buffer_get_base(ggml_backend_buffer_t buffer)
11631165
static void ggml_backend_opencl_buffer_init_tensor(ggml_backend_buffer_t buffer, ggml_tensor * tensor) {
11641166
ggml_backend_opencl_buffer_context * ctx = (ggml_backend_opencl_buffer_context *) buffer->context;
11651167

1166-
ggml_backend_opencl_context * backend_ctx =
1167-
(ggml_backend_opencl_context *)ggml_cl2_init(buffer->buft->device);
1168-
cl_context context = backend_ctx->context;
1168+
ggml_cl2_init(buffer->buft->device);
11691169

11701170
if (tensor->view_src != nullptr) {
11711171
GGML_ASSERT(tensor->view_src->buffer->buft == buffer->buft);
@@ -3604,8 +3604,9 @@ static void ggml_cl_soft_max(ggml_backend_t backend, const ggml_tensor * src0, c
36043604
const int ne02 = src0 ? src0->ne[2] : 0;
36053605
const int ne03 = src0 ? src0->ne[3] : 0;
36063606

3607-
const float scale = ((float *) dst->op_params)[0];
3608-
const float max_bias = ((float *) dst->op_params)[1];
3607+
float scale, max_bias;
3608+
memcpy(&scale, dst->op_params + 0, sizeof(float));
3609+
memcpy(&max_bias, dst->op_params + 1, sizeof(float));
36093610

36103611
const int nrows_x = ggml_nrows(src0);
36113612
const int nrows_y = src0->ne[1];
@@ -3845,10 +3846,6 @@ bool ggml_cl_compute_forward(ggml_backend_t backend, struct ggml_tensor * tensor
38453846
func = ggml_cl_cpy;
38463847
break;
38473848
case GGML_OP_DUP:
3848-
if (!any_on_device) {
3849-
return false;
3850-
}
3851-
func = ggml_cl_dup;
38523849
case GGML_OP_CONT:
38533850
if (!any_on_device) {
38543851
return false;

0 commit comments

Comments
 (0)