Skip to content

Merge gold/2021 with 0.5.0rc1 #195

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 11 commits into from
Dec 5, 2020
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
All notable changes to this project will be documented in this file.

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

## [0.4.0] - 2020-11-04
### Added
- 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.
- 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.
- Helper scripts to generate API documentation for both C API and Python.


### Fixed
- Compiler warnings when building libDPPLSyclInterface and the Cython extensions.

Expand Down
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ Build and Install Conda Package
conda create -n build-env conda-build
conda activate build-env
```
2. Build conda package
2. Set environment variable `ONEAPI_ROOT` and build conda package
```bash
conda build conda-recipe
export ONEAPI_ROOT=/opt/intel/oneapi
conda build conda-recipe -c ${ONEAPI_ROOT}/conda_channel
```
On Windows to cope with [long file names](https://github.com/IntelPython/dpctl/issues/15):
On Windows to cope with [long file names](https://github.com/IntelPython/dpctl/issues/15)
use `croot` with short folder path:
```cmd
conda build --croot=C:/tmp conda-recipe
set "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI\"
conda build --croot=C:/tmp conda-recipe -c "%ONEAPI_ROOT%\conda_channel"
```

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

Build and Install with setuptools
=================================
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you should activate it.

For install:
```cmd
python setup.py install
```

For development:
```cmd
python setup.py develop
```

Using dpCtl
===========
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you should activate it.
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you could activate it.

On Windows:
```cmd
Expand All @@ -49,6 +66,12 @@ On Linux:
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
```

When dpCtl is installed via conda package
then it uses DPC++ runtime from `dpcpp_cpp_rt` package
and it is not necessary to activate oneAPI DPC++ compiler environment.

`dpcpp_cpp_rt` package is provided by oneAPI `conda_channel`.

Examples
========
See examples in folder `examples`.
Expand Down
8 changes: 8 additions & 0 deletions backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ add_library(
source/dppl_sycl_queue_manager.cpp
source/dppl_sycl_usm_interface.cpp
source/dppl_utils.cpp
helper/source/dppl_utils_helper.cpp
)

# Install DPPLSyclInterface
target_include_directories(
DPPLSyclInterface
PRIVATE
${CMAKE_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/helper/include/
)

if(WIN32)
Expand Down Expand Up @@ -123,6 +125,12 @@ 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*")
foreach(HEADER ${HEADERS})
install(FILES "${HEADER}" DESTINATION helper/include)
endforeach()

option(
BUILD_CAPI_TESTS
"Build dpctl C API google tests"
Expand Down
31 changes: 31 additions & 0 deletions backends/helper/include/dppl_utils_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===------------------- dppl_utils.h - dpctl-C_API ---*--- C++ -----*-----===//
//
// Data Parallel Control Library (dpCtl)
//
// Copyright 2020 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file defines common helper functions used in other places in DPPL.
//===----------------------------------------------------------------------===//

#pragma once

#include <CL/sycl.hpp>
using namespace cl::sycl;

std::string DPPL_DeviceTypeToStr(info::device_type devTy);
info::device_type DPPL_StrToDeviceType(std::string devTyStr);
82 changes: 82 additions & 0 deletions backends/helper/source/dppl_utils_helper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//===------ dppl_utils_helper.cpp - dpctl-C_API ----*---- C++ -----*-----===//
//
// Data Parallel Control Library (dpCtl)
//
// Copyright 2020 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file implements the helper functions defined in dppl_utils_helper.h.
///
//===----------------------------------------------------------------------===//

#include "dppl_utils_helper.h"
#include <string>
#include <sstream>

using namespace cl::sycl;

/*!
* Transforms enum info::device_type to string.
*/
std::string DPPL_DeviceTypeToStr(info::device_type devTy)
{
std::stringstream ss;
switch (devTy)
{
case info::device_type::cpu:
ss << "cpu" << '\n';
break;
case info::device_type::gpu:
ss << "gpu" << '\n';
break;
case info::device_type::accelerator:
ss << "accelerator" << '\n';
break;
case info::device_type::custom:
ss << "custom" << '\n';
break;
case info::device_type::host:
ss << "host" << '\n';
break;
default:
ss << "unknown" << '\n';
}
return ss.str();
}

/*!
* Transforms string to enum info::device_type.
*/
info::device_type DPPL_StrToDeviceType(std::string devTyStr)
{
info::device_type devTy;
if (devTyStr == "cpu") {
devTy = info::device_type::cpu;
} else if(devTyStr == "gpu") {
devTy = info::device_type::gpu;
} else if(devTyStr == "accelerator") {
devTy = info::device_type::accelerator;
} else if(devTyStr == "custom") {
devTy = info::device_type::custom;
} else if(devTyStr == "host") {
devTy = info::device_type::host;
} else {
// \todo handle the error
throw std::runtime_error("Unknown device type.");
}
return devTy;
}
22 changes: 2 additions & 20 deletions backends/source/dppl_sycl_device_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <iostream>
#include <cstring>
#include <CL/sycl.hpp> /* SYCL headers */
#include "../helper/include/dppl_utils_helper.h"

using namespace cl::sycl;

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

auto devTy = Device.get_info<info::device::device_type>();
switch(devTy)
{
case info::device_type::cpu:
ss << "cpu" << '\n';
break;
case info::device_type::gpu:
ss << "gpu" << '\n';
break;
case info::device_type::accelerator:
ss << "accelerator" << '\n';
break;
case info::device_type::custom:
ss << "custom" << '\n';
break;
case info::device_type::host:
ss << "host" << '\n';
break;
default:
ss << "unknown" << '\n';
}
ss << DPPL_DeviceTypeToStr(devTy);

std::cout << ss.str();
}
Expand Down
22 changes: 2 additions & 20 deletions backends/source/dppl_sycl_platform_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <iostream>
#include <set>
#include <sstream>
#include "../helper/include/dppl_utils_helper.h"

#include <CL/sycl.hpp>

Expand Down Expand Up @@ -124,26 +125,7 @@ void DPPLPlatform_DumpInfo ()
<< "Device type";

auto devTy = devices[dn].get_info<info::device::device_type>();
switch (devTy)
{
case info::device_type::cpu:
ss << "cpu" << '\n';
break;
case info::device_type::gpu:
ss << "gpu" << '\n';
break;
case info::device_type::accelerator:
ss << "accelerator" << '\n';
break;
case info::device_type::custom:
ss << "custom" << '\n';
break;
case info::device_type::host:
ss << "host" << '\n';
break;
default:
ss << "unknown" << '\n';
}
ss << DPPL_DeviceTypeToStr(devTy);
}
std::cout << ss.str();
++i;
Expand Down
40 changes: 1 addition & 39 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,9 @@ IF %ERRORLEVEL% NEQ 0 (
echo "oneAPI compiler activation failed"
exit /b 1
)
REM conda uses %ERRORLEVEL% but FPGA scripts can set it. So it should be reseted.
set ERRORLEVEL=

set "CC=clang-cl.exe"
set "CXX=dpcpp.exe"

rmdir /S /Q build_cmake
mkdir build_cmake
cd build_cmake

set "DPCPP_ROOT=%ONEAPI_ROOT%\compiler\latest\windows"
set "INSTALL_PREFIX=%cd%\..\install"

rmdir /S /Q "%INSTALL_PREFIX%"

cmake -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
"-DCMAKE_INSTALL_PREFIX=%INSTALL_PREFIX%" ^
"-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX%" ^
"-DDPCPP_ROOT=%DPCPP_ROOT%" ^
"%SRC_DIR%\backends"
IF %ERRORLEVEL% NEQ 0 exit /b 1

ninja -n
ninja install
IF %ERRORLEVEL% NEQ 0 exit /b 1

cd ..
xcopy install\lib\*.lib dpctl /E /Y
xcopy install\bin\*.dll dpctl /E /Y

mkdir dpctl\include
xcopy backends\include dpctl\include /E /Y


REM required by _sycl_core(dpctl)
set "DPPL_SYCL_INTERFACE_LIBDIR=dpctl"
set "DPPL_SYCL_INTERFACE_INCLDIR=dpctl\include"

"%PYTHON%" setup.py clean --all
"%PYTHON%" setup.py build install
"%PYTHON%" setup.py install
IF %ERRORLEVEL% NEQ 0 exit /b 1

rem Build wheel package
Expand Down
42 changes: 1 addition & 41 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,13 @@
if [ ! -z "${ONEAPI_ROOT}" ]; then
# Suppress error b/c it could fail on Ubuntu 18.04
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh || true
export CC=clang
export CXX=clang++
else
echo "DPCPP is needed to build DPPL. Abort!"
exit 1
fi

rm -rf build_cmake
mkdir build_cmake
pushd build_cmake

INSTALL_PREFIX=`pwd`/../install
rm -rf ${INSTALL_PREFIX}

PYTHON_INC=`${PYTHON} -c "import distutils.sysconfig; \
print(distutils.sysconfig.get_python_inc())"`
NUMPY_INC=`${PYTHON} -c "import numpy; print(numpy.get_include())"`
DPCPP_ROOT=${ONEAPI_ROOT}/compiler/latest/linux/

cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \
-DDPCPP_ROOT=${DPCPP_ROOT} \
-DPYTHON_INCLUDE_DIR=${PYTHON_INC} \
-DNUMPY_INCLUDE_DIR=${NUMPY_INC} \
../backends

make -j 4 && make install

popd
cp install/lib/*.so dpctl/

mkdir -p dpctl/include
cp -r backends/include/* dpctl/include


# required by dpctl.sycl_core
export DPPL_SYCL_INTERFACE_LIBDIR=dpctl
export DPPL_SYCL_INTERFACE_INCLDIR=dpctl/include


# FIXME: How to pass this using setup.py? This flags is needed when
# dpcpp compiles the generated cpp file.
export CFLAGS="-fPIC -O3 ${CFLAGS}"
${PYTHON} setup.py clean --all
${PYTHON} setup.py build install
${PYTHON} setup.py install

# Build wheel package
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
Expand Down
Loading