-
Notifications
You must be signed in to change notification settings - Fork 64
Changes for new cute apis prefetch transpose vnni #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,163 @@ | ||||||
| /*************************************************************************************************** | ||||||
| * Copyright (C) 2025 Intel Corporation, All rights reserved. | ||||||
| * SPDX-License-Identifier: BSD-3-Clause | ||||||
| * | ||||||
| * Redistribution and use in source and binary forms, with or without | ||||||
| * modification, are permitted provided that the following conditions are met: | ||||||
| * | ||||||
| * 1. Redistributions of source code must retain the above copyright notice, this | ||||||
| * list of conditions and the disclaimer. | ||||||
| * | ||||||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||||||
| * this list of conditions and the following disclaimer in the documentation | ||||||
| * and/or other materials provided with the distribution. | ||||||
| * | ||||||
| * 3. Neither the name of the copyright holder nor the names of its | ||||||
| * contributors may be used to endorse or promote products derived from | ||||||
| * this software without specific prior written permission. | ||||||
| * | ||||||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||||||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||||||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||||||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF POSSIBILITY OF SUCH DAMAGE. | ||||||
| * | ||||||
| **************************************************************************************************/ | ||||||
|
|
||||||
| #include "cutlass/detail/layout.hpp" | ||||||
|
|
||||||
| #include <cute/tensor.hpp> | ||||||
| #include <cute/atom/copy_atom.hpp> | ||||||
| #include <cute/atom/copy_traits_xe_2d.hpp> | ||||||
| #include <cute/arch/copy_xe_2d.hpp> | ||||||
| #include <sycl/sycl.hpp> | ||||||
| #include <cute/util/compat.hpp> | ||||||
|
|
||||||
| #include "cutlass_unit_test.h" | ||||||
| #include "utils.hpp" | ||||||
|
|
||||||
| using namespace cute; | ||||||
| using namespace cutlass; | ||||||
| using namespace compat::experimental; | ||||||
|
|
||||||
| #define SUBGROUP_SIZE (16) | ||||||
|
|
||||||
| #if (IGC_VERSION_MAJOR > 2) || (IGC_VERSION_MAJOR == 2 && IGC_VERSION_MINOR >= 18) | ||||||
|
|
||||||
| // Kernel name for unique identification | ||||||
| template<class SrcTensor> | ||||||
| class XEPrefetch2DKernelName; | ||||||
|
|
||||||
| // Device kernel for XE_PREFETCH_2D testing | ||||||
| template <class SrcTensor, int Bits, int Height, int Width> | ||||||
| void xe_prefetch_2d_kernel(SrcTensor src) { | ||||||
| using namespace cute; | ||||||
| using Element = typename SrcTensor::value_type; | ||||||
|
|
||||||
| // Only execute with the first subgroup to avoid race conditions | ||||||
| if (sycl::ext::oneapi::this_work_item::get_nd_item<1>().get_group(0) == 0) { | ||||||
| // Get thread/subgroup information | ||||||
| auto local_id = int(sycl::ext::oneapi::this_work_item::get_nd_item<1>().get_local_id(0)); | ||||||
|
|
||||||
| // Create block 2D prefetch inside kernel (device-only operation) | ||||||
| using PrefetchOp = XE_PREFETCH_2D<Bits, Height, Width>; | ||||||
| auto tiled_prefetch = make_block_2d_copy(PrefetchOp{}, src); | ||||||
|
|
||||||
| // Get thread slice of the tiled prefetch | ||||||
| auto thr_prefetch = tiled_prefetch.get_slice(local_id); | ||||||
|
|
||||||
| // Create coordinate tensor for a single tile | ||||||
| auto coord_shape = make_shape(Int<Height>{}, Int<Width * Bits / sizeof_bits_v<Element>>{}); | ||||||
| Tensor coord_tile = make_identity_tensor(coord_shape); | ||||||
|
|
||||||
| // Partition source coordinates for prefetch | ||||||
| auto thr_src_coord = thr_prefetch.partition_S(coord_tile); | ||||||
|
|
||||||
| // Create dummy destination fragment (prefetch ignores destination) | ||||||
| auto thr_dst_frag = thr_prefetch.partition_fragment_D(coord_tile); | ||||||
|
|
||||||
| // Perform the prefetch operation | ||||||
| copy(tiled_prefetch, thr_src_coord, thr_dst_frag); | ||||||
|
|
||||||
| // Synchronize to ensure all threads complete their operations | ||||||
| sycl::group_barrier(sycl::ext::oneapi::this_work_item::get_nd_item<1>().get_group()); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Host test function template for XE_PREFETCH_2D | ||||||
| template <typename Element, int Bits, int Height, int Width> | ||||||
| void test_xe_prefetch_2d() { | ||||||
| using namespace cute; | ||||||
|
|
||||||
| // Matrix dimensions - must be compatible with block 2D constraints | ||||||
| constexpr int M = Height; | ||||||
| constexpr int N = Width * sizeof_bits_v<Element> / Bits; | ||||||
|
||||||
| constexpr int N = Width * sizeof_bits_v<Element> / Bits; | |
| constexpr int N = (Width * Bits) / sizeof_bits_v<Element>; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /*************************************************************************************************** | ||
| * Copyright (C) 2025 Intel Corporation, All rights reserved. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, this | ||
| * list of conditions and the disclaimer. | ||
| * | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * 3. Neither the name of the copyright holder nor the names of its | ||
| * contributors may be used to endorse or promote products derived from | ||
| * this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| **************************************************************************************************/ | ||
|
|
||
| #include <cute/tensor.hpp> | ||
| #include <cute/atom/copy_atom.hpp> | ||
| #include <cute/atom/copy_traits_xe_2d.hpp> | ||
| #include <cute/arch/copy_xe_2d.hpp> | ||
| #include <sycl/sycl.hpp> | ||
| #include "cutlass_unit_test.h" | ||
|
|
||
| using namespace cute; | ||
|
|
||
| #if (IGC_VERSION_MAJOR > 2) || (IGC_VERSION_MAJOR == 2 && IGC_VERSION_MINOR >= 18) | ||
|
|
||
| TEST(PVC_CuTe_Xe, XE_LOAD_2D_TRANSPOSE_API_Declaration) { | ||
| // Template: XE_LOAD_2D_TRANSPOSE<Bits, Height, Width> | ||
| // Constraints: Bits == 32 || Bits == 64, Width <= 8 | ||
| // For 64-bit: Height == 8 && Width < 4 | ||
|
|
||
| // Test 32-bit transpose operations | ||
| using TransposeOp_32bit_2x4 = XE_LOAD_2D_TRANSPOSE<32, 2, 4>; | ||
| using TransposeOp_32bit_4x8 = XE_LOAD_2D_TRANSPOSE<32, 4, 8>; | ||
| using TransposeOp_32bit_8x2 = XE_LOAD_2D_TRANSPOSE<32, 8, 2>; | ||
|
|
||
| // Test 64-bit transpose operations (limited constraints) | ||
| using TransposeOp_64bit_8x2 = XE_LOAD_2D_TRANSPOSE<64, 8, 2>; | ||
| using TransposeOp_64bit_8x3 = XE_LOAD_2D_TRANSPOSE<64, 8, 3>; | ||
|
|
||
| // Test that the operations have the required static members from XE_Copy_Op_2D_Base | ||
| static_assert(TransposeOp_32bit_2x4::AtomHeight == 2); | ||
| static_assert(TransposeOp_32bit_2x4::AtomWidth == 4); | ||
| static_assert(TransposeOp_32bit_2x4::CopyBits == 32); | ||
|
|
||
| static_assert(TransposeOp_32bit_4x8::AtomHeight == 4); | ||
| static_assert(TransposeOp_32bit_4x8::AtomWidth == 8); | ||
| static_assert(TransposeOp_32bit_4x8::CopyBits == 32); | ||
|
|
||
| static_assert(TransposeOp_64bit_8x2::AtomHeight == 8); | ||
| static_assert(TransposeOp_64bit_8x2::AtomWidth == 2); | ||
| static_assert(TransposeOp_64bit_8x2::CopyBits == 64); | ||
|
|
||
| EXPECT_TRUE(true) << "XE_LOAD_2D_TRANSPOSE API types declared successfully"; | ||
| } | ||
|
|
||
| TEST(PVC_CuTe_Xe, XE_LOAD_2D_TRANSPOSE_Constraints) { | ||
| // Test that the compile-time constraints are enforced | ||
|
|
||
| // Valid 32-bit operations | ||
| using Valid32_1 = XE_LOAD_2D_TRANSPOSE<32, 1, 1>; | ||
| using Valid32_2 = XE_LOAD_2D_TRANSPOSE<32, 16, 8>; // Width <= 8 | ||
|
|
||
| // Valid 64-bit operations (Height == 8 && Width < 4) | ||
| using Valid64_1 = XE_LOAD_2D_TRANSPOSE<64, 8, 1>; | ||
| using Valid64_2 = XE_LOAD_2D_TRANSPOSE<64, 8, 2>; | ||
| using Valid64_3 = XE_LOAD_2D_TRANSPOSE<64, 8, 3>; | ||
|
|
||
| static_assert(Valid32_1::CopyBits == 32); | ||
| static_assert(Valid32_2::CopyBits == 32); | ||
| static_assert(Valid64_1::CopyBits == 64); | ||
| static_assert(Valid64_2::CopyBits == 64); | ||
| static_assert(Valid64_3::CopyBits == 64); | ||
|
|
||
| EXPECT_TRUE(true) << "XE_LOAD_2D_TRANSPOSE constraint validation successful"; | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| TEST(PVC_CuTe_Xe, XE_LOAD_2D_TRANSPOSE_SKIPPED) { | ||
| GTEST_SKIP() << "XE_LOAD_2D_TRANSPOSE tests require IGC version 2.18 or higher. skipped"; | ||
| } | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||
| /*************************************************************************************************** | ||||||
| * Copyright (C) 2025 Intel Corporation, All rights reserved. | ||||||
| * SPDX-License-Identifier: BSD-3-Clause | ||||||
| * | ||||||
| * Redistribution and use in source and binary forms, with or without | ||||||
| * modification, are permitted provided that the following conditions are met: | ||||||
| * | ||||||
| * 1. Redistributions of source code must retain the above copyright notice, this | ||||||
| * list of conditions and the disclaimer. | ||||||
| * | ||||||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||||||
| * this list of conditions and the following disclaimer in the documentation | ||||||
| * and/or other materials provided with the distribution. | ||||||
| * | ||||||
| * 3. Neither the name of the copyright holder nor the names of its | ||||||
| * contributors may be used to endorse or promote products derived from | ||||||
| * this software without specific prior written permission. | ||||||
| * | ||||||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||||||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||||||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||||||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF POSSIBILITY OF SUCH DAMAGE. | ||||||
|
||||||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF POSSIBILITY OF SUCH DAMAGE. | |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing article 'THE' before 'POSSIBILITY'. Should be 'EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'