Skip to content

Commit bcb0e70

Browse files
authored
Merge pull request #195 from IntelPython/spokhode/update-gold-2021
Merge gold/2021 with 0.5.0rc1
2 parents e35093b + ee43a29 commit bcb0e70

File tree

16 files changed

+298
-130
lines changed

16 files changed

+298
-130
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
### Added
6+
- setup.py builds C++ backend for develop and install commands.
57

68
## [0.4.0] - 2020-11-04
79
### Added
810
- Device descriptors "max_compute_units", "max_work_item_dimensions", "max_work_item_sizes", "max_work_group_size", "max_num_sub_groups" and "aspects" for int64 atomics inside dpctl C API and inside the dpctl.SyclDevice class.
911
- MemoryUSM* classes moved to `dpctl.memory` module, added support for aligned allocation, added support for `prefetch` and `mem_advise` (sychronous) methods, implemented `copy_to_host`, `copy_from_host` and `copy_from_device` methods, pickling support, and zero-copy interoperability with Python objects which implement `__sycl_usm_array_inerface__` protocol.
1012
- Helper scripts to generate API documentation for both C API and Python.
1113

14+
1215
### Fixed
1316
- Compiler warnings when building libDPPLSyclInterface and the Cython extensions.
1417

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ Build and Install Conda Package
2020
conda create -n build-env conda-build
2121
conda activate build-env
2222
```
23-
2. Build conda package
23+
2. Set environment variable `ONEAPI_ROOT` and build conda package
2424
```bash
25-
conda build conda-recipe
25+
export ONEAPI_ROOT=/opt/intel/oneapi
26+
conda build conda-recipe -c ${ONEAPI_ROOT}/conda_channel
2627
```
27-
On Windows to cope with [long file names](https://github.com/IntelPython/dpctl/issues/15):
28+
On Windows to cope with [long file names](https://github.com/IntelPython/dpctl/issues/15)
29+
use `croot` with short folder path:
2830
```cmd
29-
conda build --croot=C:/tmp conda-recipe
31+
set "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI\"
32+
conda build --croot=C:/tmp conda-recipe -c "%ONEAPI_ROOT%\conda_channel"
3033
```
3134

3235
:warning: **You could face issues with conda-build=3.20**: Use conda-build=3.18!
@@ -36,9 +39,23 @@ conda build --croot=C:/tmp conda-recipe
3639
conda install dpctl
3740
```
3841

42+
Build and Install with setuptools
43+
=================================
44+
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you should activate it.
45+
46+
For install:
47+
```cmd
48+
python setup.py install
49+
```
50+
51+
For development:
52+
```cmd
53+
python setup.py develop
54+
```
55+
3956
Using dpCtl
4057
===========
41-
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you should activate it.
58+
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you could activate it.
4259

4360
On Windows:
4461
```cmd
@@ -49,6 +66,12 @@ On Linux:
4966
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
5067
```
5168

69+
When dpCtl is installed via conda package
70+
then it uses DPC++ runtime from `dpcpp_cpp_rt` package
71+
and it is not necessary to activate oneAPI DPC++ compiler environment.
72+
73+
`dpcpp_cpp_rt` package is provided by oneAPI `conda_channel`.
74+
5275
Examples
5376
========
5477
See examples in folder `examples`.

backends/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ add_library(
7777
source/dppl_sycl_queue_manager.cpp
7878
source/dppl_sycl_usm_interface.cpp
7979
source/dppl_utils.cpp
80+
helper/source/dppl_utils_helper.cpp
8081
)
8182

8283
# Install DPPLSyclInterface
8384
target_include_directories(
8485
DPPLSyclInterface
8586
PRIVATE
8687
${CMAKE_SOURCE_DIR}/include/
88+
${CMAKE_SOURCE_DIR}/helper/include/
8789
)
8890

8991
if(WIN32)
@@ -123,6 +125,12 @@ foreach(HEADER ${HEADERS})
123125
install(FILES "${HEADER}" DESTINATION include/Support)
124126
endforeach()
125127

