[PATCH] [OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.

Alexey Bataev a.bataev at hotmail.com
Thu Apr 23 23:01:49 PDT 2015


Hi rjmccall, hfinkel,

```
#pragma omp sections lastprivate(<var>)
<BODY>;
```
This construct is translated into something like:
```
<last_iter> = alloca i32
<init for lastprivates>;
<last_iter> = 0
; No initializer for simple variables or a default constructor is called for objects.
; For arrays perform element by element initialization by the call of the default constructor.
...
OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration.
<BODY>
...
OMP_FOR_END
if (<last_iter> != 0) {
<final copy for lastprivate>; Update original variable with the lastprivate value.
}
call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race.
```

If there is only one section, the following code is generated:
```
if (@__kmpc_single()) {
  <init for lastprivates>
  <BODY>
  if (true) {
    <final copy for lastprivate>;
  }
@__kmpc_end_single();
}
call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race.
```

http://reviews.llvm.org/D9240

Files:
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/sections_lastprivate_codegen.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9240.24355.patch
Type: text/x-patch
Size: 22128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150424/99112c49/attachment.bin>


More information about the cfe-commits mailing list