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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Managing Performance <strong>and</strong> Memory 6export OMP_NUM_THREADS= for certain shells, such asbash.orset OMP_NUM_THREADS= for other shells, such as csh ortcsh.See Using Additional Threading Control on how to set the number of threads using <strong>Intel</strong>MKL environment variables, for example, MKL_NUM_THREADS.Changing the Number of Threads <strong>at</strong> Run TimeIt is not possible to change the number of processors during run time using theenvironment variables. However, you can call OpenMP API functions from your program tochange the number of threads during run time. The following sample code demonstr<strong>at</strong>eschanging the number of threads during run time using the omp_set_num_threads()routine. See also Techniques to Set the Number of Threads.To run this example, use the omp.h header file from the <strong>Intel</strong>® Compiler package. If youdo not have the <strong>Intel</strong> Compiler but wish to explore the functionality in the example, useFortran API for omp_set_num_threads() r<strong>at</strong>her than the C version.Example 6-1 Changing the number of processors for threading#include "omp.h"#include "mkl.h"#include #define SIZE 1000void main(int args, char *argv[]){double *a, *b, *c;a = new double [SIZE*SIZE];b = new double [SIZE*SIZE];c = new double [SIZE*SIZE];6-5

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

Saved successfully!

Ooh no, something went wrong!