Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Discussions

runing a code in 2 CPUs (multithreads) on linux

kidariyoon
Beginner
1,540 Views
I am trying to run my code on 2 CPUs (multithreads) on Linux using intel compiler ver. 9.

In my makefile,

>>FFLAGS = -O3 -openmp -threads -parallel
>>INCLUDES = -I/opt/intel/mkl/9.1/include
>>LIBS = -L/opt/intel/mkl/9.1/lib/em64t -lmkl_solver -lmkl_lapack -lmkl_em64t -lguide -lpthread

once I compile, I did

%export OMP_NUM_THREADS=2

before I submit the job.

Then I see one CPU is running in its full capacity while the other is doing nothing.

Well. Clearly I am a beignner in this area and I just follow the manual as you can see.

Any help or guide will be greatly appreciated well in advance.

Thanks A Lot.

0 Kudos
9 Replies
TimP
Honored Contributor III
1,540 Views
I believe the 9.1 compiler still had the screen echo on by default, which would tell you about any loops successfully parallelized by OpenMP or auto-parallel. If your MKL calls occur inside a parallel region in your source code, MKL should not start additional threads unless you set OMP_NESTED and possibly adjust NUM_THREADS. MKL would not do so anyway unless the problem size is sufficiently large.
Running against the openmp-profile library, which you could accomplish by setting it in LD_PRELOAD, if you have linked the usual .so, should give you useful statistics in the guide.gvs file.
0 Kudos
Ron_Green
Moderator
1,540 Views
One other thing to check is your shell. "%" as a prompt has me wondering if you are using csh or tcsh as your shell (in which case the export statement is wrong).

echo $0

should give one or two things:

echo $0
-bash
(in which case your export is fine)

or

echo $0
csh

in which case you need:

spdr65 forums/70342> setenv OMP_NUM_THREADS 2
spdr65 forums/70342> echo $OMP_NUM_THREADS
2

0 Kudos
kidariyoon
Beginner
1,540 Views
Thanks for your replay.

In my case, it was the first case.


Since you are the expert in this group, let me bother you a few more times.

do you see any errors in my makefile?

is this auto-parallelization working only for intel CPU, not AMD cpu?
(linux system i am using has 1 master (intel) + 6 compute nodes (4 intel and 2 AND))


Again, thanks in well advance.
One other thing to check is your shell. "%" as a prompt has me wondering if you are using csh or tcsh as your shell (in which case the export statement is wrong).

echo $0

should give one or two things:

echo $0
-bash
(in which case your export is fine)

or

echo $0
csh

in which case you need:

spdr65 forums/70342> setenv OMP_NUM_THREADS 2
spdr65 forums/70342> echo $OMP_NUM_THREADS
2


0 Kudos
Steven_L_Intel1
Employee
1,540 Views
Auto-parallelization doesn't care who made your CPU.
0 Kudos
Ron_Green
Moderator
1,540 Views
Auto-parallelization doesn't care who made your CPU.

But Auto-parallelization and OpenMP only works on 1 node - it does not parallelize for clusters. If you need to use more than 1 node you will need to parallelize your program with MPI or something like Cluster OpenMP (http://whatif.intel.com), and that is outside of the scope of this forum.

ron
0 Kudos
kidariyoon
Beginner
1,540 Views
as one method to test my way of compiling, i'd like to run my code in serial condition. to do that, what options should i get rid of from my makefile?

>>FFLAGS = -O3 -openmp -threads -parallel
>>INCLUDES = -I/opt/intel/mkl/9.1/include
>>LIBS = -L/opt/intel/mkl/9.1/lib/em64t -lmkl_solver -lmkl_lapack -lmkl_em64t -lguide -lpthread

should be modified to


>>FFLAGS = -O3
>>INCLUDES = -I/opt/intel/mkl/9.1/include
>>LIBS = -L/opt/intel/mkl/9.1/lib/em64t -lmkl_solver -lmkl_lapack -lmkl_em64t -lguide

is this right way to make my code in serial? I'd like to make sure.....

always, thanks in advance.




Quoting - kidariyoon
I am trying to run my code on 2 CPUs (multithreads) on Linux using intel compiler ver. 9.

In my makefile,

>>FFLAGS = -O3 -openmp -threads -parallel
>>INCLUDES = -I/opt/intel/mkl/9.1/include
>>LIBS = -L/opt/intel/mkl/9.1/lib/em64t -lmkl_solver -lmkl_lapack -lmkl_em64t -lguide -lpthread

once I compile, I did

%export OMP_NUM_THREADS=2

before I submit the job.

Then I see one CPU is running in its full capacity while the other is doing nothing.

Well. Clearly I am a beignner in this area and I just follow the manual as you can see.

Any help or guide will be greatly appreciated well in advance.

Thanks A Lot.


0 Kudos
TimP
Honored Contributor III
1,540 Views
If you don't have any OpenMP function calls, it may be enough simply to omit the -openmp and -parallel options, as you said. If you do have those, you must enclose the OpenMP specific stuff by #ifdef, and invoke pre-processing:

#ifdef _OPENMP
USE OMP
#endif
....
#ifdef _OPENMP
your omp_ function calls
#endif

This facility works the same for all OpenMP, not only Intel, so the explanation in your reference is applicable.
The way you have linked, you will have automatic threading in MKL. If you wish to avoid that, you may be able to
set MKL_SERIAL environment variable, or link from the corresponding mkl serial library.
0 Kudos
kidariyoon
Beginner
1,540 Views
>If you wish to avoid that, you may be able to
>set MKL_SERIAL environment variable, or link from the corresponding mkl serial library.

You mention thatto avoid automatic threadening, I need to compile itwith serial libraries....

I am a little confused here. On linux machine, I thought there are no serial (sequencial) libraries.

Its all controlled by link options.

Do those serial libraries have different names ?

In that case, what should my LIBS line look like?

FFLAGS = -O3
LIBS = -L/opt/intel/mkl/9.1/lib/32 -lmkl_solver -lmkl_lapack -lmkl_ia32 << is this correct?

(i thought 32, 64 and em64t are nothing related to serial or parallel. hmmmmm)


always thanks in advance.


Quoting - tim18
If you don't have any OpenMP function calls, it may be enough simply to omit the -openmp and -parallel options, as you said. If you do have those, you must enclose the OpenMP specific stuff by #ifdef, and invoke pre-processing:

#ifdef _OPENMP
USE OMP
#endif
....
#ifdef _OPENMP
your omp_ function calls
#endif

This facility works the same for all OpenMP, not only Intel, so the explanation in your reference is applicable.
The way you have linked, you will have automatic threading in MKL. If you wish to avoid that, you may be able to
set MKL_SERIAL environment variable, or link from the corresponding mkl serial library.

0 Kudos
TimP
Honored Contributor III
1,540 Views
I suppose, for your version of MKL, the sequential component would have been a separate tar file, which you may not have installed.
0 Kudos
Reply