Hello World
- htugrulbuyukisik
- 14 Nis 2017
- 1 dakikada okunur
New programming methods are not complete without a simplest traditional "hello world" output, are they? Here it is:
ClNumberCruncher cr = new ClNumberCruncher( AcceleratorType.GPU, @"
__kernel void hello(__global char * arr)
{
printf(""hello world"");
}
");
ClArray<byte> array = new ClArray<byte>(1000); // or new byte[1000], both works
array.compute(cr, 1, "hello", 1000, 100); // 1000 workitems, 100 per workgroup
this code fragment chooses all available GPUs in PC and pushes a byte array to all of them, computes(each workitem prints "hello world" on console) and then gets byte array results back to same array. Actually byte array is not changed in this example. The OpenCL kernel needs to alter it using "arr" parameter.
Comentarios