[Beignet] [PATCH] refine code for the usage of set_image_base_index

Guo Yejun yejun.guo at intel.com
Mon Jun 2 11:13:54 PDT 2014


In libgbe.so and libgbeinterp.so, the same function pointer name
gbe_set_image_base_index is used for a unified source code.

In libcl.so, function pointer names begin with compiler_* point to
the functions from libgbe.so, function pointer names begin with
gbe_* point to the functions from libgbeinterp.so.

Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
 backend/src/backend/program.cpp     | 5 ++---
 backend/src/backend/program.h       | 3 +--
 backend/src/gbe_bin_generater.cpp   | 2 +-
 backend/src/gbe_bin_interpreter.cpp | 2 +-
 src/cl_gbe_loader.cpp               | 8 ++++----
 src/cl_gbe_loader.h                 | 3 ++-
 src/intel/intel_driver.c            | 2 +-
 7 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index ea36f28..949aeb4 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -1046,8 +1046,7 @@ GBE_EXPORT_SYMBOL gbe_kernel_get_sampler_data_cb *gbe_kernel_get_sampler_data =
 GBE_EXPORT_SYMBOL gbe_kernel_get_compile_wg_size_cb *gbe_kernel_get_compile_wg_size = NULL;
 GBE_EXPORT_SYMBOL gbe_kernel_get_image_size_cb *gbe_kernel_get_image_size = NULL;
 GBE_EXPORT_SYMBOL gbe_kernel_get_image_data_cb *gbe_kernel_get_image_data = NULL;
-GBE_EXPORT_SYMBOL gbe_set_image_base_index_cb *gbe_set_image_base_index_compiler = NULL;
-GBE_EXPORT_SYMBOL gbe_set_image_base_index_cb *gbe_set_image_base_index_interp = NULL;
+GBE_EXPORT_SYMBOL gbe_set_image_base_index_cb *gbe_set_image_base_index = NULL;
 GBE_EXPORT_SYMBOL gbe_get_image_base_index_cb *gbe_get_image_base_index = NULL;
 
 #ifdef GBE_COMPILER_AVAILABLE
@@ -1086,7 +1085,7 @@ namespace gbe
       gbe_kernel_get_image_size = gbe::kernelGetImageSize;
       gbe_kernel_get_image_data = gbe::kernelGetImageData;
       gbe_get_image_base_index = gbe::getImageBaseIndex;
-      gbe_set_image_base_index_compiler = gbe::setImageBaseIndex;
+      gbe_set_image_base_index = gbe::setImageBaseIndex;
       genSetupCallBacks();
       llvm::llvm_start_multithreaded();
     }
diff --git a/backend/src/backend/program.h b/backend/src/backend/program.h
index e23f4db..8727966 100644
--- a/backend/src/backend/program.h
+++ b/backend/src/backend/program.h
@@ -99,8 +99,7 @@ typedef struct ImageInfo {
 } ImageInfo;
 
 typedef void (gbe_set_image_base_index_cb)(uint32_t base_idx);
-extern gbe_set_image_base_index_cb *gbe_set_image_base_index_compiler;
-extern gbe_set_image_base_index_cb *gbe_set_image_base_index_interp;
+extern gbe_set_image_base_index_cb *gbe_set_image_base_index;
 
 typedef uint32_t (gbe_get_image_base_index_cb)();
 extern gbe_get_image_base_index_cb *gbe_get_image_base_index;
diff --git a/backend/src/gbe_bin_generater.cpp b/backend/src/gbe_bin_generater.cpp
index 0295b1a..dce0792 100644
--- a/backend/src/gbe_bin_generater.cpp
+++ b/backend/src/gbe_bin_generater.cpp
@@ -301,7 +301,7 @@ int main (int argc, const char **argv)
 
             used_index[optind-1] = 1;
             // We must set the image base index here, as we invoke the backend in a non-standard way.
-            gbe_set_image_base_index_compiler(3);
+            gbe_set_image_base_index(3);
             break;
         }
 
