summaryrefslogtreecommitdiff
path: root/src/utilities/utilities.hpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-04-01 13:36:24 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-04-01 13:36:24 +0200
commitb84d2296b87ac212474af855d916b12adf96bdb7 (patch)
tree0f2e85e1e1acef1d22f046499dd0b8a30e5da4f9 /src/utilities/utilities.hpp
parenta98c00a2671b8981579f3a73dca8fb3365a95e53 (diff)
Separated host-device and device-host memory copies from execution of the CBLAS reference code; for fair timing and code de-duplication
Diffstat (limited to 'src/utilities/utilities.hpp')
-rw-r--r--src/utilities/utilities.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp
index b3db8c22..535560a3 100644
--- a/src/utilities/utilities.hpp
+++ b/src/utilities/utilities.hpp
@@ -98,6 +98,15 @@ constexpr auto kArgHelp = "h";
constexpr auto kArgQuiet = "q";
constexpr auto kArgNoAbbreviations = "no_abbrv";
+// The buffer names
+constexpr auto kBufVecX = "X";
+constexpr auto kBufVecY = "Y";
+constexpr auto kBufMatA = "A";
+constexpr auto kBufMatB = "B";
+constexpr auto kBufMatC = "C";
+constexpr auto kBufMatAP = "AP";
+constexpr auto kBufScalar = "Scalar";
+
// =================================================================================================
// Converts a regular or complex type to it's base type (e.g. float2 to float)
@@ -202,6 +211,16 @@ struct Buffers {
Buffer<T> ap_mat;
Buffer<T> scalar;
};
+template <typename T>
+struct BuffersHost {
+ std::vector<T> x_vec;
+ std::vector<T> y_vec;
+ std::vector<T> a_mat;
+ std::vector<T> b_mat;
+ std::vector<T> c_mat;
+ std::vector<T> ap_mat;
+ std::vector<T> scalar;
+};
// =================================================================================================
@@ -250,6 +269,18 @@ void PopulateVector(std::vector<T> &vector, std::mt19937 &mt, std::uniform_real_
// =================================================================================================
+// Copies buffers from the OpenCL device to the host
+template <typename T, typename U>
+void DeviceToHost(const Arguments<U> &args, Buffers<T> &buffers, BuffersHost<T> &buffers_host,
+ Queue &queue, const std::vector<std::string> &names);
+
+// Copies buffers from the host to the OpenCL device
+template <typename T, typename U>
+void HostToDevice(const Arguments<U> &args, Buffers<T> &buffers, BuffersHost<T> &buffers_host,
+ Queue &queue, const std::vector<std::string> &names);
+
+// =================================================================================================
+
// Conversion between half and single-precision
std::vector<float> HalfToFloatBuffer(const std::vector<half>& source);
void FloatToHalfBuffer(std::vector<half>& result, const std::vector<float>& source);