Skip to content

0.5.1rc2 #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Documentation improvements
- Cmake improvements and Coverage for C API
- Add support for Level Zero
- Code of conduct

### Fixed
- Remove `cython` from `install_requires`. It allows use `dpCtl` in `numba` extensions.
- Incorrect import in example.


## [0.5.0] - 2020-12-17
### Added
- `_Memory.get_pointer_type` static method which returns kind of USM pointer.
Expand Down
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at scripting@intel.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ documents in the current source directory in a sub-directory called
`generated_docs`.

The `make Sphinx` command will generate standalone Doxygen documentation and
a consolidated Sphix documentation for both dpCtl Python and C APIs.
a consolidated Sphinx documentation for both dpCtl Python and C APIs.

Prerequisite
============
Expand Down
158 changes: 83 additions & 75 deletions dpctl-capi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project("dpCtl - A lightweight SYCL wrapper for Python")
project("dpCtl C API - A C wrapper for a subset of SYCL")

# The function checks is DPCPP_ROOT is valid and points to a dpcpp installation
function (check_for_dpcpp)
string(COMPARE EQUAL "${DPCPP_ROOT}" "" no_dpcpp_root)
if(${no_dpcpp_root})
message(FATAL_ERROR "Set the DPCPP_ROOT argument providing the path to \
a dpcpp installation.")
endif()

if(WIN32)
set (dpcpp_cmd "${DPCPP_ROOT}/bin/dpcpp")
set (dpcpp_arg "--version")
elseif(UNIX)
set (dpcpp_cmd "${DPCPP_ROOT}/bin/dpcpp")
set (dpcpp_arg "--version")
else()
message(FATAL_ERROR "Unsupported system.")
endif()
# Option to turn on support for creating Level Zero interoperability programs
# from a SPIR-V binary file.
option(DPCTL_ENABLE_LO_PROGRAM_CREATION
"Enable Level Zero Program creation from SPIR-V"
OFF
)
# Option to generate code coverage report using llvm-cov and lcov.
option(DPCTL_GENERATE_COVERAGE
"Build dpctl C API with coverage instrumentation instrumentation"
OFF
)
# Option to output html coverage report at a specific location.
option(DPCTL_COVERAGE_REPORT_OUTPUT_DIR
"Save the generated lcov html report to the specified location"
OFF
)
# Option to build the Gtests for dpctl C API
option(DPCTL_BUILD_CAPI_TESTS
"Build dpctl C API google tests"
OFF
)

# Check if dpcpp is available
execute_process(
COMMAND ${dpcpp_cmd} ${dpcpp_arg}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE dpcpp_result
OUTPUT_VARIABLE dpcpp_ver
)
# Load our CMake modules to search for DPCPP and Level Zero
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(DPCPP REQUIRED)

if(${dpcpp_result} MATCHES "0")
string(REPLACE "\n" ";" DPCPP_VERSION_LIST "${dpcpp_ver}")
list(GET DPCPP_VERSION_LIST 0 dpcpp_ver_line)
foreach(X ${DPCPP_VERSION_LIST})
message(STATUS "dpcpp ver[${dpcpp_result}]: ${X}")
endforeach()
else()
message(FATAL_ERROR "DPCPP needed to build dpctl_sycl_interface")
endif()
endfunction()
if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
set(DPCTL_ENABLE_LO_PROGRAM_CREATION 1)
find_package(LevelZero REQUIRED)
endif()

# Check for dpcpp in the specified DPCPP_ROOT
check_for_dpcpp()
configure_file(${CMAKE_SOURCE_DIR}/include/Config/dpctl_config.h.in
${CMAKE_SOURCE_DIR}/include/Config/dpctl_config.h)

