Skip to content

Commit 250e790

Browse files
Merge pull request #8182 from OuadiElfarouki/mixed_precision_gemm
sycl-exp : Enabled more data types for oneMKL's gemm_batch API
2 parents ea784c1 + a158e1b commit 250e790

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

ggml-sycl.cpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,7 @@ namespace dpct
24902490
b, ldb, beta, c, ldc, batch_size);
24912491
break;
24922492
}
2493+
#endif
24932494
case detail::get_type_combination_id(
24942495
library_data_t::real_int8, library_data_t::real_int8,
24952496
library_data_t::real_int32, library_data_t::real_int32):
@@ -2522,7 +2523,6 @@ namespace dpct
25222523
batch_size);
25232524
break;
25242525
}
2525-
#endif
25262526
case detail::get_type_combination_id(
25272527
library_data_t::real_half, library_data_t::real_half,
25282528
library_data_t::real_half, library_data_t::real_float):
@@ -2659,6 +2659,7 @@ namespace dpct
26592659
stride_c, batch_size);
26602660
break;
26612661
}
2662+
#endif
26622663
case detail::get_type_combination_id(
26632664
library_data_t::real_int8, library_data_t::real_int8,
26642665
library_data_t::real_int32, library_data_t::real_int32):
@@ -2687,7 +2688,6 @@ namespace dpct
26872688
beta, c, ldc, stride_c, batch_size);
26882689
break;
26892690
}
2690-
#endif
26912691
case detail::get_type_combination_id(
26922692
library_data_t::real_half, library_data_t::real_half,
26932693
library_data_t::real_half, library_data_t::real_float):
@@ -15026,9 +15026,6 @@ static void ggml_sycl_mul_mat_batched_sycl(const ggml_tensor *src0,
1502615026
SYCL_CHECK(ggml_sycl_set_device(g_main_device));
1502715027
dpct::queue_ptr main_stream = g_syclStreams[g_main_device][0];
1502815028

15029-
bool no_mixed_dtypes = main_stream->get_backend() == sycl::backend::ext_oneapi_cuda ||
15030-
main_stream->get_backend() == sycl::backend::ext_oneapi_hip;
15031-
1503215029
SYCL_CHECK(
1503315030
CHECK_TRY_ERROR(g_sycl_handles[g_main_device] = main_stream));
1503415031

@@ -15059,10 +15056,6 @@ static void ggml_sycl_mul_mat_batched_sycl(const ggml_tensor *src0,
1505915056

1506015057
dpct::library_data_t cu_compute_type = dpct::library_data_t::real_float;
1506115058
dpct::library_data_t cu_data_type = dpct::library_data_t::real_float;
15062-
if (no_mixed_dtypes) {
15063-
cu_compute_type = dpct::library_data_t::real_half;
15064-
cu_data_type = dpct::library_data_t::real_half;
15065-
}
1506615059

1506715060
// dst strides
1506815061
size_t nbd2 = dst->nb[2];
@@ -15076,21 +15069,8 @@ static void ggml_sycl_mul_mat_batched_sycl(const ggml_tensor *src0,
1507615069

1507715070
const void * alpha = &alpha_f32;
1507815071
const void * beta = &beta_f32;
15079-
if (no_mixed_dtypes) {
15080-
alpha = &alpha_f16;
15081-
beta = &beta_f16;
15082-
}
15083-
15084-
// TODO: Renable (dst->op_params[0] =! GGML_PREC_DEFAULT) pathway
15085-
// when oneMKL open source supports half, half, float, float: datatypes
1508615072

1508715073
dst_t = (char *) dst_ddf;
15088-
if (no_mixed_dtypes) {
15089-
dst_t = (char *) dst_f16.alloc(ne_dst);
15090-
15091-
nbd2 /= sizeof(float) / sizeof(sycl::half);
15092-
nbd3 /= sizeof(float) / sizeof(sycl::half);
15093-
}
1509415074

1509515075
GGML_ASSERT(ne12 % ne02 == 0);
1509615076
GGML_ASSERT(ne13 % ne03 == 0);
@@ -15152,11 +15132,6 @@ static void ggml_sycl_mul_mat_batched_sycl(const ggml_tensor *src0,
1515215132
(void **)(ptrs_dst.get() + 0 * ne23), cu_data_type, ne01, ne23,
1515315133
cu_compute_type)));
1515415134
}
15155-
15156-
if (no_mixed_dtypes) {
15157-
const to_fp32_sycl_t to_fp32_sycl = ggml_get_to_fp32_sycl(GGML_TYPE_F16);
15158-
to_fp32_sycl(dst_f16.get(), dst_ddf, ne_dst, main_stream);
15159-
}
1516015135
}
1516115136
catch (sycl::exception const &exc) {
1516215137
std::cerr << exc.what() << "Exception caught at file:" << __FILE__

0 commit comments

Comments
 (0)