AptypR

OpenCL Tutorial:N-Body Simulation

Discussion created by AptypR on Aug 8, 2010
Latest reply on Aug 15, 2010 by dar

I tried to compile example,given in this(http://browndeertechnology.com/docs/BDT_OpenCL_Tutorial_NBody.html) article,but i just got error nbody_output.c:14: error: invalid operands to binary + (have ‘cl_float4’ and ‘cl_float4&rsquo
nbody_output.c:16: error: invalid operands to binary / (have ‘cl_float4’ and ‘cl_float4&rsquo

nbody_output.c was changed a little,and now look like

 

/* nbody_output.c */ #include <stdio.h> #include <stdcl.h> void nbody_output( int n, cl_float4* pos ) { int i; cl_float4 ave_pos = (cl_float4){0.0f,0.0f,0.0f,0.0f}; for(i=0;i<n;i++) ave_pos+=pos[i]; ave_pos/=(cl_float4){n,n,n,n}; printf("ave_pos = {%e,%e,%e}\n", cl_float4_x(ave_pos),cl_float4_y(ave_pos),cl_float4_z(ave_pos) ); }

Outcomes