Is it possible to find number of processors available in system using CUDA runtime APIs? I know using cudaDeviceProp
structure I can gather information about particular GPU but how to gather such information about CPU core?
Asked
Active
Viewed 356 times
1

username_4567
- 4,737
- 12
- 56
- 92
1 Answers
2
CUDA doesn't run on CPU cores (are you thinking of OpenCL) so it doesn't provide any info about the CPU.
Detecting what type of cpu and how many cores would be OS specific - what platform are you on? See Get number of CPUs in Linux using C

Community
- 1
- 1

Martin Beckett
- 94,801
- 28
- 188
- 263
-
I'm on Linux. I thought in the same way..so on CPU side can pthreads/openMP help me to query number of processors? – username_4567 Aug 07 '12 at 13:59
-
See http://stackoverflow.com/questions/4586405/get-number-of-cpus-in-linux-using-c – Martin Beckett Aug 07 '12 at 14:03
-
Using OpenCL you can create a CPU Device content and query the processor count using clGetDeviceInfo() API call. This will give you the number of processors in an O/S independent way. But YMMV may vary depending on what the OpenCL implementation considers a processor. On my Core I3 laptop I get 4 processors due to hyper-threading when its only has two physical cores. – Tim Child Aug 07 '12 at 14:08
-
@TimChild - but they aren't using openCL and installing it just to get the CPU count seems a little bit overkill compared to just reading /proc/cpuinfo – Martin Beckett Aug 07 '12 at 14:18
-
I'm using CUDA...so somewhere in my program I want to launch number of pthreads=number of physical core and I want this code to be platform independent. – username_4567 Aug 08 '12 at 05:45
-
@username_4567 - there isn't a platform independant way because it's platform dependent, code in the link for win32/linux. OpenMP/TBB will automatically determine the best number of threads – Martin Beckett Aug 08 '12 at 05:49