static void Main(string[] args) { byte[] tempData = new byte[1000]; Random random = new Random(); random.NextBytes(tempData); byte[] output = new byte[1000]; DeviceGlobalMemory testIn = tempData; DeviceGlobalMemory testOut = output; Kernel kernel = Kernel.Create("run", File.ReadAllText(@"C:\Users\QuentinBrooks\Dropbox\Go AI\New C++ AI Build\C Sharp OpenCL Compile and Runner\Test.cl"), testIn, testOut); Event e = kernel.Execute(1000); kernel.CommandQueue.Finish(); UnmanagedReader reader = new UnmanagedReader(new DeviceBufferStream(testOut)); }
static void Main(string[] args) { DeviceGlobalMemory output = new Byte[4096]; DeviceGlobalMemory indeces = RandomArray(102400); DeviceGlobalMemory ops = new Byte[3072]; DeviceGlobalMemory data = RandomArray(1048576); Console.Write("Creating kernel..."); Kernel kernel = Kernel.Create("Kernel", File.ReadAllText("Test.c"), data, indeces, ops, output); Console.Write("Executing kernel..."); Event e = kernel.Execute(256, 256); kernel.CommandQueue.Finish(); Console.WriteLine("done, operation took {0}", Profiler.DurationSeconds(e)); UnmanagedReader reader = new UnmanagedReader(new DeviceBufferStream(output)); for (int i = 0; i < 256; i++) { if (i % 4 == 0) { Console.WriteLine(); } if (i % 16 == 0) { Console.WriteLine(); } Console.Write("{0}\t", reader.Read <Single>()); } }