This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Eigen3 omp

Tags: None
(comma "," separated)
andreashille
Registered Member
Posts
5
Karma
0

Eigen3 omp

Fri Apr 01, 2011 2:58 pm
Hello,

I tried to use Eigen3 in the following form:
I have one big matrix m1,
and a std::vector v, which contains some big matrices m2.

now I want:

#pragma omp for
for (int i=0; i<v.size(); i++)
v[i] *= m1

here I should win 4x times in time on a 4 CPU machine, which is not the case. Did I something wrong?
So is there a possibility to switch off Eigen3's omp support?

Kind Regards,
Andreas
manuels
Registered Member
Posts
47
Karma
0

Re: Eigen3 omp

Sat Apr 02, 2011 6:45 pm
Which compiler are you using?
Did you enable the compiler's OMP switch?
How much faster is it? Just 3x faster or not faster at all?
andreashille
Registered Member
Posts
5
Karma
0

Re: Eigen3 omp

Sat Apr 02, 2011 7:40 pm
I'am using g++ -fopenmp ...
It's not significant faster at all.
matrices m1, m2;
vector<matrices> v;
m1 *= m2;
-> 2x times faster with omp compared without omp
for (int i=0, i < v.size(); i++);
v[i] *= m2;
-> 2x times faster with omp compared without omp
on a 4-CPU machine.
but the later one should be 4x times faster, or not?

I think that Eigens omp support overules somehow my own for loop, so that it would be interesting how to switch off Eigens omp support maybe with an preprocessor directive, but keeping the omp for loop.

Kind Regards,
Andreas
manuels
Registered Member
Posts
47
Karma
0

Re: Eigen3 omp

Sun Apr 03, 2011 2:35 pm
AFAIK, matrix vector products are not paralleized in eigen, so it cannot be eigen's fault that you have such a small speedup in both scenarios.
How big are the matrices and vectors?
andreashille
Registered Member
Posts
5
Karma
0

Re: Eigen3 omp

Sun Apr 03, 2011 2:53 pm
No, the vector contains the matrices.
something like std::vector< Eigen::MatrixXf > v

The matrices are 330x330.
v has a typical size of 5000
manuels
Registered Member
Posts
47
Karma
0

Re: Eigen3 omp

Sun Apr 03, 2011 5:18 pm
So if you remove your own omp #pragma line and enable eigen's omp support, you should get full speed up. Why do you want to implement paralellization twice?
andreashille
Registered Member
Posts
5
Karma
0

Re: Eigen3 omp

Sun Apr 03, 2011 5:33 pm
1.) Because Eigen does not use all availible CPUs (only 2 of 4).
2.) I have these iteration over this big vector (that contains a lot matrices), and so I hoped to get a better performance (4 of 4).
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Eigen3 omp

Mon Apr 04, 2011 10:44 am
you configure Eigen's multithreading at runtime:

Eigen::internal::setNbThreads(1);

or at compile time:

-DEIGEN_DONT_PARALLELIZE
andreashille
Registered Member
Posts
5
Karma
0

Re: Eigen3 omp

Mon Apr 04, 2011 10:57 am
Thank you very much.
Andreas


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora