Lesson 13

Date: 4/19/2017
High Performance Computing (part I: OpenMP)
Linux System Administration

CPU core number and performance

  • Find out the number of CPU cores available on your desktop:
    grep processor /proc/cpuinfo
    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.
  • Download a source file with a C code for solving the steady state heat equation on a rectangular region:
    wget http://linuxcourse.rutgers.edu/lessons/HPC_1/download/heated_plate_openmp.c 
    Compile the source code with OpenMP:
    gcc -fopenmp -o heated_plate.x heated_plate_openmp.c -lm
  • Run the compiled executable, heated_plate.x, with one thread:
    export OMP_NUM_THREADS=1
    ./heated_plate.x > heated_plate_local_gcc_output.txt
    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:
    export OMP_NUM_THREADS=2
    ./heated_plate.x >> heated_plate_local_gcc_output.txt
    Run it with 4 threads:
    export OMP_NUM_THREADS=4
    ./heated_plate.x >> heated_plate_local_gcc_output.txt
    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:
    grep Wallclock heated_plate_local_gcc_output.txt
    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.

  • Take me to the Course Website