-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add UR loader, null adapter and basic example
The components this patch implements are mostly derived from the ones implemented by level-zero. This patch otherwise makes only the minimal amount of changes required for loader: - adds new CI that builds the loader - updates cmake scripts to build and install the loader - adds generate and check-generated custom cmake targets - adds a tiny hello-world example to verify loader functionality Co-authored-by: Brandon Yates <[email protected]> Co-authored-by: Lisanna Dettwyler <[email protected]> Co-authored-by: Patryk Kaminski <[email protected]> Co-authored-by: Krzysztof Swiecicki <[email protected]>
- Loading branch information
1 parent
62dedb0
commit eef1a3f
Showing
52 changed files
with
14,808 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CMake | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
BUILD_TYPE: Release | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install apt package | ||
run: sudo apt-get install -y doxygen | ||
|
||
- name: Install pip packages | ||
run: pip install -r third_party/requirements.txt | ||
|
||
- name: Configure CMake | ||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | ||
|
||
- name: Generate source from spec, check for uncommitted diff | ||
run: cmake --build ${{github.workspace}}/build --target check-generated | ||
|
||
- name: Build | ||
run: cmake --build ${{github.workspace}}/build | ||
|
||
- name: Test | ||
working-directory: ${{github.workspace}}/build | ||
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,10 @@ | |
# Debug files | ||
scripts/**/*.json | ||
|
||
# Python cache | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# Generated docs | ||
docs/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Unified Runtime changelog | ||
|
||
## v.X.X.X | ||
* Placeholder for first release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Security Policy | ||
|
||
## Report a Vulnerability | ||
|
||
Please report security issues or vulnerabilities to the [Intel Security Center]. | ||
|
||
For more information on how Intel works to resolve security issues, see [Vulnerability Handling Guidelines]. | ||
|
||
[Intel Security Center]:https://www.intel.com/security | ||
|
||
[Vulnerability Handling Guidelines]:https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
add_subdirectory(hello_world) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
set(TARGET_NAME hello_world) | ||
|
||
add_executable(${TARGET_NAME} | ||
${CMAKE_CURRENT_SOURCE_DIR}/hello_world.cpp | ||
) | ||
|
||
target_include_directories(${TARGET_NAME} PRIVATE | ||
${CMAKE_SOURCE_DIR}/include | ||
) | ||
|
||
if(MSVC) | ||
set_target_properties(${TARGET_NAME} | ||
PROPERTIES | ||
VS_DEBUGGER_COMMAND_ARGUMENTS "" | ||
VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" | ||
) | ||
endif() | ||
|
||
target_link_libraries(${TARGET_NAME} | ||
${PROJECT_NAME}::loader | ||
${CMAKE_DL_LIBS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* | ||
* Copyright (C) 2020-2021 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
#include <stdlib.h> | ||
#include <memory> | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include "ur_api.h" | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
int main(int argc, char *argv[]) | ||
{ | ||
ur_result_t status; | ||
|
||
ur_platform_handle_t platform = nullptr; | ||
ur_device_handle_t pDevice = nullptr; | ||
|
||
// Initialize the platform | ||
status = urInit(0, 0); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urInit failed with return code: " << status << std::endl; | ||
return 1; | ||
} | ||
std::cout << "Platform initialized.\n"; | ||
|
||
uint32_t platformCount = 0; | ||
std::vector<ur_platform_handle_t> platforms; | ||
|
||
status = urPlatformGet(1, nullptr, &platformCount); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urPlatformGet failed with return code: " << status << std::endl; | ||
goto out; | ||
} | ||
|
||
platforms.resize(platformCount); | ||
status = urPlatformGet(platformCount, platforms.data(), nullptr); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urPlatformGet failed with return code: " << status << std::endl; | ||
goto out; | ||
} | ||
|
||
for (auto p : platforms) | ||
{ | ||
uint32_t deviceCount = 0; | ||
status = urDeviceGet(p, UR_DEVICE_TYPE_GPU, 0, nullptr, &deviceCount); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urDeviceGet failed with return code: " << status << std::endl; | ||
goto out; | ||
} | ||
|
||
std::vector<ur_device_handle_t> devices(deviceCount); | ||
status = urDeviceGet(p, UR_DEVICE_TYPE_GPU, deviceCount, devices.data(), nullptr); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urDeviceGet failed with return code: " << status << std::endl; | ||
goto out; | ||
} | ||
for (auto d : devices) | ||
{ | ||
ur_device_type_t device_type; | ||
status = urDeviceGetInfo(d, UR_DEVICE_INFO_TYPE, sizeof(ur_device_type_t), static_cast<void *>(&device_type), nullptr); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urDeviceGet failed with return code: " << status << std::endl; | ||
goto out; | ||
} | ||
static const size_t DEVICE_NAME_MAX_LEN = 1024; | ||
char device_name[DEVICE_NAME_MAX_LEN] = {0}; | ||
status = urDeviceGetInfo(d, UR_DEVICE_INFO_NAME, DEVICE_NAME_MAX_LEN - 1, static_cast<void *>(&device_name), nullptr); | ||
if (status != UR_RESULT_SUCCESS) | ||
{ | ||
std::cout << "urDeviceGet failed with return code: " << status << std::endl; | ||
goto out; | ||
} | ||
if (device_type == UR_DEVICE_TYPE_GPU) | ||
{ | ||
std::cout << "Found a " << device_name << " gpu.\n"; | ||
} | ||
} | ||
} | ||
|
||
out: | ||
urTearDown(nullptr); | ||
return status == UR_RESULT_SUCCESS ? 0 : 1; | ||
} |
Oops, something went wrong.