<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Ah, you're talking about transferred definitions and code paths
activated because of those definitions? Yes, missed it.<br>
</p>
<pre class="moz-signature" cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div class="moz-cite-prefix">15.01.2020 1:47 PM, Artem Belevich
пишет:<br>
</div>
<blockquote type="cite"
cite="mid:CA+wKYkMRp_-k8vkTU5sVjmrC8DkiPfo4nE=SrHmkv+GJ3Q7M+A@mail.gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Jan 15, 2020 at 3:09
PM Alexey Bataev <<a href="mailto:a.bataev@outlook.com"
moz-do-not-send="true">a.bataev@outlook.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>And I disabled it only for device side, which is NVPTX,
no? Can host side target class report that the target is
NVPTX? If you look at the patch, it disable RTTI only if
current triple is NVPTX. Can it be true for the host? <br>
</p>
</div>
</blockquote>
<div>
<div class="gmail_default"
style="font-family:verdana,sans-serif">You are correct
that the NVPTX as the triple is never used for the host
compilation.</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif">However, I'm
talking about host-side *code* as seen by compiler during
device-side *compilation*. Keep in mind that both host and
device compilations always see both sides of the source
code. The host code seen by the compiler during
device-side compilation should be allowed to use host
features that are not available on GPU.</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif">When you RTTI got
disabled for NVPTX, it affected *all* code seen by the
compiler. When GPU-side compiler that targets NVPTX with
RTTI disabled gets to parse the host function hf() (<a
href="https://godbolt.org/z/Gzsrof" target="_blank"
moz-do-not-send="true">https://godbolt.org/z/Gzsrof</a>)
it sees typeid() and complains that RTTI is disabled, even
though it will never produce any code for hf(). It
should've allowed RTTI use in the host-only code.</div>
</div>
<div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
</div>
<div><span style="font-family:verdana,sans-serif">--Artem</span><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p> </p>
<pre cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div>15.01.2020 1:06 PM, Artem Belevich пишет:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div style="font-family:verdana,sans-serif"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Jan 15,
2020 at 2:52 PM Alexey Bataev <<a
href="mailto:a.bataev@outlook.com"
target="_blank" moz-do-not-send="true">a.bataev@outlook.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>1. The problem is that it does not produce
errors, </p>
</div>
</blockquote>
<div><span class="gmail_default"
style="font-family:verdana,sans-serif">ATM, it
does produce errors when it's disabled.</span> </div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>it leads to the emission of some declaration
that cannot be resolved by the linker. This
what I was trying to avoid.</p>
</div>
</blockquote>
<div>
<div style="font-family:verdana,sans-serif">I'm OK
with disabling it on device, but it should be
done in a way to keep RTTI in the host code
working.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">E.g.
this code should compile: <a
href="https://godbolt.org/z/Gzsrof"
target="_blank" moz-do-not-send="true">https://godbolt.org/z/Gzsrof</a></div>
<div style="font-family:verdana,sans-serif">It
still has your original change, so clang
compilation fails. It does not with NVCC.</div>
</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>2. Yes, I did not disable it on the host
side, just for the device side. I disabled it
only for NVPTX target, which is the device.<br>
</p>
</div>
</blockquote>
<div>
<div style="font-family:verdana,sans-serif">It's
fine to disable it for code generated for the
target. However, the front-end needs to be able
to deal with the host-side code where it is OK
to use RTTI.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">--Artem</div>
<br>
</div>
<div><br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p> </p>
<pre cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div>15.01.2020 12:49 PM, Artem Belevich пишет:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div style="font-family:verdana,sans-serif">Thank
you.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">In
general, RTTI should probably be treated
similar to how we deal with inline
assembly and ignore errors if they are in
the code that we're not going to codegen
during this side of compilation. E.g.
during host-side compilation we don't
complain about GPU-side registers in
inline assembly that x86 target is not
aware of. </div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">Disabling
RTTI altogether on device side makes it
impossible to use in any host-side CUDA
because RTTI code will be seen by the
device-side compiler, which will promptly
fail, which is exactly what happened in
this case -- host-side template that
relied on RTTI failed during device-side
compilation:</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif"><a
href="https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/arena.h#L536"
target="_blank" moz-do-not-send="true">https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/arena.h#L536</a><br>
</div>
<div style="font-family:verdana,sans-serif">google/protobuf/arena.h:536:15:
error: use of typeid requires -frtti<br>
AllocHook(RTTI_TYPE_ID(T), n);<br>
</div>
<div style="font-family:verdana,sans-serif">...<br>
</div>
<div style="font-family:verdana,sans-serif">2
errors generated when compiling for sm_60.<br>
</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">--Artem</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed,
Jan 15, 2020 at 2:36 PM Alexey Bataev <<a
href="mailto:a.bataev@outlook.com"
target="_blank" moz-do-not-send="true">a.bataev@outlook.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>Sure, will revert it ASAP.<br>
</p>
<pre cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div>15.01.2020 12:26 PM, Artem Belevich
пишет:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div
style="font-family:verdana,sans-serif">Alexey,</div>
<div
style="font-family:verdana,sans-serif"><br>
</div>
<div
style="font-family:verdana,sans-serif">This
breaks compilation of our cuda
code which happens to transitively
include protobuf headers.</div>
<div
style="font-family:verdana,sans-serif">Can
you, please, revert it for now
until we figure out how RTTI
should be handled?</div>
<div
style="font-family:verdana,sans-serif"><br>
</div>
<div
style="font-family:verdana,sans-serif">--Artem<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On
Tue, Jan 14, 2020 at 3:15 PM
Alexey Bataev via cfe-commits <<a
href="mailto:cfe-commits@lists.llvm.org" target="_blank"
moz-do-not-send="true">cfe-commits@lists.llvm.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"><br>
Author: Alexey Bataev<br>
Date: 2020-01-14T18:12:06-05:00<br>
New Revision:
23058f9dd4d7e18239fd63b6da52549514b45fda<br>
<br>
URL: <a
href="https://github.com/llvm/llvm-project/commit/23058f9dd4d7e18239fd63b6da52549514b45fda"
rel="noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/23058f9dd4d7e18239fd63b6da52549514b45fda</a><br>
DIFF: <a
href="https://github.com/llvm/llvm-project/commit/23058f9dd4d7e18239fd63b6da52549514b45fda.diff"
rel="noreferrer" target="_blank"
moz-do-not-send="true">https://github.com/llvm/llvm-project/commit/23058f9dd4d7e18239fd63b6da52549514b45fda.diff</a><br>
<br>
LOG: [OPENMP]Do not use RTTI by
default for NVPTX devices.<br>
<br>
NVPTX does not support RTTI, so
disable it by default.<br>
<br>
Added: <br>
clang/test/Driver/openmp-offload-gpu.cpp<br>
<br>
Modified: <br>
clang/lib/Driver/ToolChain.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff --git
a/clang/lib/Driver/ToolChain.cpp
b/clang/lib/Driver/ToolChain.cpp<br>
index cab97b1a601a..3ebbd30195b3
100644<br>
---
a/clang/lib/Driver/ToolChain.cpp<br>
+++
b/clang/lib/Driver/ToolChain.cpp<br>
@@ -68,7 +68,8 @@ static
ToolChain::RTTIMode
CalculateRTTIMode(const ArgList
&Args,<br>
}<br>
<br>
// -frtti is default, except
for the PS4 CPU.<br>
- return (Triple.isPS4CPU()) ?
ToolChain::RM_Disabled :
ToolChain::RM_Enabled;<br>
+ return (Triple.isPS4CPU() ||
Triple.isNVPTX()) ?
ToolChain::RM_Disabled<br>
+
:
ToolChain::RM_Enabled;<br>
}<br>
<br>
ToolChain::ToolChain(const Driver
&D, const llvm::Triple &T,<br>
<br>
diff --git
a/clang/test/Driver/openmp-offload-gpu.cpp
b/clang/test/Driver/openmp-offload-gpu.cpp<br>
new file mode 100644<br>
index 000000000000..9da7308506ae<br>
--- /dev/null<br>
+++
b/clang/test/Driver/openmp-offload-gpu.cpp<br>
@@ -0,0 +1,20 @@<br>
+///<br>
+/// Perform several driver tests
for OpenMP offloading<br>
+///<br>
+<br>
+// REQUIRES: clang-driver<br>
+// REQUIRES:
x86-registered-target<br>
+// REQUIRES:
powerpc-registered-target<br>
+// REQUIRES:
nvptx-registered-target<br>
+<br>
+///
###########################################################################<br>
+<br>
+/// PTXAS is passed -c flag by
default when offloading to an
NVIDIA device using OpenMP<br>
+/// Check that the flag is passed
when -fopenmp-relocatable-target
is used.<br>
+// RUN: %clangxx -###
-fopenmp=libomp
-fopenmp-targets=nvptx64-nvidia-cuda
\<br>
+// RUN: -save-temps
-no-canonical-prefixes %s -x c++
-c 2>&1 \<br>
+// RUN: | FileCheck
-check-prefix=CHK-RTTI %s<br>
+<br>
+// CHK-RTTI: clang{{.*}}"
"-triple" "nvptx64-nvidia-cuda"<br>
+// CHK-RTTI-SAME: "-fno-rtti"<br>
+<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a
href="mailto:cfe-commits@lists.llvm.org"
target="_blank"
moz-do-not-send="true">cfe-commits@lists.llvm.org</a><br>
<a
href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits"
rel="noreferrer" target="_blank"
moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div dir="ltr">--Artem Belevich</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div dir="ltr">--Artem Belevich</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div dir="ltr">--Artem Belevich</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">--Artem Belevich</div>
</div>
</div>
</blockquote>
</body>
</html>