Skip to content

Commit 5a54af4

Browse files
authored
sycl: Use syclcompat::dp4a (#10267)
* sycl: Use syclcompat::dp4a * Using the syclcompat version allow the compiler to optimize the operation with native function * Update news section * Update CI Windows oneAPI version to 2025.0 * Reword doc * Call syclcompat::dp4a inside dpct::dp4a This reverts commit 90cb61d.
1 parent 1607a5e commit 5a54af4

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ jobs:
930930
shell: bash
931931

932932
env:
933-
WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7dff44ba-e3af-4448-841c-0d616c8da6e7/w_BaseKit_p_2024.1.0.595_offline.exe
933+
WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b380d914-366b-4b77-a74a-05e3c38b3514/intel-oneapi-base-toolkit-2025.0.0.882_offline.exe
934934
WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
935935
ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
936936
steps:

docs/backend/SYCL.md

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ The following release is verified with good quality:
4141

4242
## News
4343

44+
- 2024.11
45+
- Use syclcompat to improve the performance on some platforms. This requires to use oneAPI 2025.0 or newer.
4446

4547
- 2024.8
4648
- Use oneDNN as the default GEMM library, improve the compatibility for new Intel GPUs.

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

+2-22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <sycl/sycl.hpp>
1717
#include <sycl/half_type.hpp>
18+
#include <syclcompat/math.hpp>
1819
#include <oneapi/mkl.hpp>
1920
#include <map>
2021

@@ -1830,31 +1831,10 @@ namespace dpct
18301831
: id);
18311832
}
18321833

1833-
template <typename T>
1834-
sycl::vec<T, 4> extract_and_sign_or_zero_extend4(T val)
1835-
{
1836-
return sycl::vec<T, 1>(val)
1837-
.template as<sycl::vec<
1838-
std::conditional_t<std::is_signed_v<T>, int8_t, uint8_t>, 4>>()
1839-
.template convert<T>();
1840-
}
1841-
1842-
template <typename T1, typename T2>
1843-
using dot_product_acc_t =
1844-
std::conditional_t<std::is_unsigned_v<T1> && std::is_unsigned_v<T2>,
1845-
uint32_t, int32_t>;
1846-
18471834
template <typename T1, typename T2, typename T3>
18481835
inline auto dp4a(T1 a, T2 b, T3 c)
18491836
{
1850-
dot_product_acc_t<T1, T2> res = c;
1851-
auto va = extract_and_sign_or_zero_extend4(a);
1852-
auto vb = extract_and_sign_or_zero_extend4(b);
1853-
res += va[0] * vb[0];
1854-
res += va[1] * vb[1];
1855-
res += va[2] * vb[2];
1856-
res += va[3] * vb[3];
1857-
return res;
1837+
return syclcompat::dp4a(a, b, c);
18581838
}
18591839

18601840
struct sub_sat

ggml/src/ggml-sycl/vecdotq.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,8 @@ vec_dot_iq3_xxs_q8_1(const void *__restrict__ vbq,
968968
grid1[0] ^ signs[0], signs[0], std::minus<>());
969969
const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
970970
grid2[0] ^ signs[1], signs[1], std::minus<>());
971-
sumi = dpct::dp4a(grid_l, *((int *)q8 + 0), sumi);
972-
sumi = dpct::dp4a(grid_h, *((int *)q8 + 1), sumi);
971+
sumi = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi);
972+
sumi = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi);
973973
q8 += 8;
974974
aux32 >>= 7;
975975
}
@@ -1009,8 +1009,8 @@ vec_dot_iq3_s_q8_1(const void *__restrict__ vbq,
10091009
grid1[0] ^ signs0, signs0, std::minus<>());
10101010
const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
10111011
grid2[0] ^ signs1, signs1, std::minus<>());
1012-
sumi = dpct::dp4a(grid_l, *((int *)q8 + 0), sumi);
1013-
sumi = dpct::dp4a(grid_h, *((int *)q8 + 1), sumi);
1012+
sumi = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi);
1013+
sumi = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi);
10141014
q8 += 8;
10151015
}
10161016
const float d =

0 commit comments

Comments
 (0)