Paste: opencl
Author: | erikc |
Mode: | factor |
Date: | Mon, 1 Mar 2010 09:53:02 |
Plain Text |
STRING: kernel-source2
__kernel square(
__global float* input,
__global float* output,
const unsigned int count,
const float addit)
{
int i = get_global_id(0);
if (i < count)
output[i] = input[i] * input[i] + addit ;
}
;
:: opencl-demo2 ( -- result )
[
platforms first devices>> first :> device
device 1array <context> &dispose :> context
context device f f <command-queue> &dispose :> queue
device "" context kernel-source2 1array sources>program &dispose :> program
program "square" <kernel> &dispose :> kernel
context read-access 16 float-array{ 1.0 2.0 3.0 4.0 } <buffer> &dispose :> in-data
context write-access 16 f <buffer> &dispose :> out-data
kernel 0 in-data set-kernel-arg-buffer
kernel 1 out-data set-kernel-arg-buffer
kernel 2 4 <uint> set-kernel-arg-data
kernel 3 9.5 <float> set-kernel-arg-data
queue kernel { 4 } [ ] enqueue-kernel &dispose :> event
queue flush-queue
event wait-event
queue out-data 0 buffer-ptr boa 16 read-buffer 4 <direct-float-array>
] with-destructors ;
New Annotation