-
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.
* initial sycl support * add sycl tests * add sycl ci * fix sycl ci * fix sycl ci * add sycl badge
- Loading branch information
Showing
36 changed files
with
1,853 additions
and
16 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
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,24 @@ | ||
name: sycl | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
opensycl-clang14-omp-docker: | ||
name: ${{ matrix.name }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: build docker | ||
run: | | ||
docker build . --tag nmtools:sycl-clang14-omp --file docker/sycl.dockerfile | ||
- name: run tests | ||
run: | | ||
docker run --rm nmtools:sycl-clang14-omp |
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
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,5 @@ | ||
set(CMAKE_C_COMPILER /usr/local/bin/syclcc) | ||
set(CMAKE_CXX_COMPILER /usr/local/bin/syclcc) | ||
|
||
SET (CMAKE_C_COMPILER_WORKS 1) | ||
add_compile_options(-W -Wall -Werror -Wextra -Wno-gnu-string-literal-operator-template --hipsycl-targets=omp --hipsycl-clang=/usr/bin/clang++-14) |
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,59 @@ | ||
from ubuntu:jammy as dev | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Asia | ||
|
||
run apt update && apt install -y \ | ||
build-essential cmake clang \ | ||
curl git-core gnupg locales \ | ||
zsh wget fonts-powerline \ | ||
&& locale-gen en_US.UTF-8 | ||
|
||
ENV DEBIAN_FRONTEND=dialog | ||
|
||
# generate locale for agnoster | ||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && /usr/sbin/locale-gen | ||
|
||
ENV TERM xterm | ||
|
||
# Set the default shell to bash rather than sh | ||
ENV SHELL /bin/zsh | ||
|
||
# run the installation script | ||
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true | ||
|
||
# install powerlevel10k | ||
RUN git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k | ||
|
||
RUN cd $HOME && curl -fsSLO https://raw.githubusercontent.com/romkatv/dotfiles-public/master/.purepower | ||
|
||
ADD .devcontainer/.zshrc $HOME | ||
|
||
from dev as build | ||
|
||
WORKDIR /workspace/nmtools | ||
|
||
COPY cmake cmake | ||
COPY scripts scripts | ||
COPY include include | ||
COPY tests tests | ||
COPY CMakeLists.txt CMakeLists.txt | ||
COPY nmtools.pc.in nmtools.pc.in | ||
COPY nmtoolsConfig.cmake.in nmtoolsConfig.cmake.in | ||
|
||
## install doctest | ||
COPY scripts/install_doctest.sh scripts/install_doctest.sh | ||
RUN bash scripts/install_doctest.sh | ||
|
||
RUN apt install -y libclang-dev clang-tools libomp-dev llvm-dev lld libboost-dev libboost-fiber-dev libboost-context-dev | ||
RUN bash scripts/install_opensycl.sh | ||
|
||
ARG toolchain=sycl-clang14-omp | ||
RUN mkdir -p build && cd build \ | ||
&& cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/${toolchain}.cmake \ | ||
-DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF \ | ||
-DNMTOOLS_BUILD_SYCL_TESTS=ON \ | ||
../ \ | ||
&& make -j2 VERBOSE=1 | ||
|
||
CMD ["/workspace/nmtools/build/tests/sycl/numeric-tests-sycl-doctest"] |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
*.png | ||
*.png | ||
blog | ||
milestones |
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
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,100 @@ | ||
#ifndef NMTOOLS_ARRAY_EVAL_KERNEL_HELPER_HPP | ||
#define NMTOOLS_ARRAY_EVAL_KERNEL_HELPER_HPP | ||
|
||
#include "nmtools/meta.hpp" | ||
#include "nmtools/array/ndarray.hpp" | ||
#include "nmtools/array/index/product.hpp" | ||
#include "nmtools/array/view/ref.hpp" | ||
#include "nmtools/array/view/mutable_ref.hpp" | ||
#include "nmtools/array/view/flatten.hpp" | ||
#include "nmtools/array/view/mutable_flatten.hpp" | ||
#include "nmtools/array/view/reshape.hpp" | ||
|
||
#ifdef NMTOOLS_KERNEL_MAX_DIM | ||
#define NMTOOLS_KERNEL_MAX_DIM_ NMTOOLS_KERNEL_MAX_DIM | ||
#else | ||
#define NMTOOLS_KERNEL_MAX_DIM_ 8 | ||
#endif | ||
|
||
namespace nmtools::array | ||
{ | ||
struct create_vector_t {}; | ||
|
||
template <auto DIM=0, typename size_type, typename type> | ||
nmtools_func_attribute | ||
auto create_vector(const type* data_ptr, size_type dim) | ||
{ | ||
using vector_t = meta::resolve_optype_t<create_vector_t,meta::as_type<DIM>,type>; | ||
auto vector = vector_t{}; | ||
|
||
if constexpr (meta::is_resizable_v<vector_t>) { | ||
vector.resize(dim); | ||
} | ||
|
||
for (size_type i=0; i<dim; i++) { | ||
at(vector,i) = data_ptr[i]; | ||
} | ||
|
||
return vector; | ||
} | ||
|
||
template <typename type, typename shape_type> | ||
nmtools_func_attribute | ||
auto create_array(const type* data_ptr, const shape_type& shape) | ||
{ | ||
auto numel = index::product(shape); | ||
|
||
auto ref = view::ref(data_ptr,numel); | ||
return view::reshape(ref,shape); | ||
} | ||
|
||
template <auto DIM=0, typename dim_type=unsigned long, typename size_type=unsigned long, typename type> | ||
nmtools_func_attribute | ||
auto create_array(const type* data_ptr, const size_type* shape_ptr, dim_type dim) | ||
{ | ||
auto shape = create_vector<DIM>(shape_ptr,dim); | ||
return create_array(data_ptr,shape); | ||
} | ||
|
||
template <typename type, typename shape_type> | ||
nmtools_func_attribute | ||
auto create_mutable_array(type* data_ptr, const shape_type& shape) | ||
{ | ||
const auto numel = index::product(shape); | ||
|
||
auto ref = view::mutable_ref(data_ptr,numel); | ||
return view::reshape(ref,shape); | ||
} | ||
|
||
template <auto DIM=0, typename dim_type=unsigned long, typename size_type=unsigned long, typename type> | ||
nmtools_func_attribute | ||
auto create_mutable_array(type* data_ptr, const size_type* shape_ptr, dim_type dim) | ||
{ | ||
const auto shape = create_vector<DIM>(shape_ptr,dim); | ||
return create_mutable_array(data_ptr,shape); | ||
} | ||
} | ||
|
||
namespace nmtools::meta | ||
{ | ||
template <auto DIM, typename data_type> | ||
struct resolve_optype< | ||
void, array::create_vector_t, as_type<DIM>, data_type | ||
> | ||
{ | ||
static constexpr auto vtype = [](){ | ||
if constexpr (DIM <= 0) { | ||
using type = utl::static_vector<remove_address_space_t<data_type>,NMTOOLS_KERNEL_MAX_DIM_>; | ||
return as_value_v<type>; | ||
} else { | ||
using type = nmtools_array<remove_address_space_t<data_type>,DIM>; | ||
return as_value_v<type>; | ||
} | ||
}(); | ||
using type = type_t<decltype(vtype)>; | ||
}; | ||
} | ||
|
||
#undef NMTOOLS_KERNEL_MAX_DIM_ | ||
|
||
#endif // NMTOOLS_ARRAY_EVAL_KERNEL_HELPER_HPP |
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,7 @@ | ||
#ifndef NMTOOLS_ARRAY_EVAL_SYCL_HPP | ||
#define NMTOOLS_ARRAY_EVAL_SYCL_HPP | ||
|
||
#include "nmtools/array/eval/sycl/context.hpp" | ||
#include "nmtools/array/eval/sycl/evaluator.hpp" | ||
|
||
#endif // NMTOOLS_ARRAY_EVAL_SYCL_HPP |
Oops, something went wrong.