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

[UR] add a loader_only flag to the spec #770

Merged
merged 1 commit into from
Aug 3, 2023
Merged
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
48 changes: 0 additions & 48 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,53 +2264,6 @@ def __str__(self):
###############################################################################
__use_win_types = "Windows" == platform.uname()[0]

###############################################################################
## @brief Function-pointer for urLoaderConfigCreate
if __use_win_types:
_urLoaderConfigCreate_t = WINFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) )
else:
_urLoaderConfigCreate_t = CFUNCTYPE( ur_result_t, POINTER(ur_loader_config_handle_t) )

###############################################################################
## @brief Function-pointer for urLoaderConfigRetain
if __use_win_types:
_urLoaderConfigRetain_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t )
else:
_urLoaderConfigRetain_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t )

###############################################################################
## @brief Function-pointer for urLoaderConfigRelease
if __use_win_types:
_urLoaderConfigRelease_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t )
else:
_urLoaderConfigRelease_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t )

###############################################################################
## @brief Function-pointer for urLoaderConfigGetInfo
if __use_win_types:
_urLoaderConfigGetInfo_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) )
else:
_urLoaderConfigGetInfo_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, ur_loader_config_info_t, c_size_t, c_void_p, POINTER(c_size_t) )

###############################################################################
## @brief Function-pointer for urLoaderConfigEnableLayer
if __use_win_types:
_urLoaderConfigEnableLayer_t = WINFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p )
else:
_urLoaderConfigEnableLayer_t = CFUNCTYPE( ur_result_t, ur_loader_config_handle_t, c_char_p )


###############################################################################
## @brief Table of LoaderConfig functions pointers
class ur_loader_config_dditable_t(Structure):
_fields_ = [
("pfnCreate", c_void_p), ## _urLoaderConfigCreate_t
("pfnRetain", c_void_p), ## _urLoaderConfigRetain_t
("pfnRelease", c_void_p), ## _urLoaderConfigRelease_t
("pfnGetInfo", c_void_p), ## _urLoaderConfigGetInfo_t
("pfnEnableLayer", c_void_p) ## _urLoaderConfigEnableLayer_t
]

