[Openmp-dev] Math symbols are not found during configuration

Doerfert, Johannes via Openmp-dev openmp-dev at lists.llvm.org
Wed Jul 24 19:57:35 PDT 2019


On 07/24, Jeff Hammond wrote:
> I am curious how this works.  Does the compiler not #include all headers or
> specific headers when the target compiler is running?

Correct. If you compile CUDA, or OpenMP target regions, Clang will
intercept certain header includes. Though, right now, only in the CUDA
case you will also get the system versions. For OpenMP target regions we
cannot do so as we would otherwise redefine symbols, e.g., the std::sin
version for the device and the one for the host have the same prototype.
CUDA solves this problem with the __device__/__host__ annotations.
OpenMP will with #variants.


> I make heavy use of preprocessing in all of my OpenMP codes, including the
> target ones.  I don't compile for the NVPTX back-end so I haven't seen
> problems yet but I wonder if my code is broken in that setting.

Preprocessor magic is not impacted at all. All we do is intercept
includes by providing custom headers earlier in the include path. The
preprocessor is not altered nor its function. As described above, the
difference between host and NVPTX device mode is that you will currently
not get the system/math.h header when you include math.h. Regarding your
use case, as long as the device architecture is the same as the host,
there is no need to do any of this.


Does this help?


> On Wed, Jul 24, 2019 at 1:32 PM Doerfert, Johannes <jdoerfert at anl.gov>
> wrote:
> 
> > #define works, the preprocessor works.
> >
> > When the target region is compiled we do not include math.h. This will
> > change once we get support for variants. Till then, it is either no math
> > functions or only he ones Clang CUDA provides automatically, which seems
> > not to include these defines, maybe because they are not ISO C but POSIX
> > extensions.
> >
> >
> > On 07/24, Jeff Hammond wrote:
> > > How does #define not act on the full source code? How is that a
> > compliant implementation of the preprocessor?
> > >
> > > Jeff
> > >
> > > > On Jul 24, 2019, at 12:25 PM, Doerfert, Johannes via Openmp-dev <
> > openmp-dev at lists.llvm.org> wrote:
> > > >
> > > > Hi Itaru,
> > > >
> > > > For now, you need to define them yourself when you need them in the
> > target region.
> > > > We are working on a permanent solution.
> > > >
> > > > Thanks,
> > > >  Johannes
> > > >
> > > > ________________________________________
> > > > From: Openmp-dev <openmp-dev-bounces at lists.llvm.org> on behalf of
> > Itaru Kitayama via Openmp-dev <openmp-dev at lists.llvm.org>
> > > > Sent: Tuesday, July 23, 2019 22:58
> > > > To: openmp-dev at lists.llvm.org
> > > > Subject: [Openmp-dev] Math symbols are not found during configuration
> > > >
> > > > Hi,
> > > > Adding the flag -fopenmp-targets=nvptx64 makes math symbols M_E and
> > M_PI defined in cmath not detected during the execution of CMake. How do I
> > work around this? I am using the latest trunk Clang at this moment, and
> > without the above flag, both symbols are detected properly.
> > > >
> > > > Thanks,
> > > > Itaru.
> > > > _______________________________________________
> > > > Openmp-dev mailing list
> > > > Openmp-dev at lists.llvm.org
> > > > https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev
> >
> > --
> >
> > Johannes Doerfert
> > Researcher
> >
> > Argonne National Laboratory
> > Lemont, IL 60439, USA
> >
> > jdoerfert at anl.gov
> >
> 
> 
> -- 
> Jeff Hammond
> jeff.science at gmail.com
> http://jeffhammond.github.io/

-- 

Johannes Doerfert
Researcher

Argonne National Laboratory
Lemont, IL 60439, USA

jdoerfert at anl.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190725/5bb96eef/attachment-0001.sig>


More information about the Openmp-dev mailing list