Skip to content

Commit

Permalink
Merge branch 'main' into yc/0814-buffer-native-handle-null-device-1
Browse files Browse the repository at this point in the history
  • Loading branch information
yingcong-wu authored Sep 23, 2024
2 parents 3a86207 + 7384e2d commit 7a41fb3
Show file tree
Hide file tree
Showing 149 changed files with 3,690 additions and 2,198 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
compiler: [{c: gcc, cxx: g++}]
libbacktrace: ['-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF']
pool_tracking: ['-DUMF_ENABLE_POOL_TRACKING=ON', '-DUMF_ENABLE_POOL_TRACKING=OFF']
latency_tracking: ['-DUMF_ENABLE_LATENCY_TRACKING=OFF']
latency_tracking: ['-DUR_ENABLE_LATENCY_HISTOGRAM=OFF']
include:
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -40,7 +40,7 @@ jobs:
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: clang, cxx: clang++}
latency_tracking: '-DUMF_ENABLE_LATENCY_TRACKING=ON'
latency_tracking: '-DUR_ENABLE_LATENCY_HISTOGRAM=ON'
runs-on: ${{ (matrix.os == 'ubuntu-22.04' && github.repository_owner == 'oneapi-src') && 'intel-ubuntu-22.04' || matrix.os }}

steps:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ jobs:
-DCMAKE_CXX_COMPILER="$(which clang++)"
-DLLVM_LIT="${{github.workspace}}/sycl-repo/llvm/utils/lit/lit.py"
- name: Set LIT_XFAIL_NOT
if: inputs.xfail_not != ''
run: echo "LIT_XFAIL_NOT=${{inputs.xfail_not}}" >> $GITHUB_ENV

- name: Set LIT_XFAIL
if: inputs.xfail != ''
run: echo "LIT_XFAIL=${{inputs.xfail}}" >> $GITHUB_ENV
Expand All @@ -181,6 +177,10 @@ jobs:
if: inputs.filter_out != ''
run: echo "LIT_FILTER_OUT=${{inputs.filter_out}}" >> $GITHUB_ENV

- name: Set LIT_XFAIL_NOT
if: inputs.xfail_not != ''
run: echo "LIT_XFAIL_NOT=${{inputs.xfail_not}}" >> $GITHUB_ENV

