I’ve been noticing Xorg processor usage spikes sometimes when running my CUDA programs. I only really see it when the kernel takes awhile to finish. I’m including some code that attempts to recreate the problem.
The kernel is meant to do some busy, work. The usleep is meant to reduce the busy wait from the cudaThreadSynchronize so my process CPU usage stays low.
I’m running
OS: Fedora Core7 x86_64
Linux Kernel: 2.6.21-1.3194.fc7
NVIDIA Driver: 177.67
CUDA: NVIDIA_CUDA_Toolkit_2.0_rhel5.1_x86_64
CUDA SDK: NVIDIA_CUDA_SDK_2.02.0807.1535_linux
Server Version Number: 11.0
Server Vendor String: The X.Org Foundation
Server Vendor Version: 1.3.0 (10300000)
NV-Control Version: 1.17
[codebox]#include <stdio.h>
#include <unistd.h>
global void kernel(float *x)
{
// Just do something that will take time
*x = 2.0;
float a = *x;
for(int i = 0; i < 10000; i++)
{
a *= cos(a);
}
*x = a;
}
int main(int argc, char **argv)
{
cudaSetDevice(0);
float *deviceMem;
cudaMalloc((void**)&deviceMem, sizeof(float));
for(int i = 0; i < 30;i++)
{
kernel<<<dim3(1024,1,1),dim3(512,1,1)>>>(deviceMem);
// Reduce CUDA busy wait on thread synchronize
usleep(500000);
cudaThreadSynchronize();
}
return 0;
}
[/codebox]