This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] Codegen for "#pragma omp atomic write"
ClosedPublic

Authored by ABataev on Feb 2 2015, 6:56 PM.

Details

Summary

For global reg lvalue - use regular store through global register.
For simple lvalue - use simple atomic store.
For bitfields, vector element, extended vector elements - the original value of the whole storage (for vector elements) or of some aligned value (for bitfields) is atomically read, the part of this value for the given lvalue is modified and then use atomic compare-and-exchange operation to try to atomically write modified value (if it was not modified).
Also, changes in this patch fix the bug for '#pragma omp atomic read' applied to extended vector elements.

Diff Detail

Event Timeline

ABataev updated this revision to Diff 19209.Feb 2 2015, 6:56 PM
ABataev retitled this revision from to [OPENMP] Codegen for "#pragma omp atomic write".
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev updated this object.
ABataev added a subscriber: Unknown Object (MLST).
majnemer added inline comments.
lib/CodeGen/CGStmtOpenMP.cpp
859

Shouldn't you use monotonic ordering if the omp write isn't seq_cst?

Yes, of course, just this patch was prepared before last update for
atomics. I'll update patch for sure.

Best regards,

Alexey Bataev

Software Engineer
Intel Compiler Team

16.02.2015 10:58, David Majnemer пишет:

Comment at: lib/CodeGen/CGStmtOpenMP.cpp:859
@@ +858,3 @@
+ else
+ CGF.EmitAtomicStore(ExprRValue, XLValue, /*isInit=*/false);

+ // OpenMP, 2.12.6, atomic Construct

Shouldn't you use monotonic ordering if the omp write isn't seq_cst?

http://reviews.llvm.org/D7369

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/
ABataev updated this revision to Diff 20575.Feb 24 2015, 1:40 AM

Updated patch for the latest changes in atomic processing

rjmccall edited edge metadata.Feb 26 2015, 6:57 PM

If you've verified that the changes to the memory ordering flags in the tests are wanted, then this looks good to me.

John, thanks for the review! Yes, I checked this.

Best regards,

Alexey Bataev

Software Engineer
Intel Compiler Team

27.02.2015 5:57, John McCall пишет:

If you've verified that the changes to the memory ordering flags in the tests are wanted, then this looks good to me.

http://reviews.llvm.org/D7369

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/
This revision was automatically updated to reflect the committed changes.