From 9d24b81d8357cb83ddba40421bb96e42748d1687 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Mon, 27 Nov 2023 13:20:52 +0100 Subject: [PATCH 1/7] [UR] Refactor validation layer refcount feature The leak checking feature has been expanded to include handles obtained via the ...Get() functions. --- scripts/templates/helper.py | 82 ++++++++++++------ scripts/templates/valddi.cpp.mako | 44 +++++----- source/loader/layers/validation/ur_valddi.cpp | 83 ++++++++++--------- 3 files changed, 126 insertions(+), 83 deletions(-) diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index 39fef9baac..bed05e9a8f 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -1486,45 +1486,79 @@ def get_loader_epilogue(specs, namespace, tags, obj, meta): return epilogue + +def get_event_wait_list_functions(specs, namespace, tags): + funcs = [] + for s in specs: + for obj in s['objects']: + if re.match(r"function", obj['type']): + if any(x['name'] == 'phEventWaitList' for x in obj['params']) and any( + x['name'] == 'numEventsInWaitList' for x in obj['params']): + funcs.append(make_func_name(namespace, tags, obj)) + return funcs + + """ -Public: - returns a dictionary with lists of create, retain and release functions +Private: + returns a dictionary with lists of create, get, retain and release functions """ -def get_create_retain_release_functions(specs, namespace, tags): +def _get_create_get_retain_release_functions(specs, namespace, tags): funcs = [] for s in specs: for obj in s['objects']: if re.match(r"function", obj['type']): funcs.append(make_func_name(namespace, tags, obj)) - create_suffixes = r"(Create[A-Za-z]*){1}" - retain_suffixes = r"(Retain){1}" - release_suffixes = r"(Release){1}" + create_suffixes = r"(Create[A-Za-z]*){1}$" + get_suffixes = r"(Get){1}$" + retain_suffixes = r"(Retain){1}$" + release_suffixes = r"(Release){1}$" + common_prefix = r"^" + namespace - create_exp = namespace + r"([A-Za-z]+)" + create_suffixes - retain_exp = namespace + r"([A-Za-z]+)" + retain_suffixes - release_exp = namespace + r"([A-Za-z]+)" + release_suffixes + create_exp = common_prefix + r"[A-Za-z]+" + create_suffixes + get_exp = common_prefix + r"[A-Za-z]+" + get_suffixes + retain_exp = common_prefix + r"[A-Za-z]+" + retain_suffixes + release_exp = common_prefix + r"[A-Za-z]+" + release_suffixes - create_funcs, retain_funcs, release_funcs = ( + create_funcs, get_funcs, retain_funcs, release_funcs = ( list(filter(lambda f: re.match(create_exp, f), funcs)), + list(filter(lambda f: re.match(get_exp, f), funcs)), list(filter(lambda f: re.match(retain_exp, f), funcs)), list(filter(lambda f: re.match(release_exp, f), funcs)), ) - create_funcs, retain_funcs = ( - list(filter(lambda f: re.sub(create_suffixes, "Release", f) in release_funcs, create_funcs)), - list(filter(lambda f: re.sub(retain_suffixes, "Release", f) in release_funcs, retain_funcs)), - ) + return {"create": create_funcs, "get": get_funcs, "retain": retain_funcs, "release": release_funcs} - return {"create": create_funcs, "retain": retain_funcs, "release": release_funcs} +""" +Public: + returns a list of dictionaries containing handle types and the corresponding create, get, retain and release functions +""" +def get_handle_create_get_retain_release_functions(specs, namespace, tags): + # Handles without release function + excluded_handles = ["$x_platform_handle_t", "$x_native_handle_t"] + # Handles from experimental features + exp_prefix = "$x_exp" + + funcs = _get_create_get_retain_release_functions(specs, namespace, tags) + records = [] + for h in get_adapter_handles(specs): + if h['name'] in excluded_handles or h['name'].startswith(exp_prefix): + continue -def get_event_wait_list_functions(specs, namespace, tags): - funcs = [] - for s in specs: - for obj in s['objects']: - if re.match(r"function", obj['type']): - if any(x['name'] == 'phEventWaitList' for x in obj['params']) and any( - x['name'] == 'numEventsInWaitList' for x in obj['params']): - funcs.append(make_func_name(namespace, tags, obj)) - return funcs + class_type = subt(namespace, tags, h['class']) + create_funcs = list(filter(lambda f: class_type in f, funcs['create'])) + get_funcs = list(filter(lambda f: class_type in f, funcs['get'])) + retain_funcs = list(filter(lambda f: class_type in f, funcs['retain'])) + release_funcs = list(filter(lambda f: class_type in f, funcs['release'])) + + record = {} + record['handle'] = subt(namespace, tags, h['name']) + record['create'] = create_funcs + record['get'] = get_funcs + record['retain'] = retain_funcs + record['release'] = release_funcs + + records.append(record) + + return records diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index 2e9bac3200..3e7d039c4b 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -7,7 +7,8 @@ from templates import helper as th x=tags['$x'] X=x.upper() - create_retain_release_funcs=th.get_create_retain_release_functions(specs, n, tags) + + handle_create_get_retain_release_funcs=th.get_handle_create_get_retain_release_functions(specs, n, tags) %>/* * * Copyright (C) 2023 Intel Corporation @@ -27,11 +28,12 @@ namespace ur_validation_layer %for obj in th.get_adapter_functions(specs): <% func_name=th.make_func_name(n, tags, obj) - object_param=th.make_param_lines(n, tags, obj, format=["name"])[-1] - object_param_type=th.make_param_lines(n, tags, obj, format=["type"])[-1] + param_checks=th.make_param_checks(n, tags, obj, meta=meta).items() first_errors = [X + "_RESULT_ERROR_INVALID_NULL_POINTER", X + "_RESULT_ERROR_INVALID_NULL_HANDLE"] sorted_param_checks = sorted(param_checks, key=lambda pair: False if pair[0] in first_errors else True) + + tracked_params = list(filter(lambda p: any(th.subt(n, tags, p['type']) in [hf['handle'], hf['handle'] + "*"] for hf in handle_create_get_retain_release_funcs), obj['params'])) %> /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for ${th.make_func_name(n, tags, obj)} @@ -74,37 +76,35 @@ namespace ur_validation_layer ${x}_result_t result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); - %if func_name == n + "AdapterRelease": - if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) - { - refCountContext.decrementRefCount(${object_param}, true); - } - %elif func_name == n + "AdapterRetain": + %for tp in tracked_params: + <% + tp_handle_funcs = next((hf for hf in handle_create_get_retain_release_funcs if th.subt(n, tags, tp['type']) in [hf['handle'], hf['handle'] + "*"]), None) + is_handle_to_adapter = ("_adapter_handle_t" in tp['type']) + %> + %if func_name in tp_handle_funcs['create']: if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) { - refCountContext.incrementRefCount(${object_param}, true); + refCountContext.createRefCount(*${tp['name']}); } - %elif func_name == n + "AdapterGet": - if( context.enableLeakChecking && phAdapters && result == UR_RESULT_SUCCESS ) + %elif func_name in tp_handle_funcs['get']: + if( context.enableLeakChecking && ${tp['name']} && result == UR_RESULT_SUCCESS ) { - refCountContext.createOrIncrementRefCount(*phAdapters, true); - } - %elif func_name in create_retain_release_funcs["create"]: - if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) - { - refCountContext.createRefCount(*${object_param}); + for (uint32_t i = ${th.param_traits.range_start(tp)}; i < ${th.param_traits.range_end(tp)}; i++) { + refCountContext.createOrIncrementRefCount(${tp['name']}[i], ${str(is_handle_to_adapter).lower()}); + } } - %elif func_name in create_retain_release_funcs["retain"]: + %elif func_name in tp_handle_funcs['retain']: if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) { - refCountContext.incrementRefCount(${object_param}); + refCountContext.incrementRefCount(${tp['name']}, ${str(is_handle_to_adapter).lower()}); } - %elif func_name in create_retain_release_funcs["release"]: + %elif func_name in tp_handle_funcs['release']: if( context.enableLeakChecking && result == UR_RESULT_SUCCESS ) { - refCountContext.decrementRefCount(${object_param}); + refCountContext.decrementRefCount(${tp['name']}, ${str(is_handle_to_adapter).lower()}); } %endif + %endfor return result; } diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index db59ca3b11..1a8f83e60f 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -42,7 +42,9 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( if (context.enableLeakChecking && phAdapters && result == UR_RESULT_SUCCESS) { - refCountContext.createOrIncrementRefCount(*phAdapters, true); + for (uint32_t i = 0; i < NumEntries; i++) { + refCountContext.createOrIncrementRefCount(phAdapters[i], true); + } } return result; @@ -439,6 +441,13 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_result_t result = pfnGet(hPlatform, DeviceType, NumEntries, phDevices, pNumDevices); + if (context.enableLeakChecking && phDevices && + result == UR_RESULT_SUCCESS) { + for (uint32_t i = 0; i < NumEntries; i++) { + refCountContext.createOrIncrementRefCount(phDevices[i], false); + } + } + return result; } @@ -513,7 +522,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( ur_result_t result = pfnRetain(hDevice); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hDevice); + refCountContext.incrementRefCount(hDevice, false); } return result; @@ -539,7 +548,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( ur_result_t result = pfnRelease(hDevice); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hDevice); + refCountContext.decrementRefCount(hDevice, false); } return result; @@ -788,7 +797,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( ur_result_t result = pfnRetain(hContext); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hContext); + refCountContext.incrementRefCount(hContext, false); } return result; @@ -814,7 +823,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( ur_result_t result = pfnRelease(hContext); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hContext); + refCountContext.decrementRefCount(hContext, false); } return result; @@ -1028,6 +1037,10 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( ur_result_t result = pfnImageCreate(hContext, flags, pImageFormat, pImageDesc, pHost, phMem); + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.createRefCount(*phMem); + } + return result; } @@ -1083,6 +1096,10 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( ur_result_t result = pfnBufferCreate(hContext, flags, size, pProperties, phBuffer); + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.createRefCount(*phBuffer); + } + return result; } @@ -1106,7 +1123,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRetain( ur_result_t result = pfnRetain(hMem); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hMem); + refCountContext.incrementRefCount(hMem, false); } return result; @@ -1132,7 +1149,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( ur_result_t result = pfnRelease(hMem); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hMem); + refCountContext.decrementRefCount(hMem, false); } return result; @@ -1249,6 +1266,10 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( ur_result_t result = pfnBufferCreateWithNativeHandle(hNativeMem, hContext, pProperties, phMem); + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.createRefCount(*phMem); + } + return result; } @@ -1294,6 +1315,10 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( ur_result_t result = pfnImageCreateWithNativeHandle( hNativeMem, hContext, pImageFormat, pImageDesc, pProperties, phMem); + if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { + refCountContext.createRefCount(*phMem); + } + return result; } @@ -1465,7 +1490,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( ur_result_t result = pfnRetain(hSampler); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hSampler); + refCountContext.incrementRefCount(hSampler, false); } return result; @@ -1492,7 +1517,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( ur_result_t result = pfnRelease(hSampler); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hSampler); + refCountContext.decrementRefCount(hSampler, false); } return result; @@ -1891,7 +1916,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( ur_result_t result = pfnPoolRetain(pPool); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(pPool); + refCountContext.incrementRefCount(pPool, false); } return result; @@ -1917,7 +1942,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( ur_result_t result = pfnPoolRelease(pPool); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(pPool); + refCountContext.decrementRefCount(pPool, false); } return result; @@ -2308,7 +2333,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( ur_result_t result = pfnRetain(hPhysicalMem); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hPhysicalMem); + refCountContext.incrementRefCount(hPhysicalMem, false); } return result; @@ -2335,7 +2360,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( ur_result_t result = pfnRelease(hPhysicalMem); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hPhysicalMem); + refCountContext.decrementRefCount(hPhysicalMem, false); } return result; @@ -2574,7 +2599,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRetain( ur_result_t result = pfnRetain(hProgram); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hProgram); + refCountContext.incrementRefCount(hProgram, false); } return result; @@ -2600,7 +2625,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( ur_result_t result = pfnRelease(hProgram); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hProgram); + refCountContext.decrementRefCount(hProgram, false); } return result; @@ -3098,7 +3123,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRetain( ur_result_t result = pfnRetain(hKernel); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hKernel); + refCountContext.incrementRefCount(hKernel, false); } return result; @@ -3124,7 +3149,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( ur_result_t result = pfnRelease(hKernel); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hKernel); + refCountContext.decrementRefCount(hKernel, false); } return result; @@ -3489,7 +3514,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRetain( ur_result_t result = pfnRetain(hQueue); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hQueue); + refCountContext.incrementRefCount(hQueue, false); } return result; @@ -3515,7 +3540,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( ur_result_t result = pfnRelease(hQueue); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hQueue); + refCountContext.decrementRefCount(hQueue, false); } return result; @@ -3772,7 +3797,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( ur_result_t result = pfnRetain(hEvent); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hEvent); + refCountContext.incrementRefCount(hEvent, false); } return result; @@ -3798,7 +3823,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRelease( ur_result_t result = pfnRelease(hEvent); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hEvent); + refCountContext.decrementRefCount(hEvent, false); } return result; @@ -6569,10 +6594,6 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hInteropMem); - } - return result; } @@ -6806,10 +6827,6 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( ur_result_t result = pfnRetainExp(hCommandBuffer); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.incrementRefCount(hCommandBuffer); - } - return result; } @@ -6833,10 +6850,6 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_result_t result = pfnReleaseExp(hCommandBuffer); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(hCommandBuffer); - } - return result; } @@ -7895,10 +7908,6 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( ur_result_t result = pfnReleaseExp(hContext, pMem); - if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { - refCountContext.decrementRefCount(pMem); - } - return result; } From 1c5e22b76e1f7ada4b4939cbe76aeed251d7e010 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Wed, 29 Nov 2023 10:34:33 +0100 Subject: [PATCH 2/7] [UR] Adjust validation layer leak tests Match files in leak checking tests also account for the ..Create(), ..Get() and ..Release() functions used in test setups. --- test/layers/validation/fixtures.hpp | 8 ++++++++ test/layers/validation/leaks.out.match | 14 ++++++++++++++ test/layers/validation/leaks_mt.out.match | 12 ++++++++++++ 3 files changed, 34 insertions(+) diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index ab92ba1e01..4071bbecad 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -91,6 +91,14 @@ struct valAllDevicesTest : valPlatformTest { FAIL() << "Failed to get devices"; } } + + void TearDown() override { + for (auto device : devices) { + ASSERT_EQ(urDeviceRelease(device), UR_RESULT_SUCCESS); + } + valPlatformTest::TearDown(); + } + std::vector devices; }; diff --git a/test/layers/validation/leaks.out.match b/test/layers/validation/leaks.out.match index 2a36a22263..4c7d6d3546 100644 --- a/test/layers/validation/leaks.out.match +++ b/test/layers/validation/leaks.out.match @@ -16,6 +16,8 @@ [ RUN ] valDeviceTest.testUrContextCreateLeak [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: @@ -23,45 +25,57 @@ [ RUN ] valDeviceTest.testUrContextRetainLeak [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained 2 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] valDeviceTest.testUrContextRetainNonexistent [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 {{IGNORE}} [ RUN ] valDeviceTest.testUrContextCreateSuccess [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 {{IGNORE}} [ RUN ] valDeviceTest.testUrContextRetainSuccess [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 {{IGNORE}} [ RUN ] valDeviceTest.testUrContextReleaseLeak [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] valDeviceTest.testUrContextReleaseNonexistent [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} diff --git a/test/layers/validation/leaks_mt.out.match b/test/layers/validation/leaks_mt.out.match index f1bd32f8b5..f0b318249d 100644 --- a/test/layers/validation/leaks_mt.out.match +++ b/test/layers/validation/leaks_mt.out.match @@ -2,15 +2,18 @@ [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainLeakMt/0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 3 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained 3 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainLeakMt/1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 3 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 4 @@ -20,22 +23,26 @@ [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 8 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 9 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained 9 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextReleaseLeakMt/0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextReleaseLeakMt/1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 @@ -52,23 +59,27 @@ [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -7 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained -7 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainReleaseLeakMt/0 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainReleaseLeakMt/1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} @@ -86,6 +97,7 @@ [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: {{IGNORE}} From f7bd6d9376edee23e36c8baa4c2ca36e7dce13b3 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Mon, 27 Nov 2023 17:28:47 +0100 Subject: [PATCH 3/7] [UR] Add lifetime validation to validation layer --- scripts/templates/valddi.cpp.mako | 20 +- .../layers/validation/ur_leak_check.hpp | 6 + source/loader/layers/validation/ur_valddi.cpp | 999 +++++++++++++++++- .../layers/validation/ur_validation_layer.hpp | 5 +- 4 files changed, 1027 insertions(+), 3 deletions(-) diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index 3e7d039c4b..1baf0a4773 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -74,6 +74,18 @@ namespace ur_validation_layer } + %for tp in tracked_params: + <% + tp_input_handle_funcs = next((hf for hf in handle_create_get_retain_release_funcs if th.subt(n, tags, tp['type']) == hf['handle'] and "[in]" in tp['desc']), {}) + is_related_create_get_retain_release_func = any(func_name in funcs for funcs in tp_input_handle_funcs.values()) + %> + %if tp_input_handle_funcs and not is_related_create_get_retain_release_func: + if (context.enableLifetimeValidation && !refCountContext.isReferenceValid(${tp['name']})) { + refCountContext.logInvalidReference(${tp['name']}); + } + %endif + %endfor + ${x}_result_t result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); %for tp in tracked_params: @@ -167,6 +179,7 @@ namespace ur_validation_layer if (enabledLayerNames.count(nameFullValidation)) { enableParameterValidation = true; enableLeakChecking = true; + enableLifetimeValidation = true; } else { if (enabledLayerNames.count(nameParameterValidation)) { enableParameterValidation = true; @@ -174,9 +187,14 @@ namespace ur_validation_layer if (enabledLayerNames.count(nameLeakChecking)) { enableLeakChecking = true; } + if (enabledLayerNames.count(nameLifetimeValidation)) { + // Handle lifetime validation requires leak checking feature. + enableLifetimeValidation = true; + enableLeakChecking = true; + } } - if(!enableParameterValidation && !enableLeakChecking) { + if (!enableParameterValidation && !enableLeakChecking && !enableLifetimeValidation) { return result; } diff --git a/source/loader/layers/validation/ur_leak_check.hpp b/source/loader/layers/validation/ur_leak_check.hpp index 3f3fb80b0b..b7cb487f88 100644 --- a/source/loader/layers/validation/ur_leak_check.hpp +++ b/source/loader/layers/validation/ur_leak_check.hpp @@ -115,6 +115,8 @@ struct RefCountContext { void clear() { counts.clear(); } + bool isReferenceValid(void *ptr) { return counts.count(ptr) > 0; } + void logInvalidReferences() { for (auto &[ptr, refRuntimeInfo] : counts) { context.logger.error("Retained {} reference(s) to handle {}", @@ -128,6 +130,10 @@ struct RefCountContext { } } + void logInvalidReference(void *ptr) { + context.logger.error("There are no valid references to handle {}", ptr); + } + } refCountContext; } // namespace ur_validation_layer diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 1a8f83e60f..7a4e5e0410 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -134,6 +134,11 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hAdapter)) { + refCountContext.logInvalidReference(hAdapter); + } + ur_result_t result = pfnAdapterGetLastError(hAdapter, ppMessage, pError); return result; @@ -182,6 +187,11 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hAdapter)) { + refCountContext.logInvalidReference(hAdapter); + } + ur_result_t result = pfnAdapterGetInfo(hAdapter, propName, propSize, pPropValue, pPropSizeRet); @@ -495,6 +505,11 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetInfo(hDevice, propName, propSize, pPropValue, pPropSizeRet); @@ -589,6 +604,11 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnPartition(hDevice, pProperties, NumDevices, phSubDevices, pNumDevicesRet); @@ -633,6 +653,11 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnSelectBinary(hDevice, pBinaries, NumBinaries, pSelectedBinary); @@ -662,6 +687,11 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetNativeHandle(hDevice, phNativeDevice); return result; @@ -729,6 +759,11 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetGlobalTimestamps(hDevice, pDeviceTimestamp, pHostTimestamp); @@ -874,6 +909,11 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnGetInfo(hContext, propName, propSize, pPropValue, pPropSizeRet); @@ -903,6 +943,11 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnGetNativeHandle(hContext, phNativeContext); return result; @@ -974,6 +1019,11 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnSetExtendedDeleter(hContext, pfnDeleter, pUserData); return result; @@ -1034,6 +1084,11 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnImageCreate(hContext, flags, pImageFormat, pImageDesc, pHost, phMem); @@ -1093,6 +1148,11 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnBufferCreate(hContext, flags, size, pProperties, phBuffer); @@ -1195,6 +1255,11 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnBufferPartition(hBuffer, flags, bufferCreateType, pRegion, phMem); @@ -1230,6 +1295,16 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hMem)) { + refCountContext.logInvalidReference(hMem); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetNativeHandle(hMem, hDevice, phNativeMem); return result; @@ -1263,6 +1338,11 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnBufferCreateWithNativeHandle(hNativeMem, hContext, pProperties, phMem); @@ -1312,6 +1392,11 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnImageCreateWithNativeHandle( hNativeMem, hContext, pImageFormat, pImageDesc, pProperties, phMem); @@ -1367,6 +1452,11 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hMemory)) { + refCountContext.logInvalidReference(hMemory); + } + ur_result_t result = pfnGetInfo(hMemory, propName, propSize, pPropValue, pPropSizeRet); @@ -1417,6 +1507,11 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hMemory)) { + refCountContext.logInvalidReference(hMemory); + } + ur_result_t result = pfnImageGetInfo(hMemory, propName, propSize, pPropValue, pPropSizeRet); @@ -1460,6 +1555,11 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnCreate(hContext, pDesc, phSampler); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { @@ -1564,6 +1664,11 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hSampler)) { + refCountContext.logInvalidReference(hSampler); + } + ur_result_t result = pfnGetInfo(hSampler, propName, propSize, pPropValue, pPropSizeRet); @@ -1593,6 +1698,11 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hSampler)) { + refCountContext.logInvalidReference(hSampler); + } + ur_result_t result = pfnGetNativeHandle(hSampler, phNativeSampler); return result; @@ -1626,6 +1736,11 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnCreateWithNativeHandle(hNativeSampler, hContext, pProperties, phSampler); @@ -1677,6 +1792,16 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(pool)) { + refCountContext.logInvalidReference(pool); + } + ur_result_t result = pfnHostAlloc(hContext, pUSMDesc, pool, size, ppMem); return result; @@ -1728,6 +1853,21 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(pool)) { + refCountContext.logInvalidReference(pool); + } + ur_result_t result = pfnDeviceAlloc(hContext, hDevice, pUSMDesc, pool, size, ppMem); @@ -1780,6 +1920,21 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(pool)) { + refCountContext.logInvalidReference(pool); + } + ur_result_t result = pfnSharedAlloc(hContext, hDevice, pUSMDesc, pool, size, ppMem); @@ -1808,6 +1963,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnFree(hContext, pMem); return result; @@ -1848,6 +2008,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnGetMemAllocInfo(hContext, pMem, propName, propSize, pPropValue, pPropSizeRet); @@ -1887,6 +2052,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnPoolCreate(hContext, pPoolDesc, ppPool); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { @@ -1988,6 +2158,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hPool)) { + refCountContext.logInvalidReference(hPool); + } + ur_result_t result = pfnPoolGetInfo(hPool, propName, propSize, pPropValue, pPropSizeRet); @@ -2042,6 +2217,16 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGranularityGetInfo( hContext, hDevice, propName, propSize, pPropValue, pPropSizeRet); @@ -2078,6 +2263,11 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnReserve(hContext, pStart, size, ppStart); return result; @@ -2107,6 +2297,11 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnFree(hContext, pStart, size); return result; @@ -2150,6 +2345,16 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hPhysicalMem)) { + refCountContext.logInvalidReference(hPhysicalMem); + } + ur_result_t result = pfnMap(hContext, pStart, size, hPhysicalMem, offset, flags); @@ -2180,6 +2385,11 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnUnmap(hContext, pStart, size); return result; @@ -2215,6 +2425,11 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnSetAccess(hContext, pStart, size, flags); return result; @@ -2258,6 +2473,11 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnGetInfo(hContext, pStart, size, propName, propSize, pPropValue, pPropSizeRet); @@ -2302,6 +2522,16 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnCreate(hContext, hDevice, size, pProperties, phPhysicalMem); @@ -2411,6 +2641,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnCreateWithIL(hContext, pIL, length, pProperties, phProgram); @@ -2468,6 +2703,16 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnCreateWithBinary(hContext, hDevice, size, pBinary, pProperties, phProgram); @@ -2502,6 +2747,16 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnBuild(hContext, hProgram, pOptions); return result; @@ -2532,6 +2787,16 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnCompile(hContext, hProgram, pOptions); return result; @@ -2573,6 +2838,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnLink(hContext, count, phPrograms, pOptions, phProgram); @@ -2670,6 +2940,16 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnGetFunctionPointer(hDevice, hProgram, pFunctionName, ppFunctionPointer); @@ -2720,6 +3000,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnGetInfo(hProgram, propName, propSize, pPropValue, pPropSizeRet); @@ -2764,6 +3049,16 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetBuildInfo(hProgram, hDevice, propName, propSize, pPropValue, pPropSizeRet); @@ -2800,6 +3095,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnSetSpecializationConstants(hProgram, count, pSpecConstants); @@ -2829,6 +3129,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnGetNativeHandle(hProgram, phNativeProgram); return result; @@ -2862,6 +3167,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnCreateWithNativeHandle(hNativeProgram, hContext, pProperties, phProgram); @@ -2900,6 +3210,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnCreate(hProgram, pKernelName, phKernel); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { @@ -2936,6 +3251,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnSetArgValue(hKernel, argIndex, argSize, pProperties, pArgValue); @@ -2964,6 +3284,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnSetArgLocal(hKernel, argIndex, argSize, pProperties); @@ -3015,6 +3340,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnGetInfo(hKernel, propName, propSize, pPropValue, pPropSizeRet); @@ -3056,6 +3386,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetGroupInfo(hKernel, hDevice, propName, propSize, pPropValue, pPropSizeRet); @@ -3097,6 +3437,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnGetSubGroupInfo(hKernel, hDevice, propName, propSize, pPropValue, pPropSizeRet); @@ -3178,6 +3528,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnSetArgPointer(hKernel, argIndex, pProperties, pArgValue); @@ -3216,6 +3571,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnSetExecInfo(hKernel, propName, propSize, pProperties, pPropValue); @@ -3247,6 +3607,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hArgValue)) { + refCountContext.logInvalidReference(hArgValue); + } + ur_result_t result = pfnSetArgSampler(hKernel, argIndex, pProperties, hArgValue); @@ -3279,6 +3649,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hArgValue)) { + refCountContext.logInvalidReference(hArgValue); + } + ur_result_t result = pfnSetArgMemObj(hKernel, argIndex, pProperties, hArgValue); @@ -3314,6 +3694,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnSetSpecializationConstants(hKernel, count, pSpecConstants); @@ -3343,6 +3728,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnGetNativeHandle(hKernel, phNativeKernel); return result; @@ -3382,6 +3772,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnCreateWithNativeHandle( hNativeKernel, hContext, hProgram, pProperties, phKernel); @@ -3433,6 +3833,11 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnGetInfo(hQueue, propName, propSize, pPropValue, pPropSizeRet); @@ -3485,6 +3890,16 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnCreate(hContext, hDevice, pProperties, phQueue); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { @@ -3571,6 +3986,11 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnGetNativeHandle(hQueue, pDesc, phNativeQueue); return result; @@ -3609,6 +4029,16 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnCreateWithNativeHandle( hNativeQueue, hContext, hDevice, pProperties, phQueue); @@ -3636,6 +4066,11 @@ __urdlllocal ur_result_t UR_APICALL urQueueFinish( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnFinish(hQueue); return result; @@ -3658,6 +4093,11 @@ __urdlllocal ur_result_t UR_APICALL urQueueFlush( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnFlush(hQueue); return result; @@ -3702,6 +4142,11 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hEvent)) { + refCountContext.logInvalidReference(hEvent); + } + ur_result_t result = pfnGetInfo(hEvent, propName, propSize, pPropValue, pPropSizeRet); @@ -3742,6 +4187,11 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hEvent)) { + refCountContext.logInvalidReference(hEvent); + } + ur_result_t result = pfnGetProfilingInfo(hEvent, propName, propSize, pPropValue, pPropSizeRet); @@ -3852,6 +4302,11 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hEvent)) { + refCountContext.logInvalidReference(hEvent); + } + ur_result_t result = pfnGetNativeHandle(hEvent, phNativeEvent); return result; @@ -3885,6 +4340,11 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnCreateWithNativeHandle(hNativeEvent, hContext, pProperties, phEvent); @@ -3928,6 +4388,11 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hEvent)) { + refCountContext.logInvalidReference(hEvent); + } + ur_result_t result = pfnSetCallback(hEvent, execStatus, pfnNotify, pUserData); @@ -4005,6 +4470,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnKernelLaunch( hQueue, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numEventsInWaitList, phEventWaitList, phEvent); @@ -4055,6 +4530,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnEventsWait(hQueue, numEventsInWaitList, phEventWaitList, phEvent); @@ -4105,6 +4585,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnEventsWaitWithBarrier(hQueue, numEventsInWaitList, phEventWaitList, phEvent); @@ -4172,6 +4657,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnMemBufferRead(hQueue, hBuffer, blockingRead, offset, size, pDst, numEventsInWaitList, phEventWaitList, phEvent); @@ -4242,6 +4737,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnMemBufferWrite(hQueue, hBuffer, blockingWrite, offset, size, pSrc, numEventsInWaitList, phEventWaitList, phEvent); @@ -4362,6 +4867,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnMemBufferReadRect( hQueue, hBuffer, blockingRead, bufferOrigin, hostOrigin, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, @@ -4487,6 +5002,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnMemBufferWriteRect( hQueue, hBuffer, blockingWrite, bufferOrigin, hostOrigin, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, @@ -4562,6 +5087,21 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBufferSrc)) { + refCountContext.logInvalidReference(hBufferSrc); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBufferDst)) { + refCountContext.logInvalidReference(hBufferDst); + } + ur_result_t result = pfnMemBufferCopy(hQueue, hBufferSrc, hBufferDst, srcOffset, dstOffset, size, numEventsInWaitList, phEventWaitList, phEvent); @@ -4681,6 +5221,21 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBufferSrc)) { + refCountContext.logInvalidReference(hBufferSrc); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBufferDst)) { + refCountContext.logInvalidReference(hBufferDst); + } + ur_result_t result = pfnMemBufferCopyRect( hQueue, hBufferSrc, hBufferDst, srcOrigin, dstOrigin, region, srcRowPitch, srcSlicePitch, dstRowPitch, dstSlicePitch, @@ -4770,6 +5325,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnMemBufferFill(hQueue, hBuffer, pPattern, patternSize, offset, size, numEventsInWaitList, phEventWaitList, phEvent); @@ -4847,6 +5412,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hImage)) { + refCountContext.logInvalidReference(hImage); + } + ur_result_t result = pfnMemImageRead( hQueue, hImage, blockingRead, origin, region, rowPitch, slicePitch, pDst, numEventsInWaitList, phEventWaitList, phEvent); @@ -4925,6 +5500,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hImage)) { + refCountContext.logInvalidReference(hImage); + } + ur_result_t result = pfnMemImageWrite( hQueue, hImage, blockingWrite, origin, region, rowPitch, slicePitch, pSrc, numEventsInWaitList, phEventWaitList, phEvent); @@ -5009,6 +5594,21 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hImageSrc)) { + refCountContext.logInvalidReference(hImageSrc); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hImageDst)) { + refCountContext.logInvalidReference(hImageDst); + } + ur_result_t result = pfnMemImageCopy(hQueue, hImageSrc, hImageDst, srcOrigin, dstOrigin, region, numEventsInWaitList, phEventWaitList, phEvent); @@ -5083,6 +5683,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnMemBufferMap(hQueue, hBuffer, blockingMap, mapFlags, offset, size, numEventsInWaitList, phEventWaitList, phEvent, ppRetMap); @@ -5143,6 +5753,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hMem)) { + refCountContext.logInvalidReference(hMem); + } + ur_result_t result = pfnMemUnmap(hQueue, hMem, pMappedPtr, numEventsInWaitList, phEventWaitList, phEvent); @@ -5229,6 +5849,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnUSMFill(hQueue, pMem, patternSize, pPattern, size, numEventsInWaitList, phEventWaitList, phEvent); @@ -5306,6 +5931,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnUSMMemcpy(hQueue, blocking, pDst, pSrc, size, numEventsInWaitList, phEventWaitList, phEvent); @@ -5376,6 +6006,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnUSMPrefetch(hQueue, pMem, size, flags, numEventsInWaitList, phEventWaitList, phEvent); @@ -5424,6 +6059,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnUSMAdvise(hQueue, pMem, size, advice, phEvent); return result; @@ -5529,6 +6169,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnUSMFill2D(hQueue, pMem, pitch, patternSize, pPattern, width, height, numEventsInWaitList, phEventWaitList, phEvent); @@ -5628,6 +6273,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnUSMMemcpy2D(hQueue, blocking, pDst, dstPitch, pSrc, srcPitch, width, height, numEventsInWaitList, phEventWaitList, phEvent); @@ -5699,6 +6349,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnDeviceGlobalVariableWrite( hQueue, hProgram, name, blockingWrite, count, offset, pSrc, numEventsInWaitList, phEventWaitList, phEvent); @@ -5770,6 +6430,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnDeviceGlobalVariableRead( hQueue, hProgram, name, blockingRead, count, offset, pDst, numEventsInWaitList, phEventWaitList, phEvent); @@ -5844,6 +6514,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnReadHostPipe(hQueue, hProgram, pipe_symbol, blocking, pDst, size, numEventsInWaitList, phEventWaitList, phEvent); @@ -5918,6 +6598,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnWriteHostPipe(hQueue, hProgram, pipe_symbol, blocking, pSrc, size, numEventsInWaitList, phEventWaitList, phEvent); @@ -5979,6 +6669,21 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(pool)) { + refCountContext.logInvalidReference(pool); + } + ur_result_t result = pfnPitchedAllocExp(hContext, hDevice, pUSMDesc, pool, widthInBytes, height, elementSizeBytes, ppMem, pResultPitch); @@ -6016,6 +6721,16 @@ urBindlessImagesUnsampledImageHandleDestroyExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); @@ -6052,6 +6767,16 @@ urBindlessImagesSampledImageHandleDestroyExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); @@ -6102,6 +6827,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnImageAllocateExp(hContext, hDevice, pImageFormat, pImageDesc, phImageMem); @@ -6136,6 +6871,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnImageFreeExp(hContext, hDevice, hImageMem); return result; @@ -6196,6 +6941,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnUnsampledImageCreateExp( hContext, hDevice, hImageMem, pImageFormat, pImageDesc, phMem, phImage); @@ -6262,6 +7017,21 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hSampler)) { + refCountContext.logInvalidReference(hSampler); + } + ur_result_t result = pfnSampledImageCreateExp(hContext, hDevice, hImageMem, pImageFormat, pImageDesc, hSampler, phMem, phImage); @@ -6347,6 +7117,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnImageCopyExp( hQueue, pDst, pSrc, pImageFormat, pImageDesc, imageCopyFlags, srcOffset, dstOffset, copyExtent, hostExtent, numEventsInWaitList, phEventWaitList, @@ -6426,6 +7201,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnMipmapGetLevelExp(hContext, hDevice, hImageMem, mipmapLevel, phImageMem); @@ -6460,6 +7245,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnMipmapFreeExp(hContext, hDevice, hMem); return result; @@ -6501,6 +7296,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnImportOpaqueFDExp(hContext, hDevice, size, pInteropMemDesc, phInteropMem); @@ -6557,6 +7362,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnMapExternalArrayExp( hContext, hDevice, pImageFormat, pImageDesc, hInteropMem, phImageMem); @@ -6592,6 +7407,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); return result; @@ -6634,6 +7459,16 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnImportExternalSemaphoreOpaqueFDExp( hContext, hDevice, pInteropSemaphoreDesc, phInteropSemaphore); @@ -6669,6 +7504,16 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); @@ -6717,6 +7562,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnWaitExternalSemaphoreExp( hQueue, hSemaphore, numEventsInWaitList, phEventWaitList, phEvent); @@ -6765,6 +7615,11 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnSignalExternalSemaphoreExp( hQueue, hSemaphore, numEventsInWaitList, phEventWaitList, phEvent); @@ -6801,6 +7656,16 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDevice)) { + refCountContext.logInvalidReference(hDevice); + } + ur_result_t result = pfnCreateExp(hContext, hDevice, pCommandBufferDesc, phCommandBuffer); @@ -6933,6 +7798,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnAppendKernelLaunchExp( hCommandBuffer, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numSyncPointsInWaitList, pSyncPointWaitList, @@ -7111,6 +7981,16 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hSrcMem)) { + refCountContext.logInvalidReference(hSrcMem); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDstMem)) { + refCountContext.logInvalidReference(hDstMem); + } + ur_result_t result = pfnAppendMemBufferCopyExp( hCommandBuffer, hSrcMem, hDstMem, srcOffset, dstOffset, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); @@ -7164,6 +8044,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnAppendMemBufferWriteExp( hCommandBuffer, hBuffer, offset, size, pSrc, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); @@ -7216,6 +8101,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnAppendMemBufferReadExp( hCommandBuffer, hBuffer, offset, size, pDst, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); @@ -7276,6 +8166,16 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hSrcMem)) { + refCountContext.logInvalidReference(hSrcMem); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hDstMem)) { + refCountContext.logInvalidReference(hDstMem); + } + ur_result_t result = pfnAppendMemBufferCopyRectExp( hCommandBuffer, hSrcMem, hDstMem, srcOrigin, dstOrigin, region, srcRowPitch, srcSlicePitch, dstRowPitch, dstSlicePitch, @@ -7343,6 +8243,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnAppendMemBufferWriteRectExp( hCommandBuffer, hBuffer, bufferOffset, hostOffset, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, @@ -7408,6 +8313,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnAppendMemBufferReadRectExp( hCommandBuffer, hBuffer, bufferOffset, hostOffset, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, @@ -7463,6 +8373,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hBuffer)) { + refCountContext.logInvalidReference(hBuffer); + } + ur_result_t result = pfnAppendMemBufferFillExp( hCommandBuffer, hBuffer, pPattern, patternSize, offset, size, numSyncPointsInWaitList, pSyncPointWaitList, pSyncPoint); @@ -7629,6 +8544,11 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferEnqueueExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + ur_result_t result = pfnEnqueueExp( hCommandBuffer, hQueue, numEventsInWaitList, phEventWaitList, phEvent); @@ -7707,6 +8627,16 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hQueue)) { + refCountContext.logInvalidReference(hQueue); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnCooperativeKernelLaunchExp( hQueue, hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, numEventsInWaitList, phEventWaitList, phEvent); @@ -7737,6 +8667,11 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hKernel)) { + refCountContext.logInvalidReference(hKernel); + } + ur_result_t result = pfnSuggestMaxCooperativeGroupCountExp(hKernel, pGroupCountRet); @@ -7769,6 +8704,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnBuildExp(hProgram, numDevices, phDevices, pOptions); return result; @@ -7801,6 +8741,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompileExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hProgram)) { + refCountContext.logInvalidReference(hProgram); + } + ur_result_t result = pfnCompileExp(hProgram, numDevices, phDevices, pOptions); @@ -7850,6 +8795,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramLinkExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnLinkExp(hContext, numDevices, phDevices, count, phPrograms, pOptions, phProgram); @@ -7879,6 +8829,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnImportExp(hContext, pMem, size); return result; @@ -7906,6 +8861,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(hContext)) { + refCountContext.logInvalidReference(hContext); + } + ur_result_t result = pfnReleaseExp(hContext, pMem); return result; @@ -7935,6 +8895,16 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(commandDevice)) { + refCountContext.logInvalidReference(commandDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(peerDevice)) { + refCountContext.logInvalidReference(peerDevice); + } + ur_result_t result = pfnEnablePeerAccessExp(commandDevice, peerDevice); return result; @@ -7964,6 +8934,16 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(commandDevice)) { + refCountContext.logInvalidReference(commandDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(peerDevice)) { + refCountContext.logInvalidReference(peerDevice); + } + ur_result_t result = pfnDisablePeerAccessExp(commandDevice, peerDevice); return result; @@ -8020,6 +9000,16 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( } } + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(commandDevice)) { + refCountContext.logInvalidReference(commandDevice); + } + + if (context.enableLifetimeValidation && + !refCountContext.isReferenceValid(peerDevice)) { + refCountContext.logInvalidReference(peerDevice); + } + ur_result_t result = pfnPeerAccessGetInfoExp(commandDevice, peerDevice, propName, propSize, pPropValue, pPropSizeRet); @@ -9298,6 +10288,7 @@ ur_result_t context_t::init(ur_dditable_t *dditable, if (enabledLayerNames.count(nameFullValidation)) { enableParameterValidation = true; enableLeakChecking = true; + enableLifetimeValidation = true; } else { if (enabledLayerNames.count(nameParameterValidation)) { enableParameterValidation = true; @@ -9305,9 +10296,15 @@ ur_result_t context_t::init(ur_dditable_t *dditable, if (enabledLayerNames.count(nameLeakChecking)) { enableLeakChecking = true; } + if (enabledLayerNames.count(nameLifetimeValidation)) { + // Handle lifetime validation requires leak checking feature. + enableLifetimeValidation = true; + enableLeakChecking = true; + } } - if (!enableParameterValidation && !enableLeakChecking) { + if (!enableParameterValidation && !enableLeakChecking && + !enableLifetimeValidation) { return result; } diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index d29b64230e..c58d414346 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -22,6 +22,7 @@ class __urdlllocal context_t : public proxy_layer_context_t { public: bool enableParameterValidation = false; bool enableLeakChecking = false; + bool enableLifetimeValidation = false; logger::Logger logger; ur_dditable_t urDdiTable = {}; @@ -31,7 +32,8 @@ class __urdlllocal context_t : public proxy_layer_context_t { bool isAvailable() const override { return true; } std::vector getNames() const override { - return {nameFullValidation, nameParameterValidation, nameLeakChecking}; + return {nameFullValidation, nameParameterValidation, nameLeakChecking, + nameLifetimeValidation}; } ur_result_t init(ur_dditable_t *dditable, const std::set &enabledLayerNames, @@ -42,6 +44,7 @@ class __urdlllocal context_t : public proxy_layer_context_t { const std::string nameFullValidation = "UR_LAYER_FULL_VALIDATION"; const std::string nameParameterValidation = "UR_LAYER_PARAMETER_VALIDATION"; const std::string nameLeakChecking = "UR_LAYER_LEAK_CHECKING"; + const std::string nameLifetimeValidation = "UR_LAYER_LIFETIME_VALIDATION"; }; ur_result_t bounds(ur_mem_handle_t buffer, size_t offset, size_t size); From f1dd20064ec5ef3d1c34525abf222a39a4ad3d5b Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Tue, 28 Nov 2023 17:33:12 +0100 Subject: [PATCH 4/7] [UR] Add tests for lifetime validation --- test/layers/validation/CMakeLists.txt | 1 + test/layers/validation/fixtures.hpp | 45 +++++++++++++++++------ test/layers/validation/lifetime.cpp | 21 +++++++++++ test/layers/validation/lifetime.out.match | 7 ++++ 4 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 test/layers/validation/lifetime.cpp create mode 100644 test/layers/validation/lifetime.out.match diff --git a/test/layers/validation/CMakeLists.txt b/test/layers/validation/CMakeLists.txt index 944202e0d2..9b1f5734c0 100644 --- a/test/layers/validation/CMakeLists.txt +++ b/test/layers/validation/CMakeLists.txt @@ -52,3 +52,4 @@ endfunction() add_validation_test(parameters parameters.cpp) add_validation_match_test(leaks leaks.out.match leaks.cpp) add_validation_match_test(leaks_mt leaks_mt.out.match leaks_mt.cpp) +add_validation_match_test(lifetime lifetime.out.match lifetime.cpp) diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 4071bbecad..913573b0ad 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -30,36 +30,57 @@ struct urTest : ::testing::Test { ur_loader_config_handle_t loader_config = nullptr; }; -struct valPlatformsTest : urTest { +struct valAdaptersTest : urTest { void SetUp() override { urTest::SetUp(); uint32_t adapter_count; ASSERT_EQ(urAdapterGet(0, nullptr, &adapter_count), UR_RESULT_SUCCESS); + ASSERT_GT(adapter_count, 0); adapters.resize(adapter_count); ASSERT_EQ(urAdapterGet(adapter_count, adapters.data(), nullptr), UR_RESULT_SUCCESS); - - uint32_t count; - ASSERT_EQ( - urPlatformGet(adapters.data(), adapter_count, 0, nullptr, &count), - UR_RESULT_SUCCESS); - ASSERT_NE(count, 0); - platforms.resize(count); - ASSERT_EQ(urPlatformGet(adapters.data(), adapter_count, count, - platforms.data(), nullptr), - UR_RESULT_SUCCESS); } void TearDown() override { - for (auto &adapter : adapters) { + for (auto adapter : adapters) { ASSERT_EQ(urAdapterRelease(adapter), UR_RESULT_SUCCESS); } urTest::TearDown(); } std::vector adapters; +}; + +struct valAdapterTest : valAdaptersTest { + + void SetUp() override { + valAdaptersTest::SetUp(); + adapter = adapters[0]; // TODO - which to choose? + } + + ur_adapter_handle_t adapter; +}; + +struct valPlatformsTest : valAdaptersTest { + + void SetUp() override { + valAdaptersTest::SetUp(); + + uint32_t count; + ASSERT_EQ(urPlatformGet(adapters.data(), + static_cast(adapters.size()), 0, + nullptr, &count), + UR_RESULT_SUCCESS); + ASSERT_GT(count, 0); + platforms.resize(count); + ASSERT_EQ(urPlatformGet(adapters.data(), + static_cast(adapters.size()), count, + platforms.data(), nullptr), + UR_RESULT_SUCCESS); + } + std::vector platforms; }; diff --git a/test/layers/validation/lifetime.cpp b/test/layers/validation/lifetime.cpp new file mode 100644 index 0000000000..4c642fedb0 --- /dev/null +++ b/test/layers/validation/lifetime.cpp @@ -0,0 +1,21 @@ +// Copyright (C) 2023 Intel Corporation +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +// See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "fixtures.hpp" + +TEST_F(urTest, testUrAdapterHandleLifetimeExpectFail) { + size_t size = 0; + ur_adapter_handle_t adapter = (ur_adapter_handle_t)0xC0FFEE; + ur_adapter_info_t info_type = UR_ADAPTER_INFO_BACKEND; + ASSERT_EQ(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), + UR_RESULT_ERROR_INVALID_ARGUMENT); +} + +TEST_F(valAdapterTest, testUrAdapterHandleLifetimeExpectSuccess) { + size_t size = 0; + ur_adapter_info_t info_type = UR_ADAPTER_INFO_BACKEND; + ASSERT_EQ(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), + UR_RESULT_SUCCESS); +} diff --git a/test/layers/validation/lifetime.out.match b/test/layers/validation/lifetime.out.match new file mode 100644 index 0000000000..c454500641 --- /dev/null +++ b/test/layers/validation/lifetime.out.match @@ -0,0 +1,7 @@ +{{IGNORE}} +[ RUN ] urTest.testUrAdapterHandleLifetimeExpectFail + [ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} +{{IGNORE}} +[ RUN ] valAdapterTest.testUrAdapterHandleLifetimeExpectSuccess +{{^(?!.*There are no valid references to handle).*$}} +{{IGNORE}} From dca6c8872872d404bc345b3e731e45d8cd6ffc41 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Wed, 29 Nov 2023 14:16:47 +0100 Subject: [PATCH 5/7] [UR] Add lifetime validation documentation --- scripts/core/INTRO.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/core/INTRO.rst b/scripts/core/INTRO.rst index 4bdee2aa47..52e78153ae 100644 --- a/scripts/core/INTRO.rst +++ b/scripts/core/INTRO.rst @@ -268,6 +268,8 @@ Layers currently included with the runtime are as follows: - Enables non-adapter-specific parameter validation (e.g. checking for null values). * - UR_LAYER_LEAK_CHECKING - Performs some leak checking for API calls involving object creation/destruction. + * - UR_LAYER_LIFETIME_VALIDATION + - Performs lifetime validation on objects (check if it was used within the scope of its creation and destruction) used in API calls. Automatically enables UR_LAYER_LEAK_CHECKING. * - UR_LAYER_FULL_VALIDATION - Enables UR_LAYER_PARAMETER_VALIDATION and UR_LAYER_LEAK_CHECKING. * - UR_LAYER_TRACING From 25225fd2126ba44e408a0a3955c1277e1de402b8 Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Thu, 7 Dec 2023 16:38:59 +0100 Subject: [PATCH 6/7] [UR] Expand lifetime validation with ... handle type checks. --- .../layers/validation/ur_leak_check.hpp | 64 +++++++++++++------ test/layers/validation/lifetime.cpp | 14 ++-- test/layers/validation/lifetime.out.match | 5 ++ 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/source/loader/layers/validation/ur_leak_check.hpp b/source/loader/layers/validation/ur_leak_check.hpp index b7cb487f88..8202ac447d 100644 --- a/source/loader/layers/validation/ur_leak_check.hpp +++ b/source/loader/layers/validation/ur_leak_check.hpp @@ -9,6 +9,7 @@ #include "ur_validation_layer.hpp" #include +#include #include #include @@ -20,7 +21,12 @@ struct RefCountContext { private: struct RefRuntimeInfo { int64_t refCount; + std::type_index type; std::vector backtrace; + + RefRuntimeInfo(int64_t refCount, std::type_index type, + std::vector backtrace) + : refCount(refCount), type(type), backtrace(backtrace) {} }; enum RefCountUpdateType { @@ -34,26 +40,32 @@ struct RefCountContext { std::unordered_map counts; int64_t adapterCount = 0; - void updateRefCount(void *ptr, enum RefCountUpdateType type, + template + void updateRefCount(T handle, enum RefCountUpdateType type, bool isAdapterHandle = false) { std::unique_lock ulock(mutex); + void *ptr = static_cast(handle); auto it = counts.find(ptr); switch (type) { case REFCOUNT_CREATE_OR_INCREASE: if (it == counts.end()) { - counts[ptr] = {1, getCurrentBacktrace()}; + std::tie(it, std::ignore) = counts.emplace( + ptr, RefRuntimeInfo{1, std::type_index(typeid(handle)), + getCurrentBacktrace()}); if (isAdapterHandle) { adapterCount++; } } else { - counts[ptr].refCount++; + it->second.refCount++; } break; case REFCOUNT_CREATE: if (it == counts.end()) { - counts[ptr] = {1, getCurrentBacktrace()}; + std::tie(it, std::ignore) = counts.emplace( + ptr, RefRuntimeInfo{1, std::type_index(typeid(handle)), + getCurrentBacktrace()}); } else { context.logger.error("Handle {} already exists", ptr); return; @@ -65,29 +77,31 @@ struct RefCountContext { "Attempting to retain nonexistent handle {}", ptr); return; } else { - counts[ptr].refCount++; + it->second.refCount++; } break; case REFCOUNT_DECREASE: if (it == counts.end()) { - counts[ptr] = {-1, getCurrentBacktrace()}; + std::tie(it, std::ignore) = counts.emplace( + ptr, RefRuntimeInfo{-1, std::type_index(typeid(handle)), + getCurrentBacktrace()}); } else { - counts[ptr].refCount--; + it->second.refCount--; } - if (counts[ptr].refCount < 0) { + if (it->second.refCount < 0) { context.logger.error( "Attempting to release nonexistent handle {}", ptr); - } else if (counts[ptr].refCount == 0 && isAdapterHandle) { + } else if (it->second.refCount == 0 && isAdapterHandle) { adapterCount--; } break; } context.logger.debug("Reference count for handle {} changed to {}", ptr, - counts[ptr].refCount); + it->second.refCount); - if (counts[ptr].refCount == 0) { + if (it->second.refCount == 0) { counts.erase(ptr); } @@ -99,23 +113,35 @@ struct RefCountContext { } public: - void createRefCount(void *ptr) { updateRefCount(ptr, REFCOUNT_CREATE); } + template void createRefCount(T handle) { + updateRefCount(handle, REFCOUNT_CREATE); + } - void incrementRefCount(void *ptr, bool isAdapterHandle = false) { - updateRefCount(ptr, REFCOUNT_INCREASE, isAdapterHandle); + template + void incrementRefCount(T handle, bool isAdapterHandle = false) { + updateRefCount(handle, REFCOUNT_INCREASE, isAdapterHandle); } - void decrementRefCount(void *ptr, bool isAdapterHandle = false) { - updateRefCount(ptr, REFCOUNT_DECREASE, isAdapterHandle); + template + void decrementRefCount(T handle, bool isAdapterHandle = false) { + updateRefCount(handle, REFCOUNT_DECREASE, isAdapterHandle); } - void createOrIncrementRefCount(void *ptr, bool isAdapterHandle = false) { - updateRefCount(ptr, REFCOUNT_CREATE_OR_INCREASE, isAdapterHandle); + template + void createOrIncrementRefCount(T handle, bool isAdapterHandle = false) { + updateRefCount(handle, REFCOUNT_CREATE_OR_INCREASE, isAdapterHandle); } void clear() { counts.clear(); } - bool isReferenceValid(void *ptr) { return counts.count(ptr) > 0; } + template bool isReferenceValid(T handle) { + auto it = counts.find(static_cast(handle)); + if (it == counts.end() || it->second.refCount < 1) { + return false; + } + + return (it->second.type == std::type_index(typeid(handle))); + } void logInvalidReferences() { for (auto &[ptr, refRuntimeInfo] : counts) { diff --git a/test/layers/validation/lifetime.cpp b/test/layers/validation/lifetime.cpp index 4c642fedb0..1b21d69acd 100644 --- a/test/layers/validation/lifetime.cpp +++ b/test/layers/validation/lifetime.cpp @@ -9,13 +9,19 @@ TEST_F(urTest, testUrAdapterHandleLifetimeExpectFail) { size_t size = 0; ur_adapter_handle_t adapter = (ur_adapter_handle_t)0xC0FFEE; ur_adapter_info_t info_type = UR_ADAPTER_INFO_BACKEND; - ASSERT_EQ(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), - UR_RESULT_ERROR_INVALID_ARGUMENT); + urAdapterGetInfo(adapter, info_type, 0, nullptr, &size); } TEST_F(valAdapterTest, testUrAdapterHandleLifetimeExpectSuccess) { size_t size = 0; ur_adapter_info_t info_type = UR_ADAPTER_INFO_BACKEND; - ASSERT_EQ(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), - UR_RESULT_SUCCESS); + urAdapterGetInfo(adapter, info_type, 0, nullptr, &size); +} + +TEST_F(valAdapterTest, testUrAdapterHandleTypeMismatchExpectFail) { + size_t size = 0; + // Use valid adapter handle with incorrect cast. + ur_device_handle_t device = (ur_device_handle_t)adapter; + ur_device_info_t info_type = UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION; + urDeviceGetInfo(device, info_type, 0, nullptr, &size); } diff --git a/test/layers/validation/lifetime.out.match b/test/layers/validation/lifetime.out.match index c454500641..f73bd71ba4 100644 --- a/test/layers/validation/lifetime.out.match +++ b/test/layers/validation/lifetime.out.match @@ -3,5 +3,10 @@ [ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} {{IGNORE}} [ RUN ] valAdapterTest.testUrAdapterHandleLifetimeExpectSuccess +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 {{^(?!.*There are no valid references to handle).*$}} {{IGNORE}} +[ RUN ] valAdapterTest.testUrAdapterHandleTypeMismatchExpectFail +[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +[ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} +{{IGNORE}} From c0f0a708e5099ebd08efdefb859575890271dd3c Mon Sep 17 00:00:00 2001 From: Krzysztof Swiecicki Date: Wed, 10 Jan 2024 17:11:16 +0100 Subject: [PATCH 7/7] [UR] Update copyright dates in changed files --- scripts/templates/helper.py | 2 +- scripts/templates/valddi.cpp.mako | 2 +- source/loader/layers/validation/ur_leak_check.hpp | 2 +- source/loader/layers/validation/ur_valddi.cpp | 2 +- source/loader/layers/validation/ur_validation_layer.hpp | 2 +- test/layers/validation/CMakeLists.txt | 2 +- test/layers/validation/fixtures.hpp | 2 +- test/layers/validation/lifetime.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index bed05e9a8f..3b8e5693b7 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2022-2023 Intel Corporation + Copyright (C) 2022-2024 Intel Corporation Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT diff --git a/scripts/templates/valddi.cpp.mako b/scripts/templates/valddi.cpp.mako index 1baf0a4773..c8905a7e8b 100644 --- a/scripts/templates/valddi.cpp.mako +++ b/scripts/templates/valddi.cpp.mako @@ -11,7 +11,7 @@ from templates import helper as th handle_create_get_retain_release_funcs=th.get_handle_create_get_retain_release_functions(specs, n, tags) %>/* * - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. * See LICENSE.TXT diff --git a/source/loader/layers/validation/ur_leak_check.hpp b/source/loader/layers/validation/ur_leak_check.hpp index 8202ac447d..008795078a 100644 --- a/source/loader/layers/validation/ur_leak_check.hpp +++ b/source/loader/layers/validation/ur_leak_check.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 Intel Corporation // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 7a4e5e0410..e4212212b4 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. * See LICENSE.TXT diff --git a/source/loader/layers/validation/ur_validation_layer.hpp b/source/loader/layers/validation/ur_validation_layer.hpp index c58d414346..c72932c453 100644 --- a/source/loader/layers/validation/ur_validation_layer.hpp +++ b/source/loader/layers/validation/ur_validation_layer.hpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2023 Corporation + * Copyright (C) 2023-2024 Corporation * * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. * See LICENSE.TXT diff --git a/test/layers/validation/CMakeLists.txt b/test/layers/validation/CMakeLists.txt index 9b1f5734c0..3e0446c5e4 100644 --- a/test/layers/validation/CMakeLists.txt +++ b/test/layers/validation/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2023 Intel Corporation +# Copyright (C) 2023-2024 Intel Corporation # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/layers/validation/fixtures.hpp b/test/layers/validation/fixtures.hpp index 913573b0ad..4dcb553282 100644 --- a/test/layers/validation/fixtures.hpp +++ b/test/layers/validation/fixtures.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 Intel Corporation // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/test/layers/validation/lifetime.cpp b/test/layers/validation/lifetime.cpp index 1b21d69acd..bec49826eb 100644 --- a/test/layers/validation/lifetime.cpp +++ b/test/layers/validation/lifetime.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 Intel Corporation // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception