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> /// Public constructor /// </summary> /// <param name="instance">CLAPI Instance for the current thread</param> /// <param name="folderName">Folder name where the kernels are located</param> /// <param name="genDataVectorType">The DataVectorTypes used to compile the FL Database</param> public KernelDatabase(DataVectorTypes genDataVectorType) : base( OpenCLDebugConfig.Settings, "DB" ) { GenDataType = KernelParameter.GetDataString(genDataVectorType); loadedPrograms = new List <CLProgram>(); loadedKernels = new Dictionary <string, CLKernel>(); }
/// <summary> /// Public constructor /// </summary> /// <param name="instance">CLAPI Instance for the current thread</param> /// <param name="folderName">Folder name where the kernels are located</param> /// <param name="genDataVectorType">The DataVectorTypes used to compile the FL Database</param> public KernelDatabase(CLAPI instance, string folderName, DataVectorTypes genDataVectorType) : base( OpenCLDebugConfig.Settings, "DB" ) { GenDataType = KernelParameter.GetDataString(genDataVectorType); loadedPrograms = new List <CLProgram>(); loadedKernels = new Dictionary <string, CLKernel>(); if (Directory.Exists(folderName)) { LoadFolder(instance, folderName); } }
public static string[] FindFunctions(string source, DataVectorTypes returnType, string[] prefixes) { return(FindFunctions(source, prefixes, KernelParameter.GetDataString(returnType))); }