[PATCH] [OPENMP] Codegen for 'private' clause in 'task' directive.
Alexey Bataev
a.bataev at hotmail.com
Tue Apr 28 05:25:24 PDT 2015
Hi rjmccall, hfinkel,
For tasks codegen for private/firstprivate variables are different rather than for other directives.
1. Build an internal structure of privates for each private variable:
```
struct .kmp_privates_t. {
Ty1 var1;
...
Tyn varn;
};
```
2. Add a new field to kmp_task_t type with list of privates.
```
struct kmp_task_t {
void * shareds;
kmp_routine_entry_t routine;
kmp_int32 part_id;
kmp_routine_entry_t destructors;
.kmp_privates_t. privates;
};
```
3. Replace addresses of shared variables by the addresses of private ones in a structure of captured variables.
```
kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
tt->shareds.var1_ref = &tt->privates.var1;
...
tt->shareds.varn_ref = &tt->privates.varn;
TaskFunction(gtid, tt->part_id, tt->shareds);
return 0;
}
```
4. Create a function with destructors calls for all privates after end of task region.
```
kmp_int32 .omp_task_destructor.(kmp_int32 gtid, kmp_task_t *tt) {
~Destructor(&tt->privates.var1);
...
~Destructor(&tt->privates.varn);
return 0;
}
```
5. Perform default initialization of all private fields (no initialization for POD data, default constructor calls for classes) + provide address of a destructor function after __kmpc_omp_task_alloc() and before __kmpc_omp_task() calls.
```
kmp_task_t *new_task = __kmpc_omp_task_alloc(ident_t *, kmp_int32 gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds, kmp_routine_entry_t *task_entry);
DefaultConstructor(new_task->privates.var1);
...
DefaultConstructor(new_task->privates.varn);
new_task->destructors = .omp_task_destructor.;
kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid, kmp_task_t *new_task)
```
http://reviews.llvm.org/D9322
Files:
lib/CodeGen/CGOpenMPRuntime.cpp
lib/CodeGen/CGOpenMPRuntime.h
lib/CodeGen/CGStmtOpenMP.cpp
test/OpenMP/task_private_codegen.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9322.24542.patch
Type: text/x-patch
Size: 38608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150428/4c35bcdc/attachment.bin>
More information about the cfe-commits
mailing list