diff --git a/backend/src/gbe_bin_interpreter.cpp b/backend/src/gbe_bin_interpreter.cpp
index bd160c3..64bf5c4 100644
--- a/backend/src/gbe_bin_interpreter.cpp
+++ b/backend/src/gbe_bin_interpreter.cpp
@@ -61,7 +61,7 @@ struct BinInterpCallBackInitializer
     gbe_kernel_get_sampler_data = gbe::kernelGetSamplerData;
     gbe_kernel_get_image_data = gbe::kernelGetImageData;
     gbe_get_image_base_index = gbe::getImageBaseIndex;
-    gbe_set_image_base_index_interp = gbe::setImageBaseIndex;
+    gbe_set_image_base_index = gbe::setImageBaseIndex;
   }
 
   ~BinInterpCallBackInitializer() {
diff --git a/src/cl_gbe_loader.cpp b/src/cl_gbe_loader.cpp
index 794b12b..b1b75d6 100644
--- a/src/cl_gbe_loader.cpp
+++ b/src/cl_gbe_loader.cpp
@@ -27,7 +27,7 @@ gbe_program_new_from_source_cb *compiler_program_new_from_source = NULL;
 gbe_program_serialize_to_binary_cb *compiler_program_serialize_to_binary = NULL;
 gbe_program_new_from_llvm_cb *compiler_program_new_from_llvm = NULL;
 gbe_kernel_set_const_buffer_size_cb *compiler_kernel_set_const_buffer_size = NULL;
-gbe_set_image_base_index_cb *compiler_set_image_base_index_compiler = NULL;
+gbe_set_image_base_index_cb *compiler_set_image_base_index = NULL;
 
 //function pointer from libgbeinterp.so
 gbe_program_new_from_binary_cb *gbe_program_new_from_binary = NULL;
@@ -192,7 +192,7 @@ struct GbeLoaderInitializer
     if (gbe_kernel_get_image_data == NULL)
       return false;
 
-    gbe_set_image_base_index_interp = *(gbe_set_image_base_index_cb**)dlsym(dlhInterp, "gbe_set_image_base_index_interp");
+    gbe_set_image_base_index_interp = *(gbe_set_image_base_index_cb**)dlsym(dlhInterp, "gbe_set_image_base_index");
     if (gbe_set_image_base_index_interp == NULL)
       return false;
 
@@ -236,8 +236,8 @@ struct GbeLoaderInitializer
       if (compiler_kernel_set_const_buffer_size == NULL)
         return;
 
-      compiler_set_image_base_index_compiler = *(gbe_set_image_base_index_cb **)dlsym(dlhCompiler, "gbe_set_image_base_index_compiler");
-      if (compiler_set_image_base_index_compiler == NULL)
+      compiler_set_image_base_index = *(gbe_set_image_base_index_cb **)dlsym(dlhCompiler, "gbe_set_image_base_index");
+      if (compiler_set_image_base_index == NULL)
         return;
 
       compilerLoaded = true;
diff --git a/src/cl_gbe_loader.h b/src/cl_gbe_loader.h
index be088f4..f97f296 100644
--- a/src/cl_gbe_loader.h
+++ b/src/cl_gbe_loader.h
@@ -28,7 +28,8 @@ extern gbe_program_new_from_source_cb *compiler_program_new_from_source;
 extern gbe_program_serialize_to_binary_cb *compiler_program_serialize_to_binary;
 extern gbe_program_new_from_llvm_cb *compiler_program_new_from_llvm;
 extern gbe_kernel_set_const_buffer_size_cb *compiler_kernel_set_const_buffer_size;
-extern gbe_set_image_base_index_cb *compiler_set_image_base_index_compiler;
+extern gbe_set_image_base_index_cb *compiler_set_image_base_index;
+extern gbe_set_image_base_index_cb *gbe_set_image_base_index_interp;
 int CompilerSupported();
 #ifdef __cplusplus
 }
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index dcd19ac..989193a 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -411,7 +411,7 @@ cl_intel_driver_new(cl_context_prop props)
    * Notify the gbe this base index, thus gbe can avoid conflicts
    * when it allocates slots for images*/
   if (CompilerSupported())
-    compiler_set_image_base_index_compiler(3);
+    compiler_set_image_base_index(3);
   gbe_set_image_base_index_interp(3);
 exit:
   return driver;
-- 
1.8.3.2



More information about the Beignet mailing list