Skip to content

Commit

Permalink
Merge branch 'main' into benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Xewar313 committed Nov 5, 2024
2 parents 5edd0ba + 01b3e25 commit 5800f99
Show file tree
Hide file tree
Showing 19 changed files with 542 additions and 123 deletions.
48 changes: 0 additions & 48 deletions .github/workflows/onedpl.yml

This file was deleted.

61 changes: 39 additions & 22 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
runs-on: intel-ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Ubuntu dependencies
run: scripts/install-doxygen.sh
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.10'
cache: 'pip'
Expand All @@ -48,14 +48,14 @@ jobs:
# env:
# CXX: ${{ matrix.cxx }}
# steps:
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
# - name: Generate
# run: cmake -B build
# - name: Build
# run: make -C build -j
# - name: Unit tests
# run: ctest --test-dir build -L TESTLABEL -j 4
# - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
# - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
# if: always()
# with:
# name: log-gcc-${{ env.CXX }}
Expand All @@ -66,8 +66,9 @@ jobs:
# build/examples/mp/*.log

pvc_unit_tests:
runs-on: gkpvc
timeout-minutes: 30
# runs-on: gkpvc
runs-on: ubuntu-24.04
timeout-minutes: 120
strategy:
# test everything, even if one fails
fail-fast: false
Expand All @@ -81,20 +82,36 @@ jobs:
CXX: icpx
FI_PROVIDER: tcp
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Intel APT repository
run: |
# https://www.intel.com/content/www/us/en/docs/oneapi/installation-guide-linux/2024-0/apt.html
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update -y
- name: Install oneAPI
run: sudo apt-get install intel-oneapi-compiler-dpcpp-cpp intel-oneapi-mkl-devel intel-hpckit -y
- name: Generate
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
- name: Save environment dump
run: printenv > build/envdump.txt
run: |
. /opt/intel/oneapi/setvars.sh
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
printenv > build/envdump.txt
# change this step to building just tests once unittest job is back
- name: Build everything
run: make -C build -j
# - name: Build tests
# run: cmake --build build --target all-tests -- -j
# - name: Build everything
# run: |
# . /opt/intel/oneapi/setvars.sh
# make -C build -j
- name: Build tests
run: |
. /opt/intel/oneapi/setvars.sh
cmake --build build --target all-tests -- -j 4
- name: Unit tests
# run: srun -p cluster scripts/run_command_on_compute_node.sh build/Testing/tests.outerr.txt ctest --test-dir build -L TESTLABEL -j 4
run: ctest --test-dir build -L TESTLABEL -j 4
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
run: |
. /opt/intel/oneapi/setvars.sh
ctest --test-dir build --output-on-failure -L TESTLABEL -j 4
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: always()
with:
name: log-pvc-impi-icpx-${{ matrix.config }}
Expand Down Expand Up @@ -125,7 +142,7 @@ jobs:
# env:
# CXX: icpx
# steps:
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
# - name: Generate
# run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DENABLE_ISHMEM=on -DENABLE_L0=on -DENABLE_OFI=on -DOFI_PROVIDER=psm3 -DONETILE_PVC=on
# - name: Build ISHMEM
Expand All @@ -135,7 +152,7 @@ jobs:
# - name: MP unit tests
# # run: srun -p cluster scripts/run_command_on_compute_node.sh build/Testing/mptests.outerr.txt ctest --test-dir build -R ^mp-tests-sycl -L MP -j 4
# run: ctest --test-dir build -R ^mp-tests-sycl -L MP -j 4
# - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
# - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
# if: always()
# with:
# name: log-ishmem-impi-icpx-${{ matrix.config }}
Expand All @@ -154,7 +171,7 @@ jobs:
env:
CXX: g++-13
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- run: |
echo "creating DEB package is going to be here"
Expand All @@ -169,8 +186,8 @@ jobs:
SPHINXOPTS: -q -W
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.10'
cache: 'pip'
Expand All @@ -181,7 +198,7 @@ jobs:
run: |
make -C doc/spec html
- name: Checkout gh-pages
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: gh-pages
path: gh-pages
Expand Down
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ add_custom_target(sp-all-tests)
add_custom_target(all-tests DEPENDS mp-all-tests sp-all-tests)

function(add_mp_ctest_impl)
set(options OFFLOAD GDB SYCL DRLOGS TESTLABEL)
set(options OFFLOAD GDB SYCL DRLOGS TESTLABEL PVCLABEL)
set(oneValueArgs NAME TEST_NAME NPROC TIMEOUT)
set(multiValueArgs TARGS) # Test ARGumentS

Expand Down Expand Up @@ -234,7 +234,10 @@ function(add_mp_ctest_impl)
endif()

if(AMC_TESTLABEL)
set_property(TEST ${AMC_TEST_NAME} PROPERTY LABELS TESTLABEL MP)
set_property(TEST ${AMC_TEST_NAME} PROPERTY LABELS TESTLABEL PVCLABEL MP)
endif()
if(AMC_PVCLABEL)
set_property(TEST ${AMC_TEST_NAME} PROPERTY LABELS PVCLABEL MP)
endif()
add_dependencies(mp-all-tests ${AMC_NAME})
endfunction()
Expand All @@ -250,6 +253,11 @@ function(add_mp_ctest)
add_mp_auxiliary_ctests(${ARGN})
endfunction()

function(add_mp_pvc_ctest)
add_mp_ctest_impl(${ARGN} PVCLABEL)
add_mp_auxiliary_ctests(${ARGN})
endfunction()

function(add_mp_disabled_ctest)
add_mp_ctest_impl(${ARGN})
add_mp_auxiliary_ctests(${ARGN})
Expand Down Expand Up @@ -370,7 +378,7 @@ endfunction()

