Skip to content
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

Add test phase in CI for stdexec configuration #930

Merged
merged 6 commits into from
Sep 13, 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
10 changes: 10 additions & 0 deletions ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ cpu release test gcc11:
- artifact: pipeline.yml
job: cpu release build gcc11

cpu release test gcc11 stdexec:
extends: .run_common
needs:
- cpu release build gcc11 stdexec
trigger:
include:
- artifact: pipeline.yml
job: cpu release build gcc11 stdexec


cpu release test gcc12 cxx20:
extends: .run_common
needs:
Expand Down
50 changes: 50 additions & 0 deletions include/dlaf/common/consume_rvalues.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Distributed Linear Algebra with Future (DLAF)
//
// Copyright (c) 2018-2023, ETH Zurich
// All rights reserved.
//
// Please, refer to the LICENSE file in the root directory.
// SPDX-License-Identifier: BSD-3-Clause
//
#pragma once

/// @file

#include <tuple>
#include <type_traits>
#include <utility>

namespace dlaf::common::internal {

template <typename T>
T consume_rvalue(T&& x) {
msimberg marked this conversation as resolved.
Show resolved Hide resolved
return std::move(x);
}

template <typename T>
T& consume_rvalue(T& x) {
return x;
}

/// ConsumeRvalues is a callable object wrapper that consumes rvalues passed as arguments
/// after calling the wrapped callable.
template <typename F>
struct ConsumeRvalues {
std::decay_t<F> f;

template <typename... Ts>
auto operator()(Ts&&... ts) && -> decltype(std::move(f)(consume_rvalue(std::forward<Ts>(ts))...)) {
return std::move(f)(consume_rvalue(std::forward<Ts>(ts))...);
}

template <typename... Ts>
auto operator()(Ts&&... ts) & -> decltype(f(consume_rvalue(std::forward<Ts>(ts))...)) {
return f(consume_rvalue(std::forward<Ts>(ts))...);
}
};

template <typename F>
ConsumeRvalues(F&&) -> ConsumeRvalues<std::decay_t<F>>;

}
2 changes: 2 additions & 0 deletions include/dlaf/common/unwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/// @file

#include <functional>
#include <type_traits>
aurianer marked this conversation as resolved.
Show resolved Hide resolved
#include <utility>

#include <pika/async_rw_mutex.hpp>
#include <pika/execution.hpp>
Expand Down
15 changes: 9 additions & 6 deletions include/dlaf/sender/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <pika/execution.hpp>

#include <dlaf/common/consume_rvalues.h>
#include <dlaf/common/unwrap.h>
#include <dlaf/init.h>
#include <dlaf/schedulers.h>
Expand Down Expand Up @@ -43,7 +44,7 @@ enum class TransformDispatchType { Plain, Blas, Lapack };
// allows choosing the priority.
//
// At its core, transform is a convenience wrapper around
// sender | transfer(with_priority(scheduler, priority)) | then(unwrapping(f)).
// sender | transfer(with_priority(scheduler, priority)) | then(ConsumeRvalues(unwrapping(f))).

/// Lazy transform. This does not submit the work and returns a sender.
template <TransformDispatchType Tag = TransformDispatchType::Plain, Backend B = Backend::MC,
Expand All @@ -56,8 +57,11 @@ template <TransformDispatchType Tag = TransformDispatchType::Plain, Backend B =
auto scheduler = getBackendScheduler<B>(policy.priority());
auto transfer_sender = transfer(std::forward<Sender>(sender), std::move(scheduler));

using dlaf::common::internal::ConsumeRvalues;
using dlaf::common::internal::Unwrapping;

if constexpr (B == Backend::MC) {
return then(std::move(transfer_sender), dlaf::common::internal::Unwrapping{std::forward<F>(f)});
return then(std::move(transfer_sender), ConsumeRvalues{Unwrapping{std::forward<F>(f)}});
}
else if constexpr (B == Backend::GPU) {
#if defined(DLAF_WITH_GPU)
Expand All @@ -67,16 +71,15 @@ template <TransformDispatchType Tag = TransformDispatchType::Plain, Backend B =

if constexpr (Tag == TransformDispatchType::Plain) {
return then_with_stream(std::move(transfer_sender),
dlaf::common::internal::Unwrapping{std::forward<F>(f)});
ConsumeRvalues{Unwrapping{std::forward<F>(f)}});
}
else if constexpr (Tag == TransformDispatchType::Blas) {
return then_with_cublas(std::move(transfer_sender),
dlaf::common::internal::Unwrapping{std::forward<F>(f)},
return then_with_cublas(std::move(transfer_sender), ConsumeRvalues{Unwrapping{std::forward<F>(f)}},
CUBLAS_POINTER_MODE_HOST);
}
else if constexpr (Tag == TransformDispatchType::Lapack) {
return then_with_cusolver(std::move(transfer_sender),
dlaf::common::internal::Unwrapping{std::forward<F>(f)});
ConsumeRvalues{Unwrapping{std::forward<F>(f)}});
}
else {
DLAF_STATIC_FAIL(
Expand Down
3 changes: 2 additions & 1 deletion include/dlaf/sender/transform_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <type_traits>

#include <dlaf/common/consume_rvalues.h>
#include <dlaf/common/pipeline.h>
#include <dlaf/common/unwrap.h>
#include <dlaf/communication/communicator.h>
Expand Down Expand Up @@ -88,7 +89,7 @@ template <typename F, typename Sender,
namespace ex = pika::execution::experimental;

return ex::transfer(std::forward<Sender>(sender), dlaf::internal::getMPIScheduler()) |
ex::then(MPICallHelper{std::forward<F>(f)});
ex::then(dlaf::common::internal::ConsumeRvalues{MPICallHelper{std::forward<F>(f)}});
}

/// Fire-and-forget transformMPI. This submits the work and returns void.
Expand Down