/// <summary> /// Loads an auto grouped kernel on the current accelerator. /// </summary> /// <param name="kernel">The compiled kernel to load.</param> /// <param name="kernelInfo">The resolved kernel information.</param> /// <returns>The loaded kernel.</returns> protected sealed override Kernel LoadAutoGroupedKernelInternal( CompiledKernel kernel, out KernelInfo kernelInfo) { if (kernel == null) { throw new ArgumentNullException(nameof(kernel)); } if (!(kernel is TCompiledKernel compiledKernel)) { throw new NotSupportedException(RuntimeErrorMessages.NotSupportedKernel); } if (kernel.EntryPoint.IsExplicitlyGrouped) { throw new NotSupportedException( RuntimeErrorMessages.NotSupportedExplicitlyGroupedKernel); } var result = CreateKernel(compiledKernel); int groupSize = EstimateGroupSizeInternal(result, 0, 0, out int minGridSize); result.Launcher = GenerateKernelLauncherMethod(compiledKernel, groupSize); kernelInfo = KernelInfo.CreateFrom( kernel.Info, groupSize, minGridSize); return(result); }
/// <summary> /// Loads an implicitly grouped kernel on the current accelerator. /// </summary> /// <param name="kernel">The compiled kernel to load.</param> /// <param name="customGroupSize">The user-defined group size.</param> /// <param name="kernelInfo">The resolved kernel information.</param> /// <returns>The loaded kernel.</returns> protected sealed override Kernel LoadImplicitlyGroupedKernelInternal( CompiledKernel kernel, int customGroupSize, out KernelInfo kernelInfo) { if (kernel == null) { throw new ArgumentNullException(nameof(kernel)); } if (customGroupSize < 0 || customGroupSize > MaxNumThreadsPerGroup) { throw new ArgumentOutOfRangeException(nameof(customGroupSize)); } if (!(kernel is TCompiledKernel compiledKernel)) { throw new NotSupportedException(RuntimeErrorMessages.NotSupportedKernel); } if (kernel.EntryPoint.IsExplicitlyGrouped) { throw new NotSupportedException( RuntimeErrorMessages.NotSupportedExplicitlyGroupedKernel); } kernelInfo = KernelInfo.CreateFrom( kernel.Info, customGroupSize, null); return(CreateKernel( compiledKernel, GenerateKernelLauncherMethod(compiledKernel, customGroupSize))); }
/// <summary> /// Loads an explicitly grouped kernel. /// </summary> public Kernel LoadKernel( Accelerator accelerator, CompiledKernel compiledKernel, out KernelInfo kernelInfo) { var kernel = accelerator.LoadKernel(compiledKernel); kernelInfo = KernelInfo.CreateFrom( compiledKernel.Info, null, null); return(kernel); }