int _starpu_opencl_init_context(int devid) { #ifdef STARPU_SIMGRID int j; for (j = 0; j < STARPU_MAX_PIPELINE; j++) { task_finished[devid][j] = 0; STARPU_PTHREAD_MUTEX_INIT(&task_mutex[devid][j], NULL); STARPU_PTHREAD_COND_INIT(&task_cond[devid][j], NULL); } #else /* !STARPU_SIMGRID */ cl_int err; cl_uint uint; STARPU_PTHREAD_MUTEX_LOCK(&big_lock); _STARPU_DEBUG("Initialising context for dev %d\n", devid); // Create a compute context err = 0; contexts[devid] = clCreateContext(NULL, 1, &devices[devid], NULL, NULL, &err); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); err = clGetDeviceInfo(devices[devid], CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(uint), &uint, NULL); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); starpu_malloc_set_align(uint/8); // Create execution queue for the given device queues[devid] = clCreateCommandQueue(contexts[devid], devices[devid], 0, &err); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); // Create transfer queue for the given device cl_command_queue_properties props; err = clGetDeviceInfo(devices[devid], CL_DEVICE_QUEUE_PROPERTIES, sizeof(props), &props, NULL); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); props &= ~CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; in_transfer_queues[devid] = clCreateCommandQueue(contexts[devid], devices[devid], props, &err); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); out_transfer_queues[devid] = clCreateCommandQueue(contexts[devid], devices[devid], props, &err); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); peer_transfer_queues[devid] = clCreateCommandQueue(contexts[devid], devices[devid], props, &err); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); alloc_queues[devid] = clCreateCommandQueue(contexts[devid], devices[devid], 0, &err); if (STARPU_UNLIKELY(err != CL_SUCCESS)) STARPU_OPENCL_REPORT_ERROR(err); STARPU_PTHREAD_MUTEX_UNLOCK(&big_lock); #endif /* !STARPU_SIMGRID */ return 0; }
/* create a new copy of parameter == base */ static void *starpu_unistd_o_direct_plug(void *parameter, starpu_ssize_t size) { starpu_malloc_set_align(getpagesize()); return starpu_unistd_global_plug (parameter, size); }