Skip to content

Commit a015a09

Browse files
committed
scale: minor change for readability, use size_t in test
1 parent 0906f10 commit a015a09

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

examples/kokkos-based/simple_scale_kokkos.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
#include <iostream>
44

55

6-
int main(int argc, char* argv[]) {
7-
std::cout << "hello world" << std::endl;
8-
int N = 40;
6+
int main(int argc, char* argv[])
7+
{
8+
std::cout << "dot example: calling kokkos-kernels" << std::endl;
9+
10+
std::size_t N = 40;
911
Kokkos::initialize(argc,argv);
1012
{
1113
Kokkos::View<double*> a_view("A",N);
@@ -14,15 +16,15 @@ int main(int argc, char* argv[]) {
1416
// Requires CTAD working, GCC 11.1 works but some others are buggy
1517
// std::experimental::mdspan a(a_ptr,N);
1618
std::experimental::mdspan<double,std::experimental::extents<std::experimental::dynamic_extent>> a(a_ptr,N);
17-
for(int i=0; i<a.extent(0); i++) a(i) = i;
19+
for(std::size_t i=0; i<a.extent(0); i++) a(i) = i;
1820

1921
// This forwards to KokkosKernels (https://github.com/kokkos/kokkos-kernels
2022
std::experimental::linalg::scale(KokkosKernelsSTD::kokkos_exec<>(),2.0,a);
2123
// This forwards to KokkosKernels if LINALG_ENABLE_KOKKOS_DEFAULT is ON
2224
std::experimental::linalg::scale(std::execution::par,2.0,a);
2325
// This goes to the base implementation
2426
std::experimental::linalg::scale(std::execution::seq,2.0,a);
25-
for(int i=0; i<a.extent(0); i++) printf("%i %lf\n",i,a(i));
27+
for(std::size_t i=0; i<a.extent(0); i++) printf("%i %lf\n",i,a(i));
2628
}
2729
Kokkos::finalize();
2830
}

include/experimental/__p1673_bits/blas1_scale.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ void scale(
130130
std::experimental::mdspan<ElementType, std::experimental::extents<ext ...>, Layout, Accessor> x)
131131
{
132132
// Call custom overload if available else call std implementation
133-
if constexpr(is_custom_scale_avail<
134-
decltype(execpolicy_mapper(exec)),
135-
decltype(alpha),
136-
decltype(x)
137-
>::value) {
133+
134+
constexpr bool use_custom = is_custom_scale_avail<
135+
decltype(execpolicy_mapper(exec)), decltype(alpha), decltype(x)
136+
>::value;
137+
138+
if constexpr(use_custom) {
138139
scale(execpolicy_mapper(exec), alpha, x);
139140
} else {
140141
linalg_scale(std::experimental::linalg::impl::inline_exec_t(), alpha, x);

include/experimental/__p1673_bits/linalg_execpolicy_mapper.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct default_exec_t {};
1717
}
1818

1919

20-
#if defined(LINALG_ENABLE_KOKKOS) && defined(LINALG_ENABLE_KOKKOS_DEFAULT)
20+
#if defined(LINALG_ENABLE_KOKKOS) || defined(LINALG_ENABLE_KOKKOS_DEFAULT)
2121
#include <experimental/__p1673_bits/kokkos-kernels/exec_policy_wrapper_kk.hpp>
2222
#endif
2323

0 commit comments

Comments
 (0)