From 5a93022fc12ef852c206142c6b850689807893c1 Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Mon, 7 Dec 2020 11:50:20 +0000 Subject: [PATCH] Update OpenACC for Issue #80 --- ACCStream.cpp | 15 ++++++++------- ACCStream.h | 2 +- main.cpp | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ACCStream.cpp b/ACCStream.cpp index 6efaad8..b7ff871 100644 --- a/ACCStream.cpp +++ b/ACCStream.cpp @@ -8,7 +8,7 @@ #include "ACCStream.h" template -ACCStream::ACCStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int device) +ACCStream::ACCStream(const unsigned int ARRAY_SIZE, int device) { acc_device_t device_type = acc_get_device_type(); acc_set_device_num(device, device_type); @@ -16,9 +16,9 @@ ACCStream::ACCStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int dev array_size = ARRAY_SIZE; // Set up data region on device - this->a = a; - this->b = b; - this->c = c; + a = new T[array_size]; + b = new T[array_size]; + c = new T[array_size]; #pragma acc enter data create(a[0:array_size], b[0:array_size], c[0:array_size]) {} } @@ -28,11 +28,12 @@ ACCStream::~ACCStream() { // End data region on device unsigned int array_size = this->array_size; - T *a = this->a; - T *b = this->b; - T *c = this->c; #pragma acc exit data delete(a[0:array_size], b[0:array_size], c[0:array_size]) {} + + delete[] a; + delete[] b; + delete[] c; } template diff --git a/ACCStream.h b/ACCStream.h index 8f13ed7..734c670 100644 --- a/ACCStream.h +++ b/ACCStream.h @@ -28,7 +28,7 @@ class ACCStream : public Stream T *c; public: - ACCStream(const unsigned int, T*, T*, T*, int); + ACCStream(const unsigned int, int); ~ACCStream(); virtual void copy() override; diff --git a/main.cpp b/main.cpp index ff677ff..c7e805b 100644 --- a/main.cpp +++ b/main.cpp @@ -162,7 +162,7 @@ void run() #elif defined(ACC) // Use the OpenACC implementation - stream = new ACCStream(ARRAY_SIZE, a.data(), b.data(), c.data(), deviceIndex); + stream = new ACCStream(ARRAY_SIZE, deviceIndex); #elif defined(SYCL) // Use the SYCL implementation @@ -362,7 +362,7 @@ void run_triad() #elif defined(ACC) // Use the OpenACC implementation - stream = new ACCStream(ARRAY_SIZE, a.data(), b.data(), c.data(), deviceIndex); + stream = new ACCStream(ARRAY_SIZE, deviceIndex); #elif defined(STD) // Use the STD implementation