Skip to content

Commit a708dfc

Browse files
committed
Reduce compiler warnings step 2
1 parent 3930184 commit a708dfc

File tree

9 files changed

+70
-43
lines changed

9 files changed

+70
-43
lines changed

ggml/src/ggml-sycl/common.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212

1313
#include "common.hpp"
14+
#include "ggml-impl.h"
1415

1516
int get_current_device_id() {
1617
return dpct::dev_mgr::instance().current_device_id();
@@ -28,11 +29,7 @@ void* ggml_sycl_host_malloc(size_t size) try {
2829

2930
if (err != 0) {
3031
// clear the error
31-
fprintf(
32-
stderr,
33-
"WARNING: failed to allocate %.2f MB of pinned memory: %s\n",
34-
size / 1024.0 / 1024.0,
35-
"syclGetErrorString is not supported");
32+
GGML_LOG_ERROR("WARNING: failed to allocate %.2f MB of pinned memory: %s\n", size / 1024.0 / 1024.0, "syclGetErrorString is not supported");
3633
return nullptr;
3734
}
3835

@@ -66,17 +63,21 @@ int64_t downsample_sycl_global_range(int64_t accumulate_block_num, int64_t block
6663
void ggml_sycl_op_flatten(ggml_backend_sycl_context & ctx, const ggml_tensor *src0,
6764
const ggml_tensor *src1, ggml_tensor *dst,
6865
const ggml_sycl_op_flatten_t op) try {
69-
const int64_t nrows0 = ggml_nrows(src0);
66+
67+
// TODO: What's the use of these?
68+
// const int64_t nrows0 = ggml_nrows(src0);
69+
// const int64_t nrows1 = use_src1 ? ggml_nrows(src1) : 1;
7070

7171
const bool use_src1 = src1 != nullptr;
72-
const int64_t nrows1 = use_src1 ? ggml_nrows(src1) : 1;
7372

7473
GGML_ASSERT(!use_src1 || src1->backend != GGML_BACKEND_TYPE_GPU_SPLIT);
7574
GGML_ASSERT( dst->backend != GGML_BACKEND_TYPE_GPU_SPLIT);
7675

77-
ggml_tensor_extra_gpu * src0_extra = (ggml_tensor_extra_gpu *) src0->extra;
78-
ggml_tensor_extra_gpu * src1_extra = use_src1 ? (ggml_tensor_extra_gpu *) src1->extra : nullptr;
79-
ggml_tensor_extra_gpu * dst_extra = (ggml_tensor_extra_gpu *) dst->extra;
76+
// TODO: What are these uses of these?
77+
78+
// ggml_tensor_extra_gpu * src0_extra = (ggml_tensor_extra_gpu *) src0->extra;
79+
// ggml_tensor_extra_gpu * src1_extra = use_src1 ? (ggml_tensor_extra_gpu *) src1->extra : nullptr;
80+
// ggml_tensor_extra_gpu * dst_extra = (ggml_tensor_extra_gpu *) dst->extra;
8081

8182
// dd = data device
8283
float * src0_ddf = (float *) src0->data;

ggml/src/ggml-sycl/convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ static void convert_unary(const void * __restrict__ vx, dst_t * __restrict__ y,
424424
const int64_t global_id = item_ct1.get_local_id(2) + work_group_size * item_ct1.get_group(2);
425425

426426
// make each work-item deal with more elements since sycl global range can not exceed max int
427-
const src_t * x = (src_t *) vx;
427+
const src_t * x = (const src_t *) vx;
428428
for (int64_t i = global_id; i < k; i += work_group_size * item_ct1.get_group_range(2)) {
429429
y[i] = x[i];
430430
}

ggml/src/ggml-sycl/element_wise.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void upscale_f32(const float *x, float *dst, const int nb00, const int nb01,
237237
int i02 = i12 / sf2;
238238
int i03 = i13 / sf3;
239239

240-
dst[index] = *(float *)((const char *)x + i03 * nb03 + i02 * nb02 + i01 * nb01 + i00 * nb00);
240+
dst[index] = *(const float *)((const char *)x + i03 * nb03 + i02 * nb02 + i01 * nb01 + i00 * nb00);
241241
}
242242

243243
void pad_f32(const float *x, float *dst, const int ne0, const int ne00, const int ne01, const int ne02,
@@ -251,8 +251,7 @@ void pad_f32(const float *x, float *dst, const int ne0, const int ne00, const i
251251
// operation
252252
int offset_dst = nidx + item_ct1.get_group(1) * ne0 +
253253
item_ct1.get_group(0) * ne0 * item_ct1.get_group_range(1);
254-
if (nidx < ne00 && item_ct1.get_group(1) < ne01 &&
255-
item_ct1.get_group(0) < ne02) {
254+
if (nidx < ne00 && item_ct1.get_group(1) < (size_t) ne01 && item_ct1.get_group(0) < (size_t) ne02) {
256255
int offset_src = nidx + item_ct1.get_group(1) * ne00 +
257256
item_ct1.get_group(0) * ne00 * ne01;
258257
dst[offset_dst] = x[offset_src];

ggml/src/ggml-sycl/gemm.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include "dnnl.hpp"
2424
#include "dnnl_sycl.hpp"
2525

26+
27+
// TODO: Remove this when needed
28+
# pragma clang diagnostic push
29+
# pragma clang diagnostic ignored "-Wcast-qual"
2630
class DnnlGemmWrapper {
2731
public:
2832
using dt = dnnl::memory::data_type;
@@ -96,6 +100,7 @@ class DnnlGemmWrapper {
96100
}
97101
};
98102

103+
# pragma clang diagnostic pop
99104
#endif
100105

101106
#endif // GGML_SYCL_GEMM_HPP

ggml/src/ggml-sycl/ggml-sycl.cpp

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static ggml_sycl_device_info ggml_sycl_init() {
4747

4848
info.device_count = dpct::dev_mgr::instance().device_count();
4949
if (info.device_count == 0) {
50-
GGML_LOG_ERROR("%s: failed to initialize " GGML_SYCL_NAME ": %s\n", __func__);
50+
GGML_LOG_ERROR("%s: failed to initialize: %s\n", GGML_SYCL_NAME, __func__);
5151
return info;
5252
}
5353

@@ -64,7 +64,7 @@ static ggml_sycl_device_info ggml_sycl_init() {
6464
#else
6565
GGML_LOG_INFO("%s: SYCL_USE_XMX: no\n", __func__);
6666
#endif
67-
GGML_LOG_INFO("%s: found %d " GGML_SYCL_NAME " devices:\n", __func__, info.device_count);
67+
GGML_LOG_INFO("%s: found %d %s devices:\n", __func__, info.device_count, GGML_SYCL_NAME);
6868

6969
for (int i = 0; i < info.device_count; ++i) {
7070
info.devices[i].vmm = 0;
@@ -137,7 +137,8 @@ void ggml_backend_sycl_print_sycl_devices() {
137137

138138
for (int id = 0; id < device_count; ++id) {
139139
sycl::device device = dpct::dev_mgr::instance().get_device(id);
140-
sycl::backend backend = device.get_backend();
140+
// TODO: backend variable is unused here!
141+
// sycl::backend backend = device.get_backend();
141142
std::string backend_type = get_device_backend_and_type(device);
142143
int type_id = DeviceNums[backend_type]++;
143144
std::stringstream device_type;
@@ -420,13 +421,12 @@ ggml_backend_sycl_buffer_cpy_tensor(ggml_backend_buffer_t buffer,
420421
return true;
421422
}
422423
return false;
424+
// TODO: Buffer is unused
425+
(void) buffer;
426+
} catch (const sycl::exception & exc) {
427+
std::cerr << exc.what() << "Exception caught at file:" << __FILE__ << ", line:" << __LINE__ << std::endl;
428+
std::exit(1);
423429
}
424-
catch (sycl::exception const &exc) {
425-
std::cerr << exc.what() << "Exception caught at file:" << __FILE__
426-
<< ", line:" << __LINE__ << std::endl;
427-
std::exit(1);
428-
}
429-
430430

431431
static void ggml_backend_sycl_buffer_clear(ggml_backend_buffer_t buffer,
432432
uint8_t value) try {
@@ -1092,10 +1092,7 @@ struct ggml_sycl_pool_leg : public ggml_sycl_pool {
10921092
ggml_sycl_buffer buffer_pool[MAX_SYCL_BUFFERS] = {};
10931093
size_t pool_size = 0;
10941094

1095-
explicit ggml_sycl_pool_leg(queue_ptr qptr_, int device_) :
1096-
qptr(qptr_),
1097-
device(device_) {
1098-
}
1095+
explicit ggml_sycl_pool_leg(queue_ptr qptr_, int device_) : device(device_), qptr(qptr_) {}
10991096

11001097
~ggml_sycl_pool_leg() {
11011098
for (int i = 0; i < MAX_SYCL_BUFFERS; ++i) {
@@ -1238,7 +1235,7 @@ static void quantize_q8_1(const float * __restrict__ x, void * __restrict__ vy,
12381235
zeros[i] = 0.f;
12391236
qzeros[i] = 0;
12401237
}
1241-
const TC xi = ix < kx ? *(TC *)&x[iy * kx + ix] : zeros;
1238+
const TC xi = ix < kx ? *(const TC *)&x[iy * kx + ix] : zeros;
12421239
float sum = xi[0];
12431240
float amax = sycl::fabs(xi[0]);
12441241
#pragma unroll
@@ -1799,6 +1796,8 @@ static void pool2d_nchw_kernel(
17991796
switch (op) {
18001797
case GGML_OP_POOL_AVG: res = 0; break;
18011798
case GGML_OP_POOL_MAX: res = -FLT_MAX; break;
1799+
default:
1800+
break; // TODO: handle this properly
18021801
}
18031802

18041803
for (int i = bh; i < eh; i += 1) {
@@ -1817,6 +1816,8 @@ static void pool2d_nchw_kernel(
18171816
switch (op) {
18181817
case GGML_OP_POOL_AVG: res += (cur / (kh * kw)); break;
18191818
case GGML_OP_POOL_MAX: res = sycl::max(res, (To)cur); break;
1819+
default:
1820+
break; // TODO: handle this properly
18201821
}
18211822
}
18221823
}
@@ -1856,6 +1857,7 @@ static void get_rows_sycl(ggml_backend_sycl_context & ctx, const ggml_tensor *sr
18561857
});
18571858

18581859
(void) dst;
1860+
(void) ctx;
18591861
}
18601862

18611863
template <typename src0_t>
@@ -1894,9 +1896,9 @@ static void get_rows_sycl_float(ggml_backend_sycl_context & ctx, const ggml_tens
18941896
}
18951897

18961898
(void) dst;
1899+
(void) ctx;
18971900
}
18981901

1899-
19001902
static void quantize_row_q8_1_sycl(const float *x, void *vy, const int kx,
19011903
const int ky, const int kx_padded,
19021904
queue_ptr stream) {
@@ -2484,17 +2486,19 @@ inline void ggml_sycl_op_mul_mat_sycl(
24842486
const int64_t ne00 = src0->ne[0];
24852487
const int64_t ne10 = src1->ne[0];
24862488

2487-
const int64_t ne0 = dst->ne[0];
2489+
24882490

24892491
const int64_t row_diff = row_high - row_low;
24902492

24912493
int id;
24922494
SYCL_CHECK(
24932495
CHECK_TRY_ERROR(id = get_current_device_id()));
2494-
2496+
#if !GGML_SYCL_DNNL
2497+
const int64_t ne0 = dst->ne[0];
24952498
// the main device has a larger memory buffer to hold the results from all GPUs
24962499
// ldc == nrows of the matrix that cuBLAS writes into
24972500
int ldc = id == ctx.device ? ne0 : row_diff;
2501+
#endif
24982502

24992503
#ifdef GGML_SYCL_F16
25002504
bool use_fp16 = true; // TODO(Yu) SYCL capability check
@@ -2531,9 +2535,9 @@ inline void ggml_sycl_op_mul_mat_sycl(
25312535
: src1_as_f16.get();
25322536
ggml_sycl_pool_alloc<sycl::half> dst_f16(ctx.pool(), row_diff * src1_ncols);
25332537

2534-
const sycl::half alpha_f16 = 1.0f;
2535-
const sycl::half beta_f16 = 0.0f;
25362538
#if !GGML_SYCL_DNNL
2539+
const sycl::half alpha_f16 = 1.0f;
2540+
const sycl::half beta_f16 = 0.0f;
25372541
SYCL_CHECK(CHECK_TRY_ERROR(dpct::gemm(
25382542
*stream, oneapi::mkl::transpose::trans,
25392543
oneapi::mkl::transpose::nontrans, row_diff, src1_ncols, ne10,
@@ -2570,9 +2574,9 @@ inline void ggml_sycl_op_mul_mat_sycl(
25702574
const float * src0_ddf_i = src0->type == GGML_TYPE_F32 ? (const float *) src0_dd_i : src0_ddq_as_f32.get();
25712575
const float * src1_ddf1_i = src1->type == GGML_TYPE_F32 ? (const float *) src1_ddf_i : src1_ddq_as_f32.get();
25722576

2573-
const float alpha = 1.0f;
2574-
const float beta = 0.0f;
25752577
#if !GGML_SYCL_DNNL
2578+
const float alpha = 1.0f;
2579+
const float beta = 0.0f;
25762580
# ifdef GGML_SYCL_NVIDIA
25772581
SYCL_CHECK(CHECK_TRY_ERROR(oneapi::mkl::blas::column_major::gemm(
25782582
oneapi::mkl::backend_selector<oneapi::mkl::backend::cublas>{ *stream }, oneapi::mkl::transpose::trans,
@@ -2870,7 +2874,8 @@ static void ggml_sycl_op_mul_mat(ggml_backend_sycl_context & ctx, const ggml_ten
28702874

28712875
ggml_tensor_extra_gpu * src0_extra = (ggml_tensor_extra_gpu *) src0->extra;
28722876
ggml_tensor_extra_gpu * src1_extra = (ggml_tensor_extra_gpu *) src1->extra;
2873-
ggml_tensor_extra_gpu * dst_extra = (ggml_tensor_extra_gpu *) dst->extra;
2877+
// TODO: What's the use of this?
2878+
// ggml_tensor_extra_gpu * dst_extra = (ggml_tensor_extra_gpu *) dst->extra;
28742879

28752880
const bool src0_is_contiguous = ggml_is_contiguous(src0);
28762881
const bool src1_is_contiguous = ggml_is_contiguous(src1);
@@ -3296,8 +3301,8 @@ static void ggml_sycl_mul_mat_batched_sycl(ggml_backend_sycl_context & ctx,
32963301
GGML_ASSERT(src0->type == GGML_TYPE_F16);
32973302

32983303
GGML_TENSOR_BINARY_OP_LOCALS
3299-
3300-
const int64_t ne_dst = ggml_nelements(dst);
3304+
// TODO: What's the use of this?
3305+
//const int64_t ne_dst = ggml_nelements(dst);
33013306

33023307
SYCL_CHECK(ggml_sycl_set_device(ctx.device));
33033308
queue_ptr main_stream = ctx.stream();;
@@ -3405,6 +3410,7 @@ catch (sycl::exception const &exc) {
34053410

34063411
inline bool ggml_sycl_supports_mmq(enum ggml_type type) {
34073412
// TODO: accuracy issues in MMQ
3413+
(void) type;
34083414
return false;
34093415
}
34103416

@@ -3836,13 +3842,17 @@ static void ggml_sycl_argmax(ggml_backend_sycl_context & ctx, const ggml_tensor
38363842
}
38373843

38383844
static void ggml_sycl_nop(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst) {
3845+
// TODO: Why this function even exists?
38393846
(void) src0;
38403847
(void) src1;
38413848
(void) dst;
3849+
(void) ctx;
38423850
}
38433851

38443852
void ggml_sycl_set_main_device(const int main_device) try {
3845-
if (dpct::get_current_device_id() == main_device) return;
3853+
if (dpct::get_current_device_id() == static_cast<unsigned int> (main_device)) {
3854+
return;
3855+
}
38463856
check_allow_gpu_index(main_device);
38473857
dpct::select_device(main_device);
38483858

@@ -4210,6 +4220,7 @@ try
42104220
{
42114221
ggml_backend_sycl_context *sycl_ctx =
42124222
(ggml_backend_sycl_context *)backend->context;
4223+
42134224
sycl::event *sycl_event = static_cast<sycl::event *>(event->context);
42144225

42154226
const queue_ptr &stream = sycl_ctx->stream(sycl_ctx->device, 0);
@@ -4224,7 +4235,8 @@ catch (sycl::exception const &exc)
42244235
}
42254236

42264237
static void ggml_backend_sycl_event_wait(ggml_backend_t backend, ggml_backend_event_t event) try {
4227-
ggml_backend_sycl_context* sycl_ctx = static_cast<ggml_backend_sycl_context*>(backend->context);
4238+
// TODO: sycl_ctx is unused here
4239+
// ggml_backend_sycl_context* sycl_ctx = static_cast<ggml_backend_sycl_context*>(backend->context);
42284240
sycl::event* sycl_event = static_cast<sycl::event*>(event->context);
42294241

42304242
if (ggml_backend_is_sycl(backend)) {
@@ -4632,6 +4644,8 @@ static void *ggml_backend_sycl_reg_get_proc_address(ggml_backend_reg_t reg, cons
46324644
// SYCL doesn't support registering host memory, left here for reference
46334645
// "ggml_backend_register_host_buffer"
46344646
// "ggml_backend_unregister_host_buffer"
4647+
// doing this to make the compiler happy
4648+
(void) name;
46354649
return nullptr;
46364650
}
46374651

ggml/src/ggml-sycl/mmq.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#include "mmq.hpp"
1414
#include "vecdotq.hpp"
1515

16+
// Just to make the compiler happy
17+
// TODO: Remove it when needed
18+
#pragma clang diagnostic push
19+
#pragma clang diagnostic ignored "-Wdivision-by-zero"
20+
1621
typedef void (*allocate_tiles_sycl_t)(
1722
int** x_ql,
1823
sycl::half2** x_dm,
@@ -3029,3 +3034,4 @@ catch (sycl::exception const &exc) {
30293034
<< ", line:" << __LINE__ << std::endl;
30303035
std::exit(1);
30313036
}
3037+
#pragma clang diagnostic pop

ggml/src/ggml-sycl/mmvq.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,4 +1031,5 @@ void ggml_sycl_op_mul_mat_vec_q(
10311031
(void) src1;
10321032
(void) dst;
10331033
(void) src1_ddf_i;
1034+
(void) ctx;
10341035
}

ggml/src/ggml-sycl/norm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void norm_f32(const float* x, float* dst, const int ncols, const float ep
3232
item_ct1.barrier(sycl::access::fence_space::local_space);
3333
mean_var = 0.f;
3434
int nreduce = nwarps / WARP_SIZE;
35-
for (size_t i = 0; i < nreduce; i += 1)
35+
for (size_t i = 0; i < (size_t) nreduce; i += 1)
3636
{
3737
mean_var += s_sum[lane_id + i * WARP_SIZE];
3838
}
@@ -86,7 +86,7 @@ static void group_norm_f32(const float* x, float* dst, const int group_size, con
8686
*/
8787
item_ct1.barrier();
8888
tmp = 0.f;
89-
for (size_t i = 0; i < nreduce; i += 1)
89+
for (size_t i = 0; i < (size_t) nreduce; i += 1)
9090
{
9191
tmp += s_sum[lane_id + i * WARP_SIZE];
9292
}
@@ -121,7 +121,7 @@ static void group_norm_f32(const float* x, float* dst, const int group_size, con
121121
*/
122122
item_ct1.barrier();
123123
tmp = 0.f;
124-
for (size_t i = 0; i < nreduce; i += 1)
124+
for (size_t i = 0; i < (size_t) nreduce; i += 1)
125125
{
126126
tmp += s_sum[lane_id + i * WARP_SIZE];
127127
}

ggml/src/ggml-sycl/tsembd.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ void ggml_sycl_op_timestep_embedding(ggml_backend_sycl_context & ctx, const ggml
6868
const int max_period = dst->op_params[1];
6969

7070
timestep_embedding_f32_sycl(src0_d, dst_d, src0->ne[0], dst->nb[1], dim, max_period, stream);
71+
(void) src1;
7172
}

0 commit comments

Comments
 (0)