Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
20 Views

suppress multithreading

Jump to solution

Dear all, 

I am running an extensive parameter sweep by calling a fortran executable from within a parfor loop in Matlab (2015a) on our uni-cluster which runs a Linux 64 platform. I am getting angry e-mails because my runs seem to be spawning more than 700 threas and/or processes each (I am requesting 24 cores), which overloads the machines. 

I build the fortran program FPROG using the mkl:sequential flag as follows: 

find -name '*.f90' ! -name 'modules.f90' | xargs ifort -mkl:sequential modules.f90 -I ../modules/ -module ../modules/
for prog in $@
do
    $F90 $F90FLAGS -mkl:sequential -recursive -no-ftz -o FPROG src/*.f90 share/*.f90 -I share $LINK_FNL -module modules -r8 > /dev/null
done

My superficial understanding is that if I am using MKL, I may control the number of threads by setting the environment variable MKL_NUM_THREADS, which I added to my source code by: 

call SETENVQQ("MKL_NUM_THREADS=1")

 

(Matlab is also using mkl and overwrites MKL_NUM_THREADS, so I set it also in the matlab script by: pctRunOnAll setenv('MKL_NUM_THREADS','1'). Anyway, I am quite sure that the issue is related to the fortran program because I am submitting the matlab job using the singleCompThread option on the cluster...) 

Nonetheless, the issue remains and 700+ threads are spawned. How can I control the number of threads? 

PS: I also tried compiling using  command line helper from intel: 

find -name '*.f90' ! -name 'modules.f90' | xargs ifort -I ${MKLROOT}/include modules.f90 -I ../modules/ -module ../modules/ 
for prog in $@
do
    $F90 $F90FLAGS -I ${MKLROOT}/include -recursive -no-ftz -o FPROG src/*.f* shared/*.f90 -I share $LINK_FNL -L ${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm -module modules -r8 > /dev/null
done

It did not help either.

0 Kudos

Accepted Solutions
Highlighted
Black Belt
20 Views

If mkl=sequential is recognized then mkl_num_threads will not be needed.  Check your spelling, I think you have spelled it the Windows way. I do wonder whether so many discrepancies between Windows and Linux are needed.  Check also that you didn't set -parallel in the flags groups you didn't report.

View solution in original post

0 Kudos
2 Replies
Highlighted
Black Belt
21 Views

If mkl=sequential is recognized then mkl_num_threads will not be needed.  Check your spelling, I think you have spelled it the Windows way. I do wonder whether so many discrepancies between Windows and Linux are needed.  Check also that you didn't set -parallel in the flags groups you didn't report.

View solution in original post

0 Kudos
Highlighted
Beginner
20 Views

Thank you for your reply. You are right. It should be -mkl=sequential. I did not set -parallel. Compiling with -mkl=sequential worked. The issue however, was unexpectedly matlab related.

0 Kudos