Skip to content

Commit a1ebf07

Browse files
authored
[PTI-LIB] Fix Build on oneAPI 2025.1 (#486)
The Unified Runtime public api header file changed file path. It does this frequently between oneAPI releases. This iterates though common include paths until one is found and uses that to generate the api ids. Signed-off-by: Schilling, Matthew <[email protected]>
1 parent 14fa772 commit a1ebf07

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

sdk/cmake/Modules/macros.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ macro(FindHeadersPath TARGET L0_GEN_SCRIPT GEN_FILE_NAME custom_target L0_TARGET
3535

3636
# HINTS before PATHS
3737
find_path(L0_INC_PATH
38-
NAMES level_zero
38+
NAMES level_zero/ze_api.h
3939
HINTS ${L0_TARGET_PATH}
4040
PATHS ENV CPATH)
4141
if (NOT L0_INC_PATH)
@@ -360,7 +360,7 @@ macro(AddApiGenTarget L0_GEN_SCRIPT GEN_FILE_NAME L0_TARGET)
360360

361361
# HINTS before PATHS
362362
find_path(L0_INC_PATH
363-
NAMES level_zero
363+
NAMES level_zero/ze_api.h
364364
HINTS ${L0_TARGET_PATH}
365365
PATHS ENV CPATH)
366366
if (NOT L0_INC_PATH)

sdk/src/gen_tracing_callbacks.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
STATE_CONDITION = 1
1919
STATE_SKIP = 2
2020
FILE_OPEN_PERMISSIONS = 0o600
21+
DEFAULT_UNIFIED_RUNTIME_PUBLIC_HEADERS = ["ur_api.h", "sycl/ur_api.h"]
2122

2223

2324
# https://docs.python.org/3/library/functions.html#open
@@ -47,6 +48,38 @@ def get_ocl_api_list(ocl_path):
4748
return func_list
4849

4950

51+
def get_ur_api_file_path(include_file_path, include_file=None):
52+
"""
53+
Given include file path (typically passed to the compiler and found by the
54+
build system), find where the unified runtime public API header file is.
55+
"""
56+
57+
# Invalid directory.
58+
if os.path.exists(include_file_path) == False:
59+
raise Exception("Passed non-existent file path for UR headers")
60+
61+
ur_file_path = include_file_path
62+
63+
# Assume passed the full path to file.
64+
if os.path.isfile(ur_file_path) == True:
65+
return ur_file_path
66+
67+
if include_file != None:
68+
ur_file_path = os.path.join(ur_file_path, include_file)
69+
70+
if os.path.exists(ur_file_path) == False:
71+
raise Exception("Passed non-existent file path for UR headers")
72+
73+
return ur_file_path
74+
75+
for header in DEFAULT_UNIFIED_RUNTIME_PUBLIC_HEADERS:
76+
if os.path.isfile(os.path.join(ur_file_path, header)):
77+
ur_file_path = os.path.join(ur_file_path, header)
78+
break
79+
80+
return ur_file_path
81+
82+
5083
#
5184
# Extracts api function names from ur_api.h and returns as list.
5285
# Note: The ur_api.h contains predefined ids for each api -- assumption is no recycle on deprecation.
@@ -924,9 +957,13 @@ def main():
924957

925958
pti_inc_path = sys.argv[4]
926959
ur_path = sys.argv[5]
927-
ur_file_path = os.path.join(ur_path, "sycl/ur_api.h")
960+
ur_file_path = get_ur_api_file_path(ur_path)
961+
962+
if os.path.isfile(ur_file_path) == True:
963+
print("Found UR Path: ", ur_file_path)
964+
else:
965+
sys.exit("UR file not found: " + ur_file_path)
928966

929-
print("Found UR Path: ", ur_path)
930967
regen_api_files = False # Should we regenerate and update api_id_files as well?
931968
if sys.argv[6] == "ON":
932969
print("Regeneration of api files requested!")

0 commit comments

Comments
 (0)