###############################################################################
## @brief Function-pointer for urPlatformGet
if __use_win_types:
Expand Down Expand Up @@ -3792,7 +3745,6 @@ class ur_device_dditable_t(Structure):
###############################################################################
class ur_dditable_t(Structure):
_fields_ = [
("LoaderConfig", ur_loader_config_dditable_t),
("Platform", ur_platform_dditable_t),
("Context", ur_context_dditable_t),
("Event", ur_event_dditable_t),
Expand Down
4 changes: 3 additions & 1 deletion scripts/YaML.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,14 @@ class ur_name_t(Structure):
* A function requires the following scalar fields: {`desc`, `name`}
- `desc` will be used as the function's description comment
- `name` must be a unique ISO-C standard identifier, and be PascalCase
* A function may take the following optional scalar fields: {`class`, `decl`, `condition`, `ordinal`, `version`}
* A function may take the following optional scalar fields: {`class`, `decl`, `condition`, `ordinal`, `version`, `loader_only`}
- `class` will be used to scope the function declaration within the specified C++ class
- `decl` will be used to specify the function's linkage as one of the following: {`static`}
- `condition` will be used as a C/C++ preprocessor `#if` conditional expression
- `ordinal` will be used to override the default order (in which they appear) the function appears within its section; `default="1000"`
- `version` will be used to define the minimum API version in which the function will appear; `default="1.0"` This will also affect the order in which the function appears within its section and class.
- `loader_only` will be used to decide whether the function will only be implemented by the loader and not appear in the adapters
interface.
* A function requires the following sequence of mappings: {`params`}
- A param requires the following scalar fields: {`desc`, `type`, `name`}
+ `desc` will be used as the params's description comment
Expand Down
5 changes: 5 additions & 0 deletions scripts/core/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ etors:
type: function
desc: "Create a loader config object."
class: $xLoaderConfig
loader_only: True
name: Create
decl: static
params:
Expand All @@ -41,6 +42,7 @@ params:
type: function
desc: "Get a reference to the loader config object."
class: $xLoaderConfig
loader_only: True
name: Retain
decl: static
details:
Expand All @@ -55,6 +57,7 @@ params:
type: function
desc: "Release config handle."
class: $xLoaderConfig
loader_only: True
name: Release
decl: static
details:
Expand All @@ -80,6 +83,7 @@ etors:
type: function
desc: "Retrieves various information about the loader."
class: $xLoaderConfig
loader_only: True
name: GetInfo
decl: static
details:
Expand Down Expand Up @@ -122,6 +126,7 @@ returns:
type: function
desc: "Enable a layer for the specified loader config."
class: $xLoaderConfig
loader_only: True
name: EnableLayer
decl: static
params:
Expand Down
3 changes: 0 additions & 3 deletions scripts/templates/api.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ class ${N}_DDI:
self.__dll.${x}Init(0, 0)

%for tbl in tables:
%if 'Loader' in tbl['name']:
<% continue %>
%endif
# call driver to get function pointers
${tbl['name']} = ${tbl['type']}()
r = ${x}_result_v(self.__dll.${tbl['export']['name']}(version, byref(${tbl['name']})))
Expand Down
6 changes: 0 additions & 6 deletions scripts/templates/ddi.h.mako
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ extern "C" {
#endif

%for tbl in th.get_pfntables(specs, meta, n, tags):
%if 'Loader' in tbl['export']['name']:
<% continue %>
%endif
%for obj in tbl['functions']:
///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for ${th.make_func_name(n, tags, obj)}
Expand Down Expand Up @@ -97,9 +94,6 @@ typedef ${x}_result_t (${X}_APICALL *${tbl['pfn']})(
typedef struct ${n}_dditable_t
{
%for tbl in th.get_pfntables(specs, meta, n, tags):
%if 'loader' in tbl['type']:
<% continue %>
%endif
${th.append_ws(tbl['type'], 35)} ${tbl['name']};
%endfor
} ${n}_dditable_t;
Expand Down
12 changes: 12 additions & 0 deletions scripts/templates/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@ def is_global(item, tags):
except:
return False

@staticmethod
def is_loader_only(item):
try:
return item['loader_only']
except:
return False


"""
Public:
substitutes each tag['key'] with tag['value']
Expand Down Expand Up @@ -1047,6 +1055,9 @@ def get_pfntables(specs, meta, namespace, tags):
tables = []
for cname in sorted(meta['class'], key=lambda x: meta['class'][x]['ordinal']):
objs, exp_objs = get_class_function_objs_exp(specs, cname)
objs = list(filter(lambda obj: not function_traits.is_loader_only(obj), objs))
exp_objs = list(filter(lambda obj: not function_traits.is_loader_only(obj), exp_objs))

if len(objs) > 0:
name = get_table_name(namespace, tags, objs[0])
table = "%s_%s_dditable_t"%(namespace, _camel_to_snake(name))
Expand Down Expand Up @@ -1111,6 +1122,7 @@ def get_pfntables(specs, meta, namespace, tags):

return tables


"""
Private:
returns the list of parameters, filtering based on desc tags
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/libapi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ${th.make_func_name(n, tags, obj)}(
%endfor
)
try {
%if 'Loader' in obj['class']:
%if th.function_traits.is_loader_only(obj):
return ur_lib::${th.make_func_name(n, tags, obj)}(${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
%else:
%if re.match("Init", obj['name']):
Expand Down
3 changes: 0 additions & 3 deletions scripts/templates/libddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ namespace ${x}_lib
${x}_result_t result = ${X}_RESULT_SUCCESS;

%for tbl in th.get_pfntables(specs, meta, n, tags):
%if 'Loader' in tbl['export']['name']:
<% continue %>
%endif
if( ${X}_RESULT_SUCCESS == result )
{
result = ${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} );
Expand Down