harmonize-python 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- harmonize/__init__.py +65 -0
- harmonize/__main__.py +39 -0
- harmonize/adapt.py +105 -0
- harmonize/array.py +588 -0
- harmonize/atomics.py +206 -0
- harmonize/codegen.py +409 -0
- harmonize/config.py +220 -0
- harmonize/cpp/async/future.h +64 -0
- harmonize/cpp/async/mod.h +9 -0
- harmonize/cpp/async/promise.h +747 -0
- harmonize/cpp/harmonize.h +4 -0
- harmonize/cpp/mem/mod.h +14 -0
- harmonize/cpp/mem/work.h +168 -0
- harmonize/cpp/preamble/adapt.h +162 -0
- harmonize/cpp/preamble/mod.h +133 -0
- harmonize/cpp/program/async.h +2923 -0
- harmonize/cpp/program/event.h +560 -0
- harmonize/cpp/program/mod.h +84 -0
- harmonize/cpp/sync/barrier.h +704 -0
- harmonize/cpp/sync/mod.h +9 -0
- harmonize/cpp/util/cli.h +510 -0
- harmonize/cpp/util/host.h +287 -0
- harmonize/cpp/util/iter.h +565 -0
- harmonize/cpp/util/mem.h +1050 -0
- harmonize/cpp/util/mod.h +148 -0
- harmonize/diagnostics.py +487 -0
- harmonize/errors.py +12 -0
- harmonize/logging.py +51 -0
- harmonize/pointer.py +108 -0
- harmonize/prim.py +59 -0
- harmonize/printing.py +104 -0
- harmonize/python/__init__.py +48 -0
- harmonize/runtime.py +1501 -0
- harmonize/templates.py +369 -0
- harmonize/timing.py +10 -0
- harmonize/types.py +16 -0
- harmonize_python-0.1.0.dist-info/METADATA +161 -0
- harmonize_python-0.1.0.dist-info/RECORD +40 -0
- harmonize_python-0.1.0.dist-info/WHEEL +4 -0
- harmonize_python-0.1.0.dist-info/licenses/LICENSE +29 -0
harmonize/cpp/mem/mod.h
ADDED
harmonize/cpp/mem/work.h
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#ifndef HARMONIZE_MEM_WORK
|
|
5
|
+
#define HARMONIZE_MEM_WORK
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
#include "../async/mod.h"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
//!
|
|
14
|
+
//! The `WorkLink` template struct, given a `PromiseUnion` union, an address type, and a group
|
|
15
|
+
//! size, stores an array of `GROUP_SIZE` promise unions of the corresponding type and an
|
|
16
|
+
//! address value of type `ADR_TYPE`. Instances of this template also contain a `Op` value to
|
|
17
|
+
//! identify what type of work is contained within the link, a `meta_data` field, and a `count`
|
|
18
|
+
//! field to indicate the number of contained promises.
|
|
19
|
+
//!
|
|
20
|
+
template <typename OP_SET, typename ADR_TYPE, size_t GROUP_SIZE>
|
|
21
|
+
struct WorkLink
|
|
22
|
+
{
|
|
23
|
+
|
|
24
|
+
using OpSet = OP_SET;
|
|
25
|
+
using AdrType = ADR_TYPE;
|
|
26
|
+
using UnionType = PromiseUnion<OpSet>;
|
|
27
|
+
|
|
28
|
+
UnionType promises[GROUP_SIZE];
|
|
29
|
+
|
|
30
|
+
AdrType next;
|
|
31
|
+
unsigned int meta_data;
|
|
32
|
+
unsigned int count;
|
|
33
|
+
OpDisc id;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
//! Zeros out a link, giving it a promise count of zero, a null function ID, and sets next
|
|
37
|
+
//! to the given input.
|
|
38
|
+
__host__ __device__ void empty(AdrType next_adr){
|
|
39
|
+
|
|
40
|
+
next = next_adr;
|
|
41
|
+
id = UnionType::Info::COUNT;
|
|
42
|
+
count = 0;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
template<typename OP_TYPE>
|
|
49
|
+
__device__ static constexpr Promise<OP_TYPE> promise_guard(Promise<OP_TYPE> promise) {
|
|
50
|
+
static_assert(
|
|
51
|
+
UnionType::template Lookup<OP_TYPE,OpSet>::type::CONTAINED,
|
|
52
|
+
"\n\nTYPE ERROR: Type of promise cannot be contained in atomic work link.\n\n"
|
|
53
|
+
"SUGGESTION: Double-check the signature of the atomic work link to make sure "
|
|
54
|
+
"its OpUnion template parameter contains the desired operation type.\n\n"
|
|
55
|
+
"SUGGESTION: Double-check the type signature of the promise and make sure "
|
|
56
|
+
"it is the correct operation type.\n\n"
|
|
57
|
+
);
|
|
58
|
+
return promise;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//! Appends to the `WorkLink` by an atomic addition to the count field. This is only
|
|
62
|
+
//! safe if it is already known that the `WorkLink` will have enough space to begin
|
|
63
|
+
//! with.
|
|
64
|
+
template<typename OP_TYPE>
|
|
65
|
+
__device__ bool atomic_append(Promise<OP_TYPE> promise) {
|
|
66
|
+
unsigned int index = atomicAdd(&count,1);
|
|
67
|
+
promises[index] = promise_guard(promise);
|
|
68
|
+
return (index == GROUP_SIZE);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
//!
|
|
77
|
+
//! The `WorkArena` template struct accepts an address type and a `WorkLink` struct type and
|
|
78
|
+
//! represents a buffer of work links of the given class indexable by the given address type.
|
|
79
|
+
//!
|
|
80
|
+
template <typename ADR_TYPE, typename LINK_TYPE>
|
|
81
|
+
struct WorkArena
|
|
82
|
+
{
|
|
83
|
+
|
|
84
|
+
typedef LINK_TYPE LinkType;
|
|
85
|
+
typedef ADR_TYPE LinkAdrType;
|
|
86
|
+
|
|
87
|
+
static const size_t max_size = ADR_TYPE::null;
|
|
88
|
+
size_t size;
|
|
89
|
+
LinkType *links;
|
|
90
|
+
|
|
91
|
+
__host__ __device__ LinkType& operator[](LinkAdrType adr){
|
|
92
|
+
return links[adr.adr];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
//!
|
|
101
|
+
//! The `WorkPool` template struct accepts a queue type and a `size_t` count and represents an
|
|
102
|
+
//! array of `QUEUE_COUNT` queues.
|
|
103
|
+
//!
|
|
104
|
+
template <typename QUEUE_TYPE, size_t QUEUE_COUNT>
|
|
105
|
+
struct WorkPool
|
|
106
|
+
{
|
|
107
|
+
|
|
108
|
+
static const size_t size = QUEUE_COUNT;
|
|
109
|
+
QUEUE_TYPE queues[QUEUE_COUNT];
|
|
110
|
+
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
typedef unsigned int PromiseCount;
|
|
115
|
+
typedef typename util::mem::PairEquivalent<PromiseCount>::Type PromiseCountPair;
|
|
116
|
+
//typedef unsigned long long int PromiseCountPair;
|
|
117
|
+
|
|
118
|
+
//! The `WorkFrame` template struct accepts a queue type and and a `size_t`, which is used to
|
|
119
|
+
//! define its iternal work pool. A `WorkFrame` represents a pool that tracks the current number
|
|
120
|
+
//! of contained promises as well as the number of "child" promises that could eventually return
|
|
121
|
+
//! to the frame.
|
|
122
|
+
template <typename QUEUE_TYPE, size_t QUEUE_COUNT>
|
|
123
|
+
struct WorkFrame
|
|
124
|
+
{
|
|
125
|
+
|
|
126
|
+
util::mem::PairPack<PromiseCount> children_residents;
|
|
127
|
+
WorkPool<QUEUE_TYPE, QUEUE_COUNT> pool;
|
|
128
|
+
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
//! The `WorkStack` template struct represents a series of `WorkFrames` following a heirarchy
|
|
134
|
+
//! of call depths. Currently, only a `STACK_SIZE` of zero is supported.
|
|
135
|
+
template<typename FRAME_TYPE, size_t STACK_SIZE = 0>
|
|
136
|
+
struct WorkStack {
|
|
137
|
+
static const bool FLAT = false;
|
|
138
|
+
|
|
139
|
+
static const size_t PART_MULT = 3;
|
|
140
|
+
|
|
141
|
+
static const size_t NULL_LEVEL = STACK_SIZE;
|
|
142
|
+
static const size_t MAX_LEVEL = STACK_SIZE-1;
|
|
143
|
+
|
|
144
|
+
unsigned int checkout;
|
|
145
|
+
unsigned int status_flags;
|
|
146
|
+
unsigned int depth_live;
|
|
147
|
+
FRAME_TYPE frames[STACK_SIZE];
|
|
148
|
+
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
template<typename FRAME_TYPE>
|
|
152
|
+
struct WorkStack<FRAME_TYPE, 0>
|
|
153
|
+
{
|
|
154
|
+
static const bool FLAT = true;
|
|
155
|
+
|
|
156
|
+
static const size_t PART_MULT = 1;
|
|
157
|
+
static const size_t NULL_LEVEL = 1;
|
|
158
|
+
|
|
159
|
+
unsigned int checkout;
|
|
160
|
+
unsigned int status_flags;
|
|
161
|
+
unsigned int depth_live;
|
|
162
|
+
FRAME_TYPE frames[1];
|
|
163
|
+
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
|
|
2
|
+
#ifndef HARMONIZE_ADAPT
|
|
3
|
+
#define HARMONIZE_ADAPT
|
|
4
|
+
|
|
5
|
+
#define __HIP_PLATFORM_AMD__
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
#ifdef HARMONIZE_EXTERN_ATOMICS
|
|
9
|
+
#define HARMONIZE_MAYBE_EXTERN extern "C"
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#ifndef HARMONIZE_EXTERN_ATOMICS
|
|
13
|
+
#define HARMONIZE_MAYBE_EXTERN
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#if defined(__NVCC__) || defined(__HIP_PLATFORM_NVIDIA__) || defined(__CUDACC__)
|
|
18
|
+
|
|
19
|
+
#define HARMONIZE_PLATFORM_CUDA
|
|
20
|
+
|
|
21
|
+
namespace adapt {
|
|
22
|
+
|
|
23
|
+
size_t const WARP_SIZE = 32;
|
|
24
|
+
|
|
25
|
+
#define CUDA_TYPE_ALIAS(thing) using GPUrt ## thing = cuda ## thing;
|
|
26
|
+
CUDA_TYPE_ALIAS( Error_t );
|
|
27
|
+
CUDA_TYPE_ALIAS( Event_t );
|
|
28
|
+
CUDA_TYPE_ALIAS( Stream_t );
|
|
29
|
+
#undef CUDA_TYPE_ALIAS
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
#define CUDA_CONST_ALIAS(thing) auto const GPUrt ## thing = cuda ## thing;
|
|
33
|
+
CUDA_CONST_ALIAS( Success );
|
|
34
|
+
CUDA_CONST_ALIAS( MemcpyDeviceToDevice );
|
|
35
|
+
CUDA_CONST_ALIAS( MemcpyDeviceToHost );
|
|
36
|
+
CUDA_CONST_ALIAS( MemcpyHostToDevice );
|
|
37
|
+
CUDA_CONST_ALIAS( MemcpyDefault );
|
|
38
|
+
#undef CUDA_CONST_ALIAS
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
#define CUDA_FN_ALIAS(thing) \
|
|
42
|
+
template<typename... ARGS> \
|
|
43
|
+
auto GPUrt ## thing (ARGS... args) \
|
|
44
|
+
-> decltype(cuda ## thing (std::declval<ARGS>()...)) \
|
|
45
|
+
{ \
|
|
46
|
+
return cuda ## thing(args...); \
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
CUDA_FN_ALIAS( Malloc );
|
|
50
|
+
CUDA_FN_ALIAS( MallocManaged );
|
|
51
|
+
CUDA_FN_ALIAS( DeviceSynchronize );
|
|
52
|
+
CUDA_FN_ALIAS( GetErrorString );
|
|
53
|
+
CUDA_FN_ALIAS( EventCreate );
|
|
54
|
+
CUDA_FN_ALIAS( EventRecord );
|
|
55
|
+
CUDA_FN_ALIAS( EventSynchronize );
|
|
56
|
+
CUDA_FN_ALIAS( EventElapsedTime );
|
|
57
|
+
CUDA_FN_ALIAS( GetLastError );
|
|
58
|
+
CUDA_FN_ALIAS( Memcpy );
|
|
59
|
+
CUDA_FN_ALIAS( Memset );
|
|
60
|
+
CUDA_FN_ALIAS( SetDevice );
|
|
61
|
+
CUDA_FN_ALIAS( Free );
|
|
62
|
+
|
|
63
|
+
#undef CUDA_FN_ALIAS
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
#define FN_ALIAS(renamed,original) \
|
|
67
|
+
template<typename... ARGS> \
|
|
68
|
+
auto renamed (ARGS... args) \
|
|
69
|
+
-> decltype(original (std::declval<ARGS>()...)) \
|
|
70
|
+
{ \
|
|
71
|
+
return original(args...); \
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#if __CUDA_ARCH__ < 600
|
|
75
|
+
FN_ALIAS(atomicExch_block,atomicExch)
|
|
76
|
+
FN_ALIAS(atomicCAS_block,atomicCAS)
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
#undef FN_ALIAS
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
#elif defined(__HIP_PLATFORM_AMD__)
|
|
85
|
+
|
|
86
|
+
#include <hip/hip_runtime.h>
|
|
87
|
+
|
|
88
|
+
#define HARMONIZE_PLATFORM_ROCM
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
namespace adapt {
|
|
92
|
+
|
|
93
|
+
#define __syncwarp(mask) ;
|
|
94
|
+
#define __activemask() 0x3F
|
|
95
|
+
#define __any_sync(x,y) 0x1
|
|
96
|
+
|
|
97
|
+
size_t const WARP_SIZE = 64;
|
|
98
|
+
|
|
99
|
+
#define HIP_TYPE_ALIAS(thing) using GPUrt ## thing = hip ## thing;
|
|
100
|
+
HIP_TYPE_ALIAS( Error_t );
|
|
101
|
+
HIP_TYPE_ALIAS( Event_t );
|
|
102
|
+
HIP_TYPE_ALIAS( Stream_t );
|
|
103
|
+
#undef HIP_TYPE_ALIAS
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
#define HIP_CONST_ALIAS(thing) auto const GPUrt ## thing = hip ## thing;
|
|
107
|
+
HIP_CONST_ALIAS( Success );
|
|
108
|
+
HIP_CONST_ALIAS( MemcpyDeviceToDevice );
|
|
109
|
+
HIP_CONST_ALIAS( MemcpyDeviceToHost );
|
|
110
|
+
HIP_CONST_ALIAS( MemcpyHostToDevice );
|
|
111
|
+
HIP_CONST_ALIAS( MemcpyDefault );
|
|
112
|
+
#undef HIP_CONST_ALIAS
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
#define HIP_FN_ALIAS(thing) \
|
|
116
|
+
template<typename... ARGS> \
|
|
117
|
+
auto GPUrt ## thing (ARGS... args) \
|
|
118
|
+
-> decltype(hip ## thing (std::declval<ARGS>()...)) \
|
|
119
|
+
{ \
|
|
120
|
+
return hip ## thing(args...); \
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
HIP_FN_ALIAS( Malloc );
|
|
124
|
+
HIP_FN_ALIAS( MallocManaged );
|
|
125
|
+
HIP_FN_ALIAS( DeviceSynchronize );
|
|
126
|
+
HIP_FN_ALIAS( GetErrorString );
|
|
127
|
+
HIP_FN_ALIAS( EventCreate );
|
|
128
|
+
HIP_FN_ALIAS( EventRecord );
|
|
129
|
+
HIP_FN_ALIAS( EventSynchronize );
|
|
130
|
+
HIP_FN_ALIAS( EventElapsedTime );
|
|
131
|
+
HIP_FN_ALIAS( GetLastError );
|
|
132
|
+
HIP_FN_ALIAS( Memcpy );
|
|
133
|
+
HIP_FN_ALIAS( Memset );
|
|
134
|
+
HIP_FN_ALIAS( SetDevice );
|
|
135
|
+
HIP_FN_ALIAS( Free );
|
|
136
|
+
|
|
137
|
+
#undef HIP_FN_ALIAS
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
//! On AMD, unmasked atomics to the group state (though weirdly not the group context)
|
|
143
|
+
//! will cause all atomics to be unmasked.
|
|
144
|
+
//!
|
|
145
|
+
//! This is obviously very, very bad, and either a compiler bug or a monumentally awful
|
|
146
|
+
//! result of some yet-to-be-discovered invocation of undefined behavior.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#else
|
|
153
|
+
|
|
154
|
+
#error "Platform not recognized. Valid platforms include CUDA and HIP."
|
|
155
|
+
|
|
156
|
+
#endif
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
#undef HARMONIZE_MAYBE_EXTERN
|
|
160
|
+
|
|
161
|
+
#endif
|
|
162
|
+
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
#ifndef HARMONIZE_PREAMBLE
|
|
4
|
+
#define HARMONIZE_PREAMBLE
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#include "math.h"
|
|
8
|
+
#include <vector>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <cstdio>
|
|
11
|
+
#include <type_traits>
|
|
12
|
+
#include <limits>
|
|
13
|
+
#include <memory>
|
|
14
|
+
#include <stdexcept>
|
|
15
|
+
#include <thread>
|
|
16
|
+
#include <chrono>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#define HARMONIZE
|
|
22
|
+
|
|
23
|
+
//#define DEBUG_PRINT
|
|
24
|
+
//#define RACE_COND_PRINT
|
|
25
|
+
//#define QUEUE_PRINT
|
|
26
|
+
|
|
27
|
+
#define INF_LOOP_SAFE
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
#define NOOP(x) ;
|
|
33
|
+
|
|
34
|
+
#ifdef QUEUE_PRINT
|
|
35
|
+
#define q_printf printf
|
|
36
|
+
#else
|
|
37
|
+
#define q_printf(fmt, ...) NOOP(...);
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
#ifdef RACE_COND_PRINT
|
|
42
|
+
#define rc_printf printf
|
|
43
|
+
#else
|
|
44
|
+
#define rc_printf(fmt, ...) ;
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
#ifdef DEBUG_PRINT
|
|
49
|
+
#define db_printf printf
|
|
50
|
+
#else
|
|
51
|
+
#define db_printf(fmt, ...) ;
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
#include "adapt.h"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
//#define HRM_TIME 16
|
|
60
|
+
|
|
61
|
+
#ifdef HRM_TIME
|
|
62
|
+
#define beg_time(idx) if(util::current_leader()) { _grp_ctx.time_totals[idx] -= clock64(); }
|
|
63
|
+
#define end_time(idx) if(util::current_leader()) { _grp_ctx.time_totals[idx] += clock64(); }
|
|
64
|
+
#else
|
|
65
|
+
#define beg_time(idx) ;
|
|
66
|
+
#define end_time(idx) ;
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
//#define ASYNC_LOADS
|
|
74
|
+
|
|
75
|
+
#ifdef ASYNC_LOADS
|
|
76
|
+
#include <cuda/barrier>
|
|
77
|
+
#define BARRIER_SPILL
|
|
78
|
+
#endif
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
//! A set of templates used to detect the presence of internal types
|
|
83
|
+
//! and constants.
|
|
84
|
+
namespace detector {
|
|
85
|
+
|
|
86
|
+
template <class... TYPES>
|
|
87
|
+
using void_t = void;
|
|
88
|
+
|
|
89
|
+
template <size_t VALUE>
|
|
90
|
+
using void_size = void;
|
|
91
|
+
|
|
92
|
+
template <template <class...> class LOOKUP, class GUARD, class... ARGS>
|
|
93
|
+
struct is_detected
|
|
94
|
+
{ const static bool value = false; };
|
|
95
|
+
|
|
96
|
+
template <template <class...> class LOOKUP, class... ARGS>
|
|
97
|
+
struct is_detected<LOOKUP, void_t<LOOKUP<ARGS...>>, ARGS...>
|
|
98
|
+
{ const static bool value = true; };
|
|
99
|
+
|
|
100
|
+
template<bool COND, class TRUE_TYPE = void, class FALSE_TYPE = void>
|
|
101
|
+
struct type_switch;
|
|
102
|
+
|
|
103
|
+
template<class TRUE_TYPE, class FALSE_TYPE>
|
|
104
|
+
struct type_switch<true, TRUE_TYPE,FALSE_TYPE>
|
|
105
|
+
{
|
|
106
|
+
using type = TRUE_TYPE;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
template<class TRUE_TYPE, class FALSE_TYPE>
|
|
110
|
+
struct type_switch<false, TRUE_TYPE, FALSE_TYPE>
|
|
111
|
+
{
|
|
112
|
+
using type = FALSE_TYPE;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//! Returns a type that communicates whether or not a certain templat can be
|
|
119
|
+
//! instantiated with the given set of arguments
|
|
120
|
+
template<template<class...> class LOOKUP, class... ARGS>
|
|
121
|
+
using is_detected = typename detector::is_detected<LOOKUP,void,ARGS...>;
|
|
122
|
+
|
|
123
|
+
//! Switches an internal type between the first and last type argument based upon whether or not
|
|
124
|
+
//! the second, template parameter can be instantiated with the last type argument.
|
|
125
|
+
template<class DEFAULT, template<class> class LOOKUP, class TYPE>
|
|
126
|
+
using type_switch = typename detector::type_switch<is_detected<LOOKUP,TYPE>::value ,TYPE,DEFAULT>::type;
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
#include "../util/mod.h"
|
|
131
|
+
|
|
132
|
+
#endif
|
|
133
|
+
|