Skip to content

Commit 1a20082

Browse files
authored
Merge pull request #262 from IntelPython/master
0.5.1rc2
2 parents 5fdc9a3 + be7b0b9 commit 1a20082

23 files changed

+737
-122
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- Documentation improvements
12+
- Cmake improvements and Coverage for C API
13+
- Add support for Level Zero
14+
- Code of conduct
15+
16+
### Fixed
17+
- Remove `cython` from `install_requires`. It allows use `dpCtl` in `numba` extensions.
18+
- Incorrect import in example.
19+
20+
1021
## [0.5.0] - 2020-12-17
1122
### Added
1223
- `_Memory.get_pointer_type` static method which returns kind of USM pointer.

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at scripting@intel.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ documents in the current source directory in a sub-directory called
1616
`generated_docs`.
1717

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

2121
Prerequisite
2222
============

dpctl-capi/CMakeLists.txt

Lines changed: 83 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
11
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
2-
project("dpCtl - A lightweight SYCL wrapper for Python")
2+
project("dpCtl C API - A C wrapper for a subset of SYCL")
33

4-
# The function checks is DPCPP_ROOT is valid and points to a dpcpp installation
5-
function (check_for_dpcpp)
6-
string(COMPARE EQUAL "${DPCPP_ROOT}" "" no_dpcpp_root)
7-
if(${no_dpcpp_root})
8-
message(FATAL_ERROR "Set the DPCPP_ROOT argument providing the path to \
9-
a dpcpp installation.")
10-
endif()
11-
12-
if(WIN32)
13-
set (dpcpp_cmd "${DPCPP_ROOT}/bin/dpcpp")
14-
set (dpcpp_arg "--version")
15-
elseif(UNIX)
16-
set (dpcpp_cmd "${DPCPP_ROOT}/bin/dpcpp")
17-
set (dpcpp_arg "--version")
18-
else()
19-
message(FATAL_ERROR "Unsupported system.")
20-
endif()
4+
# Option to turn on support for creating Level Zero interoperability programs
5+
# from a SPIR-V binary file.
6+
option(DPCTL_ENABLE_LO_PROGRAM_CREATION
7+
"Enable Level Zero Program creation from SPIR-V"
8+
OFF
9+
)
10+
# Option to generate code coverage report using llvm-cov and lcov.
11+
option(DPCTL_GENERATE_COVERAGE
12+
"Build dpctl C API with coverage instrumentation instrumentation"
13+
OFF
14+
)
15+
# Option to output html coverage report at a specific location.
16+
option(DPCTL_COVERAGE_REPORT_OUTPUT_DIR
17+
"Save the generated lcov html report to the specified location"
18+
OFF
19+
)
20+
# Option to build the Gtests for dpctl C API
21+
option(DPCTL_BUILD_CAPI_TESTS
22+
"Build dpctl C API google tests"
23+
OFF
24+
)
2125

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

30-
if(${dpcpp_result} MATCHES "0")
31-
string(REPLACE "\n" ";" DPCPP_VERSION_LIST "${dpcpp_ver}")
32-
list(GET DPCPP_VERSION_LIST 0 dpcpp_ver_line)
33-
foreach(X ${DPCPP_VERSION_LIST})
34-
message(STATUS "dpcpp ver[${dpcpp_result}]: ${X}")
35-
endforeach()
36-
else()
37-
message(FATAL_ERROR "DPCPP needed to build dpctl_sycl_interface")
38-
endif()
39-
endfunction()
30+
if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
31+
set(DPCTL_ENABLE_LO_PROGRAM_CREATION 1)
32+
find_package(LevelZero REQUIRED)
33+
endif()
4034

41-
# Check for dpcpp in the specified DPCPP_ROOT
42-
check_for_dpcpp()
35+
configure_file(${CMAKE_SOURCE_DIR}/include/Config/dpctl_config.h.in
36+
${CMAKE_SOURCE_DIR}/include/Config/dpctl_config.h)
4337

4438
if(WIN32)
4539
set(CMAKE_CXX_COMPILER:PATH "${DPCPP_ROOT}/bin/dpcpp")
@@ -54,6 +48,9 @@ if(WIN32)
5448
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${WARNING_FLAGS} -ggdb3 -DDEBUG")
5549
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_FLAGS} -ggdb3 -DDEBUG -Qstd=c++17")
5650
elseif(UNIX)
51+
set(CMAKE_CXX_COMPILER:PATH "${DPCPP_ROOT}/bin/dpcpp")
52+
set(CMAKE_C_COMPILER:PATH "${DPCPP_ROOT}/bin/clang")
53+
set(CMAKE_LINKER:PATH "${DPCPP_ROOT}/bin/lld")
5754
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")
5855
set(WARNING_FLAGS "-Wall -Wextra -Winit-self -Wunused-function -Wuninitialized -Wmissing-declarations -fdiagnostics-color=auto")
5956
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${SDL_FLAGS}")
@@ -80,30 +77,29 @@ add_library(
8077
helper/source/dpctl_utils_helper.cpp
8178
)
8279

