public override void Process() { Logger.Log(LogType.Log, $"Running CL Kernel: {Kernel.Name}", MIN_INSTRUCTION_SEVERITY); ArgumentResult[] results = new ArgumentResult[Arguments.Count]; Logger.Log(LogType.Log, $"[{Kernel.Name}]Computing Kernel Arguments", MIN_INSTRUCTION_SEVERITY); for (int i = 0; i < Arguments.Count; i++) { results[i] = Compute(Arguments[i]); } for (int i = 0; i < results.Length; i++) { Logger.Log(LogType.Log, $"[{Kernel.Name}]Setting Kernel Argument {Kernel.Parameter.First(x => x.Value.Id == i)}", MIN_INSTRUCTION_SEVERITY + 1); int kernelArgIndex = i + FL_HEADER_ARG_COUNT; ArgumentResult arg = results[i]; switch (arg.Type) { case FLInstructionArgumentType.Number: Kernel.SetArg(kernelArgIndex, arg.Value); //The Value is a Decimal break; case FLInstructionArgumentType.Buffer: FLBuffer bi = (FLBuffer)arg.Value; Logger.Log(LogType.Log, $"[{Kernel.Name}]Argument Buffer{bi.DefinedBufferName}", MIN_INSTRUCTION_SEVERITY + 2); Kernel.SetBuffer(kernelArgIndex, bi.Buffer); break; case FLInstructionArgumentType.Function: FLBuffer funcBuffer = (FLBuffer)arg.Value; Logger.Log(LogType.Log, $"[{Kernel.Name}]Argument Buffer{funcBuffer.DefinedBufferName}", MIN_INSTRUCTION_SEVERITY + 2); Kernel.SetBuffer(kernelArgIndex, funcBuffer.Buffer); break; default: throw new InvalidOperationException("Can not parse: " + arg.Value); } } CLAPI.Run(Root.Instance, Kernel, Root.ActiveBuffer.Buffer, Root.Dimensions, GenMaxSize, Root.ActiveChannelBuffer, 4); }
protected override void Arrange(byte[] newOrder) { MemoryBuffer newOrderBuffer = CLAPI.CreateBuffer(Root.Instance, newOrder, MemoryFlag.ReadOnly, "gpuarrange_neworder"); //Copy Active Buffer MemoryBuffer source = CLAPI.Copy <byte>(Root.Instance, Root.ActiveBuffer.Buffer); ArrangeKernel.SetBuffer(0, Root.ActiveBuffer.Buffer); ArrangeKernel.SetBuffer(1, source); ArrangeKernel.SetArg(2, Root.ActiveChannels.Length); ArrangeKernel.SetBuffer(3, newOrderBuffer); CLAPI.Run( Root.Instance, ArrangeKernel, (int)Root.ActiveBuffer.Size / Root.ActiveChannels .Length ); //Only iterating through the length as if it only has one channel. The cl kernel implementation will deal with that newOrderBuffer.Dispose(); source.Dispose(); }