This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] Codegen for 'firstprivate' clause in 'parallel' directive
ClosedPublic

Authored by ABataev on Sep 1 2014, 12:10 AM.

Details

Summary

This patch generates some helper variables that used as private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by copy using values of the original variables (with the copy constructor, if any). For arrays, initializator is generated for single element and in the codegen procedure this initial value is automatically propagated between all elements of the private copy.
In outlined function, references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables an implicit barier is generated by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables.

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev updated this revision to Diff 13135.Sep 1 2014, 12:10 AM
ABataev retitled this revision from to [OPENMP] Codegen for 'firstprivate' clause in 'parallel' directive.
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added a subscriber: Unknown Object (MLST).
ABataev updated this object.Sep 1 2014, 12:17 AM
hfinkel edited edge metadata.Sep 22 2014, 1:41 AM

Please separate out the Sema changes from this patch into a separate patch.

lib/CodeGen/CGExpr.cpp
3483 ↗(On Diff #13135)

I don't think there is any reason to move this function to a different file. You can update its signature in-place. If you want to move it to a different file for organizational reasons, please do that in a separate commit.

lib/CodeGen/CGStmtOpenMP.cpp
58 ↗(On Diff #13135)

Please extract this into a utility function.

Please separate out the Sema changes from this patch into a separate patch.

Hal, the changes in Sema are required for codegen only. I won't be able to test them without codegen.

lib/CodeGen/CGExpr.cpp
3483 ↗(On Diff #13135)

Ok, I'll return it back

lib/CodeGen/CGStmtOpenMP.cpp
58 ↗(On Diff #13135)

Ok

ABataev updated this revision to Diff 13971.Sep 23 2014, 12:31 AM
ABataev edited edge metadata.

Update after review.

  • Original Message -----

From: "Alexey Bataev" <a.bataev@hotmail.com>
To: "a bataev" <a.bataev@hotmail.com>, dgregor@apple.com, fraggamuffin@gmail.com, richard@metafoo.co.uk,
rjmccall@gmail.com, ejstotzer@gmail.com, hfinkel@anl.gov
Cc: cfe-commits@cs.uiuc.edu
Sent: Monday, September 22, 2014 11:26:56 PM
Subject: Re: [PATCH] [OPENMP] Codegen for 'firstprivate' clause in 'parallel' directive

Please separate out the Sema changes from this patch into a
separate patch.

Hal, the changes in Sema are required for codegen only. I won't be
able to test them without codegen.

Okay, obviously there are changes to the Sema tests because the messages have changed. Can you commit that change separately? If this is not reasonable/possible, please explain why.

Also, regarding the addition of the '*PrivateCopies' functions to the AST nodes, can you please explain the design? I don't understand why you seem to be duplicating some of the variables in the AST.

Thanks again,
Hal

[snip]

http://reviews.llvm.org/D5140

ABataev updated this revision to Diff 14093.Sep 25 2014, 9:23 PM

Added a comment for new private variable

hfinkel accepted this revision.Oct 7 2014, 5:44 AM
hfinkel edited edge metadata.

LGTM, thanks!

lib/CodeGen/CGStmtOpenMP.cpp
128 ↗(On Diff #14093)

Extra line.

lib/Sema/SemaOpenMP.cpp
3381 ↗(On Diff #14093)

Missing space before "This".

3386 ↗(On Diff #14093)

on the CodeGen -> in CodeGen

test/OpenMP/for_firstprivate_messages.cpp
222 ↗(On Diff #14093)

Extra newline?

This revision is now accepted and ready to land.Oct 7 2014, 5:44 AM

Hal, Thanks for the review!

lib/CodeGen/CGStmtOpenMP.cpp
128 ↗(On Diff #14093)

Removed

lib/Sema/SemaOpenMP.cpp
3381 ↗(On Diff #14093)

Fixed.

3386 ↗(On Diff #14093)

Fixed.

test/OpenMP/for_firstprivate_messages.cpp
222 ↗(On Diff #14093)

Removed

ABataev closed this revision.Oct 8 2014, 3:53 AM
ABataev updated this revision to Diff 14555.

Closed by commit rL219295 (authored by @ABataev).