array

Use this forum to discuss the book: Using OpenMP - Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas Read the viewtopic.php?f=8&t=465 for book info and to download the examples. Post your feedback about the book and examples to this forum

array

Postby mimi » Tue Apr 24, 2012 9:39 am

hello, i am trying to make one exercise where there is one 2D array and the elements of each column depend only by those from the previous column. i tried to make the elements of each column to make their calculations parallel but i dont know if this is true. here is my code

for(i=0;i<N;i++)
#pragma omp parallel for
for(j=0;j<N;j++)
array[j][i]=...

can somebody tell me if its true or if their is a better way to write it?
tnx
mimi
 
Posts: 1
Joined: Fri Apr 20, 2012 1:06 pm

Re: array

Postby ruud » Wed Apr 25, 2012 8:55 pm

Hi Mimi,

Could you perhaps give us some more detail?

In particular, what the code within the loop looks like. Also, since this is in C, you really want to change the order of the loops to access the array along the rows first, not the columns. This will make the code run much faster serially and also improve scalability of the parallel version. On top of that there is less overhead because it'll make the parallel for-loop the outermost loop.

Whether this can be done though depends on what is computed within the loop nest.

Ruud
ruud
 
Posts: 23
Joined: Mon Nov 26, 2007 2:13 am

Re: array

Postby visio » Wed May 02, 2012 11:38 pm

you should try this. Thing that you have to change, i am writing in red color
for(i=0;i<N;i++)
#pragma omp parallel for
for(j=0;j<N;j++)
array[i][j]=...
visio
 
Posts: 1
Joined: Wed May 02, 2012 11:34 pm


Return to Using OpenMP - The Book and Examples

Who is online

Users browsing this forum: No registered users and 3 guests