-
Couldn't load subscription status.
- Fork 109
BLAS 1::reciprocal
Christian Trott edited this page Jan 22, 2018
·
1 revision
Header File: KokkosBlas1_reciprocal.hpp
Usage: KokkosBlas::reciprocal(y,x);
Computes for each value of x(i) or x(i,j) the reciprocal value, and assigns it to y(i) or y(i,j) respectively.
template<class OutputVector, class InputVector>
void reciprocal (const OutputVector& Y, const InputVector& X);- OutputVector: A rank-1 or rank-2
Kokkos::Viewwith non-const data type. - InputVector: A rank-1 or rank-2
Kokkos::View
OutputVector::value_type == OutputVector::non_const_value_typeY.rank == X.rank-
Y.rank == 1orY.rank == 2 Y.extent(0) == X.extent(0)Y.extent(1) == X.extent(1)
#include<Kokkos_Core.hpp>
#include<KokkosBlas1_abs.hpp>
int main(int argc, char* argv[]) {
Kokkos::initialize();
int N = atoi(argv[1]);
Kokkos::View<double*> x("X",N);
Kokkos::View<double*> y("Y",N);
Kokkos::deep_copy(x,3.0);
KokkosBlas::reciprocal(y,x);
double sum = 0.0;
Kokkos::parallel_reduce("CheckValue", N, KOKKOS_LAMBDA (const int& i, double& lsum) {
lsum += y(i);
},sum);
printf("Sum: %lf Expected: %lf Diff: %e\n",sum,1.0*N/3.0,sum-1.0*N/3.0);
Kokkos::finalize();
}