diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2016-06-17 14:30:37 +0200 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2016-06-17 14:30:37 +0200 |
commit | f9947b4d7ffedcf98cdb128de835422f647e7f15 (patch) | |
tree | c42d427a23de5d14b3407943d529d18cd9e516f0 /src/routines/level1 | |
parent | 536b7fe4bce4b183cb060a1b9045752ae39d842f (diff) |
Removed the precision argument from the routines in favor of a single templated function
Diffstat (limited to 'src/routines/level1')
-rw-r--r-- | src/routines/level1/xamax.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xasum.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xaxpy.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xcopy.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xdot.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xnrm2.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xscal.cc | 13 | ||||
-rw-r--r-- | src/routines/level1/xswap.cc | 13 |
8 files changed, 16 insertions, 88 deletions
diff --git a/src/routines/level1/xamax.cc b/src/routines/level1/xamax.cc index 9e203d03..1a3441ef 100644 --- a/src/routines/level1/xamax.cc +++ b/src/routines/level1/xamax.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xamax<half>::precision_ = Precision::kHalf; -template <> const Precision Xamax<float>::precision_ = Precision::kSingle; -template <> const Precision Xamax<double>::precision_ = Precision::kDouble; -template <> const Precision Xamax<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xamax<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xamax<T>::Xamax(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xdot"}, precision_) { + Routine<T>(queue, event, name, {"Xdot"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/xamax.opencl" ; @@ -56,7 +47,7 @@ StatusCode Xamax<T>::DoAmax(const size_t n, // Retrieves the Xamax kernels from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel1 = Kernel(program, "Xamax"); auto kernel2 = Kernel(program, "XamaxEpilogue"); diff --git a/src/routines/level1/xasum.cc b/src/routines/level1/xasum.cc index f4d898be..85c6e1ed 100644 --- a/src/routines/level1/xasum.cc +++ b/src/routines/level1/xasum.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xasum<half>::precision_ = Precision::kHalf; -template <> const Precision Xasum<float>::precision_ = Precision::kSingle; -template <> const Precision Xasum<double>::precision_ = Precision::kDouble; -template <> const Precision Xasum<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xasum<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xasum<T>::Xasum(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xdot"}, precision_) { + Routine<T>(queue, event, name, {"Xdot"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/xasum.opencl" ; @@ -56,7 +47,7 @@ StatusCode Xasum<T>::DoAsum(const size_t n, // Retrieves the Xasum kernels from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel1 = Kernel(program, "Xasum"); auto kernel2 = Kernel(program, "XasumEpilogue"); diff --git a/src/routines/level1/xaxpy.cc b/src/routines/level1/xaxpy.cc index 221e1195..39121067 100644 --- a/src/routines/level1/xaxpy.cc +++ b/src/routines/level1/xaxpy.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xaxpy<half>::precision_ = Precision::kHalf; -template <> const Precision Xaxpy<float>::precision_ = Precision::kSingle; -template <> const Precision Xaxpy<double>::precision_ = Precision::kDouble; -template <> const Precision Xaxpy<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xaxpy<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xaxpy<T>::Xaxpy(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xaxpy"}, precision_) { + Routine<T>(queue, event, name, {"Xaxpy"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/level1.opencl" #include "../../kernels/level1/xaxpy.opencl" @@ -65,7 +56,7 @@ StatusCode Xaxpy<T>::DoAxpy(const size_t n, const T alpha, // Retrieves the Xaxpy kernel from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel = Kernel(program, kernel_name); // Upload the scalar argument as a constant buffer to the device (needed for half-precision) diff --git a/src/routines/level1/xcopy.cc b/src/routines/level1/xcopy.cc index 647a681a..d85efca3 100644 --- a/src/routines/level1/xcopy.cc +++ b/src/routines/level1/xcopy.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xcopy<half>::precision_ = Precision::kHalf; -template <> const Precision Xcopy<float>::precision_ = Precision::kSingle; -template <> const Precision Xcopy<double>::precision_ = Precision::kDouble; -template <> const Precision Xcopy<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xcopy<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xcopy<T>::Xcopy(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xaxpy"}, precision_) { + Routine<T>(queue, event, name, {"Xaxpy"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/level1.opencl" #include "../../kernels/level1/xcopy.opencl" @@ -65,7 +56,7 @@ StatusCode Xcopy<T>::DoCopy(const size_t n, // Retrieves the Xcopy kernel from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel = Kernel(program, kernel_name); // Sets the kernel arguments diff --git a/src/routines/level1/xdot.cc b/src/routines/level1/xdot.cc index eac64d13..e3a6b1f0 100644 --- a/src/routines/level1/xdot.cc +++ b/src/routines/level1/xdot.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xdot<half>::precision_ = Precision::kHalf; -template <> const Precision Xdot<float>::precision_ = Precision::kSingle; -template <> const Precision Xdot<double>::precision_ = Precision::kDouble; -template <> const Precision Xdot<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xdot<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xdot<T>::Xdot(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xdot"}, precision_) { + Routine<T>(queue, event, name, {"Xdot"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/xdot.opencl" ; @@ -60,7 +51,7 @@ StatusCode Xdot<T>::DoDot(const size_t n, // Retrieves the Xdot kernels from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel1 = Kernel(program, "Xdot"); auto kernel2 = Kernel(program, "XdotEpilogue"); diff --git a/src/routines/level1/xnrm2.cc b/src/routines/level1/xnrm2.cc index 23055aac..1730e144 100644 --- a/src/routines/level1/xnrm2.cc +++ b/src/routines/level1/xnrm2.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xnrm2<half>::precision_ = Precision::kHalf; -template <> const Precision Xnrm2<float>::precision_ = Precision::kSingle; -template <> const Precision Xnrm2<double>::precision_ = Precision::kDouble; -template <> const Precision Xnrm2<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xnrm2<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xnrm2<T>::Xnrm2(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xdot"}, precision_) { + Routine<T>(queue, event, name, {"Xdot"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/xnrm2.opencl" ; @@ -56,7 +47,7 @@ StatusCode Xnrm2<T>::DoNrm2(const size_t n, // Retrieves the Xnrm2 kernels from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel1 = Kernel(program, "Xnrm2"); auto kernel2 = Kernel(program, "Xnrm2Epilogue"); diff --git a/src/routines/level1/xscal.cc b/src/routines/level1/xscal.cc index 22d2cb5b..4792d40b 100644 --- a/src/routines/level1/xscal.cc +++ b/src/routines/level1/xscal.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xscal<half>::precision_ = Precision::kHalf; -template <> const Precision Xscal<float>::precision_ = Precision::kSingle; -template <> const Precision Xscal<double>::precision_ = Precision::kDouble; -template <> const Precision Xscal<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xscal<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xscal<T>::Xscal(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xaxpy"}, precision_) { + Routine<T>(queue, event, name, {"Xaxpy"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/level1.opencl" #include "../../kernels/level1/xscal.opencl" @@ -61,7 +52,7 @@ StatusCode Xscal<T>::DoScal(const size_t n, const T alpha, // Retrieves the Xscal kernel from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel = Kernel(program, kernel_name); // Sets the kernel arguments diff --git a/src/routines/level1/xswap.cc b/src/routines/level1/xswap.cc index b6996932..897515fb 100644 --- a/src/routines/level1/xswap.cc +++ b/src/routines/level1/xswap.cc @@ -19,19 +19,10 @@ namespace clblast { // ================================================================================================= -// Specific implementations to get the memory-type based on a template argument -template <> const Precision Xswap<half>::precision_ = Precision::kHalf; -template <> const Precision Xswap<float>::precision_ = Precision::kSingle; -template <> const Precision Xswap<double>::precision_ = Precision::kDouble; -template <> const Precision Xswap<float2>::precision_ = Precision::kComplexSingle; -template <> const Precision Xswap<double2>::precision_ = Precision::kComplexDouble; - -// ================================================================================================= - // Constructor: forwards to base class constructor template <typename T> Xswap<T>::Xswap(Queue &queue, EventPointer event, const std::string &name): - Routine<T>(queue, event, name, {"Xaxpy"}, precision_) { + Routine<T>(queue, event, name, {"Xaxpy"}, PrecisionValue<T>()) { source_string_ = #include "../../kernels/level1/level1.opencl" #include "../../kernels/level1/xswap.opencl" @@ -65,7 +56,7 @@ StatusCode Xswap<T>::DoSwap(const size_t n, // Retrieves the Xswap kernel from the compiled binary try { - const auto program = GetProgramFromCache(context_, precision_, routine_name_); + const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_); auto kernel = Kernel(program, kernel_name); // Sets the kernel arguments |