I know, there is a CUDA-function to do it, but I’d prefer to stick to OpenACC API, if it all possible. Can the number of Streaming Multiprocessors present on a GPU be queried through OpenACC means? How about the number of workers for each SM – and other such details?
Since OpenACC is agnostic as to the target device, it avoids vendor specific properties such as the number of SM. For that you’d need to call the CUDA API via the Fortran interfaces.
ierr = cudaDeviceGetAttribute(value, cudaDevAttrMultiProcessorCount, &
int(device, c_int))
For the number of workers, that’s displayed as part of the -Minfo=accel. Though that’s the number of workers per gang (i.e. CUDA Block). So the number of workers per SM would depend on how many blocks are getting scheduled per SM, which in turn depends on the occupancy.
What’s the basis for this question?
The number of workers per SM isn’t as important as the number of total threads (num workers x vector length x num gangs) per SM, which is a max of 2048.
It is not FORTRAN, but C++. And we have two loops – the outer one going over SMs, and the inner – over workers in each.
Knowing the SM-count would be useful and, as I said, I’m aware of the cudaDeviceGetAttribute. I was just hoping, some ACC function can return the same info – even if only as a vendor-specific extension.
nvc++ has some limited support for CUDA so you can call cudaDeviceGetAttribute directly, just add the “-cuda” flag.