Mercurial > hg > Game > Cerium
diff example/fft/gpu/spinFact.cc @ 1731:dc7dd1eaf6de draft
add file
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 31 Oct 2013 21:07:30 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/fft/gpu/spinFact.cc Thu Oct 31 21:07:30 2013 +0900 @@ -0,0 +1,32 @@ +#include <math.h> +#include "spinFact.h" +#ifdef __APPLE__ +#include <OpenCL/opencl.h> +#else +#include <CL/cl.h> +#endif +#include "Func.h" + +#define PI 3.14159265358979323846 +#define PI_2 1.57079632679489661923 + +SchedDefineTask1(spinFact,spinFact); + +static int +spinFact(SchedTask* s,void* rbuf,void* wbuf) +{ + cl_float2* w = (cl_float2*)s->get_outputAddr(0); + + unsigned long i = s->x; // (unsigned long)s->get_param(0); + + long n = (long)s->get_param(3); + + cl_float2 angle; + angle.x = (float)(2*i*PI/(float)n); + angle.y = (float)((2*i*PI/(float)n) + PI_2); + + w[i].x = cos(angle.x); + w[i].y = cos(angle.y); + + return 0; +}