]> granicus.if.org Git - clang/commit
[OPENMP 4.5] Codegen for 'taskloop' directive.
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 25 Apr 2016 12:22:29 +0000 (12:22 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 25 Apr 2016 12:22:29 +0000 (12:22 +0000)
commit8ee6f73c6a9cbb31eb06cb7b3fec5be953c92042
tree86a6c724ee6c93aae80dd0a973ad29b952ec8c9b
parent84b05ac1901f581f12c05e9cb979f1e60da02017
[OPENMP 4.5] Codegen for 'taskloop' directive.

The taskloop construct specifies that the iterations of one or more associated loops will be executed in parallel using OpenMP tasks. The iterations are distributed across tasks created by the construct and scheduled to be executed.
The next code will be generated for the taskloop directive:
    #pragma omp taskloop num_tasks(N) lastprivate(j)
        for( i=0; i<N*GRAIN*STRIDE-1; i+=STRIDE ) {
          int th = omp_get_thread_num();
          #pragma omp atomic
            counter++;
          #pragma omp atomic
            th_counter[th]++;
          j = i;
    }

Generated code:
task = __kmpc_omp_task_alloc(NULL,gtid,1,sizeof(struct
task),sizeof(struct shar),&task_entry);
psh = task->shareds;
psh->pth_counter = &th_counter;
psh->pcounter = &counter;
psh->pj = &j;
task->lb = 0;
task->ub = N*GRAIN*STRIDE-2;
task->st = STRIDE;
__kmpc_taskloop(
NULL,             // location
gtid,             // gtid
task,             // task structure
1,                // if clause value
&task->lb,        // lower bound
&task->ub,        // upper bound
STRIDE,           // loop increment
0,                // 1 if nogroup specified
2,                // schedule type: 0-none, 1-grainsize, 2-num_tasks
N,                // schedule value (ignored for type 0)
(void*)&__task_dup_entry // tasks duplication routine
);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267395 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGOpenMPRuntime.cpp
lib/CodeGen/CGOpenMPRuntime.h
lib/CodeGen/CGStmtOpenMP.cpp
lib/CodeGen/CodeGenFunction.h
lib/Sema/SemaOpenMP.cpp
test/OpenMP/taskloop_codegen.cpp [new file with mode: 0644]