Add OpenMP nstream kernel

This commit is contained in:
Tom Deakin 2021-02-02 11:44:37 +00:00
parent 84406024cf
commit 4c905e6a86
2 changed files with 26 additions and 0 deletions

View File

@ -191,6 +191,31 @@ void OMPStream<T>::triad()
#endif
}
template <class T>
void OMPStream<T>::nstream()
{
const T scalar = startScalar;
#ifdef OMP_TARGET_GPU
int array_size = this->array_size;
T *a = this->a;
T *b = this->b;
T *c = this->c;
#pragma omp target teams distribute parallel for simd
#else
#pragma omp parallel for
#endif
for (int i = 0; i < array_size; i++)
{
a[i] += b[i] + scalar * c[i];
}
#if defined(OMP_TARGET_GPU) && defined(_CRAYC)
// If using the Cray compiler, the kernels do not block, so this update forces
// a small copy to ensure blocking so that timing is correct
#pragma omp target update from(a[0:0])
#endif
}
template <class T>
T OMPStream<T>::dot()
{

View File

@ -36,6 +36,7 @@ class OMPStream : public Stream<T>
virtual void add() override;
virtual void mul() override;
virtual void triad() override;
virtual void nstream() override;
virtual T dot() override;
virtual void init_arrays(T initA, T initB, T initC) override;