NVIDIA / jitify

A single-header C++ library for simplifying the use of CUDA Runtime Compilation (NVRTC).
BSD 3-Clause "New" or "Revised" License
518 stars 64 forks source link

WAR for __has_include #124

Open maddyscientist opened 1 year ago

maddyscientist commented 1 year ago

This WAR addresses an issue where nvrtc can fail to correctly deal with statements of the form

#if __has_include(<HEADER_NAME>)

where even if we have the header present in the set of includes it fails to return true. The WAR here is to search for such statements when we load up headers, and if the header in question in manually found, we replace the statement with

#if 1

and if not, replace it with

#if 0

With this WAR in place, we no longer need the unneeded includes in the builtin_numeric_cuda_std_limits_program program code, since these will be automatically included now as per @robertmaynard's original intention.

maddyscientist commented 1 year ago

I think I've addressed all the comments, barring the final lambda question. Not sure this is necessarily cleaner.

leofang commented 1 year ago

Was trying this PR and saw this

cupy.cuda.compiler.JitifyException: Malformed __has_include statement (libcxx/include/__config:249)

The line number aside (which might be shifted for some reason), I see libcudacxx has this macro https://github.com/NVIDIA/libcudacxx/blob/a57dbed580e49b14ac1ad7f98496176407208aa4/include/cuda/std/detail/libcxx/include/__config#L212-L214 Could it be causing the error?