Skip to content

Commit f071e84

Browse files
committed
Merge branch 'main' into review/yang/dg2
2 parents a232e5a + 6c2329e commit f071e84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4688
-3731
lines changed

cmake/helpers.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ function(add_ur_library name)
131131
add_library(${name} ${ARGN})
132132
add_ur_target_compile_options(${name})
133133
add_ur_target_link_options(${name})
134+
if(MSVC)
135+
target_link_options(${name} PRIVATE
136+
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:/DEPENDENTLOADFLAG:0x2000>
137+
)
138+
endif()
134139
endfunction()
135140

136141
include(FetchContent)

include/ur_api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7773,7 +7773,7 @@ UR_APIEXPORT ur_result_t UR_APICALL
77737773
urBindlessImagesImageCopyExp(
77747774
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
77757775
void *pDst, ///< [in] location the data will be copied to
7776-
void *pSrc, ///< [in] location the data will be copied from
7776+
const void *pSrc, ///< [in] location the data will be copied from
77777777
const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification
77787778
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
77797779
ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H
@@ -11139,7 +11139,7 @@ typedef struct ur_bindless_images_sampled_image_create_exp_params_t {
1113911139
typedef struct ur_bindless_images_image_copy_exp_params_t {
1114011140
ur_queue_handle_t *phQueue;
1114111141
void **ppDst;
11142-
void **ppSrc;
11142+
const void **ppSrc;
1114311143
const ur_image_format_t **ppImageFormat;
1114411144
const ur_image_desc_t **ppImageDesc;
1114511145
ur_exp_image_copy_flags_t *pimageCopyFlags;

include/ur_ddi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)(
15821582
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageCopyExp_t)(
15831583
ur_queue_handle_t,
15841584
void *,
1585-
void *,
1585+
const void *,
15861586
const ur_image_format_t *,
15871587
const ur_image_desc_t *,
15881588
ur_exp_image_copy_flags_t,

scripts/core/exp-bindless-images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ params:
527527
- type: void*
528528
name: pDst
529529
desc: "[in] location the data will be copied to"
530-
- type: void*
530+
- type: const void*
531531
name: pSrc
532532
desc: "[in] location the data will be copied from"
533533
- type: "const $x_image_format_t*"

scripts/templates/ldrddi.cpp.mako

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ from templates import helper as th
2323

2424
namespace ur_loader
2525
{
26-
///////////////////////////////////////////////////////////////////////////////
27-
%for obj in th.get_adapter_handles(specs):
28-
%if 'class' in obj:
29-
<%
30-
_handle_t = th.subt(n, tags, obj['name'])
31-
_factory_t = re.sub(r"(\w+)_handle_t", r"\1_factory_t", _handle_t)
32-
_factory = re.sub(r"(\w+)_handle_t", r"\1_factory", _handle_t)
33-
%>${th.append_ws(_factory_t, 35)} ${_factory};
34-
%endif
35-
%endfor
36-
3726
%for obj in th.get_adapter_functions(specs):
3827
///////////////////////////////////////////////////////////////////////////////
3928
/// @brief Intercept function for ${th.make_func_name(n, tags, obj)}
@@ -51,6 +40,7 @@ namespace ur_loader
5140
add_local = False
5241
%>${th.get_initial_null_set(obj)}
5342

43+
[[maybe_unused]] auto context = getContext();
5444
%if re.match(r"\w+AdapterGet$", th.make_func_name(n, tags, obj)):
5545

5646
size_t adapterIndex = 0;
@@ -63,7 +53,7 @@ namespace ur_loader
6353
platform.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( 1, &${obj['params'][1]['name']}[adapterIndex], nullptr );
6454
try
6555
{
66-
${obj['params'][1]['name']}[adapterIndex] = reinterpret_cast<${n}_adapter_handle_t>(${n}_adapter_factory.getInstance(
56+
${obj['params'][1]['name']}[adapterIndex] = reinterpret_cast<${n}_adapter_handle_t>(context->factories.${n}_adapter_factory.getInstance(
6757
${obj['params'][1]['name']}[adapterIndex], &platform.dditable
6858
));
6959
}
@@ -114,7 +104,7 @@ namespace ur_loader
114104
for( uint32_t i = 0; i < library_platform_handle_count; ++i ) {
115105
uint32_t platform_index = total_platform_handle_count + i;
116106
${obj['params'][3]['name']}[ platform_index ] = reinterpret_cast<${n}_platform_handle_t>(
117-
${n}_platform_factory.getInstance( ${obj['params'][3]['name']}[ platform_index ], dditable ) );
107+
context->factories.${n}_platform_factory.getInstance( ${obj['params'][3]['name']}[ platform_index ], dditable ) );
118108
}
119109
}
120110
catch( std::bad_alloc& )
@@ -272,9 +262,16 @@ namespace ur_loader
272262
%>
273263
%for i, item in enumerate(epilogue):
274264
%if 0 == i and not item['release'] and not item['retain'] and not th.always_wrap_outputs(obj):
275-
if( ${X}_RESULT_SUCCESS != result )
265+
## TODO: Remove once we have a concrete way for submitting warnings in place.
266+
%if re.match(r"urEnqueue\w+", th.make_func_name(n, tags, obj)):
267+
// In the event of ERROR_ADAPTER_SPECIFIC we should still attempt to wrap any output handles below.
268+
if( ${X}_RESULT_SUCCESS != result && ${X}_RESULT_ERROR_ADAPTER_SPECIFIC != result )
269+
return result;
270+
%else:
271+
if( ${X}_RESULT_SUCCESS != result)
276272
return result;
277273
274+
%endif
278275
%endif
279276
## Before we can re-enable the releases we will need ref-counted object_t.
280277
## See unified-runtime github issue #1784
@@ -294,7 +291,7 @@ namespace ur_loader
294291
for (size_t i = 0; i < nelements; ++i) {
295292
if (handles[i] != nullptr) {
296293
handles[i] = reinterpret_cast<${etor['type']}>(
297-
${etor['factory']}.getInstance( handles[i], dditable ) );
294+
context->factories.${etor['factory']}.getInstance( handles[i], dditable ) );
298295
}
299296
}
300297
} break;
@@ -306,16 +303,16 @@ namespace ur_loader
306303
// convert platform handles to loader handles
307304
for( size_t i = ${item['range'][0]}; ( nullptr != ${item['name']} ) && ( i < ${item['range'][1]} ); ++i )
308305
${item['name']}[ i ] = reinterpret_cast<${item['type']}>(
309-
${item['factory']}.getInstance( ${item['name']}[ i ], dditable ) );
306+
context->factories.${item['factory']}.getInstance( ${item['name']}[ i ], dditable ) );
310307
%else:
311308
// convert platform handle to loader handle
312309
%if item['optional'] or th.always_wrap_outputs(obj):
313310
if( nullptr != ${item['name']} )
314311
*${item['name']} = reinterpret_cast<${item['type']}>(
315-
${item['factory']}.getInstance( *${item['name']}, dditable ) );
312+
context->factories.${item['factory']}.getInstance( *${item['name']}, dditable ) );
316313
%else:
317314
*${item['name']} = reinterpret_cast<${item['type']}>(
318-
${item['factory']}.getInstance( *${item['name']}, dditable ) );
315+
context->factories.${item['factory']}.getInstance( *${item['name']}, dditable ) );
319316
%endif
320317
%endif
321318
}
@@ -360,13 +357,13 @@ ${tbl['export']['name']}(
360357
if( nullptr == pDdiTable )
361358
return ${X}_RESULT_ERROR_INVALID_NULL_POINTER;
362359
363-
if( ur_loader::context->version < version )
360+
if( ur_loader::getContext()->version < version )
364361
return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION;
365362
366363
${x}_result_t result = ${X}_RESULT_SUCCESS;
367364
368365
// Load the device-platform DDI tables
369-
for( auto& platform : ur_loader::context->platforms )
366+
for( auto& platform : ur_loader::getContext()->platforms )
370367
{
371368
if(platform.initStatus != ${X}_RESULT_SUCCESS)
372369
continue;
@@ -379,7 +376,7 @@ ${tbl['export']['name']}(
379376
380377
if( ${X}_RESULT_SUCCESS == result )
381378
{
382-
if( ur_loader::context->platforms.size() != 1 || ur_loader::context->forceIntercept )
379+
if( ur_loader::getContext()->platforms.size() != 1 || ur_loader::getContext()->forceIntercept )
383380
{
384381
// return pointers to loader's DDIs
385382
%for obj in tbl['functions']:
@@ -397,7 +394,7 @@ ${tbl['export']['name']}(
397394
else
398395
{
399396
// return pointers directly to platform's DDIs
400-
*pDdiTable = ur_loader::context->platforms.front().dditable.${n}.${tbl['name']};
397+
*pDdiTable = ur_loader::getContext()->platforms.front().dditable.${n}.${tbl['name']};
401398
}
402399
}
403400

scripts/templates/ldrddi.hpp.mako

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,29 @@ from templates import helper as th
2727
namespace ur_loader
2828
{
2929
///////////////////////////////////////////////////////////////////////////////
30+
<%
31+
factories = []
32+
%>
3033
%for obj in th.get_adapter_handles(specs):
3134
%if 'class' in obj:
3235
<%
3336
_handle_t = th.subt(n, tags, obj['name'])
3437
_object_t = re.sub(r"(\w+)_handle_t", r"\1_object_t", _handle_t)
3538
_factory_t = re.sub(r"(\w+)_handle_t", r"\1_factory_t", _handle_t)
39+
_factory = re.sub(r"(\w+)_handle_t", r"\1_factory", _handle_t)
40+
factories.append((_factory_t, _factory))
3641
%>using ${th.append_ws(_object_t, 35)} = object_t < ${_handle_t} >;
3742
using ${th.append_ws(_factory_t, 35)} = singleton_factory_t < ${_object_t}, ${_handle_t} >;
3843

3944
%endif
4045
%endfor
46+
47+
struct handle_factories {
48+
%for (f_t, f) in factories:
49+
${f_t} ${f};
50+
%endfor
51+
};
52+
4153
}
4254

4355
#endif /* UR_LOADER_LDRDDI_H */

scripts/templates/libapi.cpp.mako

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,10 @@ ${th.make_func_name(n, tags, obj)}(
5656
%endfor
5757
)
5858
try {
59-
%if re.match("Init", obj['name']):
60-
<%
61-
param_checks=th.make_param_checks(n, tags, obj, meta=meta).items()
62-
%>
63-
%for key, values in param_checks:
64-
%for val in values:
65-
if( ${val} )
66-
return ${key};
67-
68-
%endfor
69-
%endfor
70-
71-
static ${x}_result_t result = ${X}_RESULT_SUCCESS;
72-
std::call_once(${x}_lib::context->initOnce, [device_flags, hLoaderConfig]() {
73-
result = ${x}_lib::context->Init(device_flags, hLoaderConfig);
74-
});
75-
76-
return result;
77-
%elif th.obj_traits.is_loader_only(obj):
59+
%if th.obj_traits.is_loader_only(obj):
7860
return ur_lib::${th.make_func_name(n, tags, obj)}(${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
7961
%else:
80-
${th.get_initial_null_set(obj)}auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::context->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
62+
${th.get_initial_null_set(obj)}auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::getContext()->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
8163
if( nullptr == ${th.make_pfn_name(n, tags, obj)} )
8264
return ${X}_RESULT_ERROR_UNINITIALIZED;
8365

scripts/templates/libddi.cpp.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace ${x}_lib
2828
///////////////////////////////////////////////////////////////////////////////
2929

3030

31-
__${x}dlllocal ${x}_result_t context_t::${n}LoaderInit()
31+
__${x}dlllocal ${x}_result_t context_t::ddiInit()
3232
{
3333
${x}_result_t result = ${X}_RESULT_SUCCESS;
3434

scripts/templates/trcddi.cpp.mako

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ namespace ur_tracing_layer
3737
%endfor
3838
)
3939
{${th.get_initial_null_set(obj)}
40-
auto ${th.make_pfn_name(n, tags, obj)} = context.${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
40+
auto ${th.make_pfn_name(n, tags, obj)} = getContext()->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
4141

4242
if( nullptr == ${th.make_pfn_name(n, tags, obj)} )
4343
return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE;
4444

4545
${th.make_pfncb_param_type(n, tags, obj)} params = { &${",&".join(th.make_param_lines(n, tags, obj, format=["name"]))} };
46-
uint64_t instance = context.notify_begin(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", &params);
46+
uint64_t instance = getContext()->notify_begin(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", &params);
4747

48-
context.logger.info("---> ${th.make_func_name(n, tags, obj)}");
48+
getContext()->logger.info("---> ${th.make_func_name(n, tags, obj)}");
4949

5050
${x}_result_t result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
5151

52-
context.notify_end(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", &params, &result, instance);
52+
getContext()->notify_end(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", &params, &result, instance);
5353

5454
std::ostringstream args_str;
5555
ur::extras::printFunctionParams(args_str, ${th.make_func_etor(n, tags, obj)}, &params);
56-
context.logger.info("({}) -> {};\n", args_str.str(), result);
56+
getContext()->logger.info("({}) -> {};\n", args_str.str(), result);
5757

5858
return result;
5959
}
@@ -79,13 +79,13 @@ namespace ur_tracing_layer
7979
%endfor
8080
)
8181
{
82-
auto& dditable = ur_tracing_layer::context.${n}DdiTable.${tbl['name']};
82+
auto& dditable = ur_tracing_layer::getContext()->${n}DdiTable.${tbl['name']};
8383

8484
if( nullptr == pDdiTable )
8585
return ${X}_RESULT_ERROR_INVALID_NULL_POINTER;
8686

87-
if (UR_MAJOR_VERSION(ur_tracing_layer::context.version) != UR_MAJOR_VERSION(version) ||
88-
UR_MINOR_VERSION(ur_tracing_layer::context.version) > UR_MINOR_VERSION(version))
87+
if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != UR_MAJOR_VERSION(version) ||
88+
UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > UR_MINOR_VERSION(version))
8989
return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION;
9090

9191
${x}_result_t result = ${X}_RESULT_SUCCESS;
@@ -122,7 +122,7 @@ namespace ur_tracing_layer
122122
// program launch and the call to `urLoaderInit`
123123
logger = logger::create_logger("tracing", true, true);
124124

125-
ur_tracing_layer::context.codelocData = codelocData;
125+
ur_tracing_layer::getContext()->codelocData = codelocData;
126126

127127
%for tbl in th.get_pfntables(specs, meta, n, tags):
128128
if( ${X}_RESULT_SUCCESS == result )

scripts/templates/ur_api.hpp.mako

Whitespace-only changes.

0 commit comments

Comments
 (0)