cores count:2, thread count:1 //problem activationg the 2 cores

cores count:2, thread count:1 //problem activationg the 2 cores

hi,

i want to use openMP directives to multiply a sparse matrix to a vector.
here is a part of the code that i want to parallelize:

int count=0;
#pragma omp parallel for
for(int a=0; a {
count=I[a+1]-I[a]+count;//count to count the number of nnz in every row.
while(index!=count)
{
k=k+A[index]*B[J[index]];// to add the multiplications of every nnz in the row by the vector
index++;
}
solution[a]=k;//fill the value of K of every row in the array solution[]
k=0;
}

i have followed these steps in my C++ project:
-include the openMP library: #include
-set project as startup
-parallel compose->use intel C++...

then run the code.
all what i'm getting is:
-cores count:2
-threads created:1

i have copied my code, past it in the wmandelbrot project, and followed the above steps. surprizingly, i have gotten these results:
-cores count:2
-threads created:2

my CPU is intel core 2 duo centrino

first: how to activate the 2 cores? it is something concerning the intel compiler? some properties or options should be modified i guess? plz help me :(

secondo: how should i deal with the shared and private in the above code? how to deal with the 'count'??

thank you in advance :)
sorry for bothering :)

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If you use MS Visual Studio go to Project Properties->C/C++->Language->OpenMP Support. Enable it.

Lots of shared variables in your code. You should make them private using private(...) options. The general rule is as follows: any variable that is stored in the code should be private unless it is a reduction variable or you use critical section to protect it from the concurrent access.

10X for the info, finally it worked :D
i've got this:
threads created: 2 :D
thank you for ur help

as for the shared variables, some readings are waiting for me, i hope i'll be able to figure it alone :)
but this rule surely will help me, thank u again :)

sorry for bothering :)

Thanks and nice to know that it worked (per Mikhail's suggestion!)...
-Cheers,
Kittur

Leave a Comment

Please sign in to add a comment. Not a member? Join today