Skip to content

Commit

Permalink
Merge remote-tracking branch 'intel/origin/main' into maronas/ext_com…
Browse files Browse the repository at this point in the history
…posite_device
  • Loading branch information
maarquitos14 committed Jan 16, 2024
2 parents a9746c2 + c63ad9b commit 7564829
Show file tree
Hide file tree
Showing 49 changed files with 698 additions and 411 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
linux:
name: Bandit
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
ubuntu-build:
name: Build - Ubuntu
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
analyze-ubuntu:
name: Analyze on Ubuntu
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Coverage

on: [push, pull_request]

permissions:
contents: read

jobs:
ubuntu-build:
name: Build - Ubuntu
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ env:
COVERITY_SCAN_BRANCH_PATTERN: "main"
TRAVIS_BRANCH: ${{ github.ref_name }}

permissions:
contents: read

jobs:
linux:
Expand Down Expand Up @@ -51,6 +53,7 @@ jobs:
-DCUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so
-DUR_BUILD_ADAPTER_NATIVE_CPU=ON
-DUR_BUILD_ADAPTER_HIP=ON
-DUR_BUILD_ADAPTER_OPENCL=ON
- name: Run Coverity
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/e2e_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Run every day at 23:00 UTC
- cron: '0 23 * * *'

permissions:
contents: read

jobs:
e2e-build-hw:
name: Build SYCL, UR, run E2E
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Run every day at 23:00 UTC
- cron: '0 23 * * *'

permissions:
contents: read

jobs:
long-fuzz-test:
name: Run long fuzz tests
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
# At 23:00 on Friday, GitHub actions schedule is in UTC time.
- cron: 0 23 * * 5

permissions:
contents: read

jobs:
weekly-prerelease:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ if(UR_ENABLE_TRACING)
)
if (MSVC)
set(TARGET_XPTI $<IF:$<CONFIG:Release>,xpti,xptid>)

# disable warning C4267: The compiler detected a conversion from size_t to a smaller type.
target_compile_options(xptifw PRIVATE /wd4267)
else()
set(TARGET_XPTI xpti)
endif()
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ List of options provided by CMake:
| UR_ENABLE_COMGR | Enable comgr lib usage | AMD/NVIDIA | AMD |
| UR_DPCXX | Path of the DPC++ compiler executable to build CTS device binaries | File path | `""` |
| UR_SYCL_LIBRARY_DIR | Path of the SYCL runtime library directory to build CTS device binaries | Directory path | `""` |
| UR_HIP_ROCM_DIR | Path of the default ROCm HIP installation | Directory path | `/opt/rocm` |
| UR_HIP_INCLUDE_DIR | Path of the ROCm HIP include directory | Directory path | `${UR_HIP_ROCM_DIR}/include` |
| UR_HIP_HSA_INCLUDE_DIRS | Path of the ROCm HSA include directory | Directory path | `${UR_HIP_ROCM_DIR}/hsa/include;${UR_HIP_ROCM_DIR}/include` |
| UR_HIP_LIB_DIR | Path of the ROCm HIP library directory | Directory path | `${UR_HIP_ROCM_DIR}/lib` |

### Additional make targets

Expand Down
8 changes: 7 additions & 1 deletion cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ function(add_ur_target_compile_options name)
/W3
/MD$<$<CONFIG:Debug>:d>
/GS
/DWIN32_LEAN_AND_MEAN
/DNOMINMAX
)

if(UR_DEVELOPER_MODE)
target_compile_options(${name} PRIVATE /WX /GS)
# _CRT_SECURE_NO_WARNINGS used mainly because of getenv
# C4267: The compiler detected a conversion from size_t to a smaller type.
target_compile_options(${name} PRIVATE
/WX /GS /D_CRT_SECURE_NO_WARNINGS /wd4267
)
endif()
endif()
endfunction()
Expand Down
167 changes: 111 additions & 56 deletions cmake/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,132 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# check if all lines match in a file
# lines in a match file can contain regex inside of double curly braces {{}}
# Check if all input file content matches match file content.
# Lines in a match file can contain regex inside of double curly braces {{}}.
# Regex patterns are limited to single line.
#
# 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
# Special tags are mutually exclusive and are expected to be located at the start of a line.
#

import os
import sys
import re
from enum import Enum


## @brief print the whole content of input and match files
def print_content(input_lines, match_lines):
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())
print("-" * 80)


if len(sys.argv) != 3:
print("Usage: python match.py <input_file> <match_file>")
sys.exit(1)

input_file = sys.argv[1]
match_file = sys.argv[2]

with open(input_file, 'r') as input, open(match_file, 'r') as match:
input_lines = input.readlines()
match_lines = match.readlines()

if len(match_lines) < len(input_lines):
print(f"Match length < input length (input: {len(input_lines)}, match: {len(match_lines)})")
print_content(input_lines, match_lines)
sys.exit(1)

input_idx = 0
opt = "{{OPT}}"
for i, match_line in enumerate(match_lines):
if match_line.startswith(opt):
optional_line = True
match_line = match_line[len(opt):]
else:
optional_line = False

# split into parts at {{ }}
match_parts = re.split(r'\{{(.*?)\}}', match_line.strip())
pattern = ""
for j, part in enumerate(match_parts):
if j % 2 == 0:
pattern += re.escape(part)
else:
pattern += part
## @brief print the incorrect match line
def print_incorrect_match(match_line, present, expected):
print("Line " + str(match_line) + " does not match")
print("is: " + present)
print("expected: " + expected)

