summaryrefslogtreecommitdiff
path: root/src/routine.cc
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-05-01 14:03:37 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2016-05-01 14:03:37 +0200
commitbee2f943ec51a3482e89cf635a2d12b6b6d96b04 (patch)
treefc93c1bef6fa19846959e55685129f439e6cfce9 /src/routine.cc
parent9602c150aa3b7f0a392207bef8cbb6048b1da891 (diff)
Changed the index buffer of IxAMAX routines to unsigned int for proper buffersize checking
Diffstat (limited to 'src/routine.cc')
-rw-r--r--src/routine.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/routine.cc b/src/routine.cc
index 35d0653c..8fa4cc79 100644
--- a/src/routine.cc
+++ b/src/routine.cc
@@ -267,6 +267,19 @@ StatusCode Routine<T>::TestVectorDot(const size_t n, const Buffer<T> &buffer, co
return StatusCode::kSuccess;
}
+// Tests vector index for validity: checks for a valid increment, a valid OpenCL buffer, and for a
+// sufficient buffer size.
+template <typename T>
+StatusCode Routine<T>::TestVectorIndex(const size_t n, const Buffer<unsigned int> &buffer,
+ const size_t offset, const size_t data_size) {
+ try {
+ auto required_size = (n + offset)*data_size;
+ auto buffer_size = buffer.GetSize();
+ if (buffer_size < required_size) { return StatusCode::kInsufficientMemoryDot; }
+ } catch (...) { return StatusCode::kInvalidVectorDot; }
+ return StatusCode::kSuccess;
+}
+
// =================================================================================================
// Copies or transposes a matrix and pads/unpads it with zeros