예제 #1
0
파일: CLAPI.cs 프로젝트: ByteChkR/VisCPU
        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);
        }
예제 #2
0
 /// <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);
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
파일: CLAPI.cs 프로젝트: ByteChkR/VisCPU
 public static void Run(CLAPI instance, CLKernel kernel, int groupSize)
 {
     kernel.Run(instance.commandQueue, 1, groupSize);
 }
예제 #5
0
 public CLProgram GetProgram(CLKernel containingKernel)
 {
     return(loadedPrograms.First(x => x.ContainedKernels.ContainsValue(containingKernel)));
 }