Skip to content

add a basic workflow #4

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 14 commits into from
Oct 25, 2023
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
52 changes: 52 additions & 0 deletions .github/workflows/docker_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause

name: Docker

on:
push:
pull_request:
workflow_dispatch:
# 8am UTC is 12am PST, 1am PDT
schedule:
- cron: '0 8 * * *'

jobs:
run_precommit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Run pre-commit
uses: pre-commit/[email protected]
run_examples:
name: Build and run examples
runs-on: ubuntu-latest
container:
image: intel/oneapi:latest
env:
CXX: icpx
CC: icx
volumes:
- ${{ github.workspace }}:/src
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup cmake
uses: jwlawson/[email protected]
- name: Build examples
run: |
cmake -B build
cmake --build build -j
- name: Run examples
run: |
mpirun -n 2 ./build/src/example1
mpirun -n 2 ./build/src/example2
mpirun -n 2 ./build/src/example3
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause

repos:

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
- id: clang-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- id: check-yaml
- id: check-case-conflict
- id: check-added-large-files
args: ['--maxkb=800']


- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ project(
VERSION 0.1
DESCRIPTION "Distributed ranges tutorial")



find_package(MPI REQUIRED)

add_subdirectory(src)
Expand All @@ -24,9 +22,9 @@ option(ENABLE_FORMAT "Build with format library" ON)
include(FetchContent)

FetchContent_Declare(
distributed-ranges
GIT_REPOSITORY https://github.com/oneapi-src/distributed-ranges.git
GIT_TAG c618154a1bceda33e5d61e1536179aeaa11b68f4)
distributed-ranges
GIT_REPOSITORY https://github.com/oneapi-src/distributed-ranges.git
GIT_TAG c618154a1bceda33e5d61e1536179aeaa11b68f4)
FetchContent_MakeAvailable(distributed-ranges)

FetchContent_Declare(
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ In case your environment is not configured properly or you just prefer a hassle-
git clone https://github.com/mateuszpn/distributed-ranges-tutorial
cd distributed-ranges-tutorial
docker run -it -v $(pwd):/custom-directory-name -u root docker.io/intel/oneapi:latest /bin/bash
cd custom-directory-name
cd custom-directory-name
CXX=icpx CC=icx cmake -B build -DENABLE_SYCL=ON
cmake --build build -j
```
Expand Down Expand Up @@ -81,12 +81,12 @@ In this way, many of the technical details related to the parallel execution of
### Namespaces

General namespace used in the library is `dr::`
For program using a single node with shared memory available for multiple CPUs and one or more GPUs, data structures and algoritms from `dr::shp::` namespace are provided.
For program using a single node with shared memory available for multiple CPUs and one or more GPUs, data structures and algorithms from `dr::shp::` namespace are provided.
For distributed memory model, use the `dr::mhp::` namespace.

### Data structures

Content of distributes-ranges' data structures is distributed over available nodes. For example, segments of `dr::mhp::distributed_vector` are located in memory of different nodes (mpi processes). Still, global view of the `distributed_vector` is uniform, with contigous indices.
Content of distributes-ranges' data structures is distributed over available nodes. For example, segments of `dr::mhp::distributed_vector` are located in memory of different nodes (mpi processes). Still, global view of the `distributed_vector` is uniform, with contiguous indices.
<!-- TODO: some pictures here -->

#### Halo concept
Expand All @@ -97,7 +97,7 @@ To support this situation, the concept of halo was introduced. A halo is an area

### Algorithms

Follwing algorithms are included in distributed-ranges, both in mhp and shp versions:
Following algorithms are included in distributed-ranges, both in mhp and shp versions:

```cpp
copy()
Expand All @@ -121,7 +121,7 @@ The examples should be compiled with SYCL compiler and run with.
mpirun -n N ./build/src/example_name
```

where `N` - number of MPI processes. Replace _example_name_ with appropiate name of a file tu run.
where `N` - number of MPI processes. Replace _example_name_ with appropriate name of a file tu run.

### Example 1

Expand All @@ -140,13 +140,13 @@ The example shows the distributed nature of dr data structures. The distributed_

[./src/example3.cpp](src/example3.cpp)

The example simulates the elementary 1-d cellular automaton (ECA). Description of what the automaton is and how it works can be found in [wikipedia](https://en.wikipedia.org/wiki/Elementary_cellular_automaton). Visulisation of the automaton work is available in [ASU team webpage](https://elife-asu.github.io/wss-modules/modules/1-1d-cellular-automata).
The example simulates the elementary 1-d cellular automaton (ECA). Description of what the automaton is and how it works can be found in [wikipedia](https://en.wikipedia.org/wiki/Elementary_cellular_automaton). Visualisation of the automaton work is available in [ASU team webpage](https://elife-asu.github.io/wss-modules/modules/1-1d-cellular-automata).

The ECA calculates the new value of a cell using old value of the cell and old values of the cell's neighbors. Therefore a halo of 1-cell width is used, to get access to neighboring cells' values when the loop eaches end of local segment of a vector.
Additionally, a use of a subrange is presented, and `transform()` function, which puts transformed values of input structure to the output structure, element by element. The transforming function is given as lambda `newvalue`.
_Please note: after each loop the vector content is printed with `fmt::print()`. The formatter function for `distributed_vector` is rather slow, as it gets the vector element by element, both from local node and remote nodes. You can think about customised, more effective way of results presentation._

<!--
Consider adding one more example:
Consider adding one more example:
*Simple 2-D operation - Find a pattern in the randomly filled array*
-->
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause

pre-commit==3.4.0
15 changes: 15 additions & 0 deletions scripts/build_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

# SPDX-FileCopyrightText: Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause

export CXX=icpx
export CC=icx

cmake -B build
cmake --build build -j

mpirun -n 2 ./build/src/example1
mpirun -n 2 ./build/src/example2
mpirun -n 2 ./build/src/example3
2 changes: 1 addition & 1 deletion security.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Security Policy
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation.
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation.

## Reporting a Vulnerability
Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(ENABLE_CUDA)
add_compile_options(-fsycl-targets=nvptx64-nvidia-cuda
-Wno-error=unknown-cuda-version)
add_link_options(-fsycl-targets=nvptx64-nvidia-cuda
-Wno-error=unknown-cuda-version)
-Wno-error=unknown-cuda-version)
endif()

add_executable(example1 example1.cpp)
Expand Down
2 changes: 1 addition & 1 deletion src/example1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ int main(int argc, char **argv) {
mhp::finalize();

return 0;
}
}
2 changes: 1 addition & 1 deletion src/example2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, char **argv) {
mhp::init(sycl::default_selector_v);

fmt::print(
"Hello, World! Distributed ranges proces is running on rank {} / {} on "
"Hello, World! Distributed ranges process is running on rank {} / {} on "
"host {}\n",
mhp::rank(), mhp::nprocs(), mhp::hostname());

Expand Down
4 changes: 2 additions & 2 deletions src/example3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace mhp = dr::mhp;
/* The example simulates the elementary 1-d cellular automaton. Description of
* what the automaton is and how it works can be found at
* https://en.wikipedia.org/wiki/Elementary_cellular_automaton
* Visulisation of the automaton work is available
* Visualisation of the automaton work is available
* https://elife-asu.github.io/wss-modules/modules/1-1d-cellular-automata
* (credit: Emergence team @ Arizona State University)*/

Expand Down Expand Up @@ -58,4 +58,4 @@ int main(int argc, char **argv) {
mhp::finalize();

return 0;
}
}