45
45
#include " vt/collective/reduce/operators/functors/plus_op.h"
46
46
#include " vt/configs/error/config_assert.h"
47
47
#include " vt/context/context.h"
48
- #include < unordered_map >
48
+ #include " vt/scheduler/scheduler.h "
49
49
#include < vt/collective/collective_ops.h>
50
50
#include < vt/objgroup/manager.h>
51
51
#include < vt/messaging/active.h>
52
52
#include < vt/collective/reduce/allreduce/rabenseifner.h>
53
53
#include < vt/collective/reduce/allreduce/recursive_doubling.h>
54
54
55
- #include < fmt-vt/core.h>
56
-
57
55
using namespace vt ;
58
56
using namespace vt ::tests::perf::common;
59
57
60
- static constexpr int num_iters = 1 ;
61
58
struct MyTest : PerfTestHarness {
62
59
void SetUp () override {
63
60
PerfTestHarness::SetUp ();
64
- data.resize (1 << 16 );
61
+ data.resize (1 << 2 );
65
62
for (auto & val : data) {
66
63
val = theContext ()->getNode () + 1 ;
67
64
}
@@ -71,7 +68,7 @@ struct MyTest : PerfTestHarness {
71
68
};
72
69
73
70
struct NodeObj {
74
- explicit NodeObj (MyTest* test_obj) : test_obj_(test_obj) { }
71
+ explicit NodeObj (MyTest* test_obj, const std::string& name ) : test_obj_(test_obj), timer_name_(name ) { }
75
72
76
73
void initialize () {
77
74
proxy_ = vt::theObjGroup ()->getProxy <NodeObj>(this );
@@ -102,6 +99,7 @@ struct NodeObj {
102
99
// for (auto val : in) {
103
100
// vtAssert(val == expected, "FAILURE!");
104
101
// }
102
+ test_obj_->StopTimer (timer_name_);
105
103
}
106
104
107
105
void newReduceComplete (std::vector<int32_t > in) {
@@ -127,6 +125,7 @@ struct NodeObj {
127
125
// for (auto val : in) {
128
126
// vtAssert(val == expected, "FAILURE!");
129
127
// }
128
+ test_obj_->StopTimer (timer_name_);
130
129
}
131
130
132
131
void reduceComplete (std::vector<int32_t > in) {
@@ -137,25 +136,26 @@ struct NodeObj {
137
136
// }
138
137
139
138
// fmt::print("\n");
139
+ test_obj_->StopTimer (timer_name_);
140
140
}
141
141
142
- private:
142
+ std::string timer_name_ = {};
143
143
MyTest* test_obj_ = nullptr ;
144
144
vt::objgroup::proxy::Proxy<NodeObj> proxy_ = {};
145
145
};
146
146
147
147
VT_PERF_TEST (MyTest, test_reduce) {
148
148
auto grp_proxy =
149
- vt::theObjGroup ()->makeCollective <NodeObj>(" test_allreduce" , this );
149
+ vt::theObjGroup ()->makeCollective <NodeObj>(" test_allreduce" , this , " Reduce -> Bcast " );
150
150
151
- vt::runInEpochCollective ([=] {
152
- grp_proxy. allreduce <&NodeObj::reduceComplete, collective::PlusOp>(data );
153
- } );
151
+ theCollective ()-> barrier ();
152
+ StartTimer ( grp_proxy[ theContext ()-> getNode ()]. get ()-> timer_name_ );
153
+ grp_proxy. allreduce <&NodeObj::reduceComplete, collective::PlusOp>(data );
154
154
}
155
155
156
156
VT_PERF_TEST (MyTest, test_allreduce_rabenseifner) {
157
157
auto proxy =
158
- vt::theObjGroup ()->makeCollective <NodeObj>(" test_allreduce_new" , this );
158
+ vt::theObjGroup ()->makeCollective <NodeObj>(" test_allreduce_new" , this , " Rabenseifner " );
159
159
160
160
using DataT = decltype (data);
161
161
using Reducer = collective::reduce::allreduce::Rabenseifner<
@@ -164,13 +164,15 @@ VT_PERF_TEST(MyTest, test_allreduce_rabenseifner) {
164
164
auto grp_proxy = vt::theObjGroup ()->makeCollective <Reducer>(
165
165
" allreduce_rabenseifner" , proxy, num_nodes_, data);
166
166
grp_proxy[my_node_].get ()->proxy_ = grp_proxy;
167
- vt::runInEpochCollective (
168
- [=] { grp_proxy[my_node_].template invoke <&Reducer::allreduce>(); });
167
+
168
+ theCollective ()->barrier ();
169
+ StartTimer (proxy[theContext ()->getNode ()].get ()->timer_name_ );
170
+ grp_proxy[my_node_].template invoke <&Reducer::allreduce>();
169
171
}
170
172
171
173
VT_PERF_TEST (MyTest, test_allreduce_recursive_doubling) {
172
174
auto proxy =
173
- vt::theObjGroup ()->makeCollective <NodeObj>(" test_allreduce_new_2" , this );
175
+ vt::theObjGroup ()->makeCollective <NodeObj>(" test_allreduce_new_2" , this , " Recursive doubling " );
174
176
175
177
using DataT = decltype (data);
176
178
using Reducer = collective::reduce::allreduce::DistanceDoubling<
@@ -179,8 +181,10 @@ VT_PERF_TEST(MyTest, test_allreduce_recursive_doubling) {
179
181
auto grp_proxy = vt::theObjGroup ()->makeCollective <Reducer>(
180
182
" allreduce_recursive_doubling" , proxy, num_nodes_, data);
181
183
grp_proxy[my_node_].get ()->proxy_ = grp_proxy;
182
- vt::runInEpochCollective (
183
- [=] { grp_proxy[my_node_].template invoke <&Reducer::allreduce>(); });
184
+
185
+ theCollective ()->barrier ();
186
+ StartTimer (proxy[theContext ()->getNode ()].get ()->timer_name_ );
187
+ grp_proxy[my_node_].template invoke <&Reducer::allreduce>();
184
188
}
185
189
186
190
VT_PERF_TEST_MAIN ()
0 commit comments