# TODO: remove once intel/llvm lit tests can properly recognize the GPU
- name: Configure hardware platform feature for L0
if: matrix.adapter.name == 'L0'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
config: "--cuda"
unit: "gpu"
extra_lit_flags: "-sv --max-time=3600"
xfail: "Regression/device_num.cpp"
6 changes: 4 additions & 2 deletions .github/workflows/e2e_level_zero.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ jobs:
config: ""
unit: "gpu"
# Failing tests
xfail: "DeviceCodeSplit/grf.cpp;ESIMD/grf.cpp;ESIMD/mask_expand_load.cpp;KernelAndProgram/target_register_alloc_mode.cpp;Matrix/SG32/get_coord_int8_matB.cpp;Matrix/get_coord_int8_matB.cpp;Matrix/joint_matrix_prefetch.cpp;Matrix/joint_matrix_rowmajorA_rowmajorB.cpp; SYCL :: ESIMD/mask_expand_load.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_bf16_fill_k_cache_OOB.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_out_bounds.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_prefetch.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_rowmajorA_rowmajorB.cpp;Matrix/element_wise_all_ops_1d.cpp;Matrix/element_wise_all_ops_1d_cont.cpp;Matrix/element_wise_all_ops_scalar.cpp;Matrix/joint_matrix_bf16_fill_k_cache_OOB.cpp;Matrix/joint_matrix_bf16_fill_k_cache_prefetch.cpp;Matrix/joint_matrix_out_bounds.cpp;Matrix/joint_matrix_unaligned_k.cpp"
xfail: "DeviceCodeSplit/grf.cpp;ESIMD/mask_expand_load.cpp;KernelAndProgram/target_register_alloc_mode.cpp;Matrix/SG32/get_coord_int8_matB.cpp;Matrix/get_coord_int8_matB.cpp;Matrix/joint_matrix_prefetch.cpp;Matrix/joint_matrix_rowmajorA_rowmajorB.cpp;ESIMD/mask_expand_load.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_bf16_fill_k_cache_OOB.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_out_bounds.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_prefetch.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_rowmajorA_rowmajorB.cpp;Matrix/element_wise_all_ops_1d.cpp;Matrix/element_wise_all_ops_1d_cont.cpp;Matrix/element_wise_all_ops_scalar.cpp;Matrix/joint_matrix_bf16_fill_k_cache_OOB.cpp;Matrix/joint_matrix_bf16_fill_k_cache_prefetch.cpp;Matrix/joint_matrix_out_bounds.cpp;Matrix/joint_matrix_unaligned_k.cpp;Matrix/SPVCooperativeMatrix/SG32/get_coord_int8_matB.cpp;Matrix/SPVCooperativeMatrix/element_wise_all_ops_1d.cpp;Matrix/SPVCooperativeMatrix/element_wise_all_ops_1d_cont.cpp;Matrix/SPVCooperativeMatrix/element_wise_all_ops_scalar.cpp;Matrix/SPVCooperativeMatrix/element_wise_ops.cpp;Matrix/SPVCooperativeMatrix/get_coord_int8_matB.cpp;Matrix/SPVCooperativeMatrix/joint_matrix_bf16_fill_k_cache_SLM.cpp;Matrix/joint_matrix_bf16_fill_k_cache_SLM.cpp"
# Unexpectedly Passed Tests
xfail_not: ""
# Flaky tests
filter_out: "ESIMD/named_barriers/loop_extended.cpp;ESIMD/local_accessor_copy_to_from.cpp;"
filter_out: "Basic/accessor/accessor.cpp|DeviceArchitecture/device_architecture_comparison_on_device_aot.cpp|Graph/Explicit/interop-level-zero-launch-kernel.cpp|Graph/RecordReplay/interop-level-zero-launch-kernel.cpp|syclcompat/launch/launch_policy_lmem.cpp"
# These runners by default spawn upwards of 260 workers.
# We also add a time out just in case some test hangs
extra_lit_flags: "--param gpu-intel-pvc=True --param gpu-intel-pvc-1T=True -sv -j 100 --max-time=3600"
2 changes: 1 addition & 1 deletion .github/workflows/e2e_opencl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
prefix: ""
config: ""
unit: "cpu"
xfail: "AOT/double.cpp;AOT/half.cpp;AOT/reqd-sg-size.cpp;Basic/built-ins/marray_geometric.cpp;KernelCompiler/kernel_compiler_spirv.cpp;KernelCompiler/opencl_queries.cpp"
xfail: "AOT/double.cpp;AOT/half.cpp;AOT/reqd-sg-size.cpp;Basic/built-ins/marray_geometric.cpp;KernelCompiler/kernel_compiler_spirv.cpp;KernelCompiler/opencl_queries.cpp;NonUniformGroups/ballot_group.cpp;NonUniformGroups/ballot_group_algorithms.cpp;NonUniformGroups/fixed_size_group_algorithms.cpp;NonUniformGroups/opportunistic_group.cpp;NonUniformGroups/opportunistic_group_algorithms.cpp;NonUniformGroups/tangle_group.cpp;NonUniformGroups/tangle_group_algorithms.cpp"
extra_lit_flags: "-sv --max-time=3600"
1 change: 1 addition & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function(add_ur_target_compile_options name)
)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
target_compile_options(${name} PRIVATE -fvisibility=hidden)
endif()
if(UR_DEVELOPER_MODE)
target_compile_options(${name} PRIVATE
Expand Down
147 changes: 108 additions & 39 deletions cmake/match.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright (C) 2023 Intel Corporation
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
Expand All @@ -12,6 +12,8 @@
# List of available special tags:
# {{OPT}} - makes content in the same line as the tag optional
# {{IGNORE}} - ignores all content until the next successfully matched line or the end of the input
# {{NONDETERMINISTIC}} - order of match rules isn't important - each (non OPT) input line is paired with a match line
# in any order
# Special tags are mutually exclusive and are expected to be located at the start of a line.
#

Expand All @@ -20,15 +22,25 @@
import re
from enum import Enum

## @brief print a sequence of lines
def print_lines(lines, hint = None):
counter = 1
for l in lines:
hint_char = " "
if hint == counter - 1:
hint_char = ">"
print("{}{:4d}| {}".format(hint_char, counter, l.strip()))
counter += 1


## @brief print the whole content of input and match files
def print_content(input_lines, match_lines, ignored_lines):
print("--- Input Lines " + "-" * 64)
print("".join(input_lines).strip())
print("--- Match Lines " + "-" * 64)
print("".join(match_lines).strip())
print("--- Ignored Lines " + "-" * 62)
print("".join(ignored_lines).strip())
def print_content(input_lines, match_lines, ignored_lines, hint_input = None, hint_match = None):
print("------ Input Lines " + "-" * 61)
print_lines(input_lines, hint_input)
print("------ Match Lines " + "-" * 61)
print_lines(match_lines, hint_match)
print("------ Ignored Lines " + "-" * 59)
print_lines(ignored_lines)
print("-" * 80)


Expand All @@ -39,6 +51,24 @@ def print_incorrect_match(match_line, present, expected):
print("expected: " + expected)


## @brief print missing match line
def print_input_not_found(input_line, input):
print("Input line " + str(input_line) + " has no match line")
print("is: " + input)


## @brief print missing input line
def print_match_not_found(match_line, input):
print("Match line " + str(match_line) + " has no input line")
print("is: " + input)


## @brief print general syntax error
def print_error(text, match_line):
print("Line " + str(match_line) + " encountered an error")
print(text)


## @brief pattern matching script status values
class Status(Enum):
INPUT_END = 1
Expand All @@ -63,6 +93,7 @@ def check_status(input_lines, match_lines):
class Tag(Enum):
OPT = "{{OPT}}" # makes the line optional
IGNORE = "{{IGNORE}}" # ignores all input until next match or end of input file
NONDETERMINISTIC = "{{NONDETERMINISTIC}}" # switches on "deterministic mode"
COMMENT = "#" # comment - line ignored


Expand All @@ -88,32 +119,53 @@ def main():
)

