Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ set (OPENCL_COMPILE_DEFINITIONS
CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES
OPENCL_ICD_LOADER_VERSION_MAJOR=3
OPENCL_ICD_LOADER_VERSION_MINOR=0
OPENCL_ICD_LOADER_VERSION_REV=7
OPENCL_ICD_LOADER_VERSION_REV=8
$<$<BOOL:${ENABLE_OPENCL_LAYERS}>:CL_ENABLE_LAYERS>
$<$<BOOL:${ENABLE_OPENCL_LOADER_MANAGED_DISPATCH}>:CL_ENABLE_LOADER_MANAGED_DISPATCH>
)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,5 @@ The following debug environment variables are available for use with the OpenCL
| OPENCL_LAYERS | Specifies a list of layers to load. | `export OPENCL_LAYERS=libLayerA.so:libLayerB.so`<br/><br/>`set OPENCL_LAYERS=libLayerA.dll;libLayerB.dll` |
| OPENCL_LAYER_PATH | On Linux and Android, specifies a directory to scan for layers to enumerate in place of the default `/etc/OpenCL/layers'. | `export OPENCL_LAYER_PATH=/my/local/layers/search/path` |
| OCL_ICD_ENABLE_TRACE | Enable the trace mechanism | `export OCL_ICD_ENABLE_TRACE=True`<br/><br/>`set OCL_ICD_ENABLE_TRACE=True`<br/>`true, T, 1 can also be used here.` |
| OCL_ICD_FORCE_LEGACY_TERMINATION | Forces using the legacy termination scheme. Legacy termination supports older layers, but does not support layer de-initialization and does not close library handles for layers or ICDs. | `export OCL_ICD_FORCE_LEGACY_TERMINATION=True`<br/><br/>`set OCL_ICD_FORCE_LEGACY_TERMINATION=True`<br/>`true, T, 1 can also be used here.` |
| OCL_ICD_DISABLE_DYNAMIC_LIBRARY_UNLOADING | Prevents the ICD loader from closing dynamic library handles for layers and ICDs. This can be used for debugging purposes or to allow leak sanitizers to have full stack traces. | `export OCL_ICD_DISABLE_DYNAMIC_LIBRARY_UNLOADING=True`<br/><br/>`set OCL_ICD_DISABLE_DYNAMIC_LIBRARY_UNLOADING=True`<br/>`true, T, 1 can also be used here.` |
25 changes: 25 additions & 0 deletions include/cl_khr_icd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@

#include <CL/cl.h>

#if !defined(CL_PLATFORM_UNLOADABLE_KHR)
#define CL_PLATFORM_UNLOADABLE_KHR 0x0921
#endif

#if defined(CL_ENABLE_LAYERS) && !defined(CL_LAYER_PROPERTIES_LIST_END)
typedef cl_properties cl_layer_properties;

#define CL_LAYER_PROPERTIES_LIST_END ((cl_layer_properties)0)

typedef cl_int CL_API_CALL
clInitLayerWithProperties_t(
cl_uint num_entries,
const cl_icd_dispatch *target_dispatch,
cl_uint *num_entries_ret,
const cl_icd_dispatch **layer_dispatch_ret,
const cl_layer_properties *properties);

typedef clInitLayerWithProperties_t *pfn_clInitLayerWithProperties;

typedef cl_int CL_API_CALL
clDeinitLayer_t(void);

typedef clDeinitLayer_t *pfn_clDeinitLayer;
#endif //defined(CL_ENABLE_LAYERS) && !defined(CL_LAYER_PROPERTIES_LIST_END)

#if !defined(CL_ICD2_TAG_KHR)
#if INTPTR_MAX == INT32_MAX
#define CL_ICD2_TAG_KHR ((intptr_t)0x434C3331)
Expand Down
17 changes: 11 additions & 6 deletions loader/cllayerinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "icd.h"
#include <stdio.h>
#include <stdlib.h>
#include <CL/cl_layer.h>
#if defined(_WIN32)
#include <io.h>
#include <share.h>
Expand Down Expand Up @@ -90,7 +89,7 @@ static void restore_outputs(void)
void printLayerInfo(const struct KHRLayer *layer)
{
cl_layer_api_version api_version = 0;
pfn_clGetLayerInfo p_clGetLayerInfo = (pfn_clGetLayerInfo)(size_t)layer->p_clGetLayerInfo;
pfn_clGetLayerInfo p_clGetLayerInfo = layer->p_clGetLayerInfo;
cl_int result = CL_SUCCESS;
size_t sz;

Expand All @@ -113,20 +112,26 @@ void printLayerInfo(const struct KHRLayer *layer)
}
}

int main (int argc, char *argv[])
static void run_silently(void (*pfn)(void))
{
(void)argc;
(void)argv;
silence_layers();
atexit(restore_outputs);
khrIcdInitialize();
pfn();
restore_outputs();
atexit(silence_layers);
}

int main (int argc, char *argv[])
{
(void)argc;
(void)argv;
run_silently(&khrIcdInitialize);
const struct KHRLayer *layer = khrFirstLayer;
while (layer)
{
printLayerInfo(layer);
layer = layer->next;
}
run_silently(&khrIcdDeinitialize);
return 0;
}
Loading