I have a 4-core cpu and I am trying to optimize my code to reduce my calculation time on products of 2000x2000 Eigen matrix. Since I am using OpenMP I was expecting to reach 400% of CPU usage. But, for some reason I am stuck at 200%.
I am using Ubuntu 14.04. My code is written in C++
. It uses the Eigen
matrix library with OpenMP
and the MKL
. I compile my code with ICC
with the following arguments:
(this is an extract of my .pro file since I use Qt)
INCLUDEPATH += /opt/intel/mkl/include
LIBS += -L/opt/intel/mkl/lib/intel64 \
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core \
-L/opt/intel/lib/intel64 \
-liomp5 -lpthread -lm
DEFINES += NDEBUG
DEFINES += EIGEN_USE_MKL_ALL
QMAKE_CXXFLAGS_RELEASE += -fast -march=corei7 -qopenmp -static
How can I reach 400% of CPU usage? Thanks.
PS: EDIT What part of my code could be useful?
int nthreads = omp_get_num_threads();
cout << endl << nthreads << " thread(s) available for computation" << endl;
cout << Eigen::nbThreads() << " thread(s) used by Eigen" << endl;
this, for instance displays 1 thread available and 4 used by Eigen. Is this normal?