/// <summary> /// Creates a compiler instance for creating 64-bit apps. /// </summary> /// <param name="cudaVersion">The cuda version or null for auto.</param> /// <param name="arch">Architecture.</param> /// <returns></returns> /// <exception cref="NotSupportedException">ProgramFilesx64 not found.</exception> public static NvccCompilerOptions Createx64(Version cudaVersion, eArchitecture arch) { string progFiles = Utility.ProgramFiles(); string toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; Version selVer; string cvStr = GetCudaVersion(cudaVersion, toolkitbasedir, out selVer); Debug.WriteLineIf(!string.IsNullOrEmpty(cvStr), "Compiler version: " + cvStr); string gpuToolKit = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT + cvStr;// cudaVersion; string compiler = gpuToolKit + Path.DirectorySeparatorChar + @"bin" + Path.DirectorySeparatorChar + csNVCC; string includeDir = gpuToolKit + Path.DirectorySeparatorChar + @"include"; NvccCompilerOptions opt = new NvccCompilerOptions("NVidia CC (x64)", compiler, includeDir, selVer, ePlatform.x64); if (!opt.TryTest()) { opt = new NvccCompilerOptions("NVidia CC (x64)", csNVCC, string.Empty, selVer, ePlatform.x64); //#if DEBUG // throw new CudafyCompileException("Test failed for NvccCompilerOptions for x64"); //#endif } opt.AddOption("-m64"); //opt.AddOption("-DCUDA_FORCE_API_VERSION=3010"); //For mixed bitness mode //if(Directory.Exists(@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include")) // opt.AddOption(@"-I""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"""); //else // opt.AddOption(@"-I""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include"""); opt.Platform = ePlatform.x64; AddArchOptions(opt, arch); return(opt); }
/// <summary> /// Creates a compiler instance for creating 32-bit apps. /// </summary> /// <param name="cudaVersion">The cuda version.</param> /// <param name="arch">Architecture.</param> /// <returns></returns> public static NvccCompilerOptions Createx86(Version cudaVersion, eArchitecture arch) { string progFiles = Utility.ProgramFiles(); string toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; Version selVer; string cvStr = GetCudaVersion(cudaVersion, toolkitbasedir, out selVer); if (string.IsNullOrEmpty(cvStr)) { progFiles = "C:\\Program Files"; toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; cvStr = GetCudaVersion(cudaVersion, toolkitbasedir); } Debug.WriteLineIf(!string.IsNullOrEmpty(cvStr), "Compiler version: " + cvStr); string gpuToolKit = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT + cvStr; string compiler = gpuToolKit + Path.DirectorySeparatorChar + @"bin" + Path.DirectorySeparatorChar + csNVCC; string includeDir = gpuToolKit + Path.DirectorySeparatorChar + @"include"; NvccCompilerOptions opt = new NvccCompilerOptions("NVidia CC (x86)", compiler, includeDir, selVer, ePlatform.x86); if (!opt.TryTest()) { opt = new NvccCompilerOptions("NVidia CC (x86)", csNVCC, string.Empty, selVer, ePlatform.x86); //#if DEBUG // throw new CudafyCompileException("Test failed for NvccCompilerOptions for x86"); //#endif } opt.AddOption("-m32"); opt.Platform = ePlatform.x86; AddArchOptions(opt, arch); return(opt); }
/// <summary> /// Creates a compiler instance for creating 64-bit apps. /// </summary> /// <param name="cudaVersion">The cuda version or null for auto.</param> /// <param name="arch">Architecture.</param> /// <returns></returns> /// <exception cref="NotSupportedException">ProgramFilesx64 not found.</exception> public static NvccCompilerOptions Createx64(Version cudaVersion, eArchitecture arch) { string progFiles = Utility.ProgramFiles(); string toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; Version selVer; string cvStr = GetCudaVersion(cudaVersion, toolkitbasedir, out selVer); Debug.WriteLineIf(!string.IsNullOrEmpty(cvStr), "Compiler version: " + cvStr); string gpuToolKit = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT + cvStr;// cudaVersion; string compiler = gpuToolKit + Path.DirectorySeparatorChar + @"bin" + Path.DirectorySeparatorChar + csNVCC; string includeDir = gpuToolKit + Path.DirectorySeparatorChar + @"include"; NvccCompilerOptions opt = new NvccCompilerOptions("NVidia CC (x64)", compiler, includeDir, selVer, ePlatform.x64); if (!opt.TryTest()) { opt = new NvccCompilerOptions("NVidia CC (x64)", csNVCC, string.Empty, selVer, ePlatform.x64); //#if DEBUG // throw new CudafyCompileException("Test failed for NvccCompilerOptions for x64"); //#endif } opt.AddOption("-m64"); //opt.AddOption("-DCUDA_FORCE_API_VERSION=3010"); //For mixed bitness mode //if(Directory.Exists(@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include")) // opt.AddOption(@"-I""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"""); //else // opt.AddOption(@"-I""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include"""); opt.Platform = ePlatform.x64; AddArchOptions(opt, arch); return opt; }
/// <summary> /// Creates a compiler instance for creating 32-bit apps. /// </summary> /// <param name="cudaVersion">The cuda version.</param> /// <param name="arch">Architecture.</param> /// <returns></returns> public static NvccCompilerOptions Createx86(Version cudaVersion, eArchitecture arch) { string progFiles = Utility.ProgramFiles(); string toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; Version selVer; string cvStr = GetCudaVersion(cudaVersion, toolkitbasedir, out selVer); if (string.IsNullOrEmpty(cvStr)) { progFiles = "C:\\Program Files"; toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; cvStr = GetCudaVersion(cudaVersion, toolkitbasedir); } Debug.WriteLineIf(!string.IsNullOrEmpty(cvStr), "Compiler version: " + cvStr); string gpuToolKit = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT + cvStr; string compiler = gpuToolKit + Path.DirectorySeparatorChar + @"bin" + Path.DirectorySeparatorChar + csNVCC; string includeDir = gpuToolKit + Path.DirectorySeparatorChar + @"include"; NvccCompilerOptions opt = new NvccCompilerOptions("NVidia CC (x86)", compiler, includeDir, selVer, ePlatform.x86); if (!opt.TryTest()) { opt = new NvccCompilerOptions("NVidia CC (x86)", csNVCC, string.Empty, selVer, ePlatform.x86); //#if DEBUG // throw new CudafyCompileException("Test failed for NvccCompilerOptions for x86"); //#endif } opt.AddOption("-m32"); opt.Platform = ePlatform.x86; AddArchOptions(opt, arch); return opt; }