Skip to content

Commit 0b52209

Browse files
committed
Fixing issues with the mdspan_to_view and dot_kokkos tests
Signed-off-by: Luc Berger-Vergiat <lberge@sandia.gov>
1 parent afd749f commit 0b52209

6 files changed

Lines changed: 51 additions & 51 deletions

File tree

include/experimental/__p1673_bits/linalg_execpolicy_mapper.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ inline constexpr bool is_linalg_execution_policy_other_than_inline_v =
8181
is_linalg_execution_policy_v<T>;
8282

8383
} // namespace impl
84-
85-
// Specialize this function to map a public execution policy
86-
// (e.g., std::execution::parallel_policy) to an internal policy.
87-
// This function must always return a different type than its input.
88-
template<class T>
89-
auto execpolicy_mapper(T) { return impl::inline_exec_t(); }
90-
9184
} // namespace linalg
9285
} // inline namespace __p1673_version_0
9386
} // namespace MDSPAN_IMPL_PROPOSED_NAMESPACE
@@ -102,6 +95,13 @@ namespace MDSPAN_IMPL_STANDARD_NAMESPACE {
10295
namespace MDSPAN_IMPL_PROPOSED_NAMESPACE {
10396
inline namespace __p1673_version_0 {
10497
namespace linalg {
98+
99+
// Specialize this function to map a public execution policy
100+
// (e.g., std::execution::parallel_policy) to an internal policy.
101+
// This function must always return a different type than its input.
102+
template<class T>
103+
auto execpolicy_mapper(T) { return impl::inline_exec_t(); }
104+
105105
namespace impl {
106106

107107
// std::remove_cvref_t is a C++20 feature.
@@ -119,7 +119,7 @@ inline auto map_execpolicy_with_check = [](auto&& policy) {
119119
using input_type = remove_cvref_t<decltype(policy)>;
120120
using return_type = remove_cvref_t<decltype(execpolicy_mapper(std::forward<decltype(policy)>(policy)))>;
121121
// Only inline_exec_t is allowed to map to itself.
122-
using inline_type = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg::impl::inline_exec_t;
122+
using inline_type = inline_exec_t;
123123
static_assert(std::is_same_v<input_type, inline_type> ||
124124
! std::is_same_v<input_type, return_type>,
125125
"Specializations of execpolicy_mapper must return "

tests/kokkos-based/dot_kokkos.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ auto dot_gold_solution(x_t x, y_t y, T initValue, bool useInit)
2121
template<class x_t, class y_t, class T>
2222
void kokkos_blas1_dot_test_impl(x_t x, y_t y, T initValue, bool useInit)
2323
{
24-
namespace stdla = std::experimental::linalg;
24+
namespace stdla = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg;
2525

2626
using value_type = typename x_t::value_type;
2727
const std::size_t extent = x.extent(0);
@@ -35,10 +35,10 @@ void kokkos_blas1_dot_test_impl(x_t x, y_t y, T initValue, bool useInit)
3535

3636
T result = {};
3737
if (useInit){
38-
result = stdla::dot(KokkosKernelsSTD::kokkos_exec<>(),
38+
result = stdla::dot(Kokkos::DefaultExecutionSpace(),
3939
x, y, initValue);
4040
}else{
41-
result = stdla::dot(KokkosKernelsSTD::kokkos_exec<>(),
41+
result = stdla::dot(Kokkos::DefaultExecutionSpace(),
4242
x, y);
4343
}
4444

tests/kokkos-based/helpers.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mdspan_t make_mdspan(ValueType *data, std::size_t ext0, std::size_t ext1) {
9292
template<class A_t, class ValueType = typename A_t::value_type>
9393
void set(A_t A, ValueType value)
9494
{
95-
using size_type = typename Kokkos::extents<size_t, >::size_type;
95+
using size_type = typename Kokkos::extents<size_t>::size_type;
9696
for (size_type i = 0; i < A.extent(0); ++i) {
9797
for (size_type j = 0; j < A.extent(1); ++j) {
9898
A(i, j) = value;
@@ -112,7 +112,7 @@ auto abs_max(mdspan<ElementType, extents<size_t, Extent>, LayoutPolicy, Accessor
112112
if (size == 0) {
113113
throw std::runtime_error("abs_max() requires non-empty input");
114114
}
115-
const auto i = std::experimental::linalg::vector_idx_abs_max(v);
115+
const auto i = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg::vector_idx_abs_max(v);
116116
if (i >= size) { // shouldn't happen: empty case is handled above
117117
throw std::runtime_error("Fatal: vector_idx_abs_max() failed");
118118
}

tests/kokkos-based/mdspan_to_view.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ void expect_shallow_copy(MDSpanType mdsp, KViewType kv)
1111
template<class MDSpanValueType, class KViewValueType = MDSpanValueType>
1212
void mdspan_to_view_test_impl()
1313
{
14-
using std::experimental::mdspan;
15-
using std::experimental::extents;
16-
using std::experimental::dynamic_extent;
14+
using Kokkos::mdspan;
15+
using Kokkos::extents;
16+
using Kokkos::dynamic_extent;
1717

1818
// rank1, non-const
1919
{
2020
std::vector<MDSpanValueType> a(5);
21-
using mdspan_t = mdspan<MDSpanValueType, extents<dynamic_extent>>;
21+
using mdspan_t = mdspan<MDSpanValueType, extents<size_t, dynamic_extent>>;
2222
mdspan_t mdsp(a.data(), a.size());
2323

2424
auto kv = KokkosKernelsSTD::Impl::mdspan_to_view(mdsp);
@@ -32,7 +32,7 @@ void mdspan_to_view_test_impl()
3232
// rank1, const
3333
{
3434
std::vector<MDSpanValueType> a(5);
35-
using mdspan_t = mdspan<const MDSpanValueType, extents<dynamic_extent>>;
35+
using mdspan_t = mdspan<const MDSpanValueType, extents<size_t, dynamic_extent>>;
3636
mdspan_t mdsp(a.data(), a.size());
3737

3838
auto kv = KokkosKernelsSTD::Impl::mdspan_to_view(mdsp);
@@ -46,7 +46,7 @@ void mdspan_to_view_test_impl()
4646
// rank2, non-const
4747
{
4848
std::vector<MDSpanValueType> a(12);
49-
using mdspan_t = mdspan<MDSpanValueType, extents<dynamic_extent, dynamic_extent>>;
49+
using mdspan_t = mdspan<MDSpanValueType, extents<size_t, dynamic_extent, dynamic_extent>>;
5050
mdspan_t mdsp(a.data(), 3, 4);
5151

5252
auto kv = KokkosKernelsSTD::Impl::mdspan_to_view(mdsp);
@@ -61,7 +61,7 @@ void mdspan_to_view_test_impl()
6161
// rank2, const
6262
{
6363
std::vector<MDSpanValueType> a(12);
64-
using mdspan_t = mdspan<const MDSpanValueType, extents<dynamic_extent, dynamic_extent>>;
64+
using mdspan_t = mdspan<const MDSpanValueType, extents<size_t, dynamic_extent, dynamic_extent>>;
6565
mdspan_t mdsp(a.data(), 3, 4);
6666

6767
auto kv = KokkosKernelsSTD::Impl::mdspan_to_view(mdsp);
@@ -94,21 +94,21 @@ TEST(mdspan_to_view, for_complex_double){
9494
template<class MDSpanValueType, class KViewValueType = MDSpanValueType>
9595
void transposed_mdspan_to_view_test_impl()
9696
{
97-
using std::experimental::mdspan;
98-
using std::experimental::extents;
99-
using std::experimental::dynamic_extent;
97+
using Kokkos::mdspan;
98+
using Kokkos::extents;
99+
using Kokkos::dynamic_extent;
100100

101-
using lr_t = std::experimental::layout_right;
102-
using ll_t = std::experimental::layout_left;
101+
using lr_t = Kokkos::layout_right;
102+
using ll_t = Kokkos::layout_left;
103103

104104
std::vector<MDSpanValueType> a(12);
105105
std::iota(a.begin(), a.end(), 0);
106106

107107
{
108108
// mdspan is layout right
109-
using mdspan_t = mdspan<MDSpanValueType, extents<dynamic_extent, dynamic_extent>, lr_t>;
109+
using mdspan_t = mdspan<MDSpanValueType, extents<size_t, dynamic_extent, dynamic_extent>, lr_t>;
110110
mdspan_t mdsp(a.data(), 3, 4);
111-
auto mdsp_T = std::experimental::linalg::transposed(mdsp);
111+
auto mdsp_T = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg::transposed(mdsp);
112112

113113
auto kv = KokkosKernelsSTD::Impl::mdspan_to_view(mdsp_T);
114114
using kv_type = decltype(kv);
@@ -117,9 +117,9 @@ void transposed_mdspan_to_view_test_impl()
117117

118118
// the conversion from transposed() to view basically discards the transposition
119119
// so behaves as if we were tranposing the nested mspan directly
120-
static_assert(std::is_same_v<typename kv_type::array_layout, Kokkos::LayoutRight>);
121-
EXPECT_TRUE(kv.extent(0) == 3);
122-
EXPECT_TRUE(kv.extent(1) == 4);
120+
static_assert(std::is_same_v<typename kv_type::array_layout, Kokkos::LayoutLeft>);
121+
EXPECT_TRUE(kv.extent(0) == 4);
122+
EXPECT_TRUE(kv.extent(1) == 3);
123123
expect_shallow_copy(mdsp, kv);
124124

125125
int count=0;
@@ -134,9 +134,9 @@ void transposed_mdspan_to_view_test_impl()
134134

135135
{
136136
// mdspan is layout left
137-
using mdspan_t = mdspan<MDSpanValueType, extents<dynamic_extent, dynamic_extent>, ll_t>;
137+
using mdspan_t = mdspan<MDSpanValueType, extents<size_t, dynamic_extent, dynamic_extent>, ll_t>;
138138
mdspan_t mdsp(a.data(), 3, 4);
139-
auto mdsp_T = std::experimental::linalg::transposed(mdsp);
139+
auto mdsp_T = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg::transposed(mdsp);
140140

141141
auto kv = KokkosKernelsSTD::Impl::mdspan_to_view(mdsp_T);
142142
using kv_type = decltype(kv);
@@ -145,9 +145,9 @@ void transposed_mdspan_to_view_test_impl()
145145

146146
// the conversion from transposed() to view basically discards the transposition
147147
// so behaves as if we were tranposing the nested mspan directly
148-
static_assert(std::is_same_v<typename kv_type::array_layout, Kokkos::LayoutLeft>);
149-
EXPECT_TRUE(kv.extent(0) == 3);
150-
EXPECT_TRUE(kv.extent(1) == 4);
148+
static_assert(std::is_same_v<typename kv_type::array_layout, Kokkos::LayoutRight>);
149+
EXPECT_TRUE(kv.extent(0) == 4);
150+
EXPECT_TRUE(kv.extent(1) == 3);
151151
expect_shallow_copy(mdsp, kv);
152152

153153
int count=0;

tpl-implementations/include/experimental/__p1673_bits/kokkos-kernels/mdspan_to_view_mapper_kk.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ template<class Layout>
1212
struct LayoutMapper;
1313

1414
template<>
15-
struct LayoutMapper<std::experimental::layout_left> {
15+
struct LayoutMapper<Kokkos::layout_left> {
1616
using type = Kokkos::LayoutLeft;
1717
};
1818

1919
template<>
20-
struct LayoutMapper<std::experimental::layout_right> {
20+
struct LayoutMapper<Kokkos::layout_right> {
2121
using type = Kokkos::LayoutRight;
2222
};
2323

@@ -54,12 +54,12 @@ auto to_kokkos_pointer(const std::complex<RealType>* p) {
5454
//
5555
template<
5656
class ElementType,
57-
std::experimental::extents<>::size_type ext,
57+
Kokkos::extents<size_t>::size_type ext,
5858
class Layout,
5959
class Accessor>
60-
auto mdspan_to_view(std::experimental::mdspan<
60+
auto mdspan_to_view(Kokkos::mdspan<
6161
ElementType,
62-
std::experimental::extents<ext>,
62+
Kokkos::extents<size_t, ext>,
6363
Layout,
6464
Accessor
6565
> a)
@@ -70,13 +70,13 @@ auto mdspan_to_view(std::experimental::mdspan<
7070

7171
template<
7272
class ElementType,
73-
std::experimental::extents<>::size_type ext0,
74-
std::experimental::extents<>::size_type ext1,
73+
Kokkos::extents<size_t>::size_type ext0,
74+
Kokkos::extents<size_t>::size_type ext1,
7575
class Layout,
7676
class Accessor>
77-
auto mdspan_to_view(std::experimental::mdspan<
77+
auto mdspan_to_view(Kokkos::mdspan<
7878
ElementType,
79-
std::experimental::extents<ext0, ext1>,
79+
Kokkos::extents<size_t, ext0, ext1>,
8080
Layout,
8181
Accessor
8282
> a)
@@ -98,7 +98,7 @@ auto mdspan_to_view(std::experimental::mdspan<
9898
Suppose that one has: A, B, C : mdspans
9999
and wants to do: C = A^T B
100100
One would do this by calling:
101-
AT = std::experimental::linalg::transposed(A)
101+
AT = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg::transposed(A)
102102
matrix_product(kokkos_exec<>, AT, B, C)
103103
104104
Our Kokkos impl would then see:
@@ -124,14 +124,14 @@ auto mdspan_to_view(std::experimental::mdspan<
124124
*/
125125
template<
126126
class ElementType,
127-
std::experimental::extents<>::size_type ext0,
128-
std::experimental::extents<>::size_type ext1,
127+
Kokkos::extents<size_t>::size_type ext0,
128+
Kokkos::extents<size_t>::size_type ext1,
129129
class NestedLayout,
130130
class Accessor>
131-
auto mdspan_to_view(std::experimental::mdspan<
131+
auto mdspan_to_view(Kokkos::mdspan<
132132
ElementType,
133-
std::experimental::extents<ext0, ext1>,
134-
std::experimental::linalg::layout_transpose<NestedLayout>,
133+
Kokkos::extents<size_t, ext0, ext1>,
134+
MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE::linalg::layout_transpose<NestedLayout>,
135135
Accessor
136136
> a)
137137
{

tpl-implementations/include/experimental/linalg_kokkoskernels

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include<mdspan/mdspan.hpp>
33
#include<KokkosBlas.hpp>
4-
// #include "__p1673_bits/kokkos-kernels/mdspan_to_view_mapper_kk.hpp"
4+
#include "__p1673_bits/kokkos-kernels/mdspan_to_view_mapper_kk.hpp"
55
#include "__p1673_bits/kokkos-kernels/kokkos_conjugate.hpp"
66

77
// blas1 (according to P1673)

0 commit comments

Comments
 (0)