From bacb5d2bb2ea7b141034878090aca850db8f9d00 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sat, 18 Jun 2016 18:16:14 +0200 Subject: Clean-up of the routine class, moved RunKernel to the routine/common file --- src/routines/common.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/routines/common.cc (limited to 'src/routines') diff --git a/src/routines/common.cc b/src/routines/common.cc new file mode 100644 index 00000000..561a1bd8 --- /dev/null +++ b/src/routines/common.cc @@ -0,0 +1,65 @@ + +// ================================================================================================= +// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This +// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- +// width of 100 characters per line. +// +// Author(s): +// Cedric Nugteren +// +// This file implements the common routine functions (see the header for more information). +// +// ================================================================================================= + +#include + +#include "internal/routines/common.h" + +namespace clblast { +// ================================================================================================= + +// Enqueues a kernel, waits for completion, and checks for errors +StatusCode RunKernel(Kernel &kernel, Queue &queue, const Device &device, + std::vector global, const std::vector &local, + EventPointer event, std::vector& waitForEvents) { + + // Tests for validity of the local thread sizes + if (local.size() > device.MaxWorkItemDimensions()) { + return StatusCode::kInvalidLocalNumDimensions; + } + const auto max_work_item_sizes = device.MaxWorkItemSizes(); + for (auto i=size_t{0}; i max_work_item_sizes[i]) { return StatusCode::kInvalidLocalThreadsDim; } + } + auto local_size = size_t{1}; + for (auto &item: local) { local_size *= item; } + if (local_size > device.MaxWorkGroupSize()) { return StatusCode::kInvalidLocalThreadsTotal; } + + // Make sure the global thread sizes are at least equal to the local sizes + for (auto i=size_t{0}; i global, const std::vector &local, + EventPointer event) { + auto emptyWaitingList = std::vector(); + return RunKernel(kernel, queue, device, global, local, event, emptyWaitingList); +} + +// ================================================================================================= +} // namespace clblast -- cgit v1.2.3