I observed something similar to what is being reported based on the posted code, and using nvprof on a linux system.
I think filing an RFE is a good suggestion.<<
Based on my profiler data, many CUDA API calls are less than a microsecond or at most a few microseconds. cudaGetDeviceProperties seems to take ~250us And it is being called quite a few times. It’s not clear to me why this couldn’t be called once per device at library initialization time, and dispense with the per-call usage altogether, but I’m not a library author.
I’ve attached an excerpt my nvprof data, for two loops through the code (instead of 1000). I would lump everything up to the first cudaLaunch call into “library initialization” and ignore all that. From that point forward, I think the timings reported are instructive. Again, this represents two loops through the test:
715.46ms 263.39us - - - - - - - - - - cudaGetDeviceProperties
715.73ms 55.951ms - - - - - - - - - - cudaMalloc
771.68ms 111.98us - - - - - - - - - - cudaMalloc
771.80ms 7.5160ms - - - - - - - - - - cudaMemcpy
772.32ms 7.1545ms - - - - - 16.777MB 2.3450GB/s Quadro 5000 (0) 1 7 [CUDA memcpy HtoD]
779.34ms 592ns - - - - - - - - - - cudaGetDeviceCount
779.34ms 2.7590us - - - - - - - - - - cudaGetDevice
779.34ms 304.57us - - - - - - - - - - cudaGetDeviceProperties
779.65ms 236ns - - - - - - - - - - cudaGetDeviceCount
779.65ms 642ns - - - - - - - - - - cudaGetDevice
779.65ms 268.27us - - - - - - - - - - cudaGetDeviceProperties
779.98ms 514ns - - - - - - - - - - cuDriverGetVersion
779.98ms 734ns - - - - - - - - - - cuInit
780.01ms 429ns - - - - - - - - - - cuDeviceGetCount
780.01ms 312ns - - - - - - - - - - cuDeviceGet
780.01ms 31.458us - - - - - - - - - - cuDeviceGetName
780.04ms 36.034us - - - - - - - - - - cuDeviceTotalMem
780.08ms 462ns - - - - - - - - - - cuDeviceGetAttribute
780.08ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.08ms 257ns - - - - - - - - - - cuDeviceGetAttribute
780.08ms 241ns - - - - - - - - - - cuDeviceGetAttribute
780.08ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.08ms 24.743us - - - - - - - - - - cuDeviceGetAttribute
780.11ms 264ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 269ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 415ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 243ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 266ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.11ms 345ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 246ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 250ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 287ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 313ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 243ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 266ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 287ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.12ms 247ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 256ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 227ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 247ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.13ms 119.11us - - - - - - - - - - cuDeviceGetAttribute
780.25ms 266ns - - - - - - - - - - cuDeviceGetAttribute
780.25ms 234ns - - - - - - - - - - cuDeviceGetAttribute
780.25ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.25ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.25ms 243ns - - - - - - - - - - cuDeviceGetAttribute
780.25ms 285ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 348ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 269ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 354ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 240ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 235ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.26ms 118.48us - - - - - - - - - - cuDeviceGetAttribute
780.38ms 265ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 247ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 236ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.38ms 316ns - - - - - - - - - - cuDeviceGet
780.39ms 28.252us - - - - - - - - - - cuDeviceGetName
780.41ms 37.196us - - - - - - - - - - cuDeviceTotalMem
780.45ms 326ns - - - - - - - - - - cuDeviceGetAttribute
780.45ms 248ns - - - - - - - - - - cuDeviceGetAttribute
780.45ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.45ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.45ms 264ns - - - - - - - - - - cuDeviceGetAttribute
780.45ms 26.340us - - - - - - - - - - cuDeviceGetAttribute
780.48ms 295ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 266ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 269ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 254ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.48ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 235ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 227ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 226ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 269ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 226ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 238ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 264ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 226ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 227ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 226ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.49ms 226ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 234ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 244ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 228ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.50ms 131.36us - - - - - - - - - - cuDeviceGetAttribute
780.64ms 279ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 266ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 241ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 235ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 232ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 234ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 269ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 253ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 233ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 245ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 237ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 240ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.64ms 127.11us - - - - - - - - - - cuDeviceGetAttribute
780.77ms 261ns - - - - - - - - - - cuDeviceGetAttribute
780.77ms 279ns - - - - - - - - - - cuDeviceGetAttribute
780.77ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.77ms 229ns - - - - - - - - - - cuDeviceGetAttribute
780.77ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.77ms 230ns - - - - - - - - - - cuDeviceGetAttribute
780.78ms 231ns - - - - - - - - - - cuDeviceGetAttribute
780.78ms 5.4230us - - - - - - - - - - cudaConfigureCall
780.79ms 2.9660us - - - - - - - - - - cudaSetupArgument
780.79ms 1.0260us - - - - - - - - - - cudaSetupArgument
780.79ms 56.559ms - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, BasicOperation<float, tReductionOp=0>>>(int, float) [547])
837.35ms 182.86us (66 1 1) (256 1 1) 11 0B 1.0240KB - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, BasicOperation<float, tReductionOp=0>>>(int, float) [547]
837.35ms 1.0080us - - - - - - - - - - cudaConfigureCall
837.35ms 733ns - - - - - - - - - - cudaSetupArgument
837.36ms 268ns - - - - - - - - - - cudaSetupArgument
837.36ms 8.9480us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, MeanOperation<float, tReductionOp=0>>>(int, float) [551])
837.37ms 345ns - - - - - - - - - - cudaGetLastError
837.37ms 495ns - - - - - - - - - - cudaGetDeviceCount
837.37ms 1.5950us - - - - - - - - - - cudaGetDevice
837.37ms 297.61us - - - - - - - - - - cudaGetDeviceProperties
837.54ms 4.8500us (1 1 1) (128 1 1) 11 0B 512B - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, MeanOperation<float, tReductionOp=0>>>(int, float) [551]
837.67ms 236ns - - - - - - - - - - cudaGetDeviceCount
837.67ms 681ns - - - - - - - - - - cudaGetDevice
837.67ms 268.77us - - - - - - - - - - cudaGetDeviceProperties
837.94ms 482ns - - - - - - - - - - cudaConfigureCall
837.94ms 357ns - - - - - - - - - - cudaSetupArgument
837.94ms 281ns - - - - - - - - - - cudaSetupArgument
837.95ms 12.138us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation1<float, float, tReductionOp=0>>>(int, float) [562])
837.96ms 375ns - - - - - - - - - - cudaConfigureCall
837.96ms 188.45us (66 1 1) (256 1 1) 12 0B 1.0240KB - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation1<float, float, tReductionOp=0>>>(int, float) [562]
837.96ms 317ns - - - - - - - - - - cudaSetupArgument
837.96ms 243ns - - - - - - - - - - cudaSetupArgument
837.96ms 8.2640us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation2<float, tReductionOp=0>>>(int, float) [566])
837.97ms 285ns - - - - - - - - - - cudaGetLastError
837.97ms 257ns - - - - - - - - - - cudaGetDeviceCount
837.97ms 753ns - - - - - - - - - - cudaGetDevice
837.97ms 267.06us - - - - - - - - - - cudaGetDeviceProperties
838.15ms 5.9460us (1 1 1) (128 1 1) 11 0B 512B - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation2<float, tReductionOp=0>>>(int, float) [566]
838.24ms 234ns - - - - - - - - - - cudaGetDeviceCount
838.24ms 631ns - - - - - - - - - - cudaGetDevice
838.24ms 263.24us - - - - - - - - - - cudaGetDeviceProperties
838.50ms 406ns - - - - - - - - - - cudaConfigureCall
838.51ms 370ns - - - - - - - - - - cudaSetupArgument
838.51ms 294ns - - - - - - - - - - cudaSetupArgument
838.51ms 9.3740us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, BasicOperation<float, tReductionOp=0>>>(int, float) [577])
838.52ms 344ns - - - - - - - - - - cudaConfigureCall
838.52ms 181.46us (66 1 1) (256 1 1) 11 0B 1.0240KB - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, BasicOperation<float, tReductionOp=0>>>(int, float) [577]
838.52ms 319ns - - - - - - - - - - cudaSetupArgument
838.52ms 244ns - - - - - - - - - - cudaSetupArgument
838.52ms 6.5750us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, MeanOperation<float, tReductionOp=0>>>(int, float) [581])
838.53ms 282ns - - - - - - - - - - cudaGetLastError
838.53ms 253ns - - - - - - - - - - cudaGetDeviceCount
838.53ms 740ns - - - - - - - - - - cudaGetDevice
838.53ms 266.13us - - - - - - - - - - cudaGetDeviceProperties
838.70ms 4.2840us (1 1 1) (128 1 1) 11 0B 512B - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, MeanOperation<float, tReductionOp=0>>>(int, float) [581]
838.79ms 240ns - - - - - - - - - - cudaGetDeviceCount
838.79ms 616ns - - - - - - - - - - cudaGetDevice
838.80ms 267.94us - - - - - - - - - - cudaGetDeviceProperties
839.06ms 454ns - - - - - - - - - - cudaConfigureCall
839.06ms 394ns - - - - - - - - - - cudaSetupArgument
839.07ms 280ns - - - - - - - - - - cudaSetupArgument
839.07ms 9.8910us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation1<float, float, tReductionOp=0>>>(int, float) [592])
839.08ms 351ns - - - - - - - - - - cudaConfigureCall
839.08ms 186.20us (66 1 1) (256 1 1) 12 0B 1.0240KB - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation1<float, float, tReductionOp=0>>>(int, float) [592]
839.08ms 317ns - - - - - - - - - - cudaSetupArgument
839.08ms 244ns - - - - - - - - - - cudaSetupArgument
839.08ms 6.5550us - - - - - - - - - - cudaLaunch (void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation2<float, tReductionOp=0>>>(int, float) [596])
839.09ms 292ns - - - - - - - - - - cudaGetLastError
839.09ms 192.77us - - - - - - - - - - cudaMemcpy
839.27ms 5.4110us (1 1 1) (128 1 1) 11 0B 512B - - Quadro 5000 (0) 1 7 void SignalReductionKernel<float, SignalReductionFunctor<float, float, float, StdDevOperation2<float, tReductionOp=0>>>(int, float) [596]
839.27ms 1.8560us - - - - - 4B 2.1552MB/s Quadro 5000 (0) 1 7 [CUDA memcpy DtoH]
839.28ms 135.97us - - - - - - - - - - cudaFree
839.42ms 90.993us - - - - - - - - - - cudaFree
Regs: Number of registers used per CUDA thread. This number includes registers used internally by the CUDA driver and/or tools and can be more than what the compiler shows.
SSMem: Static shared memory allocated per CUDA block.
DSMem: Dynamic shared memory allocated per CUDA block.