#include "openCLshared.cvl" #include #include #include $input int NUM_DEVICES; $input int MAX_NUM_DEVICES; $assume 0 < NUM_DEVICES && NUM_DEVICES < MAX_NUM_DEVICES; //kernel void square(int workgroup, int global_id, int local_id, int* input, int* output, const unsigned int count) { //int i = get_global_id(0); int i = global_id; if (i < count) { output[i] = input[i] * input[i]; //printf("output[%d] is %d\n", i, output[i]); } } /* void workfunc(size_t local, size_t global, kernel param) { for(int i = local * param.workgroup; i < local * param.workgroup + local; i++) { param.local_id = i % local; param.global_id = i; //printf("My workgroup id is %d, my global id is %d, my local id is %d\n", param.workgroup, param.global_id, param.local_id); square(param.workgroup, param.global_id, param.local_id, param.input, param.output, param.count); } } */ int main(int argc, char** argv) { float data[DATA_SIZE]; // original data set given to device float results[DATA_SIZE]; // results returned from device unsigned int correct; // number of correct results returned size_t global; // global domain size for our calculation size_t local; // local domain size for our calculation cl_device_id device_id; // compute device id cl_context context; // compute context cl_command_queue commands; // compute command queue cl_program program; // compute program cl_kernel kernel; // compute kernel cl_mem input; // device memory used for the input array cl_mem output; // device memory used for the output array //replaces clGetDeviceIDs device_id = (cl_device_id)malloc(sizeof(_cl_device_id)); //grab the number after * from input devices->id = (int*)malloc(sizeof(int) * NUM_DEVICES); for(int i = 0; i < NUM_DEVICES; i++) { devices->id[i] = i; } free(devices->id); free(devices); return 0; }