diff --git a/STDStream.cpp b/STDStream.cpp index 15ee68f..762c5d9 100644 --- a/STDStream.cpp +++ b/STDStream.cpp @@ -15,11 +15,19 @@ auto exe_policy = std::execution::par_unseq; template -STDStream::STDStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int device) - noexcept : array_size{ARRAY_SIZE}, a{a}, b{b}, c{c} +STDStream::STDStream(const unsigned int ARRAY_SIZE, int device) + noexcept : array_size{ARRAY_SIZE}, a{new T[array_size]}, b{new T[array_size]}, c{new T[array_size]} { } +template +STDStream::~STDStream() +{ + delete[] a; + delete[] b; + delete[] c; +} + template void STDStream::init_arrays(T initA, T initB, T initC) { @@ -87,3 +95,4 @@ std::string getDeviceDriver(const int) } template class STDStream; template class STDStream; + diff --git a/STDStream.h b/STDStream.h index 2088501..f24165f 100644 --- a/STDStream.h +++ b/STDStream.h @@ -24,8 +24,8 @@ class STDStream : public Stream T *c; public: - STDStream(const unsigned int, T*, T*, T*, int); - ~STDStream() = default; + STDStream(const unsigned int, int); + ~STDStream(); virtual void copy() override; virtual void add() override; @@ -36,3 +36,4 @@ class STDStream : public Stream virtual void init_arrays(T initA, T initB, T initC) override; virtual void read_arrays(std::vector& a, std::vector& b, std::vector& c) override; }; + diff --git a/main.cpp b/main.cpp index 0139714..ff677ff 100644 --- a/main.cpp +++ b/main.cpp @@ -158,7 +158,7 @@ void run() #elif defined(STD) // Use the STD implementation - stream = new STDStream(ARRAY_SIZE, a.data(), b.data(), c.data(), deviceIndex); + stream = new STDStream(ARRAY_SIZE, deviceIndex); #elif defined(ACC) // Use the OpenACC implementation @@ -366,7 +366,7 @@ void run_triad() #elif defined(STD) // Use the STD implementation - stream = new STDStream(ARRAY_SIZE, a.data(), b.data(), c.data(), deviceIndex); + stream = new STDStream(ARRAY_SIZE, deviceIndex); #elif defined(SYCL) // Use the SYCL implementation