public static MemoryBuffer Copy <T>(CLAPI instance, MemoryBuffer input) where T : struct { CLKernel k = null; if (CopyKernels.ContainsKey(instance)) { k = CopyKernels[instance]; } else { string clt = KernelParameter.GetDataString(KernelParameter.GetEnumFromType(typeof(T))); string src = COPY_KERNEL_SOURCE.Replace("__TYPE__", clt); CLProgram.TryBuildProgram(instance, src, "internal_copy_kernel.cl", out CLProgram prog); k = prog.ContainedKernels["copy"]; CopyKernels[instance] = k; } MemoryBuffer mb = CreateEmpty <T>( instance, ( int )input.Size, input.Flags, "CopyOf:" + input, true ); k.SetBuffer(0, mb); k.SetBuffer(1, input); Run(instance, k, ( int )mb.Size); return(mb); }
/// <summary> /// Runs a kernel with a valid FL kernel signature /// </summary> /// <param name="instance">CLAPI Instance for the current thread</param> /// <param name="kernel">The CLKernel to be executed</param> /// <param name="image">The image buffer that serves as input</param> /// <param name="dimensions">The dimensions of the input buffer</param> /// <param name="genTypeMaxVal">The max valuee of the generic type that is used.(byte = 255)</param> /// <param name="enabledChannels">The enabled channels for the kernel</param> /// <param name="channelCount">The amount of active channels.</param> public static void Run( CLAPI instance, CLKernel kernel, MemoryBuffer image, int3 dimensions, float genTypeMaxVal, MemoryBuffer enabledChannels, int channelCount) { kernel.Run(instance.commandQueue, image, dimensions, genTypeMaxVal, enabledChannels, channelCount); }
/// <summary> /// Tries to get the CLKernel by the specified name /// </summary> /// <param name="name">The name of the kernel</param> /// <param name="kernel">The kernel. Null if not found</param> /// <returns>Returns True if the kernel has been found</returns> public bool TryGetClKernel(string name, out CLKernel kernel) { if (loadedKernels.ContainsKey(name)) { kernel = loadedKernels[name]; return(true); } kernel = null; return(false); }
public static void Run(CLAPI instance, CLKernel kernel, int groupSize) { kernel.Run(instance.commandQueue, 1, groupSize); }
public CLProgram GetProgram(CLKernel containingKernel) { return(loadedPrograms.First(x => x.ContainedKernels.ContainsValue(containingKernel))); }