[Openmp-dev] clang: Emit Target Functions when #pragma omp declare target

Georgios Rokos via Openmp-dev openmp-dev at lists.llvm.org
Fri Dec 1 11:56:10 PST 2017

Hi Daniel,

As Jonas said, support for declare target has not been upstreamed yet. I am
working on this right now. There is a Sema patch under review, once it gets
accepted I'll also upstream the codegen patch. Hopefully we'll get done
with this soon.


From:	Daniel Schürmann via Openmp-dev <openmp-dev at lists.llvm.org>
To:	openmp-dev <openmp-dev at lists.llvm.org>
Date:	01/12/2017 10:18
Subject:	[Openmp-dev] clang: Emit Target Functions when #pragma omp
            declare	target
Sent by:	"Openmp-dev" <openmp-dev-bounces at lists.llvm.org>


I wanted to ask, if this behavior is on purpose or if I am missing

To me it seems that using "#pragma omp declare target" has no effect on
the code generation.
The specification states that variables and functions are mapped to the
In my understanding, this means that device code should be emitted.

However, CGOpenMPRuntime::emitTargetGlobal() does only search for target
#pragmas and doesn't check for OMPDeclareTargetDeclAttr. This check is
done in ASTContext::DeclMustBeEmitted(), but it seems, this can never
happen. The reason is that CodeGenModule::EmitGlobal() returns early
after calling CGOpenMPRuntime::emitTargetGlobal(). I hope, this is

It might be that this problem never showed up when the device is x86 as
well. But I don't understand how Nvidia can compile e.g. lulesh like

My question is if the intended way would be to change emitTargetGlobal()
to also emit functions/variables with OMPDeclareTargetDeclAttr.

Thanks in advance,

Openmp-dev mailing list
Openmp-dev at lists.llvm.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20171201/39b59820/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20171201/39b59820/attachment.gif>

More information about the Openmp-dev mailing list