This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Make global ctor init function a kernel
ClosedPublic

Authored by Anastasia on May 3 2019, 5:00 AM.

Details

Summary

We need to be able to enqueue internal function that initializes global constructors on the host side. Therefore it has to be converted to a kernel.

Note, supporting destruction would need some more work. However, it seems global destruction has little meaning without any dynamic resource allocation on the device and program scope variables are destroyed by the runtime when program is released.

Diff Detail

Event Timeline

Anastasia created this revision.May 3 2019, 5:00 AM
Anastasia marked an inline comment as done.May 3 2019, 5:02 AM
Anastasia added inline comments.
lib/CodeGen/CodeGenModule.cpp
1231

CFG -> CGF

kpet added inline comments.May 3 2019, 7:36 AM
lib/CodeGen/CGDeclCXX.cpp
583

functions
should be -> must be?
to the kernel -> to a kernel

584

in order that they may be launched by the host?

590

Agree that global destructors aren't that attractive a feature in most contexts. There are quite a few runtime issues with them too. We can think about this later.

593

Shouldn't the calling convention be SPIR_KERNEL if you want the function to be host-visible?

lib/CodeGen/CodeGenModule.h
1322

kernels generated implicitly
if a kernel | when a kernel

Anastasia updated this revision to Diff 198678.May 8 2019, 8:55 AM
  • Improved comments
  • Switched to SPIR kernel
kpet accepted this revision.May 9 2019, 2:31 AM

The comments could use a bit more polishing but nothing that justifies making another iteration IMHO. LGTM!

This revision is now accepted and ready to land.May 9 2019, 2:31 AM

The comments could use a bit more polishing but nothing that justifies making another iteration IMHO. LGTM!

Sure, feel free to put up a patch if you like. :)

Thanks!

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2019, 6:53 AM