#include #include #include const char *kernel_code = "__kernel void multiply_by(__global int* A, const int c) {" " A[get_global_id(0)] = c * A[get_global_id(0)];" "}"; int factorial(int n) { return (n <= 1) ? 1 : n * factorial(n-1); } int main( void ) { // OpenCL related declarations cl_int err; cl_platform_id platform; cl_device_id device; cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; cl_context ctx; cl_program program; cl_command_queue queue; cl_event event = NULL; cl_kernel k_multiplyby; int i; // const size_t N = 1024; // vector size const int c_max = 5; // max value to iterate to const int coeff = factorial(c_max); int *A, *B, *C; // A is initial, B is result, C is expected result A = (int*) malloc(N * sizeof(*A)); B = (int*) malloc(N * sizeof(*B)); C = (int*) malloc(N * sizeof(*C)); for (i=0; i