function(add_sp_ctest test_name name)
add_sp_disabled_ctest(${test_name} ${name} ${ARGN})
set_property(TEST ${test_name} PROPERTY LABELS TESTLABEL SP)
set_property(TEST ${test_name} PROPERTY LABELS TESTLABEL PVCLABEL SP)
endfunction()

install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/gbench/sp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_executable(
gemm.cpp
../common/distributed_vector.cpp
../common/dot_product.cpp
../common/inclusive_exclusive_scan.cpp
# ../common/inclusive_exclusive_scan.cpp disabled due to deadlock DRA-214
../common/sort.cpp
../common/stream.cpp)
# cmake-format: on
Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
FetchContent_Declare(
dpl
GIT_REPOSITORY https://github.com/oneapi-src/oneDPL.git
GIT_TAG 251b0b1)
GIT_TAG main)
FetchContent_MakeAvailable(dpl)

# mpi: multi-process
Expand Down
11 changes: 11 additions & 0 deletions include/dr/detail/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ template <std::integral T = std::size_t> class index {
}

constexpr bool operator==(const index &) const noexcept = default;
constexpr bool operator<(const index &other) const noexcept
requires(std::totally_ordered<T>)
{
if (first < other.first) {
return true;
}
if (first == other.first && second < other.second) {
return true;
}
return false;
}

template <std::size_t Index>
constexpr T get() const noexcept
Expand Down
1 change: 1 addition & 0 deletions include/dr/mp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include <dr/mp/views/mdspan_view.hpp>
#include <dr/mp/views/submdspan_view.hpp>
#include <dr/mp/algorithms/copy.hpp>
#include <dr/mp/algorithms/count.hpp>
#include <dr/mp/algorithms/equal.hpp>
#include <dr/mp/algorithms/fill.hpp>
#include <dr/mp/algorithms/for_each.hpp>
Expand Down
126 changes: 126 additions & 0 deletions include/dr/mp/algorithms/count.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// SPDX-FileCopyrightText: Intel Corporation
//
// SPDX-License-Identifier: BSD-3-Clause

#pragma once

namespace dr::mp::__detail {

inline auto add_counts(rng::forward_range auto &&r) {
rng::range_difference_t<decltype(r)> zero{};

return std::accumulate(rng::begin(r), rng::end(r), zero);
}

inline auto count_if_local(rng::forward_range auto &&r, auto &&pred) {
if (mp::use_sycl()) {
dr::drlog.debug(" with DPL\n");
#ifdef SYCL_LANGUAGE_VERSION
return std::count_if(mp::dpl_policy(),
dr::__detail::direct_iterator(rng::begin(r)),
dr::__detail::direct_iterator(rng::end(r)), pred);
#else
assert(false);
#endif
} else {
dr::drlog.debug(" with CPU\n");
return std::count_if(std::execution::par_unseq,
dr::__detail::direct_iterator(rng::begin(r)),
dr::__detail::direct_iterator(rng::end(r)), pred);
}
}

template <dr::distributed_range DR>
auto count_if(std::size_t root, bool root_provided, DR &&dr, auto &&pred) {
using count_type = rng::range_difference_t<decltype(dr)>;
auto comm = mp::default_comm();

if (rng::empty(dr)) {
return count_type{};
}

dr::drlog.debug("Parallel count\n");

// Count within the local segments
auto count = [=](auto &&r) {
assert(rng::size(r) > 0);
return count_if_local(r, pred);
};
auto locals = rng::views::transform(local_segments(dr), count);
auto local = add_counts(locals);

std::vector<count_type> all(comm.size());
if (root_provided) {
// Everyone gathers to root, only root adds up the counts
comm.gather(local, std::span{all}, root);
if (root == comm.rank()) {
return add_counts(all);
} else {
return count_type{};
}
} else {
// Everyone gathers and everyone adds up the counts
comm.all_gather(local, all);
return add_counts(all);
}
}

} // namespace dr::mp::__detail

namespace dr::mp {

class count_fn_ {
public:
template <typename T, dr::distributed_range DR>
auto operator()(std::size_t root, DR &&dr, const T &value) const {
auto pred = [=](auto &&v) { return v == value; };
return __detail::count_if(root, true, dr, pred);
}

template <typename T, dr::distributed_range DR>
auto operator()(DR &&dr, const T &value) const {
auto pred = [=](auto &&v) { return v == value; };
return __detail::count_if(0, false, dr, pred);
}

template <typename T, dr::distributed_iterator DI>
auto operator()(std::size_t root, DI first, DI last, const T &value) const {
auto pred = [=](auto &&v) { return v == value; };
return __detail::count_if(root, true, rng::subrange(first, last), pred);
}

template <typename T, dr::distributed_iterator DI>
auto operator()(DI first, DI last, const T &value) const {
auto pred = [=](auto &&v) { return v == value; };
return __detail::count_if(0, false, rng::subrange(first, last), pred);
}
};

inline constexpr count_fn_ count;

class count_if_fn_ {
public:
template <dr::distributed_range DR>
auto operator()(std::size_t root, DR &&dr, auto &&pred) const {
return __detail::count_if(root, true, dr, pred);
}

template <dr::distributed_range DR>
auto operator()(DR &&dr, auto &&pred) const {
return __detail::count_if(0, false, dr, pred);
}

template <dr::distributed_iterator DI>
auto operator()(std::size_t root, DI first, DI last, auto &&pred) const {
return __detail::count_if(root, true, rng::subrange(first, last), pred);
}

template <dr::distributed_iterator DI>
auto operator()(DI first, DI last, auto &&pred) const {
return __detail::count_if(0, false, rng::subrange(first, last), pred);
}
};

inline constexpr count_if_fn_ count_if;

}; // namespace dr::mp
Loading

0 comments on commit 5800f99

Please sign in to comment.