-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][Joint Matrix] Pass on address space to Load/Store #9244
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
125bc29
Some POC to control AS for joint matrix
MrSidims 5852152
[SYCL][Joint Matrix] Pass on address space to Load/Store
YuriPlyakhin 38af1a7
[SYCL][Joint Matrix] Added change for old API.
YuriPlyakhin 20feb85
Reduced fix footprint
YuriPlyakhin aa0d834
[NFC] clean up
YuriPlyakhin 0766104
[NFC] Fixed formatting.
YuriPlyakhin 25c4d7e
Added tests
YuriPlyakhin 8fc1e63
Address problem with multi_ptr.get()
YuriPlyakhin dd9ec35
[NFC] fixed typos
YuriPlyakhin 396b7a4
Use correct version for detail namespace
YuriPlyakhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===------- utils.hpp - SYCL matrix extension ----*- C++ -*------===// | ||
// | ||
// 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 | ||
// | ||
// ===--------------------------------------------------------------------=== // | ||
|
||
#pragma once | ||
|
||
#include <sycl/access/access.hpp> | ||
#include <sycl/multi_ptr.hpp> | ||
|
||
namespace sycl { | ||
__SYCL_INLINE_VER_NAMESPACE(_V1) { | ||
namespace detail { | ||
|
||
// Helper to return decorated pointer for different values | ||
// of access::decorated parameter. | ||
// If access::decorated::legacy is removed in the future | ||
// this helper usage can be replaced with ptr.get_decorated(). | ||
template <typename DecorT, typename T, access::address_space Space, | ||
access::decorated IsDecorated> | ||
DecorT *getDecorated(multi_ptr<T, Space, IsDecorated> ptr) { | ||
if constexpr (IsDecorated == access::decorated::legacy) | ||
return ptr.get(); | ||
else | ||
return ptr.get_decorated(); | ||
} | ||
|
||
} // namespace detail | ||
} // __SYCL_INLINE_VER_NAMESPACE(_V1) | ||
} // namespace sycl |
61 changes: 61 additions & 0 deletions
61
sycl/test/check_device_code/matrix/matrix_load_store_as.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// RUN: %clangxx -fsycl-device-only -S -emit-llvm -o - %s | FileCheck %s | ||
|
||
// check that correct address spaces are used to load from and store to | ||
#define SYCL_EXT_ONEAPI_MATRIX_VERSION 4 | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::oneapi::experimental::matrix; | ||
|
||
int main(void) { | ||
queue q; | ||
unsigned short *A = malloc_shared<unsigned short>(8 * 16, q); | ||
unsigned short *B = malloc_shared<unsigned short>(16 * 16, q); | ||
float *C = malloc_shared<float>(8 * 16, q); | ||
|
||
auto pA = multi_ptr<unsigned short, access::address_space::global_space>(A); | ||
auto pB = multi_ptr<unsigned short, access::address_space::global_space>(B); | ||
auto pC = multi_ptr<float, access::address_space::global_space>(C); | ||
|
||
q.submit([&](handler &h) { | ||
local_accessor<unsigned short, 2> tileA{{8, 16}, h}; | ||
|
||
h.parallel_for( | ||
nd_range<2>({1, 16}, {1, 16}), | ||
[=](nd_item<2> it) [[intel::reqd_sub_group_size(16)]] { | ||
joint_matrix<sub_group, unsigned short, use::a, 8, 16, | ||
layout::row_major> | ||
tA; | ||
joint_matrix<sub_group, unsigned short, use::b, 16, 16, | ||
ext::intel::experimental::matrix::layout::packed> | ||
tB; | ||
joint_matrix<sub_group, float, use::accumulator, 8, 16> tC; | ||
|
||
sub_group sg = it.get_sub_group(); | ||
vec<unsigned short, 8> slmvec = sg.load<8>(pA); | ||
sg.store<8>( | ||
tileA.template get_multi_ptr<sycl::access::decorated::yes>(), | ||
slmvec); | ||
it.barrier(access::fence_space::local_space); | ||
|
||
// A should load from local address space | ||
// CHECK: %{{.*}} = tail call spir_func noundef %spirv.JointMatrixINTEL._short_8_16_0_3_0 addrspace(4)* @_Z[[#]]__spirv_JointMatrixLoadINTEL{{.*}}(i16 addrspace(3)* noundef %{{.*}}, i64 noundef 16, i32 noundef 0, i32 noundef 3, i32 noundef 0) #{{.*}} | ||
joint_matrix_load( | ||
sg, tA, | ||
tileA.template get_multi_ptr<sycl::access::decorated::yes>(), 16); | ||
// B should load from global address space | ||
// CHECK: %{{.*}} = tail call spir_func noundef %spirv.JointMatrixINTEL._short_16_16_2_3_1 addrspace(4)* @_Z[[#]]__spirv_JointMatrixLoadINTEL{{.*}}(i16 addrspace(1)* noundef %{{.*}}, i64 noundef 32, i32 noundef 2, i32 noundef 3, i32 noundef 0) #{{.*}} | ||
joint_matrix_load(sg, tB, pB, 32); | ||
tC = joint_matrix_mad(sg, tA, tB, tC); | ||
// C should store to global address space | ||
// CHECK: tail call spir_func void @_Z[[#]]__spirv_JointMatrixStoreINTEL{{.*}}(float addrspace(1)* noundef %{{.*}}, %spirv.JointMatrixINTEL._float_8_16_3_3_2 addrspace(4)* noundef %{{.*}}, i64 noundef 16, i32 noundef 0, i32 noundef 3, i32 noundef 0) #{{.*}} | ||
joint_matrix_store(sg, tC, pC, 16, layout::row_major); | ||
}); | ||
}); | ||
|
||
free(A, q); | ||
free(B, q); | ||
free(C, q); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.