forked from oneapi-src/level-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f50b570
Showing
140 changed files
with
68,412 additions
and
0 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,190 @@ | ||
# Copyright (C) 2020 Intel Corporation | ||
# SPDX-License-Identifier: MIT | ||
|
||
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) | ||
|
||
# This project follows semantic versioning (https://semver.org/). Only set the | ||
# major and minor version here - patch version is determined dynamically. | ||
project(level-zero VERSION 0.91) | ||
|
||
# Patch version corresponds to # of commits on master since last version | ||
# major/minor tag (e.g., v1.0). If not building in a git repository, then get | ||
# the patch version from a VERSION_PATCH file that would be shipped with a | ||
# source distribution. | ||
if(EXISTS "${CMAKE_SOURCE_DIR}/VERSION_PATCH") | ||
file(READ "${CMAKE_SOURCE_DIR}/VERSION_PATCH" VERSION_PATCH) | ||
string(STRIP "${VERSION_PATCH}" PROJECT_VERSION_PATCH) | ||
message(STATUS "Using patch version from VERSION_PATCH file in source tree: ${PROJECT_VERSION_PATCH}") | ||
else() | ||
find_program(GIT_EXE NAMES "git" REQUIRED) | ||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git") | ||
message(ERROR "Cannot determine patch version - VERSION_PATCH file is not in source tree and source tree does not appear to be a git repository") | ||
endif() | ||
set(GIT_TAG "v${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") | ||
if(MSVC) | ||
execute_process( | ||
COMMAND CMD /c git rev-list ${GIT_TAG}..HEAD --count | ||
OUTPUT_VARIABLE VERSION_PATCH | ||
) | ||
else() | ||
execute_process( | ||
COMMAND git rev-list ${GIT_TAG}..HEAD --count | ||
OUTPUT_VARIABLE VERSION_PATCH | ||
) | ||
endif() | ||
string(STRIP "${VERSION_PATCH}" PROJECT_VERSION_PATCH) | ||
if(PROJECT_VERSION_PATCH STREQUAL "") | ||
message(ERROR "Cannot determine patch version - couldn't find ${GIT_TAG} tag in repository") | ||
endif() | ||
message(STATUS "Using patch version from commit count in git repository: ${PROJECT_VERSION_PATCH}") | ||
endif() | ||
|
||
# Update other relevant variables to include the patch | ||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") | ||
set(CMAKE_PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}") | ||
set(CMAKE_PROJECT_VERSION "${PROJECT_VERSION}") | ||
|
||
file(WRITE "${CMAKE_BINARY_DIR}/VERSION" "${PROJECT_VERSION}") | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
|
||
#Define a path for custom commands to work around MSVC | ||
set(CUSTOM_COMMAND_BINARY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) | ||
if(MSVC) | ||
#MSVC implicitly adds $<CONFIG> to the output path | ||
set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$<CONFIG>) | ||
endif() | ||
|
||
# Use same CL version defined in the runtimes | ||
add_definitions(-DCL_TARGET_OPENCL_VERSION=220) | ||
find_path(OpenCL_INCLUDE_DIR | ||
NAMES CL | ||
PATHS | ||
${OPENCL_PATH} | ||
"/usr/include/" | ||
NO_DEFAULT_PATH | ||
) | ||
if(OpenCL_INCLUDE_DIR STREQUAL "OpenCL_INCLUDE_DIR-NOTFOUND") | ||
message(FATAL_ERROR "OpenCL headers required for interop APIs") | ||
endif() | ||
include_directories(${OpenCL_INCLUDE_DIR}) | ||
|
||
#CXX compiler support | ||
if(NOT MSVC) | ||
include(CheckCXXCompilerFlag) | ||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) | ||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) | ||
if(COMPILER_SUPPORTS_CXX14) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") | ||
elseif(COMPILER_SUPPORTS_CXX0X) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
else() | ||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.") | ||
endif() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -fPIC") | ||
endif() | ||
|
||
#MSVC compile flags | ||
if(MSVC) | ||
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") | ||
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
|
||
# treat warnings as errors | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W3 /wd4996") | ||
|
||
# enable multi-process compilation | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") | ||
endif() | ||
|
||
# Option to disable tests | ||
option(${PROJECT_NAME}_BUILD_TESTS "Build unit tests." ON) | ||
|
||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/core) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/tools) | ||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/wrapper/core) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/wrapper/tools) | ||
|
||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
add_subdirectory(source) | ||
|
||
include("os_release_info.cmake") | ||
get_os_release_info(os_name os_version os_codename) | ||
#Pick only first character of os_name | ||
string(SUBSTRING "${os_name}" 0 1 os_name) | ||
|
||
file(GLOB_RECURSE LEVEL_ZERO_API_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") | ||
|
||
install(FILES ${LEVEL_ZERO_API_HEADERS} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/level_zero/ | ||
COMPONENT level-zero-devel | ||
) | ||
|
||
# If generators list was not define build native package for current distro | ||
if(NOT DEFINED CPACK_GENERATOR) | ||
if(EXISTS "/etc/debian_version") | ||
set(CPACK_GENERATOR "DEB") | ||
elseif(EXISTS "/etc/redhat-release") | ||
set(CPACK_GENERATOR "RPM") | ||
else() | ||
set(CPACK_GENERATOR "TXZ") | ||
endif() | ||
endif() | ||
|
||
set(CPACK_SET_DESTDIR TRUE) | ||
set(CPACK_PACKAGE_RELOCATABLE FALSE) | ||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "oneAPI Level Zero") | ||
set(CPACK_PACKAGE_VENDOR "Intel") | ||
|
||
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}) | ||
set(CPACK_PACKAGE_CONTACT "Intel Corporation") | ||
|
||
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") | ||
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") | ||
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") | ||
|
||
if(CPACK_GENERATOR MATCHES "RPM") | ||
set(CPACK_RPM_COMPRESSION_TYPE "xz") | ||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") | ||
set(CPACK_RPM_PACKAGE_AUTOREQ OFF) | ||
set(CPACK_RPM_PACKAGE_DESCRIPTION "oneAPI Level Zero") | ||
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Libraries") | ||
set(CPACK_RPM_PACKAGE_LICENSE "MIT") | ||
set(CPACK_RPM_PACKAGE_RELEASE 1) | ||
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) | ||
set(CPACK_RPM_PACKAGE_URL "http://01.org/compute-runtime") | ||
set(CPACK_RPM_COMPONENT_INSTALL ON) | ||
set(CPACK_RPM_LEVEL-ZERO_PACKAGE_NAME "${PROJECT_NAME}") | ||
set(CPACK_RPM_LEVEL-ZERO-DEVEL_PACKAGE_NAME "${PROJECT_NAME}-devel") | ||
set(CPACK_RPM_LEVEL-ZERO_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${os_name}${os_version}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") | ||
set(CPACK_RPM_LEVEL-ZERO-DEVEL_FILE_NAME "${PROJECT_NAME}-devel-${PROJECT_VERSION}-${os_name}${os_version}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") | ||
set(CPACK_RPM_LEVEL-ZERO-DEVEL_PACKAGE_REQUIRES "opencl-headers >= 2.2-0, level-zero = ${PROJECT_VERSION}") | ||
|
||
|
||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION | ||
/etc/ld.so.conf.d | ||
/usr/local | ||
/usr/local/lib64 | ||
/usr/local/bin | ||
/usr/local/include | ||
) | ||
endif() | ||
|
||
if(CPACK_GENERATOR MATCHES "DEB") | ||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") | ||
#set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://01.org/compute-runtime") | ||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) | ||
set(CPACK_DEBIAN_LEVEL-ZERO_PACKAGE_NAME "${PROJECT_NAME}") | ||
set(CPACK_DEBIAN_LEVEL-ZERO-DEVEL_PACKAGE_NAME "${PROJECT_NAME}-devel") | ||
set(CPACK_DEBIAN_LEVEL-ZERO_FILE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}+${os_name}${os_version}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") | ||
set(CPACK_DEBIAN_LEVEL-ZERO-DEVEL_FILE_NAME "${PROJECT_NAME}-devel_${PROJECT_VERSION}+${os_name}${os_version}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") | ||
set(CPACK_DEBIAN_LEVEL-ZERO-DEVEL_PACKAGE_DEPENDS "opencl-headers (>= 2.2~0), level-zero(=${PROJECT_VERSION})") | ||
set(CPACK_DEB_COMPONENT_INSTALL ON) | ||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) | ||
endif() | ||
|
||
INCLUDE(CPack) |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Intel Corporation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,53 @@ | ||
# Contents | ||
This repo contains the following: | ||
- Intel(R) OneApi Level Zero Specification API C/C++ header files. | ||
https://spec.oneapi.com/versions/latest/elements/l0/source/index.html | ||
|
||
- Intel(R) OneApi Level Zero loader | ||
|
||
# Building | ||
Project is defined using [CMake](https://cmake.org/). | ||
|
||
**Linux**: | ||
Executable and binaries will be in **build/bin** | ||
~~~~ | ||
mkdir build | ||
cd build | ||
cmake {path_to_source_dir} | ||
make [package] | ||
~~~~ | ||
|
||
**Linux with Docker**: | ||
~~~bash | ||
mkdir build | ||
mkdir -p .ccache | ||
|
||
docker run \ | ||
--rm \ | ||
-v $PWD:$PWD \ | ||
-w $PWD/build \ | ||
-e CCACHE_DIR=$PWD/.ccache \ | ||
-e CCACHE_BASEDIR=$PWD \ | ||
$(docker build -q \ | ||
--build-arg UID=$(id -u) \ | ||
--build-arg GID=$(id -g) \ | ||
- < docker/build-linux.Dockerfile) \ | ||
cmake \ | ||
-G Ninja \ | ||
-D CMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
-D CMAKE_BUILD_TYPE=Release \ | ||
.. | ||
|
||
docker run \ | ||
--rm \ | ||
-v $PWD:$PWD \ | ||
-w $PWD/build \ | ||
-e CCACHE_DIR=$PWD/.ccache \ | ||
-e CCACHE_BASEDIR=$PWD \ | ||
$(docker build -q \ | ||
--build-arg UID=$(id -u) \ | ||
--build-arg GID=$(id -g) \ | ||
- < docker/build-linux.Dockerfile) \ | ||
cmake --build . --config 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (C) 2020 Intel Corporation | ||
# SPDX-License-Identifier: MIT | ||
|
||
ARG IMAGE_VERSION=eoan-20200114 | ||
FROM ubuntu:$IMAGE_VERSION | ||
|
||
ARG http_proxy | ||
ENV http_proxy=$http_proxy | ||
ARG https_proxy | ||
ENV https_proxy=$https_proxy | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
ccache \ | ||
cmake \ | ||
file \ | ||
git \ | ||
opencl-headers \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ARG UID=0 | ||
ARG UNAME=user | ||
ARG GID=0 | ||
RUN groupadd --non-unique --force -g $GID user_group && \ | ||
useradd \ | ||
--shell /bin/bash \ | ||
-u $UID \ | ||
-g user_group \ | ||
--non-unique \ | ||
--comment '' \ | ||
--create-home \ | ||
$UNAME | ||
USER $UNAME |
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,37 @@ | ||
/* | ||
* | ||
* Copyright (C) 2019 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* @file ze_api.h | ||
* | ||
*/ | ||
#ifndef _ZE_API_H | ||
#define _ZE_API_H | ||
#if defined(__cplusplus) | ||
#pragma once | ||
#endif | ||
|
||
// standard headers | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
// 'core' API headers | ||
#include "ze_common.h" | ||
#include "ze_driver.h" | ||
#include "ze_device.h" | ||
#include "ze_cmdqueue.h" | ||
#include "ze_cmdlist.h" | ||
#include "ze_image.h" | ||
#include "ze_barrier.h" | ||
#include "ze_module.h" | ||
#include "ze_residency.h" | ||
#include "ze_cl_interop.h" | ||
#include "ze_event.h" | ||
#include "ze_sampler.h" | ||
#include "ze_memory.h" | ||
#include "ze_fence.h" | ||
#include "ze_copy.h" | ||
|
||
#endif // _ZE_API_H |
Oops, something went wrong.