Implement the OpenACC device string functions, and device selector
This commit is contained in:
parent
b45f311e0d
commit
0b0de4e0c3
@ -2,8 +2,11 @@
|
||||
#include "ACCStream.h"
|
||||
|
||||
template <class T>
|
||||
ACCStream<T>::ACCStream(const unsigned int ARRAY_SIZE, T *a, T *b, T *c)
|
||||
ACCStream<T>::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<T>::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<float>;
|
||||
template class ACCStream<double>;
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ class ACCStream : public Stream<T>
|
||||
T *c;
|
||||
|
||||
public:
|
||||
ACCStream(const unsigned int, T*, T*, T*);
|
||||
ACCStream(const unsigned int, T*, T*, T*, int);
|
||||
~ACCStream();
|
||||
|
||||
virtual void copy() override;
|
||||
|
||||
2
main.cpp
2
main.cpp
@ -86,7 +86,7 @@ void run()
|
||||
|
||||
#elif defined(ACC)
|
||||
// Use the OpenACC implementation
|
||||
stream = new ACCStream<T>(ARRAY_SIZE, a.data(), b.data(), c.data());
|
||||
stream = new ACCStream<T>(ARRAY_SIZE, a.data(), b.data(), c.data(), deviceIndex);
|
||||
|
||||
#elif defined(SYCL)
|
||||
// Use the SYCL implementation
|
||||
|
||||
Loading…
Reference in New Issue
Block a user