-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL] Add prototype of group algorithms #1236
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
19 commits
Select commit
Hold shift + click to select a range
9ada7f4
[SYCL] Refactor sub-group code for reuse
Pennycook a61ecd0
[SYCL] Add static members to group class
Pennycook cea1028
[SYCL] Add prototype of group algorithms
Pennycook 58ac82d
Fix clang-format errors in group algorithms
Pennycook 546101e
Fix more clang-format errors in group algorithms
Pennycook 29cf3f0
[SYCL] Convert typedefs to using syntax
Pennycook 3100d90
[SYCL] Remove copyright header from tests
Pennycook cf1c593
[SYCL] Capitalize template argument
Pennycook 3ffd441
[SYCL] Add comment to clarify broadcast overloads
Pennycook 372ba33
[SYCL] Capitalize template argument
Pennycook 8704202
[SYCL] Add comment to #endif
Pennycook febf217
[SYCL] Invert #ifdef logic for group algorithms
Pennycook 199ff41
[SYCL] Add prototype of leader algorithm
Pennycook a7d6504
[SYCL] Add PI_INVALID_DEVICE to runtime_error
Pennycook 065f2b3
[SYCL] Fix compilation with C++11
Pennycook 638fded
[SYCL] Rename function parameter id => linear_id
Pennycook 7927e7e
[SYCL] Make template specialization inline
Pennycook 35b9c8a
[SYCL] Do not rely on inline namespace
Pennycook 760761f
[SYCL] Fix SPIR-V broadcast index
Pennycook 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,55 @@ | ||
//===-- spirv.hpp - Helpers to generate SPIR-V instructions ----*- 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 <CL/__spirv/spirv_ops.hpp> | ||
#include <CL/__spirv/spirv_types.hpp> | ||
#include <CL/__spirv/spirv_vars.hpp> | ||
#include <CL/sycl/detail/generic_type_traits.hpp> | ||
#include <CL/sycl/detail/type_traits.hpp> | ||
|
||
#ifdef __SYCL_DEVICE_ONLY__ | ||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
namespace spirv { | ||
|
||
// Broadcast with scalar local index | ||
template <__spv::Scope S, typename T, typename IdT> | ||
detail::enable_if_t<std::is_integral<IdT>::value, T> | ||
GroupBroadcast(T x, IdT local_id) { | ||
using OCLT = detail::ConvertToOpenCLType_t<T>; | ||
using OCLIdT = detail::ConvertToOpenCLType_t<IdT>; | ||
OCLT ocl_x = detail::convertDataToType<T, OCLT>(x); | ||
OCLIdT ocl_id = detail::convertDataToType<IdT, OCLIdT>(local_id); | ||
return __spirv_GroupBroadcast(S, ocl_x, ocl_id); | ||
} | ||
|
||
// Broadcast with vector local index | ||
template <__spv::Scope S, typename T, int Dimensions> | ||
T GroupBroadcast(T x, id<Dimensions> local_id) { | ||
if (Dimensions == 1) { | ||
return GroupBroadcast<S>(x, local_id[0]); | ||
} | ||
using IdT = vec<size_t, Dimensions>; | ||
using OCLT = detail::ConvertToOpenCLType_t<T>; | ||
using OCLIdT = detail::ConvertToOpenCLType_t<IdT>; | ||
IdT vec_id; | ||
for (int i = 0; i < Dimensions; ++i) { | ||
vec_id[i] = local_id[Dimensions - i - 1]; | ||
} | ||
OCLT ocl_x = detail::convertDataToType<T, OCLT>(x); | ||
OCLIdT ocl_id = detail::convertDataToType<IdT, OCLIdT>(vec_id); | ||
return __spirv_GroupBroadcast(S, ocl_x, ocl_id); | ||
} | ||
|
||
} // namespace spirv | ||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) | ||
#endif // __SYCL_DEVICE_ONLY__ |
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
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.