Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of cl_khr_icd 2.0.0 #261

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
108 changes: 107 additions & 1 deletion CL/cl_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,28 @@ 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)

typedef struct _cl_instance_khr * cl_instance_khr;
typedef intptr_t cl_instance_properties_khr;

/* cl_platform_info */
#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
#define CL_PLATFORM_UNLOADABLE_KHR 0x0921

/* cl_instance_properties_khr */
#define CL_INSTANCE_PROPERTIES_LIST_END_KHR 0

/* Error codes */
#define CL_PLATFORM_NOT_FOUND_KHR -1001
#define CL_INVALID_INSTANCE_KHR -1154

/* 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
Expand All @@ -872,6 +887,62 @@ 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 ;

typedef cl_platform_id CL_API_CALL
clIcdCreateInstancePlatformKHR_t(
cl_platform_id platform,
cl_int* errcode_ret);

typedef clIcdCreateInstancePlatformKHR_t *
clIcdCreateInstancePlatformKHR_fn ;

typedef cl_int CL_API_CALL
clIcdDestroyInstancePlatformKHR_t(
cl_platform_id platform);

typedef clIcdDestroyInstancePlatformKHR_t *
clIcdDestroyInstancePlatformKHR_fn ;

typedef cl_instance_khr CL_API_CALL
clCreateInstanceKHR_t(
const cl_instance_properties_khr* properties,
cl_int* errcode_ret);

typedef clCreateInstanceKHR_t *
clCreateInstanceKHR_fn ;

typedef cl_int CL_API_CALL
clDestroyInstanceKHR_t(
cl_instance_khr instance);

typedef clDestroyInstanceKHR_t *
clDestroyInstanceKHR_fn ;

typedef cl_int CL_API_CALL
clGetPlatformIDsForInstanceKHR_t(
cl_instance_khr instance,
cl_uint num_entries,
cl_platform_id* platforms,
cl_uint* num_platforms);

typedef clGetPlatformIDsForInstanceKHR_t *
clGetPlatformIDsForInstanceKHR_fn ;

#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES)

extern CL_API_ENTRY cl_int CL_API_CALL
Expand All @@ -880,6 +951,41 @@ 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) ;

extern CL_API_ENTRY cl_platform_id CL_API_CALL
clIcdCreateInstancePlatformKHR(
cl_platform_id platform,
cl_int* errcode_ret) ;

extern CL_API_ENTRY cl_int CL_API_CALL
clIcdDestroyInstancePlatformKHR(
cl_platform_id platform) ;

extern CL_API_ENTRY cl_instance_khr CL_API_CALL
clCreateInstanceKHR(
const cl_instance_properties_khr* properties,
cl_int* errcode_ret) ;

extern CL_API_ENTRY cl_int CL_API_CALL
clDestroyInstanceKHR(
cl_instance_khr instance) ;

extern CL_API_ENTRY cl_int CL_API_CALL
clGetPlatformIDsForInstanceKHR(
cl_instance_khr instance,
cl_uint num_entries,
cl_platform_id* platforms,
cl_uint* num_platforms) ;

#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */

/***************************************************************
Expand Down
17 changes: 16 additions & 1 deletion CL/cl_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C" {
"cl_loader_layers"


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

typedef cl_uint cl_layer_info;
typedef cl_uint cl_layer_api_version;
Expand All @@ -65,6 +65,7 @@ typedef cl_uint cl_layer_api_version;

/* Misc API enums */
#define CL_LAYER_API_VERSION_100 100
#define CL_LAYER_API_VERSION_200 200


typedef cl_int CL_API_CALL
Expand All @@ -87,6 +88,13 @@ clInitLayer_t(
typedef clInitLayer_t *
clInitLayer_fn ;

typedef cl_int CL_API_CALL
clDeinitLayer_t(
void );

typedef clDeinitLayer_t *
clDeinitLayer_fn ;

/*
** The function pointer typedefs prefixed with "pfn_" are provided for
** compatibility with earlier versions of the headers. New code is
Expand All @@ -100,6 +108,9 @@ pfn_clGetLayerInfo ;
typedef clInitLayer_t *
pfn_clInitLayer ;

typedef clDeinitLayer_t *
pfn_clDeinitLayer ;

#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES)

extern CL_API_ENTRY cl_int CL_API_CALL
Expand All @@ -116,6 +127,10 @@ clInitLayer(
cl_uint* num_entries_ret,
const cl_icd_dispatch** layer_dispatch_ret) ;

extern CL_API_ENTRY cl_int CL_API_CALL
clDeinitLayer(
void ) ;

#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */

#ifdef __cplusplus
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