128+
# Install all headers in helper/include
129+
file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/helper/include/*.h*")
130+
foreach(HEADER ${HEADERS})
131+
install(FILES "${HEADER}" DESTINATION helper/include)
132+
endforeach()
133+
126134
option(
127135
BUILD_CAPI_TESTS
128136
"Build dpctl C API google tests"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===------------------- dppl_utils.h - dpctl-C_API ---*--- C++ -----*-----===//
2+
//
3+
// Data Parallel Control Library (dpCtl)
4+
//
5+
// Copyright 2020 Intel Corporation
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
///
21+
/// \file
22+
/// This file defines common helper functions used in other places in DPPL.
23+
//===----------------------------------------------------------------------===//
24+
25+
#pragma once
26+
27+
#include <CL/sycl.hpp>
28+
using namespace cl::sycl;
29+
30+
std::string DPPL_DeviceTypeToStr(info::device_type devTy);
31+
info::device_type DPPL_StrToDeviceType(std::string devTyStr);
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//===------ dppl_utils_helper.cpp - dpctl-C_API ----*---- C++ -----*-----===//
2+
//
3+
// Data Parallel Control Library (dpCtl)
4+
//
5+
// Copyright 2020 Intel Corporation
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
///
21+
/// \file
22+
/// This file implements the helper functions defined in dppl_utils_helper.h.
23+
///
24+
//===----------------------------------------------------------------------===//
25+
26+
#include "dppl_utils_helper.h"
27+
#include <string>
28+
#include <sstream>
29+
30+
using namespace cl::sycl;
31+
32+
/*!
33+
* Transforms enum info::device_type to string.
34+
*/
35+
std::string DPPL_DeviceTypeToStr(info::device_type devTy)
36+
{
37+
std::stringstream ss;
38+
switch (devTy)
39+
{
40+
case info::device_type::cpu:
41+
ss << "cpu" << '\n';
42+
break;
43+
case info::device_type::gpu:
44+
ss << "gpu" << '\n';
45+
break;
46+
case info::device_type::accelerator:
47+
ss << "accelerator" << '\n';
48+
break;
49+
case info::device_type::custom:
50+
ss << "custom" << '\n';
51+
break;
52+
case info::device_type::host:
53+
ss << "host" << '\n';
54+
break;
55+
default:
56+
ss << "unknown" << '\n';
57+
}
58+
return ss.str();
59+
}
60+
61+
/*!
62+
* Transforms string to enum info::device_type.
63+
*/
64+
info::device_type DPPL_StrToDeviceType(std::string devTyStr)
65+
{
66+
info::device_type devTy;
67+
if (devTyStr == "cpu") {
68+
devTy = info::device_type::cpu;
69+
} else if(devTyStr == "gpu") {
70+
devTy = info::device_type::gpu;
71+
} else if(devTyStr == "accelerator") {
72+
devTy = info::device_type::accelerator;
73+
} else if(devTyStr == "custom") {
74+
devTy = info::device_type::custom;
75+
} else if(devTyStr == "host") {
76+
devTy = info::device_type::host;
77+
} else {
78+
// \todo handle the error
79+
throw std::runtime_error("Unknown device type.");
80+
}
81+
return devTy;
82+
}

backends/source/dppl_sycl_device_interface.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <iostream>
3131
#include <cstring>
3232
#include <CL/sycl.hpp> /* SYCL headers */
33+
#include "../helper/include/dppl_utils_helper.h"
3334

3435
using namespace cl::sycl;
3536

@@ -58,26 +59,7 @@ void dump_device_info (const device & Device)
5859
ss << std::setw(4) << " " << std::left << std::setw(16) << "Device type";
5960

6061
auto devTy = Device.get_info<info::device::device_type>();
61-
switch(devTy)
62-
{
63-
case info::device_type::cpu:
64-
ss << "cpu" << '\n';
65-
break;
66-
case info::device_type::gpu:
67-
ss << "gpu" << '\n';
68-
break;
69-
case info::device_type::accelerator:
70-
ss << "accelerator" << '\n';
71-
break;
72-
case info::device_type::custom:
73-
ss << "custom" << '\n';
74-
break;
75-
case info::device_type::host:
76-
ss << "host" << '\n';
77-
break;
78-
default:
79-
ss << "unknown" << '\n';
80-
}
62+
ss << DPPL_DeviceTypeToStr(devTy);
8163

8264
std::cout << ss.str();
8365
}

backends/source/dppl_sycl_platform_interface.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <iostream>
3030
#include <set>
3131
#include <sstream>
32+
#include "../helper/include/dppl_utils_helper.h"
3233

3334
#include <CL/sycl.hpp>
3435

@@ -124,26 +125,7 @@ void DPPLPlatform_DumpInfo ()
124125
<< "Device type";
125126

126127
auto devTy = devices[dn].get_info<info::device::device_type>();
127-
switch (devTy)
128-
{
129-
case info::device_type::cpu:
130-
ss << "cpu" << '\n';
131-
break;
132-
case info::device_type::gpu:
133-
ss << "gpu" << '\n';
134-
break;
135-
case info::device_type::accelerator:
136-
ss << "accelerator" << '\n';
137-
break;
138-
case info::device_type::custom:
139-
ss << "custom" << '\n';
140-
break;
141-
case info::device_type::host:
142-
ss << "host" << '\n';
143-
break;
144-
default:
145-
ss << "unknown" << '\n';
146-
}
128+
ss << DPPL_DeviceTypeToStr(devTy);
147129
}
148130
std::cout << ss.str();
149131
++i;

