Skip to content

Commit 1f3e1b6

Browse files
Enabled more data types for oneMKL gemm_batch (ggml-org#8236)
1 parent 148ec97 commit 1f3e1b6

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

ggml/src/ggml-sycl.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,10 +3493,6 @@ static void ggml_sycl_mul_mat_batched_sycl(ggml_backend_sycl_context & ctx,
34933493
SYCL_CHECK(ggml_sycl_set_device(ctx.device));
34943494
queue_ptr main_stream = ctx.stream();;
34953495

3496-
bool no_mixed_dtypes = main_stream->get_backend() == sycl::backend::ext_oneapi_cuda ||
3497-
main_stream->get_backend() == sycl::backend::ext_oneapi_hip;
3498-
3499-
35003496
void * src0_ddq = src0->data;
35013497
sycl::half *src0_as_f16 = (sycl::half *)src0_ddq;
35023498
float * src1_ddf = (float *) src1->data;
@@ -3514,15 +3510,10 @@ static void ggml_sycl_mul_mat_batched_sycl(ggml_backend_sycl_context & ctx,
35143510
sycl::half *src1_f16 = src1->type == GGML_TYPE_F16 ? (sycl::half *)src1_ddf
35153511
: src1_f16_alloc.get();
35163512

3517-
ggml_sycl_pool_alloc<sycl::half> dst_f16(ctx.pool());
35183513
char * dst_t;
35193514

35203515
dpct::library_data_t cu_compute_type = dpct::library_data_t::real_float;
35213516
dpct::library_data_t cu_data_type = dpct::library_data_t::real_float;
3522-
if (no_mixed_dtypes) {
3523-
cu_compute_type = dpct::library_data_t::real_half;
3524-
cu_data_type = dpct::library_data_t::real_half;
3525-
}
35263517

35273518
// dst strides
35283519
size_t nbd2 = dst->nb[2];
@@ -3531,26 +3522,10 @@ static void ggml_sycl_mul_mat_batched_sycl(ggml_backend_sycl_context & ctx,
35313522
const float alpha_f32 = 1.0f;
35323523
const float beta_f32 = 0.0f;
35333524

3534-
const sycl::half alpha_f16 = 1.0f;
3535-
const sycl::half beta_f16 = 0.0f;
3536-
35373525
const void * alpha = &alpha_f32;
35383526
const void * beta = &beta_f32;
3539-
if (no_mixed_dtypes) {
3540-
alpha = &alpha_f16;
3541-
beta = &beta_f16;
3542-
}
3543-
3544-
// TODO: Renable (dst->op_params[0] =! GGML_PREC_DEFAULT) pathway
3545-
// when oneMKL open source supports half, half, float, float: datatypes
35463527

35473528
dst_t = (char *) dst_ddf;
3548-
if (no_mixed_dtypes) {
3549-
dst_t = (char *) dst_f16.alloc(ne_dst);
3550-
3551-
nbd2 /= sizeof(float) / sizeof(sycl::half);
3552-
nbd3 /= sizeof(float) / sizeof(sycl::half);
3553-
}
35543529

35553530
GGML_ASSERT(ne12 % ne02 == 0);
35563531
GGML_ASSERT(ne13 % ne03 == 0);
@@ -3612,11 +3587,6 @@ static void ggml_sycl_mul_mat_batched_sycl(ggml_backend_sycl_context & ctx,
36123587
(void **)(ptrs_dst.get() + 0 * ne23), cu_data_type, ne01, ne23,
36133588
cu_compute_type)));
36143589
}
3615-
3616-
if (no_mixed_dtypes) {
3617-
const to_fp32_sycl_t to_fp32_sycl = ggml_get_to_fp32_sycl(GGML_TYPE_F16);
3618-
to_fp32_sycl(dst_f16.get(), dst_ddf, ne_dst, main_stream);
3619-
}
36203590
}
36213591
catch (sycl::exception const &exc) {
36223592
std::cerr << exc.what() << "Exception caught at file:" << __FILE__

ggml/src/ggml-sycl/dpct/helper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,7 @@ namespace dpct
24262426
b, ldb, beta, c, ldc, batch_size);
24272427
break;
24282428
}
2429+
#endif
24292430
case detail::get_type_combination_id(
24302431
library_data_t::real_int8, library_data_t::real_int8,
24312432
library_data_t::real_int32, library_data_t::real_int32):
@@ -2458,7 +2459,6 @@ namespace dpct
24582459
batch_size);
24592460
break;
24602461
}
2461-
#endif
24622462
case detail::get_type_combination_id(
24632463
library_data_t::real_half, library_data_t::real_half,
24642464
library_data_t::real_half, library_data_t::real_float):
@@ -2595,6 +2595,7 @@ namespace dpct
25952595
stride_c, batch_size);
25962596
break;
25972597
}
2598+
#endif
25982599
case detail::get_type_combination_id(
25992600
library_data_t::real_int8, library_data_t::real_int8,
26002601
library_data_t::real_int32, library_data_t::real_int32):
@@ -2623,7 +2624,6 @@ namespace dpct
26232624
beta, c, ldc, stride_c, batch_size);
26242625
break;
26252626
}
2626-
#endif
26272627
case detail::get_type_combination_id(
26282628
library_data_t::real_half, library_data_t::real_half,
26292629
library_data_t::real_half, library_data_t::real_float):

0 commit comments

Comments
 (0)