13.07.2015 Views

Intel(R) - Computational and Systems Biology at MIT

Intel(R) - Computational and Systems Biology at MIT

Intel(R) - Computational and Systems Biology at MIT

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Managing Performance <strong>and</strong> Memory 6Managing Multi-core PerformanceYou can obtain best performance on systems with multi-core processors by requiring th<strong>at</strong>threads do not migr<strong>at</strong>e from core to core. To do this, bind threads to the CPU cores bysetting an affinity mask to threads. You can do it either with OpenMP facilities (which isrecommended if available, for instance, via KMP_AFFINITY environment variable using<strong>Intel</strong> OpenMP), or with a system routine, as in the example below.Suppose,• The system has two sockets with two cores each• 2 threads parallel applic<strong>at</strong>ion, which calls <strong>Intel</strong> MKL FFT, happens to run faster than in4 threads, but the performance in 2 threads is very unstableIn this case,1. Put the part of the following code fragment preceding the last comment into your codebefore FFT call to bind the threads to the cores on different sockets.2. Build your applic<strong>at</strong>ion <strong>and</strong> run it in 2 threads:env OMP_NUM_THREADS=2 ./a.outExample 6-3Setting an affinity mask by oper<strong>at</strong>ing system means using an <strong>Intel</strong>® compiler// Set affinity mask#include #include #pragma omp parallel default(shared){unsigned long mask = (1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!