Skip to content

Commit

Permalink
Added clSetPlatformDispatchDataKHR function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Nov 21, 2023
1 parent 405f5b7 commit b541e27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 10 additions & 3 deletions loader/icd.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void khrIcdVendorAdd(const char *libraryName)
pfn_clIcdGetPlatformIDs p_clIcdGetPlatformIDs = NULL;
#if KHR_LOADER_MANAGED_DISPATCH
clGetFunctionAddressForPlatformKHR_fn p_clGetFunctionAddressForPlatform = NULL;
clSetPlatformDispatchDataKHR_fn p_clSetPlatformDispatchData = NULL;
#endif
cl_uint i = 0;
cl_uint platformCount = 0;
Expand Down Expand Up @@ -108,8 +109,9 @@ void khrIcdVendorAdd(const char *libraryName)
}

#if KHR_LOADER_MANAGED_DISPATCH
// try to get clGetFunctionAddressForPlatformKHR to detect cl_khr_icd2 support
// try to get clGetFunctionAddressForPlatformKHR and clSetPlatformDispatchDataKHR to detect cl_khr_icd2 support
p_clGetFunctionAddressForPlatform = (clGetFunctionAddressForPlatformKHR_fn)(size_t)p_clGetExtensionFunctionAddress("clGetFunctionAddressForPlatformKHR");
p_clSetPlatformDispatchData = (clSetPlatformDispatchDataKHR_fn)(size_t)p_clGetExtensionFunctionAddress("clSetPlatformDispatchDataKHR");
#endif

// query the number of platforms available and allocate space to store them
Expand Down Expand Up @@ -152,6 +154,11 @@ void khrIcdVendorAdd(const char *libraryName)
KHR_ICD_TRACE("found icd 2 object, but platform is missing clGetFunctionAddressForPlatformKHR");
continue;
}
if (KHR_ICD2_HAS_TAG(platforms[i]) && !p_clSetPlatformDispatchData)
{
KHR_ICD_TRACE("found icd 2 object, but platform is missing clSetPlatformDispatchDataKHR");
continue;
}
#endif

// allocate a structure for the vendor
Expand All @@ -165,10 +172,10 @@ void khrIcdVendorAdd(const char *libraryName)

#if KHR_LOADER_MANAGED_DISPATCH
// populate cl_khr_icd2 platform's loader managed dispatch tables
if (p_clGetFunctionAddressForPlatform && KHR_ICD2_HAS_TAG(platforms[i]))
if (KHR_ICD2_HAS_TAG(platforms[i]))
{
khrIcd2PopulateDispatchTable(platforms[i], p_clGetFunctionAddressForPlatform, &vendor->dispData.dispatch);
platforms[i]->dispData = &vendor->dispData;
p_clSetPlatformDispatchData(platforms[i], &vendor->dispData);
KHR_ICD_TRACE("found icd 2 platform, using loader managed dispatch\n");
}
#endif
Expand Down
8 changes: 8 additions & 0 deletions loader/icd_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ clGetFunctionAddressForPlatformKHR_t(
typedef clGetFunctionAddressForPlatformKHR_t *
clGetFunctionAddressForPlatformKHR_fn;

typedef cl_int CL_API_CALL
clSetPlatformDispatchDataKHR_t(
cl_platform_id platform,
void *disp_data);

typedef clSetPlatformDispatchDataKHR_t *
clSetPlatformDispatchDataKHR_fn;

extern void khrIcd2PopulateDispatchTable(
cl_platform_id platform,
clGetFunctionAddressForPlatformKHR_fn p_clGetFunctionAddressForPlatform,
Expand Down

0 comments on commit b541e27

Please sign in to comment.