MAGMA  magma-1.4.0
Matrix Algebra on GPU and Multicore Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
magma_threadsetting.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void magma_setlapack_multithreads (magma_int_t numthreads)
 
void magma_setlapack_sequential ()
 
void magma_setlapack_numthreads (magma_int_t numthreads)
 
magma_int_t magma_get_numthreads ()
 

Function Documentation

magma_int_t magma_get_numthreads ( )

Definition at line 55 of file magma_threadsetting.cpp.

56 {
57  /* determine the number of threads */
58  magma_int_t threads = 0;
59  char *env;
60  // First check MKL_NUM_THREADS if MKL is used
61 #if defined(MAGMA_WITH_MKL)
62  env = getenv("MKL_NUM_THREADS");
63  if (env != NULL)
64  threads = atoi(env);
65 #endif
66  // Second check OMP_NUM_THREADS
67  if (threads < 1){
68  env = getenv("OMP_NUM_THREADS");
69  if (env != NULL)
70  threads = atoi(env);
71  }
72  // Third use the number of CPUs
73  if (threads < 1)
74  threads = sysconf(_SC_NPROCESSORS_ONLN);
75  // Fourth use one thread
76  if (threads < 1)
77  threads = 1;
78 
79  return threads;
80 }
int magma_int_t
Definition: magmablas.h:12

Here is the caller graph for this function:

void magma_setlapack_multithreads ( magma_int_t  numthreads)

Internal routines

void magma_setlapack_numthreads ( magma_int_t  num_threads)

switch lapack thread_num initialization

Definition at line 23 of file magma_threadsetting.cpp.

24 {
25 #if defined(_OPENMP)
26  omp_set_num_threads( num_threads );
27  #if defined(MAGMA_WITH_MKL)
28  mkl_set_num_threads( num_threads );
29  #endif
30 #elif defined(MAGMA_WITH_MKL)
31  mkl_set_num_threads( num_threads );
32  #ifndef NO_WARNING
33  printf("==========================================================================================\n");
34  printf(" WARNING a parallel section (D&C) that use OPENMP could not perform in parallel because \n");
35  printf(" it need to be compiled with multi thread library and add -fopenmp(gcc)/-openmp(icc) \n");
36  printf(" to both compilation and linkage flags. \n");
37  printf(" If you wish to remove the printout of this WARNING, please compile with -DNO_WARNING \n");
38  printf("==========================================================================================\n");
39  #endif
40 #else
41  #ifndef NO_WARNING
42  printf("==========================================================================================\n");
43  printf(" WARNING you are calling a parallel section without linking with a multithread library \n");
44  printf(" please compile with multi thread library and add -fopenmp(gcc)/-openmp(icc) to both \n");
45  printf(" compilation and linkage flags. \n");
46  printf(" If you wish to remove the printout of this WARNING, please compile with -DNO_WARNING \n");
47  printf("==========================================================================================\n");
48  #endif
49 #endif
50 }
void magma_setlapack_sequential ( )