Пример #1
0
        internal CudaKernel(
            CudaAccelerator accelerator,
            PTXCompiledKernel kernel,
            MethodInfo launcher)
            : base(accelerator, kernel, launcher)
        {
#if DEBUG
            var kernelLoaded = CurrentAPI.LoadModule(
                out modulePtr,
                kernel.PTXAssembly,
                out string errorLog);
            if (kernelLoaded != CudaError.CUDA_SUCCESS)
            {
                Debug.WriteLine("Kernel loading failed:");
                if (string.IsNullOrWhiteSpace(errorLog))
                {
                    Debug.WriteLine(">> No error information available");
                }
                else
                {
                    Debug.WriteLine(errorLog);
                }
            }
            CudaException.ThrowIfFailed(kernelLoaded);
#else
            CudaException.ThrowIfFailed(
                CurrentAPI.LoadModule(
                    out modulePtr,
                    kernel.PTXAssembly));
#endif
            CudaException.ThrowIfFailed(
                CurrentAPI.GetModuleFunction(
                    out functionPtr,
                    modulePtr,
                    PTXCompiledKernel.EntryName));
        }