From 3106a340a01cf4a760d828e38d560ed6044e100a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 13 Oct 2020 14:17:00 +1000 Subject: [PATCH] clover: fix api zero sized enqueue Reviewed-by: Karol Herbst Part-of: --- src/gallium/frontends/clover/api/kernel.cpp | 3 --- src/gallium/frontends/clover/core/kernel.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gallium/frontends/clover/api/kernel.cpp b/src/gallium/frontends/clover/api/kernel.cpp index d172750481e..c937642fccf 100644 --- a/src/gallium/frontends/clover/api/kernel.cpp +++ b/src/gallium/frontends/clover/api/kernel.cpp @@ -271,9 +271,6 @@ namespace { if (dims < 1 || dims > q.device().max_block_size().size()) throw error(CL_INVALID_WORK_DIMENSION); - if (!d_grid_size || any_of(is_zero(), grid_size)) - throw error(CL_INVALID_GLOBAL_WORK_SIZE); - return grid_size; } diff --git a/src/gallium/frontends/clover/core/kernel.cpp b/src/gallium/frontends/clover/core/kernel.cpp index 5d8b0452563..894b3bfffe2 100644 --- a/src/gallium/frontends/clover/core/kernel.cpp +++ b/src/gallium/frontends/clover/core/kernel.cpp @@ -67,6 +67,10 @@ kernel::launch(command_queue &q, const auto m = program().build(q.device()).binary; const auto reduced_grid_size = map(divides(), grid_size, block_size); + + if (any_of(is_zero(), grid_size)) + return; + void *st = exec.bind(&q, grid_offset); struct pipe_grid_info info = {}; @@ -137,6 +141,9 @@ kernel::name() const { std::vector kernel::optimal_block_size(const command_queue &q, const std::vector &grid_size) const { + if (any_of(is_zero(), grid_size)) + return grid_size; + return factor::find_grid_optimal_factor( q.device().max_threads_per_block(), q.device().max_block_size(), grid_size);