diff --git a/ACCStream.cpp b/ACCStream.cpp index ca5ef7b..85bf600 100644 --- a/ACCStream.cpp +++ b/ACCStream.cpp @@ -2,8 +2,11 @@ #include "ACCStream.h" template -ACCStream::ACCStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c) +ACCStream::ACCStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c, int device) { + + acc_set_device_num(device, acc_device_nvidia); + array_size = ARRAY_SIZE; // Set up data region on device @@ -106,8 +109,28 @@ void ACCStream::triad() void listDevices(void) { // Get number of devices + int count = acc_get_num_devices(acc_device_nvidia); + + // Print device list + if (count == 0) + { + std::cerr << "No devices found." << std::endl; + } + else + { + std::cout << "There are " << count << " devices." << std::endl; + } } +std::string getDeviceName(const int) +{ + return std::string("Device name unavailable"); +} + +std::string getDeviceDriver(const int) +{ + return std::string("Device driver unavailable"); +} template class ACCStream; template class ACCStream; diff --git a/ACCStream.h b/ACCStream.h index 4c69986..d6e5728 100644 --- a/ACCStream.h +++ b/ACCStream.h @@ -22,7 +22,7 @@ class ACCStream : public Stream T *c; public: - ACCStream(const unsigned int, T*, T*, T*); + ACCStream(const unsigned int, T*, T*, T*, int); ~ACCStream(); virtual void copy() override; diff --git a/main.cpp b/main.cpp index f12a7e1..59411b8 100644 --- a/main.cpp +++ b/main.cpp @@ -86,7 +86,7 @@ void run() #elif defined(ACC) // Use the OpenACC implementation - stream = new ACCStream(ARRAY_SIZE, a.data(), b.data(), c.data()); + stream = new ACCStream(ARRAY_SIZE, a.data(), b.data(), c.data(), deviceIndex); #elif defined(SYCL) // Use the SYCL implementation