Interface Documentation
Version: invalid
flecsi
exec
launch.hh
Go to the documentation of this file.
1
/*
2
@@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3
/@@///// /@@ @@////@@ @@////// /@@
4
/@@ /@@ @@@@@ @@ // /@@ /@@
5
/@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6
/@@//// /@@/@@@@@@@/@@ ////////@@/@@
7
/@@ /@@/@@//// //@@ @@ /@@/@@
8
/@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9
// /// ////// ////// //////// //
10
11
Copyright (c) 2016, Triad National Security, LLC
12
All rights reserved.
13
*/
14
#pragma once
15
18
#if !defined(__FLECSI_PRIVATE__)
19
#error Do not include this file directly
20
#endif
21
22
#include <cstddef>
23
#include <type_traits>
24
#include <utility>
25
26
namespace
flecsi
{
27
namespace
exec {
28
29
namespace
detail {
30
// We care about value category, so we want to use perfect forwarding.
31
// However, such a template is a better match for some arguments than any
32
// single non-template overload, so we use SFINAE to detect that we have
33
// no replacement defined for an argument.
34
template
<
class
=
void
>
35
struct
task_param
{};
36
template
<
class
P,
class
A,
class
=
void
>
// A is a reference type
37
struct
replace_argument
{
38
static
A replace(A a) {
39
return
static_cast<
A
>
(a);
40
}
41
};
42
template
<
class
P,
class
A>
43
struct
replace_argument
<P,
44
A,
45
decltype(void(
task_param
<P>::replace(std::declval<A>())))> {
46
static
decltype(
auto
) replace(A a) {
47
return
task_param<P>::replace
(static_cast<A>(a));
48
}
49
};
50
}
// namespace detail
51
// Replaces certain task arguments before conversion to the parameter type.
52
template
<
class
P,
class
T>
53
decltype(
auto
)
54
replace_argument
(T && t) {
55
return
detail::replace_argument<std::decay_t<P>
, T &&>::replace(
56
std::forward<T>(t));
57
}
58
59
enum class
launch_type_t : size_t { single, index };
60
62
struct
launch_domain
{
63
explicit
constexpr
launch_domain
(std::size_t s = 0) : sz(s) {}
64
void
size(std::size_t s) {
65
sz = s;
66
}
67
constexpr std::size_t size()
const
{
68
return
sz;
69
}
70
constexpr
bool
operator==(
const
launch_domain & o)
const
{
71
return
this
== &o;
72
}
73
constexpr
bool
operator!=(
const
launch_domain & o)
const
{
74
return
!(*
this
== o);
75
}
76
77
private
:
78
std::size_t sz;
79
};
80
81
}
// namespace exec
82
83
inline
constexpr
exec::launch_domain
single(1), index;
84
93
template
<
typename
Return,
94
exec::launch_type_t Launch = exec::launch_type_t::single>
95
struct
future
;
96
97
#ifdef DOXYGEN // implemented per-backend
98
template
<
typename
Return>
99
struct
future
<Return> {
101
void
wait()
const
;
103
Return
get
(
bool
silence_warnings =
false
)
const
;
104
};
105
106
template
<
typename
Return>
107
struct
future
<Return, exec::launch_type_t::index> {
109
void
wait(
bool
silence_warnings =
false
)
const
;
111
Return
get
(std::size_t index = 0,
bool
silence_warnings =
false
)
const
;
112
};
113
#endif
114
115
namespace
exec {
116
template
<
class
R>
117
struct
detail::task_param
<
future
<R>> {
118
static
future<R>
replace(
const
future<R, launch_type_t::index>
&) {
119
return
{};
120
}
121
};
122
123
template
<
class
>
124
inline
constexpr
bool
is_index_future =
false
;
125
template
<
class
R>
126
inline
constexpr
bool
is_index_future<future<R, launch_type_t::index>> =
true
;
127
}
// namespace exec
128
129
}
// namespace flecsi
flecsi::exec::detail::replace_argument
Definition:
launch.hh:37
flecsi::future
Definition:
launch.hh:95
flecsi::future< R >
Definition:
future.hh:23
flecsi::exec::launch_domain
A launch domain with a static identity but a runtime size.
Definition:
launch.hh:62
flecsi::exec::detail::task_param
Definition:
launch.hh:35
flecsi
Definition:
control.hh:31
Generated by
1.8.13