if(WIN32)
set(CMAKE_CXX_COMPILER:PATH "${DPCPP_ROOT}/bin/dpcpp")
Expand All @@ -54,6 +48,9 @@ if(WIN32)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${WARNING_FLAGS} -ggdb3 -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_FLAGS} -ggdb3 -DDEBUG -Qstd=c++17")
elseif(UNIX)
set(CMAKE_CXX_COMPILER:PATH "${DPCPP_ROOT}/bin/dpcpp")
set(CMAKE_C_COMPILER:PATH "${DPCPP_ROOT}/bin/clang")
set(CMAKE_LINKER:PATH "${DPCPP_ROOT}/bin/lld")
set(SDL_FLAGS "-fstack-protector -fstack-protector-all -fpic -fPIC -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks")
set(WARNING_FLAGS "-Wall -Wextra -Winit-self -Wunused-function -Wuninitialized -Wmissing-declarations -fdiagnostics-color=auto")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${SDL_FLAGS}")
Expand All @@ -80,30 +77,29 @@ add_library(
helper/source/dpctl_utils_helper.cpp
)

# Install DPCTLSyclInterface
target_include_directories(
DPCTLSyclInterface
PRIVATE
${CMAKE_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/helper/include/
target_include_directories(DPCTLSyclInterface
PRIVATE
${CMAKE_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/helper/include/
${DPCPP_SYCL_INCLUDE_DIR}
)
target_link_libraries(DPCTLSyclInterface
PRIVATE ${DPCPP_SYCL_LIBRARY}
PRIVATE ${DPCPP_OPENCL_LIBRARY}
)

if(WIN32)
message(
STATUS
"SYCL_INCLUDE_DIR: "
${DPCPP_ROOT}/include/sycl
)
target_include_directories(
DPCTLSyclInterface
PUBLIC
${DPCPP_ROOT}/include/sycl
)
target_link_libraries(
DPCTLSyclInterface
PRIVATE ${DPCPP_ROOT}/lib/sycl.lib
PRIVATE ${DPCPP_ROOT}/lib/OpenCL.lib
)
if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
if(UNIX)
target_include_directories(DPCTLSyclInterface
PRIVATE
${LEVEL_ZERO_INCLUDE_DIR}
)
else()
message(WARNING
"DPCTL support Level Zero program creation not supported "
"on this system."
)
endif()
endif()

install(
Expand All @@ -114,34 +110,46 @@ install(
)

# Install all headers
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/*.h*")
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/*.h")
foreach(HEADER ${HEADERS})
install(FILES "${HEADER}" DESTINATION include)
endforeach()

# Install all headers in include/Support
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/Support/*.h*")
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/Support/*.h")
foreach(HEADER ${HEADERS})
install(FILES "${HEADER}" DESTINATION include/Support)
endforeach()

# Install all headers in helper/include
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/helper/include/*.h*")
# Install all headers in include/Config
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/Config/*.h")
foreach(HEADER ${HEADERS})
install(FILES "${HEADER}" DESTINATION helper/include)
install(FILES "${HEADER}" DESTINATION include/Config)
endforeach()

option(
BUILD_CAPI_TESTS
"Build dpctl C API google tests"
OFF
)
# Enable code coverage related settings
if(DPCTL_GENERATE_COVERAGE)
# check if llvm-cov and lcov are available
find_package(Lcov REQUIRED)
# These flags are set inside FindDPCPP
if(NOT (${LLVM_COV_FOUND} AND ${LLVM_PROFDATA_FOUND}))
message(FATAL_ERROR
"llvm-cov and llvm-profdata are needed to generate coverage."
)
endif()
# Turn on DPCTL_BUILD_CAPI_TESTS as building tests is needed to generate
# coverage reports
set(DPCTL_BUILD_CAPI_TESTS "ON")
if(DPCTL_COVERAGE_REPORT_OUTPUT_DIR)
set(COVERAGE_OUTPUT_DIR ${DPCTL_COVERAGE_REPORT_OUTPUT_DIR})
message(STATUS "Coverage reports to be saved at ${COVERAGE_OUTPUT_DIR}")
else()
set(COVERAGE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
message(STATUS "Coverage reports to be saved at ${COVERAGE_OUTPUT_DIR}")
endif()
endif()

# Enable to build the dpCtl backend test cases
if(BUILD_CAPI_TESTS)
# Add sub-directory to build the dpCtl C API test cases
if(DPCTL_BUILD_CAPI_TESTS)
add_subdirectory(tests)
endif()


# Todo : Add build rules for doxygen
# maybe refer https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/
Loading