-
Notifications
You must be signed in to change notification settings - Fork 71
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
New submdspan CPP 17 compatible #227
Merged
Merged
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e004a42
Added new submdspan implementation
crtrott 8cfc22f
Fix build errors on Mac
crtrott 9c97013
Add missing strides parameter
crtrott 4bf8a09
Account for strided_index_range stride in submdspan
crtrott 4defa5e
Fix bug in submdspan_extents for strided_index_range slice
crtrott 39450c1
Fix missing include
crtrott aefb6e5
Expand submdspan typed test to actually do runtime check
crtrott f516e85
Add simple strided_index_range test
crtrott ce9c272
Clang 14 needed explicit structured binding construction
crtrott f558537
Fix some comments and rename map to mapping in mapping_offset
crtrott 8a4586b
Rewrite the logic to preserve layout_right and layout_left
crtrott 79c1232
Add more tests
crtrott 55c9979
Reformatting submdspan_extents
crtrott 4749d80
Apply clang-format to submdspan files
crtrott c8e33dc
Backport new submdspan to C++17
crtrott 8ff29f8
Make new submdspan work with NVCC and test on device
crtrott fa91897
Disable submdspan in C++14 mode
crtrott 36b9376
Delete old submdspan impl
crtrott 471ecbc
Update license files where missing
crtrott d7f2b3e
Based on Marks Review: always use C++17 inv_map_rank
crtrott a08fc05
Fix a comment
crtrott 277bb26
Test submdspan customization point
crtrott 7b80df4
Apply some changes suggested in review.
crtrott 15899dc
Support and add test for compile time zero length/stride index range
crtrott 98c6086
Fix some warnings and rename parameter pack
crtrott b4a7aeb
Actually run the submdspan test on device too
crtrott c99e6e5
Fix warnings
crtrott 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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,34 @@ | ||||||||||||
|
||||||||||||
//@HEADER | ||||||||||||
// ************************************************************************ | ||||||||||||
// | ||||||||||||
// Kokkos v. 4.0 | ||||||||||||
// Copyright (2022) National Technology & Engineering | ||||||||||||
// Solutions of Sandia, LLC (NTESS). | ||||||||||||
// | ||||||||||||
// Under the terms of Contract DE-NA0003525 with NTESS, | ||||||||||||
// the U.S. Government retains certain rights in this software. | ||||||||||||
// | ||||||||||||
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. | ||||||||||||
// See https://kokkos.org/LICENSE for license information. | ||||||||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||||||||
// | ||||||||||||
//@HEADER | ||||||||||||
|
||||||||||||
namespace std { | ||||||||||||
namespace experimental { | ||||||||||||
|
||||||||||||
// Slice Specifier allowing for strides and compile time extent | ||||||||||||
template <class OffsetType, class ExtentType, class StrideType> | ||||||||||||
struct strided_index_range { | ||||||||||||
using offset_type = OffsetType; | ||||||||||||
using extent_type = ExtentType; | ||||||||||||
using stride_type = StrideType; | ||||||||||||
|
||||||||||||
OffsetType offset; | ||||||||||||
ExtentType extent; | ||||||||||||
StrideType stride; | ||||||||||||
}; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we consider enforcing the Mandates here?
Suggested change
In the change above, template<class T>
struct is_integral_constant : std::false_type {};
template<std::integral T, T Value>
struct is_integral_constant<std::integral_constant<T, Value>> : std::true_type {};
template<class T>
constexpr inline bool is_integral_constant_v = is_integral_constant<T>::value; |
||||||||||||
|
||||||||||||
} // experimental | ||||||||||||
} // std |
This file contains 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,40 @@ | ||
//@HEADER | ||
// ************************************************************************ | ||
// | ||
// Kokkos v. 4.0 | ||
// Copyright (2022) National Technology & Engineering | ||
// Solutions of Sandia, LLC (NTESS). | ||
// | ||
// Under the terms of Contract DE-NA0003525 with NTESS, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://kokkos.org/LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//@HEADER | ||
|
||
#include "submdspan_extents.hpp" | ||
#include "submdspan_mapping.hpp" | ||
|
||
namespace std { | ||
namespace experimental { | ||
template <class ElementType, class Extents, class LayoutPolicy, | ||
class AccessorPolicy, class... SliceSpecifiers> | ||
MDSPAN_INLINE_FUNCTION | ||
constexpr auto | ||
submdspan(const mdspan<ElementType, Extents, LayoutPolicy, AccessorPolicy> &src, | ||
SliceSpecifiers... slices) { | ||
const auto sub_mapping_offset = submdspan_mapping(src.mapping(), slices...); | ||
// NVCC has a problem with the deduction so lets figure out the type | ||
using sub_mapping_t = std::remove_cv_t<decltype(sub_mapping_offset.mapping)>; | ||
using sub_extents_t = typename sub_mapping_t::extents_type; | ||
using sub_layout_t = typename sub_mapping_t::layout_type; | ||
using sub_accessor_t = typename AccessorPolicy::offset_policy; | ||
return mdspan<ElementType, sub_extents_t, sub_layout_t, sub_accessor_t>( | ||
src.accessor().offset(src.data_handle(), sub_mapping_offset.offset), | ||
sub_mapping_offset.mapping, | ||
sub_accessor_t(src.accessor())); | ||
} | ||
} // namespace experimental | ||
} // namespace std |
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.
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.
This is called
strided_slice
now in the paper, but I'm OK with doing the rename as a separate PR.