<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr">You are proposing to use C++ in the OpenMP RTL? That will make it dependent on the C++ compiler runtime, no?</div><div dir="ltr"><br></div><div dir="ltr">Jeff</div><div dir="ltr"><br>On Jul 5, 2019, at 1:46 PM, Doerfert, Johannes via Openmp-dev <<a href="mailto:openmp-dev@lists.llvm.org">openmp-dev@lists.llvm.org</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr">

<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">


<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
This proposal does not try to have a pure c++ device runtime library. I want a core implemented in C++, or just interpretable as C++, and device specific parts implemented in a different clang supported language.<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
When I tried to do the OpenMP rewrite a while ago I also realized we need 5.0 or even 5.1 features to do so. Once we do, there will still be device specific parts that require other languages or language extensions, e.g. intrinsics. However, clang already supports
 cuda intrinsics in offloaded regions when we are targeting nvptx.<br>
<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
<span id="OutlookSignature">
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Get <a href="https://aka.ms/ghei36">Outlook for Android</a></div>
</span><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Alexey Bataev <<a href="mailto:Alexey.Bataev@ibm.com">Alexey.Bataev@ibm.com</a>><br>
<b>Sent:</b> Friday, July 5, 2019 2:32:55 PM<br>
<b>To:</b> Doerfert, Johannes<br>
<b>Cc:</b> <a href="mailto:openmp-dev@lists.llvm.org">openmp-dev@lists.llvm.org</a>; <a href="mailto:Gregory.Rodgers@amd.com">Gregory.Rodgers@amd.com</a>; Xinmin Tian; Rokos, Georgios; Finkel, Hal J.; Hernandez, Oscar R.; Lingda Li; Denny, Joel<br>
<b>Subject:</b> Re: [RFC] Device runtime library (re)design</font>
<div> </div>
</div>
<div>
<p><font size="2">Some time ago we had an idea to rewrite the device part of the library using C++ with OpenMP declare target constructs. I think, it would be good to try to write the lib using OpenMP. But, most probably, we're missing some important parts,
 like device only declare target and,most probably, declare variant for some device specific constructs.<br>
</font><font size="2">But you can start to work on this or try to implement declare target device only part.
<br>
</font><font size="2">I don't think that pure C++ will work here since those libraries are purely device libraries. And you need some constructs to express this important part. Not sure that pure C++ will allow to do this.<br>
</font><font size="2"><br>
</font><font size="2">Best regards,<br>
</font><font size="2">Alexey Bataev<br>
</font><font size="2"><br>
</font><font size="2">> 5 июля 2019 г., в 13:16, Doerfert, Johannes <<a href="mailto:jdoerfert@anl.gov">jdoerfert@anl.gov</a>> написал(а):<br>
</font><font size="2">> <br>
</font><font size="2">> Tl;dr<br>
</font><font size="2">> We should extract device specific code out of the OpenMP deviceRTL such that we can reuse the common logic (>90%) for all devices.<br>
</font><font size="2">> We also need to improve the documentation and we should think about bringing the code into the LLVM coding style.<br>
</font><font size="2">> <br>
</font><font size="2">> <br>
</font><font size="2">> Requested changes:<br>
</font><font size="2">> I would like is to change the OpenMP device runtime library design (openmp/libomptarget/deviceRTLs) towards the following goals:<br>
</font><font size="2">> 1) Allow reuse of common logic between different devices in a clean and extensible way.<br>
</font><font size="2">> 2) Improve the documentation, e.g., doxygen comments and code comments, for the code.<br>
</font><font size="2">> 3) Follow the same coding style as LLVM core.<br>
</font><font size="2">> <br>
</font><font size="2">> Disclaimer:<br>
</font><font size="2">> First, I do not want to say it currently is impossible the reuse the code for other devices or the code is not documented at all. What I<br>
</font><font size="2">> think is that we can improve both substantially if we choose to do so. Also, a change in coding style is easier now than later, so if we<br>
</font><font size="2">> decide to do refactoring, that can be included without adding to much churn.<br>
</font><font size="2">> <br>
</font><font size="2">> Motivation:<br>
</font><font size="2">> Now we can discuss if we should do any of the proposed changes but I guess most of them have clear benefits. I am also not the first<br>
</font><font size="2">> to suggest them. Point 1 was mentioned with the initial drop of the device runtime [0], but it was rejected for time reasons. Point 2<br>
</font><font size="2">> was recently discussed as a pressing issue in multiple reviews. Point 3 is a general observation as writing and reviewing code for the<br>
</font><font size="2">> openmp sub project is unnecessarily hard for LLVM developers due to the different coding style.<br>
</font><font size="2">> <br>
</font><font size="2">> Proposed structure:<br>
</font><font size="2">> In order to ease the reuse by new devices we should have a common core with device independent logic, e.g., in<br>
</font><font size="2">> openmp/ibomptarget/deviceRTLs/common<br>
</font><font size="2">> including an interface that declares all device specific methods needed by the core logic. The interface is then the<br>
</font><font size="2">> only thing implemented in the device subfolders, e.g., <br>
</font><font size="2">> openmp/ibomptarget/deviceRTLs/nvptx, openmp/ibomptarget/deviceRTLs/amdgpu, ...<br>
</font><font size="2">> To get to this goal, all device specific code has to be extracted from the core logic. The prototypes below show that this<br>
</font><font size="2">> is fairly easy to do.<br>
</font><font size="2">> <br>
</font><font size="2">> <br>
</font><font size="2">> Feasibility and prototypes:<br>
</font><font size="2">> To showcase the direction I would like is to move to I "redesigned" three files (out of ~20) with the above goals in mind. The patches<br>
</font><font size="2">> can be found here:<br>
</font><font size="2">> <a href="https://reviews.llvm.org/D64217">https://reviews.llvm.org/D64217</a>
<br>
</font><font size="2">> <a href="https://reviews.llvm.org/D64218">https://reviews.llvm.org/D64218</a>
<br>
</font><font size="2">> <a href="https://reviews.llvm.org/D64219">https://reviews.llvm.org/D64219</a>
<br>
</font><font size="2">> Note that there is a vast design space even if we agree to the above three goals. As a consequence, I'd like us to use the patches to<br>
</font><font size="2">> discuss general design decisions not specific ones until we agreed on a path forward.<br>
</font><font size="2">> <br>
</font><font size="2">> <br>
</font><font size="2">> Please let me know what you think,<br>
</font><font size="2">> Johannes<br>
</font><font size="2">> <br>
</font><font size="2">> <br>
</font><font size="2">> <br>
</font><font size="2">> [0] <a href="https://reviews.llvm.org/D14254#949985">https://reviews.llvm.org/D14254#949985</a>
<br>
</font><font size="2">> <br>
</font><font size="2">> <br>
</font><font size="2">> ---------------------------------------<br>
</font><font size="2">> Johannes Doerfert<br>
</font><font size="2">> Researcher<br>
</font><font size="2">> <br>
</font><font size="2">> Argonne National Laboratory<br>
</font><font size="2">> Lemont, IL 60439, USA<br>
</font><font size="2">> <br>
</font><font size="2">> <a href="mailto:jdoerfert@anl.gov">jdoerfert@anl.gov</a><br>
</font><font size="2">> <br>
</font><br>
</p>
</div>


</div></blockquote><blockquote type="cite"><div dir="ltr"><span>_______________________________________________</span><br><span>Openmp-dev mailing list</span><br><span><a href="mailto:Openmp-dev@lists.llvm.org">Openmp-dev@lists.llvm.org</a></span><br><span><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev</a></span><br></div></blockquote></body></html>