Skip to content

Commit

Permalink
Extension of cl_khr_icd to 2.0.0 with loader managed dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Sep 5, 2024
1 parent 1e19333 commit cbf115c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
35 changes: 34 additions & 1 deletion CL/cl_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,21 @@ clLogMessagesToStderrAPPLE(
"cl_khr_icd"


#define CL_KHR_ICD_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0)
#define CL_KHR_ICD_EXTENSION_VERSION CL_MAKE_VERSION(2, 0, 0)

/* cl_platform_info */
#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920

/* Error codes */
#define CL_PLATFORM_NOT_FOUND_KHR -1001

/* ICD 2 tag value */
#if INTPTR_MAX == INT32_MAX
#define CL_ICD2_TAG_KHR ((intptr_t)0x434C3331)
#else
#define CL_ICD2_TAG_KHR ((intptr_t)0x4F50454E434C3331)
#endif


typedef cl_int CL_API_CALL
clIcdGetPlatformIDsKHR_t(
Expand All @@ -872,6 +879,22 @@ clIcdGetPlatformIDsKHR_t(
typedef clIcdGetPlatformIDsKHR_t *
clIcdGetPlatformIDsKHR_fn ;

typedef void* CL_API_CALL
clIcdGetFunctionAddressForPlatformKHR_t(
cl_platform_id platform,
const char* func_name);

typedef clIcdGetFunctionAddressForPlatformKHR_t *
clIcdGetFunctionAddressForPlatformKHR_fn ;

typedef cl_int CL_API_CALL
clIcdSetPlatformDispatchDataKHR_t(
cl_platform_id platform,
void* dispatch_data);

typedef clIcdSetPlatformDispatchDataKHR_t *
clIcdSetPlatformDispatchDataKHR_fn ;

#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES)

extern CL_API_ENTRY cl_int CL_API_CALL
Expand All @@ -880,6 +903,16 @@ clIcdGetPlatformIDsKHR(
cl_platform_id* platforms,
cl_uint* num_platforms) ;

extern CL_API_ENTRY void* CL_API_CALL
clIcdGetFunctionAddressForPlatformKHR(
cl_platform_id platform,
const char* func_name) ;

extern CL_API_ENTRY cl_int CL_API_CALL
clIcdSetPlatformDispatchDataKHR(
cl_platform_id platform,
void* dispatch_data) ;

#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */

/***************************************************************
Expand Down
4 changes: 4 additions & 0 deletions scripts/cl_ext.h.mako
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ extern "C" {
% if type.get('name') in typedefs:
${typedefs[type.get('name')].Typedef.ljust(27)} ${type.get('name')};
% elif type.get('name') in macros:
% if macros[type.get('name')].Macro == '':
${macros[type.get('name')].Define}
% else:
#define ${type.get('name')}${macros[type.get('name')].Macro}
% endif
% elif type.get('name') in structs:
<%
struct = structs[type.get('name')]
Expand Down
5 changes: 5 additions & 0 deletions scripts/gen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def get_apimacros(spec):
name = name.strip()
macro = macro.rstrip() # keep spaces on the left!
macros[name] = Macro(define, name, macro)
elif noneStr(type.text).strip().startswith("#if"):
define = noneStr(type.text).strip()
name = type.get('name')
name = name.strip()
macros[name] = Macro(define, name, '')
return macros

def get_apistructs(spec):
Expand Down

0 comments on commit cbf115c

Please sign in to comment.