-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] Add support for the SYCL_INTEL_local_memory extension to headers #3228
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
16 commits
Select commit
Hold shift + click to select a range
ee590a9
[SYCL] Add support for group_local_memory_for_overwrite to headers
sergey-semenov fc3fcec
Update sycl/include/CL/sycl/group_local_memory.hpp
sergey-semenov 7ea5ac4
Fix unused variable warning
sergey-semenov 67254a4
Fix unused variable warning
sergey-semenov b54803a
Move the allocation function to sycl_fe_intrins.hpp
sergey-semenov ec92916
Merge branch 'sycl' into grouplocalmemory
sergey-semenov cdd809b
Add group_local_memory implementation
sergey-semenov 2583fba
Merge branch 'sycl' into grouplocalmemory
sergey-semenov 1806296
Apply clang-format
sergey-semenov 065ab9e
Add missing includes
sergey-semenov cd64a69
Merge branch 'sycl' into grouplocalmemory
sergey-semenov ea40791
Merge branch 'sycl' into grouplocalmemory
sergey-semenov cb5a9ce
Fix an unused variable warning
sergey-semenov b126135
Apply clang-format
sergey-semenov 460b715
Merge branch 'sycl' into grouplocalmemory
sergey-semenov f5dd455
Perfect-forward constructor arguments
sergey-semenov 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| //==----- group_local_memory.hpp --- SYCL group local memory extension -----==// | ||
| // | ||
| // 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 <CL/__spirv/spirv_vars.hpp> | ||
| #include <CL/sycl/detail/defines_elementary.hpp> | ||
| #include <CL/sycl/detail/sycl_fe_intrins.hpp> | ||
| #include <CL/sycl/detail/type_traits.hpp> | ||
| #include <CL/sycl/exception.hpp> | ||
| #include <CL/sycl/group.hpp> | ||
| #include <CL/sycl/multi_ptr.hpp> | ||
|
|
||
| #include <cstdint> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| __SYCL_INLINE_NAMESPACE(cl) { | ||
| namespace sycl { | ||
|
|
||
| template <typename T, typename Group> | ||
| std::enable_if_t<std::is_trivially_destructible<T>::value && | ||
| detail::is_group<Group>::value, | ||
| multi_ptr<T, access::address_space::local_space>> | ||
| __SYCL_ALWAYS_INLINE group_local_memory_for_overwrite(Group g) { | ||
| (void)g; | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| __attribute__((opencl_local)) std::uint8_t *AllocatedMem = | ||
| __sycl_allocateLocalMemory(sizeof(T), alignof(T)); | ||
| return reinterpret_cast<__attribute__((opencl_local)) T *>(AllocatedMem); | ||
| #else | ||
| throw feature_not_supported( | ||
| "SYCL_INTEL_local_memory extension is not supported on host device", | ||
| PI_INVALID_OPERATION); | ||
| #endif | ||
| } | ||
|
|
||
| template <typename T, typename Group, typename... Args> | ||
| std::enable_if_t<std::is_trivially_destructible<T>::value && | ||
| detail::is_group<Group>::value, | ||
| multi_ptr<T, access::address_space::local_space>> | ||
| __SYCL_ALWAYS_INLINE group_local_memory(Group g, Args &&... args) { | ||
| (void)g; | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| __attribute__((opencl_local)) std::uint8_t *AllocatedMem = | ||
| __sycl_allocateLocalMemory(sizeof(T), alignof(T)); | ||
|
|
||
| // TODO switch to using group::get_local_linear_id here once it's implemented | ||
| id<3> Id = __spirv::initLocalInvocationId<3, id<3>>(); | ||
| if (Id == id<3>(0, 0, 0)) | ||
| new (AllocatedMem) T(std::forward<Args>(args)...); | ||
| detail::workGroupBarrier(); | ||
| return reinterpret_cast<__attribute__((opencl_local)) T *>(AllocatedMem); | ||
| #else | ||
| // Silence unused variable warning | ||
| [&args...] {}(); | ||
| throw feature_not_supported( | ||
| "SYCL_INTEL_local_memory extension is not supported on host device", | ||
| PI_INVALID_OPERATION); | ||
| #endif | ||
| } | ||
| } // namespace sycl | ||
| } // __SYCL_INLINE_NAMESPACE(cl) | ||
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.
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.
NIT: descriptive macro for this -
UNUSED_ARG(g)?Uh oh!
There was an error while loading. Please reload this page.
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.
I don't mind the change, but if it is to be made, it would be more appropriate as a separate one for the whole runtime codebase, since direct casting to void is used extensively right now.