Beispiel #1
0
        internal JitResult(JitCompiler compiler, String ptx, CUjit_result result)
        {
            var log = Traces.Jit.Info;
            log.EnsureBlankLine();

            CompilationTarget = compiler.Target;
            CompilationOptimizationLevel = compiler.OptimizationLevel;
            CompilationTuning = compiler.Tuning;
            CompilationWallTime = result.WallTime;
            CompilationInfoLog = result.InfoLog == String.Empty ? null : result.InfoLog;
            if (CompilationInfoLog != null) log.WriteLine(CompilationInfoLog);
            CompilationErrorLog = result.ErrorLog == String.Empty ? null : result.ErrorLog;

            Ptx = ptx;
            ErrorCode = (CudaError)result.ErrorCode;

            if (ErrorCode == CudaError.Success)
            {
                Module = new JittedModule(this, result.Module);
                log.WriteLine("JIT compilation succeeded in {0} and produced {1}." , CompilationWallTime, Module);

                log.EnsureBlankLine();
                log.WriteLine("Loading entry points of {0}...", Module);
                Module.Functions.ForEach(function =>
                {
                    log.WriteLine("Found entry point {0}...", function.Name);
                    log.WriteLine("Successfully resolved it as {0}.", function.Handle);
                    log.WriteLine("    Max threads per block        : {0}", function.MaxThreadsPerBlock);
                    log.WriteLine("    Shared memory requirements   : {0} bytes", function.SharedSizeBytes);
                    log.WriteLine("    Constant memory requirements : {0} bytes", function.ConstSizeBytes);
                    log.WriteLine("    Local memory requirements    : {0} bytes", function.LocalSizeBytes);
                    log.WriteLine("    Register memory requirements : {0} registers", function.NumRegs);
                    log.WriteLine("    PTX version                  : {0}", function.PtxVersion);
                    log.WriteLine("    Binary version               : {0}", function.BinaryVersion);
                });
            }
            else
            {
                log.WriteLine("JIT compilation failed in {0}." + Environment.NewLine, CompilationWallTime);
                throw new JitException(this);
            }
        }
Beispiel #2
0
        public static CUjit_result cuModuleLoadDataEx(IntPtr image, CUjit_options options)
        {
            return Wrap(() =>
            {
                try
                {
                    // todo. an attempt to pass the Target value directly leads to CUDA_ERROR_INVALID_VALUE
                    // as of now, this feature is not really important, so I'm marking it as TBI
                    options.TargetFromContext.AssertTrue();

                    using (var native_options = new nativeModuleLoadDataExOptions(options))
                    {
                        CUmodule module;
                        var error = nativeModuleLoadDataEx(out module, image, native_options.Count, native_options.Keys, native_options.Values);

                        var result = new CUjit_result();
                        result.ErrorCode = error;
                        result.Module = module;
                        result.WallTime = native_options.WallTime;
                        result.InfoLog = native_options.InfoLog;
                        result.ErrorLog = native_options.ErrorLog;
                        return result;
                    }
                }
                catch (CudaException)
                {
                    throw;
                }
                catch (DllNotFoundException dnfe)
                {
                    throw new CudaException(CudaError.NoDriver, dnfe);
                }
                catch (Exception e)
                {
                    throw new CudaException(CudaError.Unknown, e);
                }
            });
        }