ignored_lines = []
matched_lines = set()

input_idx = 0
match_idx = 0
tags_in_effect = []
deterministic_mode = False
while True:
# check file status
status = check_status(input_lines[input_idx:], match_lines[match_idx:])
if (status == Status.INPUT_AND_MATCH_END) or (status == Status.MATCH_END and Tag.IGNORE in tags_in_effect):
# all lines matched or the last line in match file is an ignore tag
sys.exit(0)
elif status == Status.MATCH_END:
print_incorrect_match(match_idx + 1, input_lines[input_idx].strip(), "");
print_content(input_lines, match_lines, ignored_lines)
sys.exit(1)
elif status == Status.INPUT_END:
# If we get to the end of the input, but still have pending matches,
# then that's a failure unless all pending matches are optional -
# otherwise we're done
while match_idx < len(match_lines):
if not (match_lines[match_idx].startswith(Tag.OPT.value) or
match_lines[match_idx].startswith(Tag.IGNORE.value)):
print_incorrect_match(match_idx + 1, "", match_lines[match_idx]);
print_content(input_lines, match_lines, ignored_lines)
if deterministic_mode:
if status == Status.INPUT_END:
# Convert the list of seen matches to the list of unseen matches
remaining_matches = set(range(len(match_lines))) - matched_lines
for m in remaining_matches:
line = match_lines[m]
if line.startswith(Tag.OPT.value) or line.startswith(Tag.NONDETERMINISTIC.value):
continue
print_match_not_found(m + 1, match_lines[m])
print_content(input_lines, match_lines, ignored_lines, hint_match=m)
sys.exit(1)
match_idx += 1
sys.exit(0)

sys.exit(0)
elif status == Status.MATCH_END:
print_input_not_found(input_idx + 1, input_lines[input_idx])
print_content(input_lines, match_lines, ignored_lines, hint_input=input_idx)
sys.exit(1)
else:
if (status == Status.INPUT_AND_MATCH_END) or (status == Status.MATCH_END and Tag.IGNORE in tags_in_effect):
# all lines matched or the last line in match file is an ignore tag
sys.exit(0)
elif status == Status.MATCH_END:
print_incorrect_match(input_idx + 1, input_lines[input_idx].strip(), "")
print_content(input_lines, match_lines, ignored_lines, hint_input=input_idx)
sys.exit(1)
elif status == Status.INPUT_END:
# If we get to the end of the input, but still have pending matches,
# then that's a failure unless all pending matches are optional -
# otherwise we're done
while match_idx < len(match_lines):
if not (match_lines[match_idx].startswith(Tag.OPT.value) or
match_lines[match_idx].startswith(Tag.IGNORE.value) or
match_lines[match_idx].startswith(Tag.NONDETERMINISTIC.value)):
print_incorrect_match(match_idx + 1, "", match_lines[match_idx])
print_content(input_lines, match_lines, ignored_lines, hint_match=match_idx)
sys.exit(1)
match_idx += 1
sys.exit(0)

input_line = input_lines[input_idx].strip() if input_idx < len(input_lines) else ""
match_line = match_lines[match_idx]
Expand All @@ -122,7 +174,15 @@ def main():
if match_line.startswith(Tag.OPT.value):
tags_in_effect.append(Tag.OPT)
match_line = match_line[len(Tag.OPT.value):]
elif match_line.startswith(Tag.NONDETERMINISTIC.value) and not deterministic_mode:
deterministic_mode = True
match_idx = 0
input_idx = 0
continue
elif match_line.startswith(Tag.IGNORE.value):
if deterministic_mode:
print_error(r"Can't use \{{IGNORE\}} in deterministic mode")
sys.exit(2)
tags_in_effect.append(Tag.IGNORE)
match_idx += 1
continue # line with ignore tag should be skipped
Expand All @@ -137,20 +197,29 @@ def main():
pattern += part

