-
Notifications
You must be signed in to change notification settings - Fork 73
/
tuning1.cxx
51 lines (43 loc) · 1.58 KB
/
tuning1.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <cstdio>
template<auto x, typename type_t>
constexpr bool is_value_in_enum = (... || (type_t.enum_values == (type_t)x));
// Set of device architectures. Will be part of CUDA Toolkit.
enum class sm_selector : unsigned long long {
sm_35 = 35, sm_37 = 37,
sm_50 = 50, sm_52 = 52, sm_53 = 53,
sm_60 = 60, sm_61 = 61, sm_62 = 62,
sm_70 = 70, sm_72 = 72, sm_75 = 75,
sm_80 = 80, sm_86 = 86,
};
// tuning params
using nt [[attribute ]] = int;
using vt [[attribute(1)]] = int;
using occ [[attribute(0)]] = int;
// flags
using strided [[attribute]] = void;
using persistent [[attribute]] = void;
// Tunings for a specific operation.
enum class tuning_t {
kepler [[ .nt=128, .vt=5 ]] = 35,
maxwell [[ .nt=256, .vt=7, .persistent ]] = 52,
pascal [[ .nt=64, .vt=11, .strided ]] = 61,
turing [[ .nt=256, .vt=15, .occ=3 ]] = 75,
ampere [[ .nt=256, .vt=19, .strided ]] = 86,
};
// Test that each tuning corresponds to an actual device architecture.
static_assert(
is_value_in_enum<tuning_t.enum_values, sm_selector>,
tuning_t.enum_names + " (" + ((int)tuning_t.enum_values).string + ") is invalid)"
)...;
int main() {
// Print the tunings using a loop.
printf("With a loop:\n");
@meta for enum(tuning_t tuning : tuning_t) {
printf("%-10s: %3dx%2d\n", tuning.string,
@enum_attribute(tuning, nt), @enum_attribute(tuning, vt));
}
// Print the tunings using pack expansion.
printf("\nWith a pack expansion:\n");
printf("%-10s: %3dx%2d\n", tuning_t.enum_names,
@enum_attributes(tuning_t, nt), @enum_attributes(tuning_t, vt)) ...;
}