Replace functions deprecated in OpenCL 1.2
authorErik Lindahl <erik@kth.se>
Thu, 25 Jun 2015 19:01:26 +0000 (15:01 -0400)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 29 Jun 2015 19:37:38 +0000 (21:37 +0200)
Check for CL_VERSION_1_2 in the source, and
use newer versions in that case to avoid
warnings about deprecated functions.

Change-Id: I6f70e0178fa06c59be57168d94aae0fd7df148f5

cmake/gmxManageOpenCL.cmake
src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl.cpp

index 254ecf16939f25d779f719ec5a708c1d764c4ac5..721defc8dfa6eafb47244c2086272a8df72f5b92 100644 (file)
@@ -52,11 +52,6 @@ else ()
     return()
 endif()
 
-# Prevent warnings when linking against OpenCL > 1.1
-if (OPENCL_VERSION_STRING VERSION_GREATER 1.1)
-    set(OPENCL_DEFINITIONS "-DCL_USE_DEPRECATED_OPENCL_1_1_APIS")
-endif()
-
 # Tell compiler to hide warnings for comments caused by cl_gl_ext.h on Linux
 if (UNIX)
     set(OPENCL_DEFINITIONS ${OPENCL_DEFINITIONS} " -Wno-comment")
@@ -64,9 +59,6 @@ endif()
 
 add_definitions(${OPENCL_DEFINITIONS})
 
-
-#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
-
 include_directories(${OPENCL_INCLUDE_DIRS})
 
 macro(gmx_gpu_setup)
index 476372e455b7cb514d6cccdb1bdd78dcd5fa9c0f..344464350d0831bd9ee4032aeed1f2c727ec2a1b 100644 (file)
@@ -325,7 +325,11 @@ void sync_ocl_event(cl_command_queue stream, cl_event *ocl_event)
     cl_int gmx_unused cl_error;
 
     /* Enqueue wait */
+#ifdef CL_VERSION_1_2
+    cl_error = clEnqueueBarrierWithWaitList(stream, 1, ocl_event, NULL);
+#else
     cl_error = clEnqueueWaitForEvents(stream, 1, ocl_event);
+#endif
 
     assert(CL_SUCCESS == cl_error);
 
@@ -453,7 +457,11 @@ void nbnxn_gpu_launch_kernel(gmx_nbnxn_ocl_t               *nb,
     {
         if (iloc == eintLocal)
         {
+#ifdef CL_VERSION_1_2
+            cl_error = clEnqueueMarkerWithWaitList(stream, 0, NULL, &(nb->misc_ops_done));
+#else
             cl_error = clEnqueueMarker(stream, &(nb->misc_ops_done));
+#endif
             assert(CL_SUCCESS == cl_error);
         }
         else
@@ -946,7 +954,11 @@ void nbnxn_gpu_launch_cpyback(gmx_nbnxn_ocl_t               *nb,
        data back first. */
     if (iloc == eintNonlocal)
     {
+#ifdef CL_VERSION_1_2
+        cl_error = clEnqueueMarkerWithWaitList(stream, 0, NULL, &(nb->nonlocal_done));
+#else
         cl_error = clEnqueueMarker(stream, &(nb->nonlocal_done));
+#endif
         assert(CL_SUCCESS == cl_error);
     }