cuda-api-wrappers
cuda-api-wrappers copied to clipboard
Should cuda::device::count() return an std::size or a device::id_t?
Should cuda::device::count() return an std::size or a device::id_t?
std::size_t is semantically more accurate, i.e. it's the size of a set of devices. It's non-negative. And in C++ we use this types for this purpose a lot.
cuda::device::id_t is what the underlying API returns, so it has the appropriate range; it's smaller-sized; and it won't give you warnings when you compare device::id_t's to it (although it will give you warnings if you cmpare unsigned indices to it...)
Which should it be?