summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-03-10 20:49:59 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-03-10 20:49:59 +0100
commitd754586b49c6af64e049b625060ef7be08fa5525 (patch)
tree4c59c32c41e7c2acb38dbe23ad740278c10cc1a2
parent92a657290a9ed470ab8b5e8fc895361b15b87995 (diff)
Added proper testing of the alpha parameter; finalized the batched AXPY implementation
-rw-r--r--CHANGELOG7
-rw-r--r--src/kernels/level1/xaxpy.opencl6
-rw-r--r--src/utilities/utilities.hpp2
-rw-r--r--test/routines/levelx/xaxpybatched.hpp19
4 files changed, 16 insertions, 18 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d5e0a2ba..254d6b7b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,13 +7,14 @@ Development version (next release)
- Fixed bugs in the half-precision routines HTBMV/HTPMV/HTRMV/HSYR2K/HTRMM
- Tests now also exit with an error code when OpenCL errors or compilation errors occur
- Tests now also check for the L2 error in case of half-precision
-- Added the OverrideParameters function to the API to be able to supply custom tuning parmeters
- Various minor fixes and enhancements
- Added tuned parameters for various devices (see README)
-- Added level-2 routines:
+- Added the OverrideParameters function to the API to be able to supply custom tuning parmeters
+- Added triangular solver (level-2 & level-3) routines:
* STRSV/DTRSV/CTRSV/ZTRSV (experimental, un-optimized)
-- Added level-3 routines:
* STRSM/DTRSM/CTRSM/ZTRSM (experimental, un-optimized)
+- Added batched (non-BLAS) routines:
+ * SAXPYBATCHED/DAXPYBATCHED/CAXPYBATCHED/ZAXPYBATCHED/HAXPYBATCHED (batched version of AXPY)
Version 0.10.0
- Updated to version 8.0 of the CLCudaAPI C++11 OpenCL header
diff --git a/src/kernels/level1/xaxpy.opencl b/src/kernels/level1/xaxpy.opencl
index 3f5ab2b5..f44bbce0 100644
--- a/src/kernels/level1/xaxpy.opencl
+++ b/src/kernels/level1/xaxpy.opencl
@@ -57,9 +57,9 @@ void XaxpyFast(const int n, const real_arg arg_alpha,
// Full version of the kernel with offsets and strided accesses: batched version
__kernel __attribute__((reqd_work_group_size(WGS, 1, 1)))
-void XaxpyBatched(const int n, const __global real_arg* arg_alphas,
- const __global real* restrict xgm, const __global int* restrict x_offsets, const int x_inc,
- __global real* ygm, const __global int* restrict y_offsets, const int y_inc) {
+void XaxpyBatched(const int n, const __constant real_arg* arg_alphas,
+ const __global real* restrict xgm, const __constant int* x_offsets, const int x_inc,
+ __global real* ygm, const __constant int* y_offsets, const int y_inc) {
const int batch = get_group_id(1);
const real alpha = GetRealArg(arg_alphas[batch]);
diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp
index d271ffee..b3db8c22 100644
--- a/src/utilities/utilities.hpp
+++ b/src/utilities/utilities.hpp
@@ -164,6 +164,8 @@ struct Arguments {
std::vector<size_t> a_offsets = {0};
std::vector<size_t> b_offsets = {0};
std::vector<size_t> c_offsets = {0};
+ std::vector<T> alphas = {ConstantOne<T>()};
+ std::vector<T> betas = {ConstantOne<T>()};
// Sizes
size_t x_size = 1;
size_t y_size = 1;
diff --git a/test/routines/levelx/xaxpybatched.hpp b/test/routines/levelx/xaxpybatched.hpp
index 8f6a5985..ee15ff92 100644
--- a/test/routines/levelx/xaxpybatched.hpp
+++ b/test/routines/levelx/xaxpybatched.hpp
@@ -46,11 +46,6 @@ class TestXaxpyBatched {
kArgBatchCount, kArgAlpha};
}
- // Helper to determine a different alpha value per batch
- static T GetAlpha(const T alpha_base, const size_t batch_id) {
- return alpha_base + Constant<T>(batch_id);
- }
-
// Helper for the sizes per batch
static size_t PerBatchSizeX(const Arguments<T> &args) { return args.n * args.x_inc; }
static size_t PerBatchSizeY(const Arguments<T> &args) { return args.n * args.y_inc; }
@@ -67,11 +62,15 @@ class TestXaxpyBatched {
static void SetSizes(Arguments<T> &args) {
args.x_size = GetSizeX(args);
args.y_size = GetSizeY(args);
+
+ // Also sets the batch-related variables
args.x_offsets = std::vector<size_t>(args.batch_count);
args.y_offsets = std::vector<size_t>(args.batch_count);
+ args.alphas = std::vector<T>(args.batch_count);
for (auto batch = size_t{0}; batch < args.batch_count; ++batch) {
args.x_offsets[batch] = batch * PerBatchSizeX(args) + args.x_offset;
args.y_offsets[batch] = batch * PerBatchSizeY(args) + args.y_offset;
+ args.alphas[batch] = args.alpha + Constant<T>(batch);
}
}
@@ -94,11 +93,7 @@ class TestXaxpyBatched {
static StatusCode RunRoutine(const Arguments<T> &args, Buffers<T> &buffers, Queue &queue) {
auto queue_plain = queue();
auto event = cl_event{};
- auto alphas = std::vector<T>();
- for (auto batch = size_t{0}; batch < args.batch_count; ++batch) {
- alphas.push_back(GetAlpha(args.alpha, batch));
- }
- auto status = AxpyBatched(args.n, alphas.data(),
+ auto status = AxpyBatched(args.n, args.alphas.data(),
buffers.x_vec(), args.x_offsets.data(), args.x_inc,
buffers.y_vec(), args.y_offsets.data(), args.y_inc,
args.batch_count,
@@ -113,7 +108,7 @@ class TestXaxpyBatched {
auto queue_plain = queue();
for (auto batch = size_t{0}; batch < args.batch_count; ++batch) {
auto event = cl_event{};
- auto status = clblasXaxpy(args.n, GetAlpha(args.alpha, batch),
+ auto status = clblasXaxpy(args.n, args.alphas[batch],
buffers.x_vec, args.x_offsets[batch], args.x_inc,
buffers.y_vec, args.y_offsets[batch], args.y_inc,
1, &queue_plain, 0, nullptr, &event);
@@ -134,7 +129,7 @@ class TestXaxpyBatched {
buffers.x_vec.Read(queue, args.x_size, x_vec_cpu);
buffers.y_vec.Read(queue, args.y_size, y_vec_cpu);
for (auto batch = size_t{0}; batch < args.batch_count; ++batch) {
- cblasXaxpy(args.n, GetAlpha(args.alpha, batch),
+ cblasXaxpy(args.n, args.alphas[batch],
x_vec_cpu, args.x_offsets[batch], args.x_inc,
y_vec_cpu, args.y_offsets[batch], args.y_inc);
}