summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2023-05-10 12:48:25 +0200
committerGitHub <noreply@github.com>2023-05-10 12:48:25 +0200
commitd94d086d6f92ff1f73bd2a8595a974f6802b3f24 (patch)
treec06a19431635f2477578199cf9d87ff8050b901a /src
parent4f24d927302078a416dea1bc29d714a95732b8e9 (diff)
TBMV/TPMV/TRSV: Use the minimum x buffer size for copying to a temp buffer (#461)
Diffstat (limited to 'src')
-rw-r--r--src/routines/level2/xtbmv.cpp5
-rw-r--r--src/routines/level2/xtpmv.cpp5
-rw-r--r--src/routines/level2/xtrsv.cpp2
3 files changed, 7 insertions, 5 deletions
diff --git a/src/routines/level2/xtbmv.cpp b/src/routines/level2/xtbmv.cpp
index 117d26e0..87053deb 100644
--- a/src/routines/level2/xtbmv.cpp
+++ b/src/routines/level2/xtbmv.cpp
@@ -36,8 +36,9 @@ void Xtbmv<T>::DoTbmv(const Layout layout, const Triangle triangle,
const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc) {
// Creates a copy of X: a temporary scratch buffer
- auto scratch_buffer = Buffer<T>(context_, n*x_inc + x_offset);
- x_buffer.CopyTo(queue_, n*x_inc + x_offset, scratch_buffer);
+ const auto x_size = (1 + (n - 1) * x_inc) + x_offset;
+ auto scratch_buffer = Buffer<T>(context_, x_size);
+ x_buffer.CopyTo(queue_, x_size, scratch_buffer);
// The data is either in the upper or lower triangle
size_t is_upper = ((triangle == Triangle::kUpper && layout != Layout::kRowMajor) ||
diff --git a/src/routines/level2/xtpmv.cpp b/src/routines/level2/xtpmv.cpp
index 00282378..2190a6f5 100644
--- a/src/routines/level2/xtpmv.cpp
+++ b/src/routines/level2/xtpmv.cpp
@@ -36,8 +36,9 @@ void Xtpmv<T>::DoTpmv(const Layout layout, const Triangle triangle,
const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc) {
// Creates a copy of X: a temporary scratch buffer
- auto scratch_buffer = Buffer<T>(context_, n*x_inc + x_offset);
- x_buffer.CopyTo(queue_, n*x_inc + x_offset, scratch_buffer);
+ const auto x_size = (1 + (n - 1) * x_inc) + x_offset;
+ auto scratch_buffer = Buffer<T>(context_, x_size);
+ x_buffer.CopyTo(queue_, x_size, scratch_buffer);
// The data is either in the upper or lower triangle
size_t is_upper = ((triangle == Triangle::kUpper && layout != Layout::kRowMajor) ||
diff --git a/src/routines/level2/xtrsv.cpp b/src/routines/level2/xtrsv.cpp
index 2a5a5664..b50b259b 100644
--- a/src/routines/level2/xtrsv.cpp
+++ b/src/routines/level2/xtrsv.cpp
@@ -99,7 +99,7 @@ void Xtrsv<T>::DoTrsv(const Layout layout, const Triangle triangle,
// TODO: Make x with 0 offset and unit increment by creating custom copy-to and copy-from kernels
const auto x_offset = b_offset;
const auto x_inc = b_inc;
- const auto x_size = n*x_inc + x_offset;
+ const auto x_size = (1 + (n - 1) * x_inc) + x_offset;
auto x_buffer = Buffer<T>(context_, x_size);
b_buffer.CopyTo(queue_, x_size, x_buffer);