-
Notifications
You must be signed in to change notification settings - Fork 98
BLAS 1::fill
Christian Trott edited this page Jan 22, 2018
·
1 revision
Header File: KokkosBlas1_fill.hpp
Usage: KokkosBlas::fill(x,alpha);
Set each value of x(i)
or x(i,j)
to alpha
.
template<class Vector>
void fill (const Vector& X, Vector::const_value_type& alpha);
- X: A rank-1 or rank-2
Kokkos::View
with non-const data type. - alpha: A scalar.
Vector::value_type == Vector::non_const_value_type
-
X.rank == 1
orX.rank == 2
#include<Kokkos_Core.hpp>
#include<KokkosBlas1_fill.hpp>
int main(int argc, char* argv[]) {
Kokkos::initialize();
int N = atoi(argv[1]);
Kokkos::View<double*> x("X",N);
double alpha = 1.5;
KokkosBlas::fill(x,alpha);
double sum = 0.0;
Kokkos::parallel_reduce("CheckValue", N, KOKKOS_LAMBDA (const int& i, double& lsum) {
lsum += x(i);
},sum);
printf("Sum: %lf Expected: %lf Diff: %e\n",sum,1.0*N*1.5,sum-1.0*N*1.5);
Kokkos::finalize();
}