From 358ccbe20e4296fea7463908b287d12cd5b88900 Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 19 Jul 2012 11:13:50 +0200 Subject: [PATCH] [debug] improve platform dump LIG-icd test must must display the platform in order to avoid to call lGetExtensionFunctionAddress in dummy ICD --- ocl_icd_debug.h | 12 +++++++++++- ocl_icd_loader.c | 4 +++- tests/02-LIG-icd.sh | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ocl_icd_debug.h b/ocl_icd_debug.h index 2a32e5a..d8f40ea 100644 --- a/ocl_icd_debug.h +++ b/ocl_icd_debug.h @@ -25,6 +25,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef OCL_ICD_LOADER_DEBUG_H #define OCL_ICD_LOADER_DEBUG_H +#ifdef DEBUG_OCL_ICD_PROVIDE_DUMP_FIELD +# define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#endif #include #pragma GCC visibility push(hidden) @@ -59,7 +62,10 @@ extern int debug_ocl_icd_mask; debug(D_TRACE, "return: %s", ret); \ return ret; \ } while(0) -void dump_platform(cl_platform_id pid); +# ifdef DEBUG_OCL_ICD_PROVIDE_DUMP_FIELD +typedef __typeof__(clGetExtensionFunctionAddress) *clGEFA_t; +void dump_platform(clGEFA_t f, cl_platform_id pid); +# endif static inline void debug_init(void) { static int done=0; if (!done) { @@ -72,6 +78,10 @@ static inline void debug_init(void) { done=1; } } + +# define dump_field(pid, f, name) \ + debug(D_DUMP, "%40s=%p [%p/%p]", #name, pid->dispatch->name, f(#name), ((long)(pid->dispatch->clGetExtensionFunctionAddressForPlatform)>10)?pid->dispatch->clGetExtensionFunctionAddressForPlatform(pid, #name):NULL) + #else # define debug(...) (void)0 # define RETURN(val) return (val) diff --git a/ocl_icd_loader.c b/ocl_icd_loader.c index ace7276..5c0b7a1 100644 --- a/ocl_icd_loader.c +++ b/ocl_icd_loader.c @@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma GCC visibility push(hidden) #include "ocl_icd_loader.h" +#define DEBUG_OCL_ICD_PROVIDE_DUMP_FIELD #include "ocl_icd_debug.h" #define ETC_OPENCL_VENDORS "/etc/OpenCL/vendors" @@ -223,6 +224,7 @@ static inline cl_uint _open_drivers(DIR *dir, const char* dir_path) { static void* _get_function_addr(void* dlh, clGetExtensionFunctionAddress_fn fn, const char*name) { void *addr1; + debug(D_LOG,"Looking for function %s",name); addr1=dlsym(dlh, name); if (addr1 == NULL) { debug(D_WARN, "Missing global symbol '%s' in ICD, should be skipped", name); @@ -332,7 +334,7 @@ static inline void _find_and_check_platforms(cl_uint num_icds) { p->pid=platforms[j]; #if DEBUG_OCL_ICD if (debug_ocl_icd_mask & D_DUMP) { - dump_platform(p->pid); + dump_platform(p->vicd->ext_fn_ptr, p->pid); } #endif char *param_value=_malloc_clGetPlatformInfo(plt_info_ptr, p->pid, CL_PLATFORM_EXTENSIONS, "extensions"); diff --git a/tests/02-LIG-icd.sh b/tests/02-LIG-icd.sh index baddea6..6fec528 100755 --- a/tests/02-LIG-icd.sh +++ b/tests/02-LIG-icd.sh @@ -1,6 +1,6 @@ #!/bin/bash -export OCL_ICD_DEBUG=15 +export OCL_ICD_DEBUG=7 export OCL_ICD_VENDORS=vendors NAME="$(basename "$0")" -- 2.32.0.93.g670b81a890