conda-recipe/bld.bat

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,9 @@ IF %ERRORLEVEL% NEQ 0 (
33
echo "oneAPI compiler activation failed"
44
exit /b 1
55
)
6-
REM conda uses %ERRORLEVEL% but FPGA scripts can set it. So it should be reseted.
7-
set ERRORLEVEL=
8-
9-
set "CC=clang-cl.exe"
10-
set "CXX=dpcpp.exe"
11-
12-
rmdir /S /Q build_cmake
13-
mkdir build_cmake
14-
cd build_cmake
15-
16-
set "DPCPP_ROOT=%ONEAPI_ROOT%\compiler\latest\windows"
17-
set "INSTALL_PREFIX=%cd%\..\install"
18-
19-
rmdir /S /Q "%INSTALL_PREFIX%"
20-
21-
cmake -G Ninja ^
22-
-DCMAKE_BUILD_TYPE=Release ^
23-
"-DCMAKE_INSTALL_PREFIX=%INSTALL_PREFIX%" ^
24-
"-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX%" ^
25-
"-DDPCPP_ROOT=%DPCPP_ROOT%" ^
26-
"%SRC_DIR%\backends"
27-
IF %ERRORLEVEL% NEQ 0 exit /b 1
28-
29-
ninja -n
30-
ninja install
31-
IF %ERRORLEVEL% NEQ 0 exit /b 1
32-
33-
cd ..
34-
xcopy install\lib\*.lib dpctl /E /Y
35-
xcopy install\bin\*.dll dpctl /E /Y
36-
37-
mkdir dpctl\include
38-
xcopy backends\include dpctl\include /E /Y
39-
40-
41-
REM required by _sycl_core(dpctl)
42-
set "DPPL_SYCL_INTERFACE_LIBDIR=dpctl"
43-
set "DPPL_SYCL_INTERFACE_INCLDIR=dpctl\include"
446

457
"%PYTHON%" setup.py clean --all
46-
"%PYTHON%" setup.py build install
8+
"%PYTHON%" setup.py install
479
IF %ERRORLEVEL% NEQ 0 exit /b 1
4810

4911
rem Build wheel package

conda-recipe/build.sh

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,13 @@
44
if [ ! -z "${ONEAPI_ROOT}" ]; then
55
# Suppress error b/c it could fail on Ubuntu 18.04
66
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh || true
7-
export CC=clang
8-
export CXX=clang++
97
else
108
echo "DPCPP is needed to build DPPL. Abort!"
119
exit 1
1210
fi
1311

14-
rm -rf build_cmake
15-
mkdir build_cmake
16-
pushd build_cmake
17-
18-
INSTALL_PREFIX=`pwd`/../install
19-
rm -rf ${INSTALL_PREFIX}
20-
21-
PYTHON_INC=`${PYTHON} -c "import distutils.sysconfig; \
22-
print(distutils.sysconfig.get_python_inc())"`
23-
NUMPY_INC=`${PYTHON} -c "import numpy; print(numpy.get_include())"`
24-
DPCPP_ROOT=${ONEAPI_ROOT}/compiler/latest/linux/
25-
26-
cmake \
27-
-DCMAKE_BUILD_TYPE=Release \
28-
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
29-
-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \
30-
-DDPCPP_ROOT=${DPCPP_ROOT} \
31-
-DPYTHON_INCLUDE_DIR=${PYTHON_INC} \
32-
-DNUMPY_INCLUDE_DIR=${NUMPY_INC} \
33-
../backends
34-
35-
make -j 4 && make install
36-
37-
popd
38-
cp install/lib/*.so dpctl/
39-
40-
mkdir -p dpctl/include
41-
cp -r backends/include/* dpctl/include
42-
43-
44-
# required by dpctl.sycl_core
45-
export DPPL_SYCL_INTERFACE_LIBDIR=dpctl
46-
export DPPL_SYCL_INTERFACE_INCLDIR=dpctl/include
47-
48-
49-
# FIXME: How to pass this using setup.py? This flags is needed when
50-
# dpcpp compiles the generated cpp file.
51-
export CFLAGS="-fPIC -O3 ${CFLAGS}"
5212
${PYTHON} setup.py clean --all
53-
${PYTHON} setup.py build install
13+
${PYTHON} setup.py install
5414

5515
# Build wheel package
5616
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then

0 commit comments

Comments
 (0)