# empty input file or end of input file, from now on match file must be optional
if not input_lines:
if optional_line is True:
continue
else:
print("End of input file or empty file.")
print("expected: " + match_line.strip())

## @brief pattern matching script status values
class Status(Enum):
INPUT_END = 1
MATCH_END = 2
INPUT_AND_MATCH_END = 3
PROCESSING = 4


## @brief check matching script status
def check_status(input_lines, match_lines):
if not input_lines and not match_lines:
return Status.INPUT_AND_MATCH_END
elif not input_lines:
return Status.INPUT_END
elif not match_lines:
return Status.MATCH_END
return Status.PROCESSING


## @brief pattern matching tags.
## Tags are expected to be at the start of the line.
class Tag(Enum):
OPT = "{{OPT}}" # makes the line optional
IGNORE = "{{IGNORE}}" # ignores all input until next match or end of input file


## @brief main function for the match file processing script
def main():
if len(sys.argv) != 3:
print("Usage: python match.py <input_file> <match_file>")
sys.exit(1)

input_file = sys.argv[1]
match_file = sys.argv[2]

with open(input_file, 'r') as input, open(match_file, 'r') as match:
input_lines = input.readlines()
match_lines = match.readlines()

ignored_lines = []

input_idx = 0
match_idx = 0
tags_in_effect = []
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)

input_line = input_lines[input_idx].strip()
if not re.fullmatch(pattern, input_line):
if optional_line is True:
continue
input_line = input_lines[input_idx].strip() if input_idx < len(input_lines) else ""
match_line = match_lines[match_idx]

# check for tags
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.IGNORE.value):
tags_in_effect.append(Tag.IGNORE)
match_idx += 1
continue # line with ignore tag should be skipped

# split into parts at {{ }}
match_parts = re.split(r'\{{(.*?)\}}', match_line.strip())
pattern = ""
for j, part in enumerate(match_parts):
if j % 2 == 0:
pattern += re.escape(part)
else:
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
else:
print("Line " + str(i+1) + " does not match")
print("is: " + input_line)
print("expected: " + match_line.strip())
print_content(input_lines, match_lines)
print_incorrect_match(match_idx + 1, input_line, match_line.strip())
print_content(input_lines, match_lines, ignored_lines)
sys.exit(1)
else:
if (input_idx == len(input_lines) - 1):
input_lines = []
else:
input_idx += 1


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,

UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetNativeHandle(
ur_device_handle_t hDevice, ur_native_handle_t *phNativeHandle) {
*phNativeHandle = reinterpret_cast<ur_native_handle_t>(hDevice->get());
*phNativeHandle = reinterpret_cast<ur_native_handle_t>(
static_cast<std::uintptr_t>(hDevice->get()));
return UR_RESULT_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ urToCudaImageChannelFormat(ur_image_channel_type_t image_channel_type,
std::make_pair(image_channel_type, num_channels));
cuda_format = cuda_format_and_size.first;
pixel_size_bytes = cuda_format_and_size.second;
} catch (std::out_of_range &e) {
} catch (const std::out_of_range &) {
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler,
ImageTexDesc.mipmapFilterMode = MipFilterMode;
ImageTexDesc.maxMipmapLevelClamp = hSampler->MaxMipmapLevelClamp;
ImageTexDesc.minMipmapLevelClamp = hSampler->MinMipmapLevelClamp;
ImageTexDesc.maxAnisotropy = hSampler->MaxAnisotropy;
ImageTexDesc.maxAnisotropy = static_cast<unsigned>(hSampler->MaxAnisotropy);

// The address modes can interfere with other dimensionsenqueueEventsWait
// e.g. 1D texture sampling can be interfered with when setting other
Expand Down
3 changes: 2 additions & 1 deletion source/adapters/cuda/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ ur_result_t ur_program_handle_t_::buildProgram(const char *BuildOptions) {
getMaxRegistersJitOptionValue(this->BuildOptions, MaxRegs);
if (Valid) {
Options.push_back(CU_JIT_MAX_REGISTERS);
OptionVals.push_back(reinterpret_cast<void *>(MaxRegs));
OptionVals.push_back(
reinterpret_cast<void *>(static_cast<std::uintptr_t>(MaxRegs)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/adapters/cuda/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ urSamplerCreate(ur_context_handle_t hContext, const ur_sampler_desc_t *pDesc,
new ur_sampler_handle_t_(hContext)};

if (pDesc->stype == UR_STRUCTURE_TYPE_SAMPLER_DESC) {
Sampler->Props |= pDesc->normalizedCoords;
Sampler->Props |= static_cast<uint32_t>(pDesc->normalizedCoords);
Sampler->Props |= pDesc->filterMode << 1;
Sampler->Props |= pDesc->addressingMode << 2;
} else {
Expand Down
7 changes: 2 additions & 5 deletions source/adapters/cuda/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "event.hpp"
#include "platform.hpp"
#include "queue.hpp"
#include "ur_util.hpp"
#include "usm.hpp"

#include <cuda.h>
Expand Down Expand Up @@ -227,11 +228,7 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem,
return ReturnValue(UR_USM_TYPE_HOST);
}
// should never get here
#ifdef _MSC_VER
__assume(0);
#else
__builtin_unreachable();
#endif
ur::unreachable();
}
case UR_USM_ALLOC_INFO_BASE_PTR: {
#if CUDA_VERSION >= 10020
Expand Down
Loading

0 comments on commit 7564829

Please sign in to comment.