83-
# Install DPCTLSyclInterface
84-
target_include_directories(
85-
DPCTLSyclInterface
86-
PRIVATE
87-
${CMAKE_SOURCE_DIR}/include/
88-
${CMAKE_SOURCE_DIR}/helper/include/
80+
target_include_directories(DPCTLSyclInterface
81+
PRIVATE
82+
${CMAKE_SOURCE_DIR}/include/
83+
${CMAKE_SOURCE_DIR}/helper/include/
84+
${DPCPP_SYCL_INCLUDE_DIR}
85+
)
86+
target_link_libraries(DPCTLSyclInterface
87+
PRIVATE ${DPCPP_SYCL_LIBRARY}
88+
PRIVATE ${DPCPP_OPENCL_LIBRARY}
8989
)
9090

91-
if(WIN32)
92-
message(
93-
STATUS
94-
"SYCL_INCLUDE_DIR: "
95-
${DPCPP_ROOT}/include/sycl
96-
)
97-
target_include_directories(
98-
DPCTLSyclInterface
99-
PUBLIC
100-
${DPCPP_ROOT}/include/sycl
101-
)
102-
target_link_libraries(
103-
DPCTLSyclInterface
104-
PRIVATE ${DPCPP_ROOT}/lib/sycl.lib
105-
PRIVATE ${DPCPP_ROOT}/lib/OpenCL.lib
106-
)
91+
if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
92+
if(UNIX)
93+
target_include_directories(DPCTLSyclInterface
94+
PRIVATE
95+
${LEVEL_ZERO_INCLUDE_DIR}
96+
)
97+
else()
98+
message(WARNING
99+
"DPCTL support Level Zero program creation not supported "
100+
"on this system."
101+
)
102+
endif()
107103
endif()
108104

109105
install(
@@ -114,34 +110,46 @@ install(
114110
)
115111

116112
# Install all headers
117-
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/*.h*")
113+
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/*.h")
118114
foreach(HEADER ${HEADERS})
119115
install(FILES "${HEADER}" DESTINATION include)
120116
endforeach()
121117

122118
# Install all headers in include/Support
123-
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/Support/*.h*")
119+
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/Support/*.h")
124120
foreach(HEADER ${HEADERS})
125121
install(FILES "${HEADER}" DESTINATION include/Support)
126122
endforeach()
127123

128-
# Install all headers in helper/include
129-
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/helper/include/*.h*")
124+
# Install all headers in include/Config
125+
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/include/Config/*.h")
130126
foreach(HEADER ${HEADERS})
131-
install(FILES "${HEADER}" DESTINATION helper/include)
127+
install(FILES "${HEADER}" DESTINATION include/Config)
132128
endforeach()
133129

134-
option(
135-
BUILD_CAPI_TESTS
136-
"Build dpctl C API google tests"
137-
OFF
138-
)
130+
# Enable code coverage related settings
131+
if(DPCTL_GENERATE_COVERAGE)
132+
# check if llvm-cov and lcov are available
133+
find_package(Lcov REQUIRED)
134+
# These flags are set inside FindDPCPP
135+
if(NOT (${LLVM_COV_FOUND} AND ${LLVM_PROFDATA_FOUND}))
136+
message(FATAL_ERROR
137+
"llvm-cov and llvm-profdata are needed to generate coverage."
138+
)
139+
endif()
140+
# Turn on DPCTL_BUILD_CAPI_TESTS as building tests is needed to generate
141+
# coverage reports
142+
set(DPCTL_BUILD_CAPI_TESTS "ON")
143+
if(DPCTL_COVERAGE_REPORT_OUTPUT_DIR)
144+
set(COVERAGE_OUTPUT_DIR ${DPCTL_COVERAGE_REPORT_OUTPUT_DIR})
145+
message(STATUS "Coverage reports to be saved at ${COVERAGE_OUTPUT_DIR}")
146+
else()
147+
set(COVERAGE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
148+
message(STATUS "Coverage reports to be saved at ${COVERAGE_OUTPUT_DIR}")
149+
endif()
150+
endif()
139151

140-
# Enable to build the dpCtl backend test cases
141-
if(BUILD_CAPI_TESTS)
152+
# Add sub-directory to build the dpCtl C API test cases
153+
if(DPCTL_BUILD_CAPI_TESTS)
142154
add_subdirectory(tests)
143155
endif()
144-
145-
146-
# Todo : Add build rules for doxygen
147-
# maybe refer https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/

0 commit comments

Comments
 (0)