| 3 | using namespace xsched::opencl; |
| 4 | |
| 5 | OpenclKernelCommand::OpenclKernelCommand(cl_kernel kernel, cl_uint work_dim, |
| 6 | const size_t *global_work_offset, |
| 7 | const size_t *global_work_size, |
| 8 | const size_t *local_work_size, |
| 9 | cl_uint num_events_in_wait_list, |
| 10 | const cl_event *event_wait_list, |
| 11 | cl_event *event, |
| 12 | size_t num_args, KernelArgument *args) |
| 13 | : kernel_(kernel), work_dim_(work_dim), |
| 14 | num_events_in_wait_list_(num_events_in_wait_list), event_wait_list_(event_wait_list), |
| 15 | event_(event), num_args_(num_args) |
| 16 | { |
| 17 | if (work_dim_ <= 0) return; |
| 18 | |
| 19 | const size_t buf_size = work_dim_ * sizeof(size_t); |
| 20 | global_work_size_ = (size_t *)malloc(buf_size); |
| 21 | memcpy(global_work_size_, global_work_size, buf_size); |
| 22 | |
| 23 | // local_work_size is optional and can be nullptr |
| 24 | if (local_work_size != nullptr) { |
| 25 | local_work_size_ = (size_t *)malloc(buf_size); |
| 26 | memcpy(local_work_size_, local_work_size, buf_size); |
| 27 | } |
| 28 | |
| 29 | // global_work_offset is optional and can be nullptr |
| 30 | if (global_work_offset != nullptr) { |
| 31 | global_work_offset_ = (size_t *)malloc(buf_size); |
| 32 | memcpy(global_work_offset_, global_work_offset, buf_size); |
| 33 | } |
| 34 | |
| 35 | if (num_args_ <= 0) return; |
| 36 | args_ = (KernelArgument *)malloc(num_args_ * sizeof(KernelArgument)); |
| 37 | for (size_t i = 0; i < num_args_; i++) { |
| 38 | args_[i].index = args[i].index; |
| 39 | args_[i].size = args[i].size; |
| 40 | args_[i].value = nullptr; |
| 41 | if (args[i].size == 0 || args[i].value == nullptr) continue; |
| 42 | args_[i].value = malloc(args[i].size); |
| 43 | memcpy(args_[i].value, args[i].value, args[i].size); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | OpenclKernelCommand::~OpenclKernelCommand() |
| 48 | { |
nothing calls this directly
no outgoing calls
no test coverage detected