[compute] 07/46: Runtime OpenCL version check in tests

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Dec 21 18:28:37 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository compute.

commit 1b059f8100dfa3bc7313ee6906d762dcf4067d44
Author: Jakub Szuppe <j.szuppe at gmail.com>
Date:   Thu Sep 24 15:08:52 2015 +0200

    Runtime OpenCL version check in tests
---
 test/test_buffer.cpp        |  2 ++
 test/test_command_queue.cpp | 18 ++++++++++++------
 test/test_copy.cpp          |  2 ++
 test/test_fill.cpp          |  2 ++
 test/test_image1d.cpp       |  2 ++
 test/test_image2d.cpp       |  2 ++
 test/test_pipe.cpp          |  2 ++
 test/test_svm_ptr.cpp       |  4 ++++
 test/test_user_event.cpp    |  2 ++
 9 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/test/test_buffer.cpp b/test/test_buffer.cpp
index 4b052fd..d984ef2 100644
--- a/test/test_buffer.cpp
+++ b/test/test_buffer.cpp
@@ -164,6 +164,8 @@ BOOST_AUTO_TEST_CASE(destructor_templated_callback)
 
 BOOST_AUTO_TEST_CASE(create_subbuffer)
 {
+    REQUIRES_OPENCL_VERSION(1, 1);
+
     size_t base_addr_align = device.get_info<CL_DEVICE_MEM_BASE_ADDR_ALIGN>() / 8;
     size_t multiplier = 16;
     size_t buffer_size = base_addr_align * multiplier;
diff --git a/test/test_command_queue.cpp b/test/test_command_queue.cpp
index 6a61fdd..b690d75 100644
--- a/test/test_command_queue.cpp
+++ b/test/test_command_queue.cpp
@@ -137,13 +137,17 @@ BOOST_AUTO_TEST_CASE(kernel_profiling)
 BOOST_AUTO_TEST_CASE(construct_from_cl_command_queue)
 {
     // create cl_command_queue
+    cl_command_queue cl_queue;
 #ifdef CL_VERSION_2_0
-    cl_command_queue cl_queue =
-      clCreateCommandQueueWithProperties(context, device.id(), 0, 0);
-#else
-    cl_command_queue cl_queue =
-      clCreateCommandQueue(context, device.id(), 0, 0);
-#endif
+    if (device.check_version(2, 0)){ // runtime check
+        cl_queue =
+            clCreateCommandQueueWithProperties(context, device.id(), 0, 0);
+    } else
+#endif // CL_VERSION_2_0
+    {
+        cl_queue =
+            clCreateCommandQueue(context, device.id(), 0, 0);
+    }
     BOOST_VERIFY(cl_queue);
 
     // create boost::compute::command_queue
@@ -160,6 +164,8 @@ BOOST_AUTO_TEST_CASE(construct_from_cl_command_queue)
 #ifdef CL_VERSION_1_1
 BOOST_AUTO_TEST_CASE(write_buffer_rect)
 {
+    REQUIRES_OPENCL_VERSION(1, 1);
+
     // skip this test on AMD GPUs due to a buggy implementation
     // of the clEnqueueWriteBufferRect() function
     if(device.vendor() == "Advanced Micro Devices, Inc." &&
diff --git a/test/test_copy.cpp b/test/test_copy.cpp
index 4e2106e..307949f 100644
--- a/test/test_copy.cpp
+++ b/test/test_copy.cpp
@@ -283,6 +283,8 @@ BOOST_AUTO_TEST_CASE(check_copy_type)
 #ifdef CL_VERSION_2_0
 BOOST_AUTO_TEST_CASE(copy_svm_ptr)
 {
+    REQUIRES_OPENCL_VERSION(2, 0);
+
     int data[] = { 1, 3, 2, 4 };
 
     compute::svm_ptr<int> ptr = compute::svm_alloc<int>(context, 4);
diff --git a/test/test_fill.cpp b/test/test_fill.cpp
index ffae7d3..27da911 100644
--- a/test/test_fill.cpp
+++ b/test/test_fill.cpp
@@ -290,6 +290,8 @@ BOOST_AUTO_TEST_CASE(fill_clone_buffer)
 #ifdef CL_VERSION_2_0
 BOOST_AUTO_TEST_CASE(fill_svm_buffer)
 {
+    REQUIRES_OPENCL_VERSION(2, 0);
+
     bc::svm_ptr<int> ptr = bc::svm_alloc<int>(context, 16);
     bc::fill_n(ptr, 16, 42, queue);
 
diff --git a/test/test_image1d.cpp b/test/test_image1d.cpp
index 9dc54ff..6ea84e7 100644
--- a/test/test_image1d.cpp
+++ b/test/test_image1d.cpp
@@ -30,6 +30,8 @@ BOOST_AUTO_TEST_CASE(image1d_get_supported_formats)
 #ifdef CL_VERSION_1_2
 BOOST_AUTO_TEST_CASE(fill_image1d)
 {
+    REQUIRES_OPENCL_VERSION(1, 2); // device OpenCL version check
+
     // single-channel unsigned char
     compute::image_format format(CL_R, CL_UNSIGNED_INT8);
 
diff --git a/test/test_image2d.cpp b/test/test_image2d.cpp
index 5560a09..a1e5ab0 100644
--- a/test/test_image2d.cpp
+++ b/test/test_image2d.cpp
@@ -123,6 +123,8 @@ BOOST_AUTO_TEST_CASE(clone_image)
 #ifdef CL_VERSION_1_2
 BOOST_AUTO_TEST_CASE(fill_image)
 {
+    REQUIRES_OPENCL_VERSION(1, 2); // device OpenCL version check
+
     compute::image_format format(CL_RGBA, CL_UNSIGNED_INT8);
 
     if(!compute::image2d::is_supported_format(format, context)){
diff --git a/test/test_pipe.cpp b/test/test_pipe.cpp
index bfae233..2f3814d 100644
--- a/test/test_pipe.cpp
+++ b/test/test_pipe.cpp
@@ -25,6 +25,8 @@ BOOST_AUTO_TEST_CASE(empty)
 #ifdef CL_VERSION_2_0
 BOOST_AUTO_TEST_CASE(create_pipe)
 {
+    REQUIRES_OPENCL_VERSION(2, 0);
+
     compute::pipe pipe(context, 16 * sizeof(float), 128);
     BOOST_CHECK_EQUAL(pipe.get_info<CL_PIPE_PACKET_SIZE>(), 64);
     BOOST_CHECK_EQUAL(pipe.get_info<CL_PIPE_MAX_PACKETS>(), 128);
diff --git a/test/test_svm_ptr.cpp b/test/test_svm_ptr.cpp
index 045bb2d..ad00340 100644
--- a/test/test_svm_ptr.cpp
+++ b/test/test_svm_ptr.cpp
@@ -28,12 +28,16 @@ BOOST_AUTO_TEST_CASE(empty)
 #ifdef CL_VERSION_2_0
 BOOST_AUTO_TEST_CASE(alloc)
 {
+    REQUIRES_OPENCL_VERSION(2, 0);
+
     compute::svm_ptr<int> ptr = compute::svm_alloc<int>(context, 8);
     compute::svm_free(context, ptr);
 }
 
 BOOST_AUTO_TEST_CASE(sum_svm_kernel)
 {
+    REQUIRES_OPENCL_VERSION(2, 0);
+
     const char source[] = BOOST_COMPUTE_STRINGIZE_SOURCE(
         __kernel void sum_svm_mem(__global const int *ptr, __global int *result)
         {
diff --git a/test/test_user_event.cpp b/test/test_user_event.cpp
index 6614ead..3a2c6b7 100644
--- a/test/test_user_event.cpp
+++ b/test/test_user_event.cpp
@@ -20,6 +20,8 @@ BOOST_AUTO_TEST_CASE(empty){}
 #ifdef CL_VERSION_1_1
 BOOST_AUTO_TEST_CASE(user_event)
 {
+    REQUIRES_OPENCL_VERSION(1, 1);
+
     boost::compute::user_event event(context);
     BOOST_CHECK(event.get() != cl_event());
     BOOST_CHECK(event.status() != CL_COMPLETE);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/compute.git



More information about the debian-science-commits mailing list