[PATCH] D42642: [CUDA] Detect installation in PATH

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 11:25:22 PST 2018


Hahnfeld added a comment.

In https://reviews.llvm.org/D42642#992137, @tra wrote:

> I've thought a bit more about this and there's another quirk -- symlinks.
>
> What if we've found /usr/bin/ptxas and is a symlink pointing to the real ptxas in the CUDA installation? If we add /usr to the list of candidates it will not help us at all. We should probably find the real path and add another candidate path derived from it.


Yes, this might be a valid use case, for example linking `/usr/bin/ptxas` to `/opt/cuda/bin/ptxas` or something. I think there should be an LLVM function to get the `realpath`, let me check that.
(In fact I have symlinks in my environment but it doesn't matter in this case because we are just linking the complete CUDA installation to another path...)



================
Comment at: lib/Driver/ToolChains/Cuda.cpp:206
     // -nocudalib hasn't been specified.
-    if (LibDeviceMap.empty() && !Args.hasArg(options::OPT_nocudalib))
+    if (CheckLibDevice && LibDeviceMap.empty())
       continue;
----------------
tra wrote:
> Hahnfeld wrote:
> > tra wrote:
> > > I think this may be too strict.
> > > 
> > > Checking directory structure for the purposes of detecting CUDA SDK should work well enough to weed out false detection for 'split' CUDA installation and we've verified libdevice directory presence above. 
> > > 
> > > Checking for libdevice bitcode is somewhat orthogonal to this. IMO, regardless of how we've found the installation directory, whether we have suitable libdevice version there should not matter if user explicitly passed -nocudalib. Insisting on libdevice presence in this situation would be somewhat surprising. 
> > > 
> > > 
> > > 
> > > 
> > > 
> > So you are suggesting to revert the change to this line, right?
> Yes, if you agree with my reasoning.
> 
I generally agree that the working bitcode files are orthogonal to the directory structure. However I would argue that there won't be a real world scenario of an empty directory called `nvvm/libdevice` without any libdevice files in there. That said it probably doesn't make a difference, so I'll follow the separation of concerns.


https://reviews.llvm.org/D42642





More information about the cfe-commits mailing list