This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] Initial codegen for 'omp sections' and 'omp section' directives.
ClosedPublic

Authored by ABataev on Mar 11 2015, 2:29 AM.

Details

Summary

If only one section is found in the sections region, it is emitted just like single region.
Otherwise it is emitted as a static non-chunked loop.

#pragma omp sections
{
#pragma omp section
{1}
...
#pragma omp section
{n}
}

is translated to something like

i32 <iter_var>
i32 <last_iter> = 0
i32 <lower_bound> = 0
i32 <upper_bound> = n-1
i32 <stride> = 1
call void @__kmpc_for_static_init_4(<loc>, i32 <gtid>, i32 34/*static non-chunked*/, i32* <last_iter>, i32* <lower_bound>, i32* <upper_bound>, i32* <stride>, i32 1/*increment always 1*/, i32 1/*chunk always 1*/)
<upper_bound> = min(<upper_bound>, n-1)
<iter_var> = <lb>
check:
br <iter_var> <= <upper_bound>, label cont, label exit
continue:
switch (IV) {
case 0:
{1};
break;
...
case <NumSection> - 1:
{n};
break;
}
++<iter_var>
br label check
exit:
call void @__kmpc_for_static_fini(<loc>, i32 <gtid>)

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev updated this revision to Diff 21681.Mar 11 2015, 2:29 AM
ABataev retitled this revision from to [OPENMP] Initial codegen for 'omp sections' and 'omp section' directives..
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added a subscriber: Unknown Object (MLST).
rjmccall edited edge metadata.Mar 12 2015, 12:52 AM

Looks good. A couple minor requests:

lib/CodeGen/CGStmtOpenMP.cpp
306 ↗(On Diff #21681)

It's better to use EmitBranchOnBoolExpr here.

772 ↗(On Diff #21681)

Braces.

ABataev updated this revision to Diff 21807.Mar 12 2015, 1:19 AM
ABataev edited edge metadata.

John, thanks for the review! Fixed all problems.

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.