public static void detectPlatform() { Type t = Type.GetType ("Mono.Runtime"); if (t != null) sysPlatform = ePlatform.MONO; return; }
/// <summary> /// Initializes a new instance of the <see cref="CompilerOptions"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="compilerPath">The compiler path.</param> /// <param name="includeDirectory">The include directory.</param> /// <param name="compilerVersion">Compiler/toolkit version (e.g. CUDA V5.0).</param> protected CompilerOptions(string name, string compilerPath, string includeDirectory, Version compilerVersion, ePlatform platform ) { _options = new List<string>(); _sources = new List<string>(); _outputs = new List<string>(); Name = name; CompilerPath = compilerPath; //Directory = string.Empty; Include = includeDirectory; GenerateDebugInfo = false; Version = compilerVersion; Platform = platform; CompileMode = eCudafyCompileMode.Default; }
/// <summary> /// Initializes a new instance of the <see cref="NvccCompilerOptions"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="compiler">The compiler.</param> /// <param name="includeDirectory">The include directory.</param> /// <param name="compilerVersion">Compiler/toolkit version (e.g. CUDA V5.0).</param> public NvccCompilerOptions(string name, string compiler, string includeDirectory, Version compilerVersion, ePlatform platform) : base(name, compiler, includeDirectory, compilerVersion, platform) { }
private PlatformID (ePlatform _platform, string _identifier) { // Initialize Platform = _platform; Value = _identifier; }
internal void StorePTXFile(string sourceCodeFileId, ePlatform platform, eArchitecture arch, string path) { using (StreamReader sr = File.OpenText(path)) { string ptx = sr.ReadToEnd(); _PTXModules.Add(new PTXModule() { Platform = platform, PTX = ptx, Architecture = arch, SourceCodeID = sourceCodeFileId }); } }
///// <summary> ///// Determines whether module has binary for the specified platform. ///// </summary> ///// <param name="platform">The platform.</param> ///// <returns> ///// <c>true</c> if module has binary for the specified platform; otherwise, <c>false</c>. ///// </returns> //public bool HasBinaryForPlatform(ePlatform platform) //{ // return _BinaryModules.Count(b => b.Platform == platform) > 0; //} /// <summary> /// Determines whether module has binary for the specified platform and architecture. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The architecture.</param> /// <returns> /// <c>true</c> if module has binary for the specified platform and architecture; otherwise, <c>false</c>. /// </returns> public bool HasBinaryForPlatform(ePlatform platform, eArchitecture arch) { ePlatform currPlatform = platform == ePlatform.Auto ? CurrentPlatform : platform; return _BinaryModules.Count(b => b.Platform == currPlatform && b.Architecture == arch) > 0; }
/// <summary> /// Determines whether module has PTX or binary for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The architecture.</param> /// <returns> /// <c>true</c> if module has module for the specified values; otherwise, <c>false</c>. /// </returns> public bool HasProgramModuleForPlatform(ePlatform platform, eArchitecture arch) { return HasPTXForPlatform(platform, arch) || HasBinaryForPlatform(platform, arch); }
/// <summary> /// Verifies the checksums of all functions, constants and types. /// </summary> /// <param name="platform">Platform.</param> /// <param name="arch">Architecture.</param> /// <returns>True if checksums match and total number of members is greater than one, else false.</returns> public bool TryVerifyChecksums(ePlatform platform, eArchitecture arch) { if (GetTotalMembers() == 0) return false; if (arch != eArchitecture.Unknown && !HasProgramModuleForPlatform(platform, arch)) return false; foreach (var kvp in Functions) if (kvp.Value.TryVerifyChecksums() == false) return false; foreach (var kvp in Constants) if (kvp.Value.TryVerifyChecksums() == false) return false; foreach (var kvp in Types) if (kvp.Value.TryVerifyChecksums() == false) return false; return true; }
public static CompileProperties Create(ePlatform platform = ePlatform.Auto, eArchitecture arch = eArchitecture.sm_13, eCudafyCompileMode mode = eCudafyCompileMode.Default, string workingDir = null, bool debugInfo = false) { CompileProperties tp = new CompileProperties(); eLanguage language = GetLanguage(arch); if (language == eLanguage.Cuda) { // Get ProgramFiles directory and CUDA directories // Get architecture string progFiles = null; switch (platform) { case ePlatform.x64: progFiles = Utility.ProgramFilesx64(); break; case ePlatform.x86: progFiles = Utility.ProgramFilesx86(); break; default: progFiles = Utility.ProgramFiles(); if (platform == ePlatform.Auto) platform = IntPtr.Size == 4 ? ePlatform.x86 : ePlatform.x64; break; } string toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; Version selVer; string cvStr = GetCudaVersion(toolkitbasedir, out selVer); if (string.IsNullOrEmpty(cvStr)) throw new CudafyCompileException(CudafyCompileException.csCUDA_DIR_NOT_FOUND); string gpuToolKit = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT + cvStr; tp.CompilerPath = gpuToolKit + Path.DirectorySeparatorChar + @"bin" + Path.DirectorySeparatorChar + csNVCC; tp.IncludeDirectoryPath = gpuToolKit + Path.DirectorySeparatorChar + @"include"; tp.Architecture = (arch == eArchitecture.Unknown) ? eArchitecture.sm_13 : arch; bool binary = ((mode & eCudafyCompileMode.Binary) == eCudafyCompileMode.Binary); string tempFileName = "CUDAFYSOURCETEMP.tmp"; string cuFileName = tempFileName.Replace(".tmp", ".cu"); string outputFileName = tempFileName.Replace(".tmp", binary ? ".cubin" : ".ptx"); tp.InputFile = cuFileName; tp.OutputFile = outputFileName; if ((mode & eCudafyCompileMode.DynamicParallelism) == eCudafyCompileMode.DynamicParallelism) { tp.AdditionalInputArgs = "cudadevrt.lib cublas_device.lib -dlink"; } } else { mode = eCudafyCompileMode.TranslateOnly; tp.Architecture = (arch == eArchitecture.Unknown) ? eArchitecture.OpenCL : arch; } tp.WorkingDirectory = Directory.Exists(workingDir) ? workingDir : Environment.CurrentDirectory; tp.Platform = platform; tp.CompileMode = mode; tp.GenerateDebugInfo = debugInfo; return tp; }
public int WGLoginOpt(ePlatform platform, int overtime) { return(AndroidConnector.LoginOpt((int)platform, overtime)); }
public void WGLogin(ePlatform platform) { AndroidConnector.Login((int)platform); }
public bool WGIsPlatformInstalled(ePlatform platform) { return(AndroidConnector.IsPlatformInstalled((int)platform)); }
public string WGGetPlatformAPPVersion(ePlatform platform) { return(AndroidConnector.GetPlatformAPPVersion((int)platform)); }
/// <summary> /// Cudafies the specified types for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The CUDA or OpenCL architecture.</param> /// <param name="types">The types.</param> /// <returns>A CudafyModule.</returns> public static CudafyModule Cudafy(ePlatform platform, eArchitecture arch, params Type[] types) { return(Cudafy(platform, arch, null, true, types)); }
/// <summary> /// Cudafies the specified types. Working directory will be as per CudafyTranslator.WorkingDirectory. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The CUDA or OpenCL architecture.</param> /// <param name="cudaVersion">The CUDA version. Specify null to automatically use the highest installed version.</param> /// <param name="compile">if set to <c>true</c> compile to PTX.</param> /// <param name="types">The types.</param> /// <returns>A CudafyModule.</returns> public static CudafyModule Cudafy(ePlatform platform, eArchitecture arch, Version cudaVersion, bool compile, params Type[] types) { var cp = CompilerHelper.Create(ePlatform.Auto, arch, eCudafyCompileMode.Default, WorkingDirectory, GenerateDebug); return(Cudafy(cp, types)); }
/// <summary> /// Cudafies the specified types. Working directory will be as per CudafyTranslator.WorkingDirectory. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The CUDA or OpenCL architecture.</param> /// <param name="cudaVersion">The CUDA version. Specify null to automatically use the highest installed version.</param> /// <param name="compile">if set to <c>true</c> compile to PTX.</param> /// <param name="types">The types.</param> /// <returns>A CudafyModule.</returns> public static CudafyModule Cudafy(ePlatform platform, eArchitecture arch, Version cudaVersion, bool compile, params Type[] types) { var cp = CompilerHelper.Create(ePlatform.Auto, arch, eCudafyCompileMode.Default, WorkingDirectory, GenerateDebug); if (!compile) cp.CompileMode = eCudafyCompileMode.TranslateOnly; return Cudafy(cp, types); }
/// <summary> /// Determines whether module has binary for the specified platform and architecture. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The architecture.</param> /// <returns> /// <c>true</c> if module has binary for the specified platform and an architecture equal or less than that specified; otherwise, <c>false</c>. /// </returns> public bool HasPTXForPlatform(ePlatform platform, eArchitecture arch) { return _PTXModules.Count(b => b.Platform == platform && b.Architecture <= arch) > 0; }
/// <summary> /// Determines whether module has PTX for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <returns> /// <c>true</c> if module has PTX for the specified platform; otherwise, <c>false</c>. /// </returns> public bool HasPTXForPlatform(ePlatform platform) { return _PTXModules.Count(ptx => ptx.Platform == platform) > 0; }
/// <summary> /// Determines whether module has PTX for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <returns> /// <c>true</c> if module has PTX for the specified platform; otherwise, <c>false</c>. /// </returns> public bool HasPTXForPlatform(ePlatform platform) { ePlatform currPlatform = platform == ePlatform.Auto ? CurrentPlatform : platform; return _PTXModules.Count(ptx => ptx.Platform == currPlatform) > 0; }
///// <summary> ///// Determines whether module has binary for the specified platform. ///// </summary> ///// <param name="platform">The platform.</param> ///// <returns> ///// <c>true</c> if module has binary for the specified platform; otherwise, <c>false</c>. ///// </returns> //public bool HasBinaryForPlatform(ePlatform platform) //{ // return _BinaryModules.Count(b => b.Platform == platform) > 0; //} /// <summary> /// Determines whether module has binary for the specified platform and architecture. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The architecture.</param> /// <returns> /// <c>true</c> if module has binary for the specified platform and architecture; otherwise, <c>false</c>. /// </returns> public bool HasBinaryForPlatform(ePlatform platform, eArchitecture arch) { return _BinaryModules.Count(b => b.Platform == platform && b.Architecture == arch) > 0; }
/// <summary> /// Determines whether module has PTX or binary for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <returns> /// <c>true</c> if module has module for the specified value; otherwise, <c>false</c>. /// </returns> public bool HasProgramModuleForPlatform(ePlatform platform) { return HasPTXForPlatform(platform) || HasBinaryForPlatform(platform); }
/// <summary> /// Determines whether module has binary for the specified platform and architecture. /// </summary> /// <param name="platform">The platform.</param> /// <returns> /// <c>true</c> if module has binary for the specified platform; otherwise, <c>false</c>. /// </returns> public bool HasBinaryForPlatform(ePlatform platform) { return _BinaryModules.Count(b => b.Platform == platform) > 0; }
/// <summary> /// Determines whether module has binary for the specified platform and architecture. /// </summary> /// <param name="platform">The platform.</param> /// <returns> /// <c>true</c> if module has binary for the specified platform; otherwise, <c>false</c>. /// </returns> public bool HasBinaryForPlatform(ePlatform platform) { ePlatform currPlatform = platform == ePlatform.Auto ? CurrentPlatform : platform; return _BinaryModules.Count(b => b.Platform == currPlatform) > 0; }
/// <summary> /// Cudafies for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The CUDA or OpenCL architecture.</param> /// <returns>A CudafyModule.</returns> public static CudafyModule Cudafy(ePlatform platform, eArchitecture arch) { StackTrace stackTrace = new StackTrace(); Type type = stackTrace.GetFrame(1).GetMethod().ReflectedType; CudafyModule km = CudafyModule.TryDeserialize(type.Name); if (km == null || !km.TryVerifyChecksums()) { km = Cudafy(platform, arch, type); km.Name = type.Name; km.TrySerialize(); } return km; }
internal void StoreBinaryFile(string sourceCodeFileId, ePlatform platform, eArchitecture arch, string path) { if(!File.Exists(path)) path = "a_dlink.cubin"; byte[] bytes = File.ReadAllBytes(path); _BinaryModules.Add(new BinaryModule() { Platform = platform, Binary = bytes, Architecture = arch, SourceCodeID = sourceCodeFileId }); }
/// <summary> /// Cudafies the specified types for the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The CUDA or OpenCL architecture.</param> /// <param name="types">The types.</param> /// <returns>A CudafyModule.</returns> public static CudafyModule Cudafy(ePlatform platform, eArchitecture arch, params Type[] types) { return Cudafy(platform, arch, null, true, types); }
/// <summary> /// Cudafies the specified types. Working directory will be as per CudafyTranslator.WorkingDirectory. /// </summary> /// <param name="platform">The platform.</param> /// <param name="arch">The CUDA or OpenCL architecture.</param> /// <param name="cudaVersion">The CUDA version. Specify null to automatically use the highest installed version.</param> /// <param name="compile">if set to <c>true</c> compile to PTX.</param> /// <param name="types">The types.</param> /// <returns>A CudafyModule.</returns> public static CudafyModule CudafyOld(ePlatform platform, eArchitecture arch, Version cudaVersion, bool compile, params Type[] types) { CudafyModule km = null; CUDALanguage.ComputeCapability = GetComputeCapability(arch); _architecture = arch; if (arch > eArchitecture.OpenCL) CudafyTranslator.Language = eLanguage.OpenCL; km = DoCudafy(null, types); if (km == null) throw new CudafyFatalException(CudafyFatalException.csUNEXPECTED_STATE_X, "CudafyModule km = null"); km.WorkingDirectory = WorkingDirectory; if (compile && LanguageSpecifics.Language == eLanguage.Cuda) { if (platform == ePlatform.Auto) platform = IntPtr.Size == 8 ? ePlatform.x64 : ePlatform.x86; if (platform != ePlatform.x86) km.CompilerOptionsList.Add(NvccCompilerOptions.Createx64(cudaVersion, arch)); if (platform != ePlatform.x64) km.CompilerOptionsList.Add(NvccCompilerOptions.Createx86(cudaVersion, arch)); km.GenerateDebug = GenerateDebug; km.TimeOut = TimeOut; km.Compile(eGPUCompiler.CudaNvcc, DeleteTempFiles); } Type lastType = types.Last(t => t != null); if(lastType != null) km.Name = lastType.Name; return km; }
public static CompileProperties Create(ePlatform platform = ePlatform.Auto, eArchitecture arch = eArchitecture.sm_20, eCudafyCompileMode mode = eCudafyCompileMode.Default, string workingDir = null, bool debugInfo = false) { CompileProperties tp = new CompileProperties(); eLanguage language = GetLanguage(arch); if (language == eLanguage.Cuda) { string progFiles = Utility.ProgramFiles(); tp.CompilerPath = NvccExe.getCompilerPath(); tp.IncludeDirectoryPath = NvccExe.getIncludePath(); tp.PathEnvVarExtraEntries = new string[ 1 ] { NvccExe.getClExeDirectory() }; tp.Architecture = (arch == eArchitecture.Unknown) ? eArchitecture.sm_20 : arch; bool binary = ((mode & eCudafyCompileMode.Binary) == eCudafyCompileMode.Binary); string tempFileName = "CUDAFYSOURCETEMP.tmp"; string cuFileName = tempFileName.Replace(".tmp", ".cu"); string outputFileName = tempFileName.Replace(".tmp", binary ? ".cubin" : ".ptx"); tp.InputFile = cuFileName; tp.OutputFile = outputFileName; if ((mode & eCudafyCompileMode.DynamicParallelism) == eCudafyCompileMode.DynamicParallelism) { tp.AdditionalInputArgs = "cudadevrt.lib cublas_device.lib -dlink"; } if (arch == eArchitecture.Emulator) mode = eCudafyCompileMode.TranslateOnly; } else { mode = eCudafyCompileMode.TranslateOnly; tp.Architecture = (arch == eArchitecture.Unknown) ? eArchitecture.OpenCL : arch; } tp.WorkingDirectory = Directory.Exists(workingDir) ? workingDir : Environment.CurrentDirectory; tp.Platform = platform; tp.CompileMode = mode; tp.GenerateDebugInfo = debugInfo; return tp; }
public static CompileProperties Create(ePlatform platform = ePlatform.Auto, eArchitecture arch = eArchitecture.sm_13, eCudafyCompileMode mode = eCudafyCompileMode.Default, string workingDir = null, bool debugInfo = false) { CompileProperties tp = new CompileProperties(); eLanguage language = GetLanguage(arch); if (language == eLanguage.Cuda) { // Get ProgramFiles directory and CUDA directories // Get architecture string progFiles = null; switch (platform) { case ePlatform.x64: progFiles = Utility.ProgramFilesx64(); break; case ePlatform.x86: progFiles = Utility.ProgramFilesx86(); break; default: progFiles = Utility.ProgramFiles(); if (platform == ePlatform.Auto) { platform = IntPtr.Size == 4 ? ePlatform.x86 : ePlatform.x64; } break; } string toolkitbasedir = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT; Version selVer; string cvStr = GetCudaVersion(toolkitbasedir, out selVer); if (string.IsNullOrEmpty(cvStr)) { throw new CudafyCompileException(CudafyCompileException.csCUDA_DIR_NOT_FOUND); } string gpuToolKit = progFiles + Path.DirectorySeparatorChar + csGPUTOOLKIT + cvStr; tp.CompilerPath = gpuToolKit + Path.DirectorySeparatorChar + @"bin" + Path.DirectorySeparatorChar + csNVCC; tp.IncludeDirectoryPath = gpuToolKit + Path.DirectorySeparatorChar + @"include"; tp.Architecture = (arch == eArchitecture.Unknown) ? eArchitecture.sm_13 : arch; bool binary = ((mode & eCudafyCompileMode.Binary) == eCudafyCompileMode.Binary); string tempFileName = "CUDAFYSOURCETEMP.tmp"; string cuFileName = tempFileName.Replace(".tmp", ".cu"); string outputFileName = tempFileName.Replace(".tmp", binary ? ".cubin" : ".ptx"); tp.InputFile = cuFileName; tp.OutputFile = outputFileName; if ((mode & eCudafyCompileMode.DynamicParallelism) == eCudafyCompileMode.DynamicParallelism) { tp.AdditionalInputArgs = "cudadevrt.lib cublas_device.lib -dlink"; } } else { mode = eCudafyCompileMode.TranslateOnly; tp.Architecture = (arch == eArchitecture.Unknown) ? eArchitecture.OpenCL : arch; } tp.WorkingDirectory = Directory.Exists(workingDir) ? workingDir : Environment.CurrentDirectory; tp.Platform = platform; tp.CompileMode = mode; tp.GenerateDebugInfo = debugInfo; return(tp); }