This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

omp workshare (PR35423) & beginner questions


Hello,

I am a beginner interested in learning gcc internals and contributing
to the community.

I have started implementing PR35423 - omp workshare in the fortran
front-end. I have some questions - any guidance and suggestions are
welcome:

- For scalar assignments, wrapping them in OMP_SINGLE clause.

- Array/subarray assignments: For assignments handled by the
scalarizer,  I now create an OMP_FOR loop instead of a LOOP_EXPR for
the outermost scalarized loop. This achieves worksharing at the
outermost loop level.

Some array assignments are handled by functions (e.g.
gfc_build_memcpy_call generates calls to memcpy). For these, I believe
we need to divide the arrays into chunks and have each thread call the
builtin function on its own chunk. E.g. If we have the following call
in a parallel workshare construct:

memcpy(dst, src, len)

I generate this pseudocode:

{
  numthreads = omp_get_numthreads();
  chunksize = len / numthreads;
  chunksize = chunksize + ( len != chunksize*numthreads)
}

#omp for
   for (i = 0; i < numthreads; i++) {
          mysrc = src + i*chunksize;
          mydst = dst + i*chunksize;
          mylen = min(chunksize, len - (i*chunksize));
          memcpy(mydst, mysrc, mylen);
  }

If you have a suggestion to implement this in a simpler way, let me know.

The above code executes parallel in every thread. Alternatively, the
first block above can be wrapped in omp_single, but the numthreads &
chunksize variables should then be
declared shared instead of private. All the variables above
are private by default, since they are declared in a parallel
construct.

How can I set the scoping for a specific variable in a given
omp for construct? Is the following correct to make a variable shared:

tmp = build_omp_clause(OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL(tmp) = variable;
omp_clauses = gfc_tran_add_clause(tmp, );

-  I still need to do worksharing for array reduction operators (e.g.
SUM,ALL, MAXLOC etc). For these, I think a combination of OMP_FOR/OMP_SINGLE or
OMP_REDUCTION is needed. I will also try to work on WHERE and
FORALL statements.


I am also interested in gomp3 implementation and performance issues.
If there are not-worked-on issues suitable for newbies, please share
or update http://gcc.gnu.org/wiki/openmp. Can someone elaborate on the
"Fine tune the auto scheduling feature for parallel loops" issue?

Also, in the beginner projects
(http://gcc.gnu.org/projects/beginner.html) , under "optimizer
improvements", it would be good to know which of these projects are
not stale/obsolete. Middle-end or x86/x86_64 backend issues for
beginners are of interest.

thanks,

- Vasilis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]