I have a sample C program for addition. When I compile and run it with GCC it is using only one CPU core.
Is there any way to compile a C program so that it can use
Try adding the following pragma right above your for loops:
#pragma omp parallel for
for(i=0; i<8000000000; i++) {
ptr[i] = i/10000;
}
And add the -fopenmp option to your build options when you call gcc. By default, OpenMP will create as many threads as cores in your machine and will share workload evenly between them.
You can check this article for more information on OpenMP.