extern internal static ComputeErrorCode GetKernelWorkGroupInfo( CLKernelHandle kernel, CLDeviceHandle device, ComputeKernelWorkGroupInfo param_name, IntPtr param_value_size, IntPtr param_value, out IntPtr param_value_size_ret);
/// <summary> /// Creates a kernel for every <c>kernel</c> function in program. /// </summary> /// <returns> The collection of created kernels. </returns> /// <remarks> kernels are not created for any <c>kernel</c> functions in program that do not have the same function definition across all devices for which a program executable has been successfully built. </remarks> public ICollection <IComputeKernel> CreateAllKernels(IComputeProgram program) { var kernels = new Collection <IComputeKernel>(); var error = OpenCL110.CreateKernelsInProgram( program.Handle, 0, null, out int kernelsCount); ComputeException.ThrowOnError(error); var kernelHandles = new CLKernelHandle[kernelsCount]; error = OpenCL110.CreateKernelsInProgram( program.Handle, kernelsCount, kernelHandles, out kernelsCount); ComputeException.ThrowOnError(error); for (int i = 0; i < kernelsCount; i++) { kernels.Add(CreateKernel(kernelHandles[i])); } return(kernels); }
public GPURadixSort( ComputeCommandQueue commandQue, ComputeContext context, ComputeDevice device ) { gpuConstants = new GPUConstants(); gpuConstants.L = radix_BitsL; gpuConstants.numGroupsPerBlock = NumGroupsPerBlock; gpuConstants.R = R; gpuConstants.numThreadsPerGroup = numThreadsPerBlock / NumGroupsPerBlock; gpuConstants.numThreadsPerBlock = numThreadsPerBlock; gpuConstants.numBlocks = numBlocks; gpuConstants.numRadices = num_Radices; gpuConstants.numRadicesPerBlock = num_Radices / numBlocks; gpuConstants.bitMask = BIT_MASK_START; counters.Initialize(); ComputeErrorCode error; cxGPUContext = context.Handle; cqCommandQueue = commandQue.Handle; _device = device.Handle; //Create a command queue, where all of the commands for execution will be added /*cqCommandQueue = CL10.CreateCommandQueue(cxGPUContext, _device, (CommandQueueProperties)0, out error); * CheckErr(error, "CL10.CreateCommandQueue");*/ string programSource = System.IO.File.ReadAllText(programPath); IntPtr[] progSize = new IntPtr[] { (IntPtr)programSource.Length }; string flags = "-cl-fast-relaxed-math"; ComputeProgram prog = new ComputeProgram(context, programSource); prog.Build(new List <ComputeDevice>() { device }, flags, null, IntPtr.Zero); if (prog.GetBuildStatus(device) != ComputeProgramBuildStatus.Success) { Debug.WriteLine(prog.GetBuildLog(device)); throw new ArgumentException("UNABLE to build programm"); } // ComputeProgram clProgramRadix = CL10.CreateProgramWithSource(cxGPUContext, 1, new[] { programSource },progSize, // out error); CLProgramHandle clProgramRadix = prog.Handle; ckSetupAndCount = CL10.CreateKernel(clProgramRadix, "SetupAndCount", out error); CheckErr(error, "CL10.CreateKernel"); ckSumIt = CL10.CreateKernel(clProgramRadix, "SumIt", out error); CheckErr(error, "CL10.CreateKernel"); ckReorderingKeysOnly = CL10.CreateKernel(clProgramRadix, "ReorderingKeysOnly", out error); CheckErr(error, "CL10.CreateKernel"); ckReorderingKeyValue = CL10.CreateKernel(clProgramRadix, "ReorderingKeyValue", out error); CheckErr(error, "CL10.CreateKernel"); }
internal ComputeKernel(CLKernelHandle handle, ComputeProgram program) { Handle = handle; SetID(Handle.Value); context = program.Context; functionName = GetStringInfo <CLKernelHandle, ComputeKernelInfo>(Handle, ComputeKernelInfo.FunctionName, CLInterface.CL12.GetKernelInfo); this.program = program; }
internal IComputeKernel CreateKernel(CLKernelHandle handle) { var kernel = new ComputeKernel110(); kernel.Handle = handle; kernel.SetID(kernel.Handle.Value); kernel.FunctionName = kernel.GetStringInfo(kernel.Handle, ComputeKernelInfo.FunctionName, OpenCL110.GetKernelInfoWrapper); logger.Info("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); return(kernel); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Initializes a new instance of the Cloo.ComputeKernel class. </summary> /// /// <param name="handle"> The handle of the <see cref="ComputeKernel"/>. </param> /// <param name="program"> Gets the <see cref="ComputeProgram"/> that the /// <see cref="ComputeKernel"/> belongs to. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// internal ComputeKernel(CLKernelHandle handle, ComputeProgram program) { Handle = handle; SetID(Handle.Value); context = program.Context; functionName = GetStringInfo <CLKernelHandle, ComputeKernelInfo>(Handle, ComputeKernelInfo.FunctionName, CL12.GetKernelInfo); this.program = program; Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Initializes a new instance of the Cloo.ComputeKernel class. </summary> /// /// <param name="handle"> The handle of the <see cref="ComputeKernel"/>. </param> /// <param name="program"> Gets the <see cref="ComputeProgram"/> that the /// <see cref="ComputeKernel"/> belongs to. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// internal ComputeKernel(CLKernelHandle handle, ComputeProgram program) { Handle = handle; SetID(Handle.Value); context = program.Context; functionName = GetStringInfo <CLKernelHandle, ComputeKernelInfo>(Handle, ComputeKernelInfo.FunctionName, CL12.GetKernelInfo); this.program = program; RILogManager.Default?.SendTrace(string.Intern("Create ") + this + string.Intern(" in Thread(") + Thread.CurrentThread.ManagedThreadId + string.Intern(")."), string.Intern("Information")); }
/// <summary> /// Creates a kernel for every <c>kernel</c> function in program. /// </summary> /// <returns> The collection of created kernels. </returns> /// <remarks> kernels are not created for any <c>kernel</c> functions in program that do not have the same function definition across all devices for which a program executable has been successfully built. </remarks> public ICollection <IComputeKernel> CreateAllKernels(IComputeProgram program) { var kernels = new Collection <IComputeKernel>(); OpenCL110.CreateKernelsInProgramWrapper(program.Handle, 0, null, out int kernelsCount); var kernelHandles = new CLKernelHandle[kernelsCount]; OpenCL110.CreateKernelsInProgramWrapper(program.Handle, kernelsCount, kernelHandles, out kernelsCount); for (int i = 0; i < kernelsCount; i++) { kernels.Add(CreateKernel(kernelHandles[i])); } return(kernels); }
internal ComputeKernel(string functionName, ComputeProgram program) { ComputeErrorCode error = ComputeErrorCode.Success; Handle = CL10.CreateKernel(program.Handle, functionName, out error); ComputeException.ThrowOnError(error); SetID(Handle.Value); context = program.Context; this.functionName = functionName; this.program = program; #if DEBUG Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); #endif }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a <see cref="ComputeKernel"/> for every <c>kernel</c> function in /// <see cref="ComputeProgram"/>. /// </summary> /// /// <remarks> /// <see cref="ComputeKernel"/>s are not created for any <c>kernel</c> functions in /// <see cref="ComputeProgram"/> that do not have the same function definition across all /// <see cref="ComputeProgram.Devices"/> for which a program executable has been successfully /// built. /// </remarks> /// /// <returns> The collection of created <see cref="ComputeKernel"/>s. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// public ICollection <ComputeKernel> CreateAllKernels() { ICollection <ComputeKernel> kernels = new Collection <ComputeKernel>(); CLKernelHandle[] kernelHandles; ComputeErrorCode error = CL12.CreateKernelsInProgram(Handle, 0, null, out var kernelsCount); ComputeException.ThrowOnError(error); kernelHandles = new CLKernelHandle[kernelsCount]; error = CL12.CreateKernelsInProgram(Handle, kernelsCount, kernelHandles, out kernelsCount); ComputeException.ThrowOnError(error); for (int i = 0; i < kernelsCount; i++) { kernels.Add(new ComputeKernel(kernelHandles[i], this)); } return(kernels); }
extern internal static ComputeErrorCode GetKernelInfo( CLKernelHandle kernel, ComputeKernelInfo param_name, IntPtr param_value_size, IntPtr param_value, out IntPtr param_value_size_ret);
extern internal static ComputeErrorCode ReleaseKernel(CLKernelHandle kernel);
extern internal static ComputeErrorCode SetKernelArg( CLKernelHandle kernel, Int32 arg_index, IntPtr arg_size, IntPtr arg_value);