Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Commit e7e9039

Browse files
committed
Find Computing Toolkit in default program files path
1 parent 9d711ae commit e7e9039

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Cudafy/Compilers/NvccExe.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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" };

CudafyByExample/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ static void Main(string[] args)
2323
CudafyModes.Target = eGPUType.Cuda; // To use OpenCL, change this enum
2424
CudafyModes.DeviceId = 0;
2525
CudafyTranslator.Language = CudafyModes.Target == eGPUType.OpenCL ? eLanguage.OpenCL : eLanguage.Cuda;
26+
27+
Console.WriteLine("===================================\n CudafyByExample\n Hybrid DSP Systems\nCopyright © Hybrid DSP Systems 2011\n===================================");
28+
Console.WriteLine("\n* VS 2019 & .NET 4.8\n* optimization by RapidDev\n");
29+
2630
try
2731
{
2832
int deviceCount = CudafyHost.GetDeviceCount(CudafyModes.Target);

0 commit comments

Comments
 (0)