Search code examples
intel-mkl

mkl_set_num_threads() is not working accordingly


I want to create different No of MKL threads for each process per node (same cluster). No of threads per process are provided in input file in such manner.

Host Threads

host name_1 t=4

host name_2 t=7

host_name_3 t=2

My code is some thing like that:

  #ifdef HAVE_LIBMKL_CORE
  char* subopts = strdup(conf->subopts);
  char* subopts_0 = subopts;
  char* tokens[] = {"t"};
  char* value;
  while (*subopts != '\0') {
    switch (getsubopt(&subopts, tokens, &value)) {
      case 0:
        int threads = atoi(value);
        mkl_set_num_threads(threads);
        break;
    }
  }
  free(subopts_0);
  #endif

When I build the performance model of each node. It shows the same result for all. Instead the process with more thread should be faster.Can some one help me why mkl_set_num_threads(threads) is not working properly. Or how I can check to assure that desired no of threads are created after that function?


Solution

  • I get it work.For the sake if some one also has the same problem, I am posting my answer. I just add mkl_set_dynamic(0); to disable dynamic threading and it works :)