Add dot kernel to Kokkos
This commit is contained in:
parent
d3b497a9ca
commit
823e12708f
@ -121,6 +121,23 @@ void KOKKOSStream<T>::triad()
|
||||
Kokkos::fence();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T KOKKOSStream<T>::dot()
|
||||
{
|
||||
View<double *, DEVICE> a(*d_a);
|
||||
View<double *, DEVICE> b(*d_b);
|
||||
|
||||
T sum = 0.0;
|
||||
|
||||
parallel_reduce(array_size, KOKKOS_LAMBDA (const int index, double &tmp)
|
||||
{
|
||||
tmp += a[index] * b[index];
|
||||
}, sum);
|
||||
|
||||
return sum;
|
||||
|
||||
}
|
||||
|
||||
void listDevices(void)
|
||||
{
|
||||
std::cout << "This is not the device you are looking for.";
|
||||
|
||||
@ -47,6 +47,7 @@ class KOKKOSStream : public Stream<T>
|
||||
virtual void add() override;
|
||||
virtual void mul() override;
|
||||
virtual void triad() override;
|
||||
virtual T dot() override;
|
||||
|
||||
virtual void write_arrays(
|
||||
const std::vector<T>& a, const std::vector<T>& b, const std::vector<T>& c) override;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user