-
Couldn't load subscription status.
- Fork 793
[SYCL][NFC] Move NDRDescT and ArgDesc to separate headers #20157
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 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| //==-------------- CG.hpp - SYCL standard header file ----------------------==// | ||
| // | ||
| // 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/detail/kernel_desc.hpp> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
|
|
||
| // The structure represents kernel argument. | ||
| class ArgDesc { | ||
| public: | ||
| ArgDesc(sycl::detail::kernel_param_kind_t Type, void *Ptr, int Size, | ||
| int Index) | ||
| : MType(Type), MPtr(Ptr), MSize(Size), MIndex(Index) {} | ||
|
|
||
| sycl::detail::kernel_param_kind_t MType; | ||
| void *MPtr; | ||
| int MSize; | ||
| int MIndex; | ||
| }; | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
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,116 @@ | ||
| //==-------------- CG.hpp - SYCL standard header file ----------------------==// | ||
vinser52 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // | ||
| // 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/nd_range.hpp> | ||
| #include <sycl/range.hpp> | ||
|
|
||
| #include <array> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
| // The structure represents NDRange - global, local sizes, global offset and | ||
| // number of dimensions. | ||
|
|
||
| // TODO: A lot of tests rely on particular values to be set for dimensions that | ||
| // are not used. To clarify, for example, if a 2D kernel is invoked, in | ||
| // NDRDescT, the value of index 2 in GlobalSize must be set to either 1 or 0 | ||
| // depending on which constructor is used for no clear reason. | ||
| // Instead, only sensible defaults should be used and tests should be updated | ||
| // to reflect this. | ||
| class NDRDescT { | ||
|
|
||
| public: | ||
| NDRDescT() = default; | ||
| NDRDescT(const NDRDescT &Desc) = default; | ||
| NDRDescT(NDRDescT &&Desc) = default; | ||
|
|
||
| template <int Dims_> | ||
| NDRDescT(sycl::range<Dims_> N, bool SetNumWorkGroups) : Dims{size_t(Dims_)} { | ||
| if (SetNumWorkGroups) { | ||
| for (size_t I = 0; I < Dims_; ++I) { | ||
| NumWorkGroups[I] = N[I]; | ||
| } | ||
| } else { | ||
| for (size_t I = 0; I < Dims_; ++I) { | ||
| GlobalSize[I] = N[I]; | ||
| } | ||
|
|
||
| for (int I = Dims_; I < 3; ++I) { | ||
| GlobalSize[I] = 1; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| template <int Dims_> | ||
| NDRDescT(sycl::range<Dims_> NumWorkItems, sycl::range<Dims_> LocalSizes, | ||
| sycl::id<Dims_> Offset) | ||
| : Dims{size_t(Dims_)} { | ||
| for (size_t I = 0; I < Dims_; ++I) { | ||
| GlobalSize[I] = NumWorkItems[I]; | ||
| LocalSize[I] = LocalSizes[I]; | ||
| GlobalOffset[I] = Offset[I]; | ||
| } | ||
|
|
||
| for (int I = Dims_; I < 3; ++I) { | ||
| LocalSize[I] = LocalSizes[0] ? 1 : 0; | ||
| } | ||
|
|
||
| for (int I = Dims_; I < 3; ++I) { | ||
| GlobalSize[I] = 1; | ||
| } | ||
| } | ||
|
|
||
| template <int Dims_> | ||
| NDRDescT(sycl::range<Dims_> NumWorkItems, sycl::id<Dims_> Offset) | ||
| : Dims{size_t(Dims_)} { | ||
| for (size_t I = 0; I < Dims_; ++I) { | ||
| GlobalSize[I] = NumWorkItems[I]; | ||
| GlobalOffset[I] = Offset[I]; | ||
| } | ||
| } | ||
|
|
||
| template <int Dims_> | ||
| NDRDescT(sycl::nd_range<Dims_> ExecutionRange) | ||
| : NDRDescT(ExecutionRange.get_global_range(), | ||
| ExecutionRange.get_local_range(), | ||
| ExecutionRange.get_offset()) {} | ||
|
|
||
| template <int Dims_> | ||
| NDRDescT(sycl::range<Dims_> Range) | ||
| : NDRDescT(Range, /*SetNumWorkGroups=*/false) {} | ||
|
|
||
| template <int Dims_> void setClusterDimensions(sycl::range<Dims_> N) { | ||
| if (this->Dims != size_t(Dims_)) { | ||
| throw std::runtime_error( | ||
| "Dimensionality of cluster, global and local ranges must be same"); | ||
| } | ||
|
|
||
| for (int I = 0; I < Dims_; ++I) | ||
| ClusterDimensions[I] = N[I]; | ||
| } | ||
|
|
||
| NDRDescT &operator=(const NDRDescT &Desc) = default; | ||
| NDRDescT &operator=(NDRDescT &&Desc) = default; | ||
|
|
||
| std::array<size_t, 3> GlobalSize{0, 0, 0}; | ||
| std::array<size_t, 3> LocalSize{0, 0, 0}; | ||
| std::array<size_t, 3> GlobalOffset{0, 0, 0}; | ||
| /// Number of workgroups, used to record the number of workgroups from the | ||
| /// simplest form of parallel_for_work_group. If set, all other fields must be | ||
| /// zero | ||
| std::array<size_t, 3> NumWorkGroups{0, 0, 0}; | ||
| std::array<size_t, 3> ClusterDimensions{1, 1, 1}; | ||
| size_t Dims = 0; | ||
| }; | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
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.