[Beignet] [PATCH 06/10] OCL20: Add functions for runtime to get the device enqueue info.
Yang Rong
rong.r.yang at intel.com
Thu Mar 17 10:53:54 UTC 2016
Add two functions gbe_kernel_use_device_enqueue and
gbe_program_get_device_enqueue_kernel_name.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
backend/src/backend/program.cpp | 17 ++++++++++++++++-
backend/src/backend/program.h | 6 ++++++
backend/src/gbe_bin_interpreter.cpp | 2 ++
src/cl_gbe_loader.cpp | 10 ++++++++++
src/cl_gbe_loader.h | 2 ++
5 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 4ecb7cb..871b65b 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -90,7 +90,6 @@ namespace gbe {
name(name), args(NULL), argNum(0), curbeSize(0), stackSize(0), useSLM(false),
slmSize(0), ctx(NULL), samplerSet(NULL), imageSet(NULL), printfSet(NULL),
useDeviceEnqueue(false) {}
-
Kernel::~Kernel(void) {
if(ctx) GBE_DELETE(ctx);
if(samplerSet) GBE_DELETE(samplerSet);
@@ -1007,6 +1006,12 @@ namespace gbe {
return program->getKernelNum();
}
+ const static char* programGetDeviceEnqueueKernelName(gbe_program gbeProgram, uint32_t index) {
+ if (gbeProgram == NULL) return 0;
+ const gbe::Program *program = (const gbe::Program*) gbeProgram;
+ return program->getDeviceEnqueueKernelName(index);
+ }
+
static gbe_kernel programGetKernelByName(gbe_program gbeProgram, const char *name) {
if (gbeProgram == NULL) return NULL;
const gbe::Program *program = (gbe::Program*) gbeProgram;
@@ -1157,6 +1162,12 @@ namespace gbe {
return ps->getPrintfNum();
}
+ static uint32_t kernelUseDeviceEnqueue(gbe_kernel gbeKernel) {
+ if (gbeKernel == NULL) return 0;
+ const gbe::Kernel *kernel = (const gbe::Kernel*) gbeKernel;
+ return kernel->getUseDeviceEnqueue();
+ }
+
static void* kernelDupPrintfSet(gbe_kernel gbeKernel) {
if (gbeKernel == NULL) return NULL;
const gbe::Kernel *kernel = (const gbe::Kernel*) gbeKernel;
@@ -1252,6 +1263,7 @@ GBE_EXPORT_SYMBOL gbe_program_delete_cb *gbe_program_delete = NULL;
GBE_EXPORT_SYMBOL gbe_program_get_kernel_num_cb *gbe_program_get_kernel_num = NULL;
GBE_EXPORT_SYMBOL gbe_program_get_kernel_by_name_cb *gbe_program_get_kernel_by_name = NULL;
GBE_EXPORT_SYMBOL gbe_program_get_kernel_cb *gbe_program_get_kernel = NULL;
+GBE_EXPORT_SYMBOL gbe_program_get_device_enqueue_kernel_name_cb *gbe_program_get_device_enqueue_kernel_name = NULL;
GBE_EXPORT_SYMBOL gbe_kernel_get_name_cb *gbe_kernel_get_name = NULL;
GBE_EXPORT_SYMBOL gbe_kernel_get_attributes_cb *gbe_kernel_get_attributes = NULL;
GBE_EXPORT_SYMBOL gbe_kernel_get_code_cb *gbe_kernel_get_code = NULL;
@@ -1282,6 +1294,7 @@ GBE_EXPORT_SYMBOL gbe_get_printf_indexbuf_bti_cb *gbe_get_printf_indexbuf_bti =
GBE_EXPORT_SYMBOL gbe_release_printf_info_cb *gbe_release_printf_info = NULL;
GBE_EXPORT_SYMBOL gbe_get_printf_sizeof_size_cb *gbe_get_printf_sizeof_size = NULL;
GBE_EXPORT_SYMBOL gbe_output_printf_cb *gbe_output_printf = NULL;
+GBE_EXPORT_SYMBOL gbe_kernel_use_device_enqueue_cb *gbe_kernel_use_device_enqueue = NULL;
#ifdef GBE_COMPILER_AVAILABLE
namespace gbe
@@ -1301,6 +1314,7 @@ namespace gbe
gbe_program_clean_llvm_resource = gbe::programCleanLlvmResource;
gbe_program_delete = gbe::programDelete;
gbe_program_get_kernel_num = gbe::programGetKernelNum;
+ gbe_program_get_device_enqueue_kernel_name = gbe::programGetDeviceEnqueueKernelName;
gbe_program_get_kernel_by_name = gbe::programGetKernelByName;
gbe_program_get_kernel = gbe::programGetKernel;
gbe_kernel_get_name = gbe::kernelGetName;
@@ -1333,6 +1347,7 @@ namespace gbe
gbe_get_printf_sizeof_size = gbe::kernelGetPrintfSizeOfSize;
gbe_release_printf_info = gbe::kernelReleasePrintfSet;
gbe_output_printf = gbe::kernelOutputPrintf;
+ gbe_kernel_use_device_enqueue = gbe::kernelUseDeviceEnqueue;
genSetupCallBacks();
}
diff --git a/backend/src/backend/program.h b/backend/src/backend/program.h
index 8f1ac66..1e8b358 100644
--- a/backend/src/backend/program.h
+++ b/backend/src/backend/program.h
@@ -289,6 +289,9 @@ extern gbe_program_get_kernel_by_name_cb *gbe_program_get_kernel_by_name;
typedef gbe_kernel (gbe_program_get_kernel_cb)(gbe_program, uint32_t ID);
extern gbe_program_get_kernel_cb *gbe_program_get_kernel;
+typedef const char* (gbe_program_get_device_enqueue_kernel_name_cb)(gbe_program, uint32_t ID);
+extern gbe_program_get_device_enqueue_kernel_name_cb *gbe_program_get_device_enqueue_kernel_name;
+
/*! Get the kernel name */
typedef const char *(gbe_kernel_get_name_cb)(gbe_kernel);
extern gbe_kernel_get_name_cb *gbe_kernel_get_name;
@@ -362,6 +365,9 @@ extern gbe_kernel_use_slm_cb *gbe_kernel_use_slm;
typedef int32_t (gbe_kernel_get_slm_size_cb)(gbe_kernel);
extern gbe_kernel_get_slm_size_cb *gbe_kernel_get_slm_size;
+typedef uint32_t (gbe_kernel_use_device_enqueue_cb)(gbe_kernel);
+extern gbe_kernel_use_device_enqueue_cb *gbe_kernel_use_device_enqueue;
+
/*mutex to lock global llvmcontext access.*/
extern void acquireLLVMContextLock();
extern void releaseLLVMContextLock();
diff --git a/backend/src/gbe_bin_interpreter.cpp b/backend/src/gbe_bin_interpreter.cpp
index 0957092..2231494 100644
--- a/backend/src/gbe_bin_interpreter.cpp
+++ b/backend/src/gbe_bin_interpreter.cpp
@@ -38,6 +38,7 @@ struct BinInterpCallBackInitializer
gbe_program_get_kernel_num = gbe::programGetKernelNum;
gbe_program_get_kernel_by_name = gbe::programGetKernelByName;
gbe_program_get_kernel = gbe::programGetKernel;
+ gbe_program_get_device_enqueue_kernel_name = gbe::programGetDeviceEnqueueKernelName;
gbe_kernel_get_code_size = gbe::kernelGetCodeSize;
gbe_kernel_get_code = gbe::kernelGetCode;
gbe_kernel_get_arg_num = gbe::kernelGetArgNum;
@@ -73,6 +74,7 @@ struct BinInterpCallBackInitializer
gbe_get_printf_sizeof_size = gbe::kernelGetPrintfSizeOfSize;
gbe_release_printf_info = gbe::kernelReleasePrintfSet;
gbe_output_printf = gbe::kernelOutputPrintf;
+ gbe_kernel_use_device_enqueue = gbe::kernelUseDeviceEnqueue;
}
~BinInterpCallBackInitializer() {
diff --git a/src/cl_gbe_loader.cpp b/src/cl_gbe_loader.cpp
index d75c92c..57b8327 100644
--- a/src/cl_gbe_loader.cpp
+++ b/src/cl_gbe_loader.cpp
@@ -44,6 +44,7 @@ gbe_program_delete_cb *interp_program_delete = NULL;
gbe_program_get_kernel_num_cb *interp_program_get_kernel_num = NULL;
gbe_program_get_kernel_by_name_cb *interp_program_get_kernel_by_name = NULL;
gbe_program_get_kernel_cb *interp_program_get_kernel = NULL;
+gbe_program_get_device_enqueue_kernel_name_cb *interp_program_get_device_enqueue_kernel_name = NULL;
gbe_kernel_get_name_cb *interp_kernel_get_name = NULL;
gbe_kernel_get_attributes_cb *interp_kernel_get_attributes = NULL;
gbe_kernel_get_code_cb *interp_kernel_get_code = NULL;
@@ -74,6 +75,7 @@ gbe_get_printf_sizeof_size_cb* interp_get_printf_sizeof_size = NULL;
gbe_release_printf_info_cb* interp_release_printf_info = NULL;
gbe_output_printf_cb* interp_output_printf = NULL;
gbe_kernel_get_arg_info_cb *interp_kernel_get_arg_info = NULL;
+gbe_kernel_use_device_enqueue_cb *interp_kernel_use_device_enqueue = NULL;
struct GbeLoaderInitializer
{
@@ -135,6 +137,10 @@ struct GbeLoaderInitializer
if (interp_program_get_kernel == NULL)
return false;
+ interp_program_get_device_enqueue_kernel_name = *(gbe_program_get_device_enqueue_kernel_name_cb**)dlsym(dlhInterp, "gbe_program_get_device_enqueue_kernel_name");
+ if (interp_program_get_device_enqueue_kernel_name == NULL)
+ return false;
+
interp_kernel_get_name = *(gbe_kernel_get_name_cb**)dlsym(dlhInterp, "gbe_kernel_get_name");
if (interp_kernel_get_name == NULL)
return false;
@@ -255,6 +261,10 @@ struct GbeLoaderInitializer
if (interp_kernel_get_arg_info == NULL)
return false;
+ interp_kernel_use_device_enqueue = *(gbe_kernel_use_device_enqueue_cb**)dlsym(dlhInterp, "gbe_kernel_use_device_enqueue");
+ if (interp_kernel_use_device_enqueue == NULL)
+ return false;
+
return true;
}
diff --git a/src/cl_gbe_loader.h b/src/cl_gbe_loader.h
index 28741ff..56521fe 100644
--- a/src/cl_gbe_loader.h
+++ b/src/cl_gbe_loader.h
@@ -44,6 +44,7 @@ extern gbe_program_delete_cb *interp_program_delete;
extern gbe_program_get_kernel_num_cb *interp_program_get_kernel_num;
extern gbe_program_get_kernel_by_name_cb *interp_program_get_kernel_by_name;
extern gbe_program_get_kernel_cb *interp_program_get_kernel;
+extern gbe_program_get_device_enqueue_kernel_name_cb *interp_program_get_device_enqueue_kernel_name;
extern gbe_kernel_get_name_cb *interp_kernel_get_name;
extern gbe_kernel_get_attributes_cb *interp_kernel_get_attributes;
extern gbe_kernel_get_code_cb *interp_kernel_get_code;
@@ -74,6 +75,7 @@ extern gbe_get_printf_sizeof_size_cb* interp_get_printf_sizeof_size;
extern gbe_release_printf_info_cb* interp_release_printf_info;
extern gbe_output_printf_cb* interp_output_printf;
extern gbe_kernel_get_arg_info_cb *interp_kernel_get_arg_info;
+extern gbe_kernel_use_device_enqueue_cb * interp_kernel_use_device_enqueue;
int CompilerSupported();
#ifdef __cplusplus
--
1.9.1
More information about the Beignet
mailing list