diff --git a/SYCL/Matrix/XMX8/joint_matrix_all_sizes_bfloat16.cpp b/SYCL/Matrix/XMX8/joint_matrix_all_sizes_bfloat16.cpp new file mode 100644 index 0000000000..f16d2e1f9a --- /dev/null +++ b/SYCL/Matrix/XMX8/joint_matrix_all_sizes_bfloat16.cpp @@ -0,0 +1,62 @@ +//==-------- joint_matrix_all_sizes.cpp - DPC++ joint_matrix---------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// REQUIRES: matrix-xmx8 + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_ALL_BF16 +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_1 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_2 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_3 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_4 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_5 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_6 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_7 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_8 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +#include +#include + +using namespace sycl; +using namespace sycl::ext::oneapi::experimental::matrix; +using bfloat16 = sycl::ext::oneapi::bfloat16; + +#define SG_SZ 8 + +#include "../joint_matrix_all_sizes_impl.hpp" diff --git a/SYCL/Matrix/XMX8/joint_matrix_all_sizes_int8.cpp b/SYCL/Matrix/XMX8/joint_matrix_all_sizes_int8.cpp new file mode 100644 index 0000000000..549337f0f1 --- /dev/null +++ b/SYCL/Matrix/XMX8/joint_matrix_all_sizes_int8.cpp @@ -0,0 +1,62 @@ +//==-------- joint_matrix_all_sizes.cpp - DPC++ joint_matrix---------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// REQUIRES: matrix-xmx8 + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_ALL_INT8 +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_1 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_2 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_3 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_4 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_5 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_6 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_7 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_8 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +#include +#include + +using namespace sycl; +using namespace sycl::ext::oneapi::experimental::matrix; +using bfloat16 = sycl::ext::oneapi::bfloat16; + +#define SG_SZ 8 + +#include "../joint_matrix_all_sizes_impl.hpp" diff --git a/SYCL/Matrix/joint_matrix_all_sizes_bfloat16.cpp b/SYCL/Matrix/joint_matrix_all_sizes_bfloat16.cpp new file mode 100644 index 0000000000..db87153d41 --- /dev/null +++ b/SYCL/Matrix/joint_matrix_all_sizes_bfloat16.cpp @@ -0,0 +1,62 @@ +//==-------- joint_matrix_all_sizes.cpp - DPC++ joint_matrix---------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// REQUIRES: matrix + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_ALL_BF16 +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_1 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_2 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_3 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_4 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_5 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_6 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_7 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_BF16_8 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +#include +#include + +using namespace sycl; +using namespace sycl::ext::oneapi::experimental::matrix; +using bfloat16 = sycl::ext::oneapi::bfloat16; + +#define SG_SZ 16 + +#include "joint_matrix_all_sizes_impl.hpp" diff --git a/SYCL/Matrix/joint_matrix_all_sizes_impl.hpp b/SYCL/Matrix/joint_matrix_all_sizes_impl.hpp new file mode 100644 index 0000000000..f379f43c27 --- /dev/null +++ b/SYCL/Matrix/joint_matrix_all_sizes_impl.hpp @@ -0,0 +1,230 @@ +#define BF16_EPSILON 0.00781250 +static constexpr size_t M_MULTIPLIER = 16; + +template struct big_matrix { +private: + T *mat; + +public: + T *get_data() { return mat; } + void set_data(T *data) { mat = data; } + big_matrix(T *data) : mat(data) {} +}; + +template +void matrix_vnni(unsigned int rows, unsigned int cols, T *src, T *dest, + unsigned int vnniFactor) { + for (unsigned int i = 0; i < rows / vnniFactor; i++) { + for (unsigned int j = 0; j < cols; j++) { + for (unsigned int k = 0; k < vnniFactor; k++) { + dest[i * cols * vnniFactor + j * vnniFactor + k] = + src[(i * vnniFactor + k) * cols + j]; + } + } + } +} + +template +void matrix_multiply(big_matrix &C, big_matrix &A, + big_matrix &B) { + size_t NDRangeM = M / TM; + size_t NDRangeN = N / TN; + buffer bufA(A.get_data(), range<2>(M, K)); + buffer bufB(B.get_data(), range<2>(K, N)); + buffer bufC(C.get_data(), range<2>(M, N)); + + queue q; + q.submit([&](handler &cgh) { + sycl::accessor accC{bufC, cgh, sycl::read_write}; + sycl::accessor accA{bufA, cgh, sycl::read_only}; + sycl::accessor accB{bufB, cgh, sycl::read_only}; + + cgh.parallel_for( + nd_range<2>({NDRangeM, NDRangeN * SG_SZ}, {1, 1 * SG_SZ}), + [=](nd_item<2> spmd_item) [[intel::reqd_sub_group_size(SG_SZ)]] + + { + // The submatrix API has to be accessed by all the workitems in a + // subgroup these functions will be called once by the subgroup no + // code divergence between the workitems + const auto global_idx = spmd_item.get_global_id(0); + const auto global_idy = spmd_item.get_global_id(1); + const auto sg_startx = global_idx - spmd_item.get_local_id(0); + const auto sg_starty = global_idy - spmd_item.get_local_id(1); + + sub_group sg = spmd_item.get_sub_group(); + joint_matrix sub_a; + // For B, we assume B has been already VNNIed. + joint_matrix + sub_b; + joint_matrix sub_c; + + joint_matrix_load(sg, sub_c, + accC.get_pointer() + (sg_startx * TM) * N + + sg_starty / SG_SZ * TN, + N, layout::row_major); + for (int k = 0; k < K / TK; k += 1) { + joint_matrix_load( + sg, sub_a, accA.get_pointer() + (sg_startx * TM) * K + k * TK, + K); + joint_matrix_load(sg, sub_b, + accB.get_pointer() + + (k * TK / vnniFactor) * (N * vnniFactor) + + sg_starty / SG_SZ * TN * vnniFactor, + N * vnniFactor); + sub_c = joint_matrix_mad(sg, sub_a, sub_b, sub_c); + } + joint_matrix_store(sg, sub_c, + accC.get_pointer() + (sg_startx * TM) * N + + sg_starty / SG_SZ * TN, + N, layout::row_major); + }); // parallel for + }).wait(); +} + +static constexpr size_t MATRIX_N = 128; +static constexpr size_t MATRIX_K = 128; + +float make_fp32(bfloat16 x) { + unsigned int y = *((int *)&x); + y = y << 16; + float *res = reinterpret_cast(&y); + return *res; +} + +template +void matrix_multiply_ref(Ta *A, Ta *B, Tc *C, int M, int N, int K) { + for (int m = 0; m < M; m++) + for (int n = 0; n < N; n++) { + for (int k = 0; k < K; k++) { + if (std::is_same_v && std::is_same_v) + C[m * N + n] += make_fp32(A[m * K + k]) * make_fp32(B[k * N + n]); + if (std::is_same_v && std::is_same_v) + C[m * N + n] += A[m * K + k] * B[k * N + n]; + } + } +} + +template +int init_and_multiply() { + + static constexpr size_t MATRIX_M = tM * M_MULTIPLIER; + std::cout << "MATRIX_M=" << MATRIX_M << "\n"; + + Ta A[MATRIX_M][MATRIX_K]; + Ta B[MATRIX_K][MATRIX_N]; + Ta Bvnni[MATRIX_K / vnni_factor][MATRIX_N * vnni_factor]; + Tc C[MATRIX_M][MATRIX_N]; + Tc D[MATRIX_M][MATRIX_N]; + + for (int i = 0; i < MATRIX_M; i++) { + for (int j = 0; j < MATRIX_K; j++) { + if (std::is_same_v && std::is_same_v) + A[i][j] = bfloat16(1.0f * (i + j)); + if (std::is_same_v && std::is_same_v) + A[i][j] = i + j; + } + } + for (int i = 0; i < MATRIX_K; i++) { + for (int j = 0; j < MATRIX_N; j++) { + if (std::is_same_v && std::is_same_v) + B[i][j] = bfloat16(2.0f * i + 3.0f * j); + if (std::is_same_v && std::is_same_v) + B[i][j] = i + 2 * j; + } + } + for (int i = 0; i < MATRIX_M; i++) { + for (int j = 0; j < MATRIX_N; j++) { + C[i][j] = 1; + D[i][j] = 1; + } + } + + big_matrix MC((Tc *)&C); + big_matrix MD((Tc *)&D); + big_matrix MA((Ta *)&A); + matrix_vnni(MATRIX_K, MATRIX_N, (Ta *)&B, (Ta *)&Bvnni, vnni_factor); + big_matrix MBvnni( + (Ta *)&Bvnni); + + matrix_multiply(MC, MA, MBvnni); + matrix_multiply_ref((Ta *)A, (Ta *)B, (Tc *)D, MATRIX_M, MATRIX_N, MATRIX_K); + + bool res = true; + for (int i = 0; i < MATRIX_M; i++) { + for (int j = 0; j < MATRIX_N; j++) { + if constexpr (std::is_same_v && std::is_same_v) { + if (fabs(C[i][j] - D[i][j]) > BF16_EPSILON) { + res = false; + std::cout << "Failed bfloat16: C is " << C[i][j] << ", D is " + << D[i][j] << std::endl; + } + } else if (std::is_same_v && std::is_same_v) { + if (C[i][j] != D[i][j]) { + res = false; + std::cout << "Failed int8_t: C is " << C[i][j] << ", D is " << D[i][j] + << std::endl; + } + } + } + } + std::cout << (res ? "passed" : "failed") << std::endl; + return !res; +} + +int main() { +#if defined(JOINT_MATRIX_TEST_BF16_1) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_2) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_3) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_4) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_5) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_6) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_7) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_BF16_8) || defined(JOINT_MATRIX_TEST_ALL_BF16) + init_and_multiply(); +#endif + +#if defined(JOINT_MATRIX_TEST_INT8_1) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_2) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_3) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_4) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_5) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_6) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_7) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif +#if defined(JOINT_MATRIX_TEST_INT8_8) || defined(JOINT_MATRIX_TEST_ALL_INT8) + init_and_multiply(); +#endif + return 0; +} diff --git a/SYCL/Matrix/joint_matrix_all_sizes_int8.cpp b/SYCL/Matrix/joint_matrix_all_sizes_int8.cpp new file mode 100644 index 0000000000..fa227ee3bd --- /dev/null +++ b/SYCL/Matrix/joint_matrix_all_sizes_int8.cpp @@ -0,0 +1,62 @@ +//==-------- joint_matrix_all_sizes.cpp - DPC++ joint_matrix---------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// REQUIRES: matrix + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_ALL_INT8 +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_1 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_2 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_3 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_4 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_5 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_6 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_7 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl %s -o %t.out -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 -DJOINT_MATRIX_TEST_INT8_8 +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=0 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env IGC_JointMatrixLoadStoreOpt=1 %GPU_RUN_PLACEHOLDER %t.out + +#include +#include + +using namespace sycl; +using namespace sycl::ext::oneapi::experimental::matrix; +using bfloat16 = sycl::ext::oneapi::bfloat16; + +#define SG_SZ 16 + +#include "joint_matrix_all_sizes_impl.hpp"