It seems to me that the right way to support this kind of thing is decorators on suites:<div><br></div><div>def sample_for():</div><div>    @parallel.for:</div><div>        for i in range(n):</div><div>            do_something(i)</div>

<div><br></div><div>def sample_sections():</div><div>    @parallel.sections:</div><div>        @parallel.section:</div><div>            do_one()</div><div>        @parallel.section:</div><div>            do_two()</div><div>

        @parallel.section:</div><div>            do_three()</div><div><br></div><div>Now there's a lot I don't know about python internals that may make this more/less practical. The suite decorator would of course be able to do the same kinds of things that a function decorator can so this is not just limited to the parallel example.</div>

<div><br></div><div>--- Bruce</div><div><br><br><div class="gmail_quote">On Mon, Oct 12, 2009 at 6:46 PM, Sturla Molden <span dir="ltr"><<a href="mailto:sturla@molden.no">sturla@molden.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br><br>
   #pragma omp parallel for private(i)<br>
   for (i=0; i<n; i++)<br>
      /* whatever */<br>
<br>
A simple pragma tells that the loop is parallel, and that the counter is private to the thread. Calling multiple task in separate threads are equally simple:<br>
<br>
  #pragma omp parallel sections<br>
  {<br>
     #pragma omp section<br>
     task1();<br>
<br>
     #pragma omp section<br>
     task2();<br>
<br>
     #pragma omp section<br>
     task3();<br>
<br>
  }<br>
<br></blockquote></div></div>