| |
CPU core number and performance
Exercise
Find out the number of CPU cores available on your desktop:
In the output, you should see 'processor : 0' and 'processor : 1', which means there are two CPU cores available, and you can utilize them for running two OpenMP threads concurrently.
Alternatively, you can run command lscpu
Download a source file with a C code for solving the steady state heat equation on a rectangular region:
Compile the source code with OpenMP:
Run the compiled executable, heated_plate.x, with one thread:
While the application is running, open another console terminal and run
command top. It shows the CPU and RAM utilization, as well as the most
resource consuming processes. Type "1" to see the utilization of all the CPU
cores. Type "H" to see all the process threads.
Run it with 2 threads:
Run it with 4 threads:
The output results in the three runs above have been written in file heated_plate_local_gcc_output.txt
Compare the run time (Wallclock time) in the above cases:
Notice that the shortest Wallclock time was achieved in the 2 thread run , about
41.6 sec, almost twice faster than in the serial case, one core run.
In case of the 4 threads, the run took about 2 seconds longer due to
a slight overhead caused by the thread competition for the two CPU cores.
|
|