[Gridflow-dev] [PD] OpenMP and Pd
Pedro Lopes
pedro.lopes at ist.utl.pt
Mon Dec 6 12:37:33 EST 2010
Yep, the idea behind openMP is related to what you normally call directives
or pragmas[1]. OpenMP offers a set of such directives so you can choose ways
to parallelize *chunks* of your code accordingly to the best option you
want. List of pragmas here [2].
The very basic example is a parallel for:
int main(int argc, char *argv[]) {
const int N = 100000;
int i, a[N];
#pragma omp parallel for
for (i = 0; i < N; i++)
a[i] = 2 * i;
return 0;}
And yes, you only type "#pragma omp parallel for" before the "for"
statement. Nothing more. You can test within your systems for the results.
Now just a final, very important notice: I am no openMP expert, just looking
for interesting ways of speeding things up, there are other as mentioned in
this list, several other times.
[1]
http://books.google.pt/books?id=MeFLQSKmaJYC&printsec=frontcover&dq=openMP&source=bl&ots=5yWLnT441E&sig=ckzBbxx3u_EbWPNxaf9MkFn-CFM&hl=pt-PT&ei=6h39TPHeIY6j4QaWprypBw&sa=X&oi=book_result&ct=result&resnum=8&ved=0CGAQ6AEwBw#v=onepage&q&f=false
[2]
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/compiler/ref/ruprpdir.htm
On Mon, Dec 6, 2010 at 3:09 PM, Mathieu Bouchard <matju at artengine.ca> wrote:
> On Mon, 6 Dec 2010, Claude Heiland-Allen wrote:
>
> NB: while it does use more than one core, I just compared with the single
>> core version of gridflow without openmp and it uses only 25% of my cpu (on
>> one core) while the openmp version uses 145% of my cpu (spread over two
>> cores). So, it's no magic bullet...
>>
>
> I don't know how OpenMP works, but is there a way to apply it selectively
> to only part of a project ? I'm just guessing that it could make a big
> difference, e.g. if you don't apply it to numop*.cxx but you do apply it to
> much of the rest (perhaps also exclude gridflow.cxx itself because it
> contains the BitPacking class).
>
> I just had this idea because of what you told me on the #dataflow chat.
>
> _______________________________________________________________________
> | Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
>
--
Pedro Lopes (MSc)
contact: pedro.lopes at ist.utl.pt
website: http://web.ist.utl.pt/Pedro.Lopes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.artengine.ca/pipermail/gridflow-dev/attachments/20101206/1e033334/attachment.htm>
More information about the Gridflow-dev
mailing list