@@ -12,8 +12,19 @@ internal static class NvccExe
1212 /// <remarks>Throws an exception if it's not installed.</remarks>
1313 static string getToolkitBaseDir ( )
1414 {
15- //Just for now
16- return @"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2" ;
15+ //Find Computing Toolkit in the default path
16+ string prFil = Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFiles ) ;
17+ prFil = Path . Combine ( prFil , @"NVIDIA GPU Computing Toolkit\CUDA" ) ;
18+
19+ if ( Directory . Exists ( prFil ) )
20+ {
21+ string [ ] ctDirs = Directory . GetDirectories ( prFil ) ;
22+ if ( ctDirs . Length > 0 )
23+ for ( int i = ctDirs . Length ; i > 0 ; i -- )
24+ return Path . Combine ( prFil , ctDirs [ i - 1 ] ) ;
25+ }
26+
27+ throw new CudafyCompileException ( "nVidia GPU Toolkit error: Computing Toolkit was not found" ) ;
1728 }
1829
1930
@@ -52,10 +63,15 @@ public static string getClExeDirectory()
5263
5364 string [ ] vsDirs = Directory . GetDirectories ( vsPath ) ;
5465
66+ string coVer = @"bin\Hostx64\x86" ;
67+ if ( Environment . Is64BitProcess )
68+ coVer = @"bin\Hostx64\x64" ;
69+
70+
5571 if ( vsDirs . Length > 0 )
5672 for ( int i = vsDirs . Length ; i > 0 ; i -- )
57- if ( File . Exists ( Path . Combine ( vsDirs [ i - 1 ] , @"bin\Hostx64\x64 \cl.exe") ) )
58- return Path . Combine ( vsDirs [ i - 1 ] , @"bin\Hostx64\x64" ) ;
73+ if ( File . Exists ( Path . Combine ( vsDirs [ i - 1 ] , coVer + @" \cl.exe") ) )
74+ return Path . Combine ( vsDirs [ i - 1 ] , coVer ) ;
5975
6076 //Traditional method of searching by the registry
6177 string [ ] versionsToTry = new string [ ] { "12.0" , "11.0" } ;
0 commit comments