summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-03-06 15:48:11 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2016-03-06 15:48:11 +0100
commit306bf67660da4f1adacaedf9066925240abf4ea9 (patch)
tree6f94fcd0d394e9874eaa24e637b7c56e0b2c8e0d /src
parent60da54da5d8cb8dc763c13ba48ec6d8e557a609d (diff)
Added preliminary support for xHPR2 and xSPR2 routines
Diffstat (limited to 'src')
-rw-r--r--src/clblast.cc54
-rw-r--r--src/kernels/level2/level2.opencl13
-rw-r--r--src/routines/level2/xhpr.cc3
-rw-r--r--src/routines/level2/xhpr2.cc53
-rw-r--r--src/routines/level2/xspr.cc3
-rw-r--r--src/routines/level2/xspr2.cc53
6 files changed, 160 insertions, 19 deletions
diff --git a/src/clblast.cc b/src/clblast.cc
index 6b8ac409..3695aa02 100644
--- a/src/clblast.cc
+++ b/src/clblast.cc
@@ -44,9 +44,11 @@
#include "internal/routines/level2/xher.h"
#include "internal/routines/level2/xhpr.h"
#include "internal/routines/level2/xher2.h"
+#include "internal/routines/level2/xhpr2.h"
#include "internal/routines/level2/xsyr.h"
#include "internal/routines/level2/xspr.h"
#include "internal/routines/level2/xsyr2.h"
+#include "internal/routines/level2/xspr2.h"
// BLAS level-3 includes
#include "internal/routines/level3/xgemm.h"
@@ -1052,14 +1054,24 @@ template StatusCode Her2<double2>(const Layout, const Triangle,
// Hermitian packed rank-2 matrix update: CHPR2/ZHPR2
template <typename T>
-StatusCode Hpr2(const Layout, const Triangle,
- const size_t,
- const T,
- const cl_mem, const size_t, const size_t,
- const cl_mem, const size_t, const size_t,
- cl_mem, const size_t,
- cl_command_queue*, cl_event*) {
- return StatusCode::kNotImplemented;
+StatusCode Hpr2(const Layout layout, const Triangle triangle,
+ const size_t n,
+ const T alpha,
+ const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
+ const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
+ cl_mem ap_buffer, const size_t ap_offset,
+ cl_command_queue* queue, cl_event* event) {
+ auto queue_cpp = Queue(*queue);
+ auto event_cpp = Event(*event);
+ auto routine = Xhpr2<T>(queue_cpp, event_cpp);
+ auto status = routine.SetUp();
+ if (status != StatusCode::kSuccess) { return status; }
+ return routine.DoHpr2(layout, triangle,
+ n,
+ alpha,
+ Buffer<T>(x_buffer), x_offset, x_inc,
+ Buffer<T>(y_buffer), y_offset, y_inc,
+ Buffer<T>(ap_buffer), ap_offset);
}
template StatusCode Hpr2<float2>(const Layout, const Triangle,
const size_t,
@@ -1178,14 +1190,24 @@ template StatusCode Syr2<double>(const Layout, const Triangle,
// Symmetric packed rank-2 matrix update: SSPR2/DSPR2
template <typename T>
-StatusCode Spr2(const Layout, const Triangle,
- const size_t,
- const T,
- const cl_mem, const size_t, const size_t,
- const cl_mem, const size_t, const size_t,
- cl_mem, const size_t,
- cl_command_queue*, cl_event*) {
- return StatusCode::kNotImplemented;
+StatusCode Spr2(const Layout layout, const Triangle triangle,
+ const size_t n,
+ const T alpha,
+ const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
+ const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
+ cl_mem ap_buffer, const size_t ap_offset,
+ cl_command_queue* queue, cl_event* event) {
+ auto queue_cpp = Queue(*queue);
+ auto event_cpp = Event(*event);
+ auto routine = Xspr2<T>(queue_cpp, event_cpp);
+ auto status = routine.SetUp();
+ if (status != StatusCode::kSuccess) { return status; }
+ return routine.DoSpr2(layout, triangle,
+ n,
+ alpha,
+ Buffer<T>(x_buffer), x_offset, x_inc,
+ Buffer<T>(y_buffer), y_offset, y_inc,
+ Buffer<T>(ap_buffer), ap_offset);
}
template StatusCode Spr2<float>(const Layout, const Triangle,
const size_t,
diff --git a/src/kernels/level2/level2.opencl b/src/kernels/level2/level2.opencl
index 1b0efeab..be979766 100644
--- a/src/kernels/level2/level2.opencl
+++ b/src/kernels/level2/level2.opencl
@@ -109,7 +109,18 @@ inline void MatrixUpdate2(const int id1, const int id2, const int max1, const in
// Bounds of a regular matrix
if (id1 < max1 && id2 < max2) {
- const int a_index = id2*a_ld + id1 + a_offset;
+ #if defined(ROUTINE_SPR2) || defined(ROUTINE_HPR2)
+ int a_index;
+ if (is_upper) {
+ a_index = (id1 <= id2) ? ((id2+1)*id2)/2 + id1 : ((id1+1)*id1)/2 + id2;
+ }
+ else {
+ a_index = (id1 >= id2) ? ((2*a_ld-(id2+1))*id2)/2 + id1 : ((2*a_ld-(id1+1))*id1)/2 + id2;
+ }
+ a_index += a_offset;
+ #else
+ const int a_index = id2*a_ld + id1 + a_offset;
+ #endif
// Loads the current value of the A matrix
const real avalue = agm[a_index];
diff --git a/src/routines/level2/xhpr.cc b/src/routines/level2/xhpr.cc
index 24d7ae95..b0cea72f 100644
--- a/src/routines/level2/xhpr.cc
+++ b/src/routines/level2/xhpr.cc
@@ -37,7 +37,8 @@ StatusCode Xhpr<T,U>::DoHpr(const Layout layout, const Triangle triangle,
// Specific Xhpr functionality is implemented in the kernel using defines
return DoHer(layout, triangle, n, alpha,
x_buffer, x_offset, x_inc,
- ap_buffer, ap_offset, n, true);
+ ap_buffer, ap_offset, n,
+ true); // packed matrix
}
// =================================================================================================
diff --git a/src/routines/level2/xhpr2.cc b/src/routines/level2/xhpr2.cc
new file mode 100644
index 00000000..ded35e53
--- /dev/null
+++ b/src/routines/level2/xhpr2.cc
@@ -0,0 +1,53 @@
+
+// =================================================================================================
+// 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 <www.cedricnugteren.nl>
+//
+// This file implements the Xhpr2 class (see the header for information about the class).
+//
+// =================================================================================================
+
+#include "internal/routines/level2/xhpr2.h"
+
+#include <string>
+
+namespace clblast {
+// =================================================================================================
+
+// Constructor: forwards to base class constructor
+template <typename T>
+Xhpr2<T>::Xhpr2(Queue &queue, Event &event, const std::string &name):
+ Xher2<T>(queue, event, name) {
+}
+
+// =================================================================================================
+
+// The main routine
+template <typename T>
+StatusCode Xhpr2<T>::DoHpr2(const Layout layout, const Triangle triangle,
+ const size_t n,
+ const T alpha,
+ const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc,
+ const Buffer<T> &y_buffer, const size_t y_offset, const size_t y_inc,
+ const Buffer<T> &ap_buffer, const size_t ap_offset) {
+
+ // Specific Xhpr2 functionality is implemented in the kernel using defines
+ return DoHer2(layout, triangle, n, alpha,
+ x_buffer, x_offset, x_inc,
+ y_buffer, y_offset, y_inc,
+ ap_buffer, ap_offset, n,
+ true); // packed matrix
+}
+
+// =================================================================================================
+
+// Compiles the templated class
+template class Xhpr2<float2>;
+template class Xhpr2<double2>;
+
+// =================================================================================================
+} // namespace clblast
diff --git a/src/routines/level2/xspr.cc b/src/routines/level2/xspr.cc
index 7ef41fba..2d998e0b 100644
--- a/src/routines/level2/xspr.cc
+++ b/src/routines/level2/xspr.cc
@@ -37,7 +37,8 @@ StatusCode Xspr<T>::DoSpr(const Layout layout, const Triangle triangle,
// Specific Xspr functionality is implemented in the kernel using defines
return DoHer(layout, triangle, n, alpha,
x_buffer, x_offset, x_inc,
- ap_buffer, ap_offset, n, true);
+ ap_buffer, ap_offset, n,
+ true); // packed matrix
}
// =================================================================================================
diff --git a/src/routines/level2/xspr2.cc b/src/routines/level2/xspr2.cc
new file mode 100644
index 00000000..fd5232da
--- /dev/null
+++ b/src/routines/level2/xspr2.cc
@@ -0,0 +1,53 @@
+
+// =================================================================================================
+// 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 <www.cedricnugteren.nl>
+//
+// This file implements the Xspr2 class (see the header for information about the class).
+//
+// =================================================================================================
+
+#include "internal/routines/level2/xspr2.h"
+
+#include <string>
+
+namespace clblast {
+// =================================================================================================
+
+// Constructor: forwards to base class constructor
+template <typename T>
+Xspr2<T>::Xspr2(Queue &queue, Event &event, const std::string &name):
+ Xher2<T>(queue, event, name) {
+}
+
+// =================================================================================================
+
+// The main routine
+template <typename T>
+StatusCode Xspr2<T>::DoSpr2(const Layout layout, const Triangle triangle,
+ const size_t n,
+ const T alpha,
+ const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc,
+ const Buffer<T> &y_buffer, const size_t y_offset, const size_t y_inc,
+ const Buffer<T> &ap_buffer, const size_t ap_offset) {
+
+ // Specific Xspr2 functionality is implemented in the kernel using defines
+ return DoHer2(layout, triangle, n, alpha,
+ x_buffer, x_offset, x_inc,
+ y_buffer, y_offset, y_inc,
+ ap_buffer, ap_offset, n,
+ true); // packed matrix
+}
+
+// =================================================================================================
+
+// Compiles the templated class
+template class Xspr2<float>;
+template class Xspr2<double>;
+
+// =================================================================================================
+} // namespace clblast