| 729 | static thread_local host_exec_context_t host_exec_context; |
| 730 | |
| 731 | void host_kernel::execute(const compute_queue& cqueue, |
| 732 | const bool& is_cooperative, |
| 733 | const bool& wait_until_completion floor_unused /* will always wait anyways */, |
| 734 | const uint32_t& work_dim, |
| 735 | const uint3& global_work_size, |
| 736 | const uint3& local_work_size, |
| 737 | const vector<compute_kernel_arg>& args, |
| 738 | const vector<const compute_fence*>& wait_fences floor_unused, |
| 739 | const vector<compute_fence*>& signal_fences floor_unused, |
| 740 | const char* debug_label floor_unused, |
| 741 | kernel_completion_handler_f&& completion_handler) const { |
| 742 | // TODO: implement waiting for "wait_fences" and signaling "signal_fences" (for now, this is blocking anyways) |
| 743 | |
| 744 | // no cooperative support yet |
| 745 | if (is_cooperative) { |
| 746 | log_error("cooperative kernel execution is not supported for Host-Compute"); |
| 747 | return; |
| 748 | } |
| 749 | |
| 750 | // extract/handle kernel arguments |
| 751 | vector<const void*> vptr_args; |
| 752 | vector<unique_ptr<void*[]>> array_args; |
| 753 | vptr_args.reserve(args.size()); |
| 754 | for (const auto& arg : args) { |
| 755 | if (auto buf_ptr = get_if<const compute_buffer*>(&arg.var)) { |
| 756 | vptr_args.emplace_back(((const host_buffer*)(*buf_ptr))->get_host_buffer_ptr_with_sync()); |
| 757 | } else if (auto vec_buf_ptrs = get_if<const vector<compute_buffer*>*>(&arg.var)) { |
| 758 | auto arr_arg = make_unique<void*[]>((*vec_buf_ptrs)->size()); |
| 759 | auto arr_buf_ptr = arr_arg.get(); |
| 760 | for (const auto& buf : **vec_buf_ptrs) { |
| 761 | *arr_buf_ptr++ = (buf ? ((const host_buffer*)buf)->get_host_buffer_ptr_with_sync() : nullptr); |
| 762 | } |
| 763 | vptr_args.emplace_back(arr_arg.get()); |
| 764 | array_args.emplace_back(std::move(arr_arg)); |
| 765 | } else if (auto vec_buf_sptrs = get_if<const vector<shared_ptr<compute_buffer>>*>(&arg.var)) { |
| 766 | auto arr_arg = make_unique<void*[]>((*vec_buf_sptrs)->size()); |
| 767 | auto arr_buf_ptr = arr_arg.get(); |
| 768 | for (const auto& buf : **vec_buf_sptrs) { |
| 769 | *arr_buf_ptr++ = (buf ? ((const host_buffer*)buf.get())->get_host_buffer_ptr_with_sync() : nullptr); |
| 770 | } |
| 771 | vptr_args.emplace_back(arr_arg.get()); |
| 772 | array_args.emplace_back(std::move(arr_arg)); |
| 773 | } else if (auto img_ptr = get_if<const compute_image*>(&arg.var)) { |
| 774 | vptr_args.emplace_back(((const host_image*)(*img_ptr))->get_host_image_program_info_with_sync()); |
| 775 | } else if (auto vec_img_ptrs = get_if<const vector<compute_image*>*>(&arg.var); vec_img_ptrs && *vec_img_ptrs) { |
| 776 | auto arr_arg = make_unique<void*[]>((*vec_img_ptrs)->size()); |
| 777 | auto arr_img_ptr = arr_arg.get(); |
| 778 | for (const auto& img : **vec_img_ptrs) { |
| 779 | *arr_img_ptr++ = (img ? ((const host_image*)img)->get_host_image_program_info_with_sync() : nullptr); |
| 780 | } |
| 781 | vptr_args.emplace_back(arr_arg.get()); |
| 782 | array_args.emplace_back(std::move(arr_arg)); |
| 783 | } else if (auto vec_img_sptrs = get_if<const vector<shared_ptr<compute_image>>*>(&arg.var); vec_img_sptrs && *vec_img_sptrs) { |
| 784 | auto arr_arg = make_unique<void*[]>((*vec_img_sptrs)->size()); |
| 785 | auto arr_img_ptr = arr_arg.get(); |
| 786 | for (const auto& img : **vec_img_sptrs) { |
| 787 | *arr_img_ptr++ = (img ? ((const host_image*)img.get())->get_host_image_program_info_with_sync() : nullptr); |
| 788 | } |
no test coverage detected