This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Work around a new quirk in CUDA9 headers.
ClosedPublic

Authored by tra on Sep 15 2017, 9:33 AM.

Details

Summary

In CUDA-9 some of device-side math functions that we need are conditionally
defined within '#if _GLIBCXX_MATH_H'. We need to temporarily undo the guard
around inclusion of math_functions.hpp

Diff Detail

Repository
rL LLVM

Event Timeline

tra created this revision.Sep 15 2017, 9:33 AM
jlebar edited edge metadata.Sep 15 2017, 9:40 AM

This is a bit of a Chesterton's Fence -- do we know why they're doing this?

I guess it's probably going to be OK because our overriding semantics will make it OK, and our test-suite tests (should) exercise all of math.h. But I'm still a little worried about it.

tra added a comment.Sep 15 2017, 9:53 AM

I don't think we really care why they do it for nvcc.
My understanding is that nvcc needs to avoid name clashes between their implementation of functions and the ones that come from the host headers and that's why they have to tread really carefully around host includes.

We just need to get those definitions of the device-side functions and we don't care whether host-side functions with the same name are visible at the same time. I wish CUDA would just put all device-side function definitions into a separate file/namespace and let us cherry-pick them at will. Alas, we have to work around nvcc's work arounds...

BTW, this change essentially augments the job that the "#undef GNUC" above used to do in older CUDA versions. CUDA9 replaced GNUC with _GLIBCXX_MATH_H in CUDA-9 in some places.

jlebar accepted this revision.Sep 15 2017, 9:56 AM

BTW, this change essentially augments the job that the "#undef GNUC" above used to do in older CUDA versions. CUDA9 replaced GNUC with _GLIBCXX_MATH_H in CUDA-9 in some places.

Ah, that's right. Okay then. :)

This revision is now accepted and ready to land.Sep 15 2017, 9:56 AM
This revision was automatically updated to reflect the committed changes.