Skip to content

Commit 26c0a40

Browse files
committed
Remove some more evidence of mock layer, change callbacks to singleton.
TODO: docs, testing
1 parent 46e3b7d commit 26c0a40

16 files changed

+618
-759
lines changed

include/ur_api.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ urLoaderConfigSetCodeLocationCallback(
742742

743743
///////////////////////////////////////////////////////////////////////////////
744744
/// @brief Callback to replace or instrument generic mock functionality in the
745-
/// mock layer.
745+
/// mock adapter.
746746
typedef ur_result_t (*ur_mock_callback_t)(
747747
void *pParams ///< [in][out] Pointer to the appropriate param struct for the function
748748
);
@@ -754,7 +754,7 @@ typedef ur_result_t (*ur_mock_callback_t)(
754754
/// - The mock adapter will default to returning ::UR_RESULT_SUCCESS for all
755755
/// entry points. It will also create and correctly reference count dummy
756756
/// handles where appropriate. Its behaviour can be modified by linking
757-
/// the ::ur_mock library and using the mock_callbacks object.
757+
/// the ::ur_mock_headers library and using the callbacks object.
758758
///
759759
/// @returns
760760
/// - ::UR_RESULT_SUCCESS

scripts/core/loader.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ params:
198198
type: function
199199
desc: "The only adapter reported with mock enabled will be the mock adapter."
200200
details:
201-
- "The mock adapter will default to returning $X_RESULT_SUCCESS for all entry points. It will also create and correctly reference count dummy handles where appropriate. Its behaviour can be modified by linking the $x_mock library and using the mock_callbacks object."
201+
- "The mock adapter will default to returning $X_RESULT_SUCCESS for all entry points. It will also create and correctly reference count dummy handles where appropriate. Its behaviour can be modified by linking the $x_mock_headers library and using the callbacks object."
202202
class: $xLoaderConfig
203203
loader_only: True
204204
name: "SetMockingEnabled"

scripts/generate_code.py

-29
Original file line numberDiff line numberDiff line change
@@ -287,30 +287,6 @@ def _mako_tracing_layer_cpp(path, namespace, tags, version, specs, meta):
287287
specs=specs,
288288
meta=meta)
289289

290-
"""
291-
generates c/c++ files from the specification documents
292-
"""
293-
def _mako_mock_layer_cpp(path, namespace, tags, version, specs, meta):
294-
dstpath = os.path.join(path, "mock")
295-
os.makedirs(dstpath, exist_ok=True)
296-
297-
template = "mockddi.cpp.mako"
298-
fin = os.path.join(templates_dir, template)
299-
300-
name = "%s_mockddi"%(namespace)
301-
filename = "%s.cpp"%(name)
302-
fout = os.path.join(dstpath, filename)
303-
304-
print("Generating %s..."%fout)
305-
return util.makoWrite(
306-
fin, fout,
307-
name=name,
308-
ver=version,
309-
namespace=namespace,
310-
tags=tags,
311-
specs=specs,
312-
meta=meta)
313-
314290
"""
315291
generates c/c++ files from the specification documents
316292
"""
@@ -441,11 +417,6 @@ def generate_layers(path, section, namespace, tags, version, specs, meta):
441417
loc += _mako_tracing_layer_cpp(layer_dstpath, namespace, tags, version, specs, meta)
442418
print("TRACING Generated %s lines of code.\n"%loc)
443419

444-
loc = 0
445-
loc += _mako_mock_layer_cpp(layer_dstpath, namespace, tags, version, specs, meta)
446-
print("MOCK Generated %s lines of code.\n"%loc)
447-
448-
449420
"""
450421
Entry-point:
451422
generates common utilities for unified_runtime

scripts/templates/mockddi.cpp.mako

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace driver
4343
${th.make_pfncb_param_type(n, tags, obj)} params = { &${",&".join(th.make_param_lines(n, tags, obj, format=["name"]))} };
4444

4545
auto beforeCallback = reinterpret_cast<ur_mock_callback_t>(
46-
mock::callbacks::get_before_callback("${fname}"));
46+
mock::callbacks.get_before_callback("${fname}"));
4747
if(beforeCallback) {
4848
result = beforeCallback( &params );
4949
if(result != UR_RESULT_SUCCESS) {
@@ -52,7 +52,7 @@ namespace driver
5252
}
5353

5454
auto replaceCallback = reinterpret_cast<ur_mock_callback_t>(
55-
mock::callbacks::get_replace_callback("${fname}"));
55+
mock::callbacks.get_replace_callback("${fname}"));
5656
if(replaceCallback) {
5757
result = replaceCallback( &params );
5858
}
@@ -104,7 +104,7 @@ namespace driver
104104
}
105105

106106
auto afterCallback = reinterpret_cast<ur_mock_callback_t>(
107-
mock::callbacks::get_after_callback("${fname}"));
107+
mock::callbacks.get_after_callback("${fname}"));
108108
if(afterCallback) {
109109
return afterCallback( &params );
110110
}

scripts/templates/valddi.cpp.mako

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ namespace ur_validation_layer
172172
%endfor
173173
${x}_result_t
174174
context_t::init(ur_dditable_t *dditable,
175-
const std::set<std::string> &enabledLayerNames, codeloc_data) {
175+
const std::set<std::string> &enabledLayerNames,
176+
codeloc_data) {
176177
${x}_result_t result = ${X}_RESULT_SUCCESS;
177178

178179
if (enabledLayerNames.count(nameFullValidation)) {

0 commit comments

Comments
 (0)