@@ -294,12 +294,23 @@ namespace detail {
294294
295295 void create_host_compute_task (int dimensions, range<3 > global_range, id<3 > global_offset, range<3 > granularity) {
296296 assert (task == nullptr );
297+ if (global_range.size () == 0 ) {
298+ // TODO this can be easily supported by not creating a task in case the execution range is empty
299+ throw std::runtime_error{" The execution range of distributed host tasks must have at least one item" };
300+ }
297301 task = detail::task::make_host_compute (
298302 tid, dimensions, global_range, global_offset, granularity, std::move (cgf), std::move (access_map), std::move (reductions));
299303 }
300304
301305 void create_device_compute_task (int dimensions, range<3 > global_range, id<3 > global_offset, range<3 > granularity, std::string debug_name) {
302306 assert (task == nullptr );
307+ if (global_range.size () == 0 ) {
308+ // TODO unless reductions are involved, this can be easily supported by not creating a task in case the execution range is empty.
309+ // Edge case: If the task includes reductions that specify property::reduction::initialize_to_identity, we need to create a task that sets
310+ // the buffer state to an empty pending_reduction_state in the graph_generator. This will cause a trivial reduction_command to be generated on
311+ // each node that reads from the reduction output buffer, initializing it to the identity value locally.
312+ throw std::runtime_error{" The execution range of device tasks must have at least one item" };
313+ }
303314 task = detail::task::make_device_compute (
304315 tid, dimensions, global_range, global_offset, granularity, std::move (cgf), std::move (access_map), std::move (reductions), std::move (debug_name));
305316 }
0 commit comments