This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Encode offload target triples into comdat key for offload initialization code
ClosedPublic

Authored by sdmitriev on Aug 2 2018, 8:16 PM.

Details

Summary

Encoding offload target triples onto comdat group key for offload initialization code guarantees that it will be executed once per each unique combination of offload targets.

Diff Detail

Event Timeline

sdmitriev created this revision.Aug 2 2018, 8:16 PM
mgrang added a comment.Aug 2 2018, 8:55 PM

Please add some unit tests.

lib/CodeGen/CGOpenMPRuntime.cpp
3830
sdmitriev updated this revision to Diff 159028.Aug 3 2018, 9:36 AM

Replaced std::sort with llvm::sort. Added a test for offload target registration code for two offload targets.

ABataev added inline comments.Aug 3 2018, 10:37 AM
lib/CodeGen/CGOpenMPRuntime.cpp
3825

Preallocate the memory for all elements at construction, you know the number of elements.

sdmitriev added inline comments.Aug 3 2018, 10:52 AM
lib/CodeGen/CGOpenMPRuntime.cpp
3825

Agree.

sdmitriev updated this revision to Diff 159058.Aug 3 2018, 11:15 AM
ABataev added inline comments.Aug 3 2018, 11:28 AM
lib/CodeGen/CGOpenMPRuntime.cpp
3828–3829

Use something like this:

llvm::copy(Devices, std::next(RegFnNameParts.begin(), 2));
3830

Also, use std::next(RegFnNameParts.begin(), 2)

sdmitriev updated this revision to Diff 159074.Aug 3 2018, 1:09 PM
This revision is now accepted and ready to land.Aug 3 2018, 1:12 PM
This revision was automatically updated to reflect the committed changes.