summaryrefslogtreecommitdiff
path: root/test/test_utilities.hpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-10-15 13:56:19 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-10-15 13:56:19 +0200
commita3069a97c3e5c22635786870c8a9d02ca16d3d1d (patch)
tree862676b6695e82d275d6f98ed4ed350186c00a82 /test/test_utilities.hpp
parent7408da174c848ffeaa1fe2da52f26a057e65b0f1 (diff)
Prepared test and client infrastructure for use with the CUDA API
Diffstat (limited to 'test/test_utilities.hpp')
-rw-r--r--test/test_utilities.hpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/test_utilities.hpp b/test/test_utilities.hpp
index fe7a9cd2..d03c55fc 100644
--- a/test/test_utilities.hpp
+++ b/test/test_utilities.hpp
@@ -89,8 +89,25 @@ std::vector<float> HalfToFloatBuffer(const std::vector<half>& source);
void FloatToHalfBuffer(std::vector<half>& result, const std::vector<float>& source);
// As above, but now for OpenCL data-types instead of std::vectors
-Buffer<float> HalfToFloatBuffer(const Buffer<half>& source, RawCommandQueue queue_raw);
-void FloatToHalfBuffer(Buffer<half>& result, const Buffer<float>& source, RawCommandQueue queue_raw);
+#ifdef OPENCL_API
+ Buffer<float> HalfToFloatBuffer(const Buffer<half>& source, RawCommandQueue queue_raw);
+ void FloatToHalfBuffer(Buffer<half>& result, const Buffer<float>& source, RawCommandQueue queue_raw);
+#endif
+
+// =================================================================================================
+
+// Creates a buffer but don't test for validity. That's the reason this is not using the clpp11.h or
+// cupp11.h interface.
+template <typename T>
+Buffer<T> CreateInvalidBuffer(const Context& context, const size_t size) {
+ #ifdef OPENCL_API
+ auto raw_buffer = clCreateBuffer(context(), CL_MEM_READ_WRITE, size * sizeof(T), nullptr, nullptr);
+ #elif CUDA_API
+ CUdeviceptr raw_buffer;
+ cuMemAlloc(&raw_buffer, size * sizeof(T));
+ #endif
+ return Buffer<T>(raw_buffer);
+}
// =================================================================================================
} // namespace clblast