I'm trying to run the following basic C++ program using stdpar and the nvc++ compiler.
#include <iostream>
#include <vector>
#include <algorithm>
#include <execution>
int main()
{
std::vector<int> v = { 10, 9, 8, 6, 7, 2, 5, 1 };
std::cout << "Elements before sorting" << std::endl;
std::sort(std::execution::par, v.begin(), v.end());
return 0;
}
The program compiles fine using -stdpar -gpu=cc86, but the line std::sort(std::execution::par, v.begin(), v.end()); throws the following error when running using ./a.out:
terminate called after throwing an instance of 'thrust::system::system_error'
what(): radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal
Aborted (core dumped)
Because the HPC SDK for CUDA is only available on Linux, I'm currently running all of the above in a Windows subsystem. I've checked and the versions of CUDA and HPC SDK match and point to the right folders. Also, I've set CUDA_VISIBLE_DEVICES=0 just to make sure CUDA was accessing the correct GPU but unfortunately the error persists. Because the error mentions thrust::system::system_error, could this be a bug or problem with thrust? The program runs fine if you replace std::execution::par by std::execution::seq so that would point in the direction of thrust. Is there anything else that I can try? Thanks in advance.