public void Run(IComputeContext context, TextWriter log) { try { log.Write("Creating command queue... "); var commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None); log.WriteLine("done."); log.Write("Generating data... "); int linearSize = 24; SysIntX2 rectSize = new SysIntX2(4, 6); SysIntX3 cubicSize = new SysIntX3(2, 3, 4); float[] linearIn = new float[linearSize]; float[] linearOut = new float[linearSize]; float[,] rectIn = new float[(int)rectSize.Y, (int)rectSize.X]; float[,] rectOut = new float[(int)rectSize.Y, (int)rectSize.X]; float[,,] cubicIn = new float[(int)cubicSize.Z, (int)cubicSize.Y, (int)cubicSize.X]; float[,,] cubicOut = new float[(int)cubicSize.Z, (int)cubicSize.Y, (int)cubicSize.X]; for (int i = 0; i < linearSize; i++) { linearIn[i] = i; } for (int i = 0; i < (int)rectSize.X; i++) { for (int j = 0; j < (int)rectSize.Y; j++) { rectIn[j, i] = (float)(rectSize.X.ToInt32() * j + i); } } for (int i = 0; i < (int)cubicSize.X; i++) { for (int j = 0; j < (int)cubicSize.Y; j++) { for (int k = 0; k < (int)cubicSize.Z; k++) { cubicIn[k, j, i] = (float)(k * cubicSize.Y.ToInt32() * cubicSize.X.ToInt32() + cubicSize.X.ToInt32() * j + i); } } } log.WriteLine("done."); log.Write("Creating buffer... "); var buffer = new ComputeBuffer <float>(context, ComputeMemoryFlags.ReadWrite, linearSize); log.WriteLine("done."); GC.Collect(); log.Write("Writing to buffer (linear)... "); commands.WriteToBuffer(linearIn, buffer, false, null); log.WriteLine("done."); log.Write("Reading from buffer (linear)... "); commands.ReadFromBuffer(buffer, ref linearOut, false, null); log.WriteLine("done."); GC.Collect(); commands.Finish(); log.Write("Comparing data... "); Compare(linearIn, linearOut); log.WriteLine("passed."); GC.Collect(); log.Write("Writing to buffer (rectangular)... "); commands.WriteToBuffer(rectIn, buffer, false, new SysIntX2(), new SysIntX2(), rectSize, null); log.WriteLine("done."); GC.Collect(); log.Write("Reading from buffer (rectangular)... "); commands.ReadFromBuffer(buffer, ref rectOut, false, new SysIntX2(), new SysIntX2(), rectSize, null); log.WriteLine("done."); GC.Collect(); commands.Finish(); log.Write("Comparing data... "); Compare(rectIn, rectOut); log.WriteLine("passed."); GC.Collect(); log.Write("Writing to buffer (cubic)... "); commands.WriteToBuffer(cubicIn, buffer, false, new SysIntX3(), new SysIntX3(), cubicSize, null); log.WriteLine("done."); GC.Collect(); log.Write("Reading from buffer (cubic)... "); commands.ReadFromBuffer(buffer, ref cubicOut, false, new SysIntX3(), new SysIntX3(), cubicSize, null); log.WriteLine("done."); GC.Collect(); commands.Finish(); log.Write("Comparing data... "); Compare(cubicIn, cubicOut); log.WriteLine("passed."); } catch (Exception e) { log.WriteLine(e.ToString()); } }
public extern static CLMemoryHandle CreateSubBuffer( CLMemoryHandle buffer, ComputeMemoryFlags flags, ComputeBufferCreateType buffer_create_type, ref SysIntX2 buffer_create_info, out ComputeErrorCode errcode_ret);
public CLMemoryHandle CreateSubBuffer(CLMemoryHandle buffer, ComputeMemoryFlags flags, ComputeBufferCreateType buffer_create_type, ref SysIntX2 buffer_create_info, out ComputeErrorCode errcode_ret) { throw new NotImplementedException(); }
public static extern CLMemoryHandle CreateSubBuffer( CLMemoryHandle buffer, ComputeMemoryFlags flags, ComputeBufferCreateType buffer_create_type, ref SysIntX2 buffer_create_info, out ComputeErrorCode errcode_ret);
public extern static CLMemoryHandle CreateSubBuffer( CLMemoryHandle buffer, OpenCLMemoryFlags flags, OpenCLBufferCreateType buffer_create_type, ref SysIntX2 buffer_create_info, out OpenCLErrorCode errcode_ret);
public new CLMemoryHandle CreateSubBuffer(CLMemoryHandle buffer, ComputeMemoryFlags flags, ComputeBufferCreateType buffer_create_type, ref SysIntX2 buffer_create_info, out ComputeErrorCode errcode_ret) { return StaticCreateSubBuffer(buffer, flags, buffer_create_type, ref buffer_create_info, out errcode_ret); }
CLMemoryHandle ICL11.CreateSubBuffer(CLMemoryHandle buffer, ComputeMemoryFlags flags, ComputeBufferCreateType buffer_create_type, ref SysIntX2 buffer_create_info, out ComputeErrorCode errcode_ret) { return(CreateSubBuffer(buffer, flags, buffer_create_type, ref buffer_create_info, out errcode_ret)); }