kokkos-execution 0.0.1
Loading...
Searching...
No Matches
dependency.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_DEPENDENCY_HPP
2#define KOKKOS_EXECUTION_IMPL_DEPENDENCY_HPP
3
4#include "Kokkos_Macros.hpp"
5#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6import kokkos.core;
7#else
8# include "Kokkos_Core.hpp"
9#endif
10
13
15
16template <Kokkos::ExecutionSpace Exec>
17struct HasExecWaitEvent : std::false_type { };
18
20template <typename Exec>
22
35template <Kokkos::ExecutionSpace ExecTo, Kokkos::ExecutionSpace ExecFrom>
36struct Dependency {
37 Dependency(const ExecTo&, const ExecFrom& exec_from) {
38 exec_from.fence(std::string(KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(ExecFrom, ": dependency")));
39 }
40};
41
42template <Kokkos::ExecutionSpace Exec>
43requires(!has_exec_wait_event<Exec>)
45 Dependency(const Exec& exec_to, const Exec& exec_from) {
46 if (exec_from != exec_to) {
47 exec_from.fence(std::string(KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(Exec, ": dependency")));
48 }
49 }
50};
51
52template <Kokkos::ExecutionSpace Exec>
53requires has_exec_wait_event<Exec>
54struct [[nodiscard]]
55Dependency<Exec, Exec> {
56 Event<Exec> event{};
57
59 Dependency(const Exec& exec_to, const Exec& exec_from) {
60 if (exec_from != exec_to) {
61 record(event, exec_from);
62 wait(exec_to, event);
63 }
64 }
65};
66
67} // namespace Kokkos::Execution::Impl
68
69#if defined(KOKKOS_ENABLE_CUDA)
71#endif
72#if defined(KOKKOS_ENABLE_HIP)
74#endif
75#if defined(KOKKOS_ENABLE_HPX)
77#endif
78#if defined(KOKKOS_ENABLE_SYCL)
80#endif
81
82#endif // KOKKOS_EXECUTION_IMPL_DEPENDENCY_HPP
Constrain an EventType type to be a valid event type for Exec execution space type.
Definition event.hpp:31
Determine if the Kokkos backend can enqueue a wait for an event into an execution space instance.
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
void record(Event< Exec > &event, const Exec &exec)
Record event on exec.
Definition event.hpp:145
void wait(const Event< Exec > &... events)
Wait for events to complete.
Definition event.hpp:157
Dependency(const Exec &exec_to, const Exec &exec_from)
Dependency(const ExecTo &, const ExecFrom &exec_from)
An event that can be recorded on an execution space instance.
Definition event.hpp:115