[cig-commits] [commit] devel, master: Protect multiline macro function definitions (2db7be0)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Nov 6 08:32:56 PST 2014


Repository : https://github.com/geodynamics/specfem3d_globe

On branches: devel,master
Link       : https://github.com/geodynamics/specfem3d_globe/compare/bc58e579b3b0838a0968725a076f5904845437ca...be63f20cbb6f462104e949894dbe205d2398cd7f

>---------------------------------------------------------------

commit 2db7be0b2999fd3a8b8314b4b1c60402b4b0929b
Author: Kevin Pouget <kevin.pouget at imag.fr>
Date:   Thu Oct 23 15:35:42 2014 +0200

    Protect multiline macro function definitions
    
    unprotected macro functions are incompatible with inline "if (use_opencl) MACRO_FCT()" ...


>---------------------------------------------------------------

2db7be0b2999fd3a8b8314b4b1c60402b4b0929b
 src/gpu/mesh_constants_ocl.h | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/gpu/mesh_constants_ocl.h b/src/gpu/mesh_constants_ocl.h
index 03b4844..f74743a 100644
--- a/src/gpu/mesh_constants_ocl.h
+++ b/src/gpu/mesh_constants_ocl.h
@@ -43,7 +43,7 @@ const char* clewErrorString (cl_int error);
   size_t size;                                      \
   cl_buffer_region region_type;
 
-#define INIT_OFFSET_OCL(_buffer_, _offset_)                             \
+#define INIT_OFFSET_OCL(_buffer_, _offset_) do {                        \
   if (run_opencl) {                                                     \
     clCheck (clGetMemObjectInfo (mp->_buffer_.ocl, CL_MEM_FLAGS, sizeof(cl_uint), &buffer_create_type, NULL)); \
     clCheck (clGetMemObjectInfo (mp->_buffer_.ocl, CL_MEM_SIZE , sizeof(size_t), &size, NULL)); \
@@ -53,25 +53,30 @@ const char* clewErrorString (cl_int error);
                                                                         \
     _buffer_##_##_offset_.ocl = clCreateSubBuffer (mp->_buffer_.ocl, buffer_create_type, CL_BUFFER_CREATE_TYPE_REGION, \
                                                    (void *) &region_type, clck_(&mocl_errcode)); \
-  }
+  }                                                                     \
+    } while (0)
+    
 
 
-#define RELEASE_OFFSET_OCL(_buffer_, _offset_)                  \
+#define RELEASE_OFFSET_OCL(_buffer_, _offset_) do {             \
   if (run_opencl) {                                             \
     clCheck(clReleaseMemObject(_buffer_##_##_offset_.ocl));     \
-  }
+  }                                                             \
+  } while (0)
 
-#define ALLOC_PINNED_BUFFER_OCL(_buffer_, _size_)                       \
+#define ALLOC_PINNED_BUFFER_OCL(_buffer_, _size_) do {                  \
   mp->h_pinned_##_buffer_ = clCreateBuffer(mocl.context, CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, \
                                            _size_, NULL, clck_(&mocl_errcode)); \
   mp->h_##_buffer_ = (realw *) clEnqueueMapBuffer(mocl.command_queue, mp->h_pinned_##_buffer_, CL_TRUE, \
                                                   CL_MAP_READ | CL_MAP_WRITE, 0, _size_, 0, \
-                                                  NULL, NULL, clck_(&mocl_errcode))
+                                                  NULL, NULL, clck_(&mocl_errcode)); \
+  } while (0)
 
-#define RELEASE_PINNED_BUFFER_OCL(_buffer_)                             \
-  clCheck(clEnqueueUnmapMemObject(mocl.command_queue, mp->h_pinned_##_buffer_, \
-                                  mp->h_##_buffer_, 0, NULL, NULL));                      \
-  clCheck(clReleaseMemObject (mp->h_pinned_##_buffer_))
+#define RELEASE_PINNED_BUFFER_OCL(_buffer_) do {                        \
+    clCheck(clEnqueueUnmapMemObject(mocl.command_queue, mp->h_pinned_##_buffer_, \
+                                    mp->h_##_buffer_, 0, NULL, NULL));  \
+    clCheck(clReleaseMemObject (mp->h_pinned_##_buffer_));              \
+      } while (0)
     
 
 /* ----------------------------------------------------------------------------------------------- */
@@ -96,10 +101,12 @@ static inline cl_int _clCheck(cl_int errcode, const char *file, int line, const
 
 /* ----------------------------------------------------------------------------------------------- */
 
-#define TAKE_REF_OCL(_buffer_)                                  \
+#define TAKE_REF_OCL(_buffer_) do {                             \
   if (run_opencl) {                                             \
     clCheck(clRetainMemObject(_buffer_.ocl));                   \
-  }
+  }                                                             \
+  } while (0)
+
 
 /* ----------------------------------------------------------------------------------------------- */
 



More information about the CIG-COMMITS mailing list