# match or process tags
if re.fullmatch(pattern, input_line):
input_idx += 1
match_idx += 1
tags_in_effect = []
elif Tag.OPT in tags_in_effect:
match_idx += 1
tags_in_effect.remove(Tag.OPT)
elif Tag.IGNORE in tags_in_effect:
ignored_lines.append(input_line + os.linesep)
input_idx += 1
if deterministic_mode:
if re.fullmatch(pattern, input_line) and match_idx not in matched_lines:
input_idx += 1
matched_lines.add(match_idx)
match_idx = 0
tags_in_effect = []
else:
match_idx += 1
else:
print_incorrect_match(match_idx + 1, input_line, match_line.strip())
print_content(input_lines, match_lines, ignored_lines)
sys.exit(1)
if re.fullmatch(pattern, input_line):
input_idx += 1
match_idx += 1
tags_in_effect = []
elif Tag.OPT in tags_in_effect:
match_idx += 1
tags_in_effect.remove(Tag.OPT)
elif Tag.IGNORE in tags_in_effect:
ignored_lines.append(input_line + os.linesep)
input_idx += 1
else:
print_incorrect_match(match_idx + 1, input_line, match_line.strip())
print_content(input_lines, match_lines, ignored_lines, hint_match=match_idx, hint_input=input_idx)
sys.exit(1)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions examples/collector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI})
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)

if(MSVC)
target_compile_definitions(${TARGET_NAME} PRIVATE
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY)
endif()
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS)
10 changes: 9 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,17 @@ typedef enum ur_structure_type_t {
#if defined(_WIN32)
/// @brief Microsoft-specific dllexport storage-class attribute
#define UR_APIEXPORT __declspec(dllexport)
#endif // defined(_WIN32)
#endif // UR_APIEXPORT

///////////////////////////////////////////////////////////////////////////////
#ifndef UR_APIEXPORT
#if __GNUC__ >= 4
/// @brief GCC-specific dllexport storage-class attribute
#define UR_APIEXPORT __attribute__((visibility("default")))
#else
#define UR_APIEXPORT
#endif // defined(_WIN32)
#endif // __GNUC__ >= 4
#endif // UR_APIEXPORT

///////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17403,6 +17403,11 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
return os;
}

inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool_t value) {
os << (value ? "true" : "false");
return os;
}

namespace ur::details {
///////////////////////////////////////////////////////////////////////////////
// @brief Print pointer value
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ desc: "Microsoft-specific dllexport storage-class attribute"
condition: "defined(_WIN32)"
name: $X_APIEXPORT
value: __declspec(dllexport)
--- #--------------------------------------------------------------------------
type: macro
desc: "GCC-specific dllexport storage-class attribute"
condition: "__GNUC__ >= 4"
name: $X_APIEXPORT
value: __attribute__ ((visibility ("default")))
altvalue: ""
--- #--------------------------------------------------------------------------
type: macro
Expand Down
5 changes: 5 additions & 0 deletions scripts/templates/print.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
%endfor
%endfor

inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool_t value) {
os << (value ? "true" : "false");
return os;
}

namespace ${x}::details {
///////////////////////////////////////////////////////////////////////////////
// @brief Print pointer value
Expand Down
12 changes: 8 additions & 4 deletions scripts/templates/trcddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ namespace ur_tracing_layer
${th.make_pfncb_param_type(n, tags, obj)} params = { &${",&".join(th.make_param_lines(n, tags, obj, format=["name"]))} };
uint64_t instance = getContext()->notify_begin(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", &params);

getContext()->logger.info("---> ${th.make_func_name(n, tags, obj)}");
auto &logger = getContext()->logger;

logger.info("---> ${th.make_func_name(n, tags, obj)}");

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

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

std::ostringstream args_str;
ur::extras::printFunctionParams(args_str, ${th.make_func_etor(n, tags, obj)}, &params);
getContext()->logger.info("({}) -> {};\n", args_str.str(), result);
if (logger.getLevel() <= logger::Level::INFO) {
std::ostringstream args_str;
ur::extras::printFunctionParams(args_str, ${th.make_func_etor(n, tags, obj)}, &params);
logger.info("({}) -> {};\n", args_str.str(), result);
}

return result;
}
Expand Down
7 changes: 1 addition & 6 deletions source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
return ReturnValue(4318u);
}
case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: {
int ComputeUnits = 0;
UR_CHECK_ERROR(cuDeviceGetAttribute(
&ComputeUnits, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
hDevice->get()));
detail::ur::assertion(ComputeUnits >= 0);
return ReturnValue(static_cast<uint32_t>(ComputeUnits));
return ReturnValue(hDevice->getNumComputeUnits());
}
case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS: {
return ReturnValue(MaxWorkItemDimensions);
Expand Down
Loading

0 comments on commit 7a41fb3

Please sign in to comment.