@@ -227,6 +227,164 @@ TYPED_TEST(RowGatherer, CanApplyAsyncWithMultipleColumns)
227227}
228228
229229
230+ TYPED_TEST (RowGatherer, CanApplyAsyncWithEvent)
231+ {
232+ using Dense = gko::matrix::Dense<double >;
233+ using Vector = gko::experimental::distributed::Vector<double >;
234+ int rank = this ->comm .rank ();
235+ auto offset = static_cast <double >(rank * 3 );
236+ auto b = Vector::create (
237+ this ->exec , this ->comm , gko::dim<2 >{18 , 1 },
238+ gko::initialize<Dense>({offset, offset + 1 , offset + 2 }, this ->exec ));
239+ auto expected = this ->template create_recv_connections <double >()[rank];
240+ auto x = Vector::create (this ->mpi_exec , this ->comm ,
241+ gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
242+ gko::dim<2 >{expected.get_size (), 1 });
243+
244+ auto ev = this ->rg ->apply_prepare (b, x);
245+ auto req = this ->rg ->apply_finalize (b, x, ev);
246+ req.wait ();
247+
248+ auto expected_vec = Vector::create (
249+ this ->mpi_exec , this ->comm , gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
250+ Dense::create (this ->mpi_exec , gko::dim<2 >{expected.get_size (), 1 },
251+ expected, 1 ));
252+ GKO_ASSERT_MTX_NEAR (x->get_local_vector (), expected_vec->get_local_vector (),
253+ 0.0 );
254+ }
255+
256+
257+ TYPED_TEST (RowGatherer, CanApplyAsyncWithEventConsequetively)
258+ {
259+ using Dense = gko::matrix::Dense<double >;
260+ using Vector = gko::experimental::distributed::Vector<double >;
261+ int rank = this ->comm .rank ();
262+ auto offset = static_cast <double >(rank * 3 );
263+ auto b = Vector::create (
264+ this ->exec , this ->comm , gko::dim<2 >{18 , 1 },
265+ gko::initialize<Dense>({offset, offset + 1 , offset + 2 }, this ->exec ));
266+ auto expected = this ->template create_recv_connections <double >()[rank];
267+ auto x = Vector::create (this ->mpi_exec , this ->comm ,
268+ gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
269+ gko::dim<2 >{expected.get_size (), 1 });
270+
271+ this ->rg ->apply_finalize (b, x, this ->rg ->apply_prepare (b, x)).wait ();
272+ this ->rg ->apply_finalize (b, x, this ->rg ->apply_prepare (b, x)).wait ();
273+
274+ auto expected_vec = Vector::create (
275+ this ->mpi_exec , this ->comm , gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
276+ Dense::create (this ->mpi_exec , gko::dim<2 >{expected.get_size (), 1 },
277+ expected, 1 ));
278+ GKO_ASSERT_MTX_NEAR (x->get_local_vector (), expected_vec->get_local_vector (),
279+ 0.0 );
280+ }
281+
282+
283+ TYPED_TEST (RowGatherer, CanApplyAsyncWithEventAndWorkspace)
284+ {
285+ using Dense = gko::matrix::Dense<double >;
286+ using Vector = gko::experimental::distributed::Vector<double >;
287+ int rank = this ->comm .rank ();
288+ auto offset = static_cast <double >(rank * 3 );
289+ auto b = Vector::create (
290+ this ->exec , this ->comm , gko::dim<2 >{18 , 1 },
291+ gko::initialize<Dense>({offset, offset + 1 , offset + 2 }, this ->exec ));
292+ auto expected = this ->template create_recv_connections <double >()[rank];
293+ auto x = Vector::create (this ->mpi_exec , this ->comm ,
294+ gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
295+ gko::dim<2 >{expected.get_size (), 1 });
296+ gko::array<char > workspace;
297+
298+ auto ev = this ->rg ->apply_prepare (b, x, workspace);
299+ auto req = this ->rg ->apply_finalize (b, x, ev, workspace);
300+ req.wait ();
301+
302+ auto expected_vec = Vector::create (
303+ this ->mpi_exec , this ->comm , gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
304+ Dense::create (this ->mpi_exec , gko::dim<2 >{expected.get_size (), 1 },
305+ expected, 1 ));
306+ GKO_ASSERT_MTX_NEAR (x->get_local_vector (), expected_vec->get_local_vector (),
307+ 0.0 );
308+ ASSERT_GT (workspace.get_size (), 0 );
309+ }
310+
311+
312+ TYPED_TEST (RowGatherer, CanApplyAsyncMultipleTimesWithEventAndWorkspace)
313+ {
314+ using Dense = gko::matrix::Dense<double >;
315+ using Vector = gko::experimental::distributed::Vector<double >;
316+ int rank = this ->comm .rank ();
317+ auto offset = static_cast <double >(rank * 3 );
318+ auto b1 = Vector::create (
319+ this ->exec , this ->comm , gko::dim<2 >{18 , 1 },
320+ gko::initialize<Dense>({offset, offset + 1 , offset + 2 }, this ->exec ));
321+ auto b2 = gko::clone (b1);
322+ b2->scale (gko::initialize<Dense>({-1 }, this ->exec ));
323+ auto expected = this ->template create_recv_connections <double >()[rank];
324+ auto x1 = Vector::create (this ->mpi_exec , this ->comm ,
325+ gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
326+ gko::dim<2 >{expected.get_size (), 1 });
327+ auto x2 = gko::clone (x1);
328+ gko::array<char > workspace1;
329+ gko::array<char > workspace2;
330+
331+ auto ev1 = this ->rg ->apply_prepare (b1, x1, workspace1);
332+ auto ev2 = this ->rg ->apply_prepare (b2, x2, workspace2);
333+ auto req1 = this ->rg ->apply_finalize (b1, x1, ev1, workspace1);
334+ auto req2 = this ->rg ->apply_finalize (b2, x2, ev2, workspace2);
335+ req1.wait ();
336+ req2.wait ();
337+
338+ auto expected_vec1 = Vector::create (
339+ this ->mpi_exec , this ->comm , gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
340+ Dense::create (this ->mpi_exec , gko::dim<2 >{expected.get_size (), 1 },
341+ expected, 1 ));
342+ auto expected_vec2 = gko::clone (expected_vec1);
343+ expected_vec2->scale (gko::initialize<Dense>({-1 }, this ->exec ));
344+ GKO_ASSERT_MTX_NEAR (x1->get_local_vector (),
345+ expected_vec1->get_local_vector (), 0.0 );
346+ GKO_ASSERT_MTX_NEAR (x2->get_local_vector (),
347+ expected_vec2->get_local_vector (), 0.0 );
348+ }
349+
350+
351+ TYPED_TEST (
352+ RowGatherer,
353+ CanApplyAsyncWithEventAndWorkspaceEnsuringPrepareAndFinalizeSeparately)
354+ {
355+ using Dense = gko::matrix::Dense<double >;
356+ using Vector = gko::experimental::distributed::Vector<double >;
357+ int rank = this ->comm .rank ();
358+ auto offset = static_cast <double >(rank * 3 );
359+ auto b = Vector::create (
360+ this ->exec , this ->comm , gko::dim<2 >{18 , 1 },
361+ gko::initialize<Dense>({offset, offset + 1 , offset + 2 }, this ->exec ));
362+ auto expected = this ->template create_recv_connections <double >()[rank];
363+ auto modified_expected =
364+ gko::array<double >(expected.get_executor (), expected.get_size ());
365+ modified_expected.fill (0.0 );
366+ auto x = Vector::create (this ->mpi_exec , this ->comm ,
367+ gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
368+ gko::dim<2 >{expected.get_size (), 1 });
369+ gko::array<char > workspace;
370+
371+ auto ev = this ->rg ->apply_prepare (b, x, workspace);
372+ // we modify the workspace to all 0
373+ workspace.fill (static_cast <char >(0 ));
374+ this ->exec ->synchronize ();
375+ auto req = this ->rg ->apply_finalize (b, x, ev, workspace);
376+ req.wait ();
377+
378+ auto expected_vec = Vector::create (
379+ this ->mpi_exec , this ->comm , gko::dim<2 >{this ->rg ->get_size ()[0 ], 1 },
380+ Dense::create (this ->mpi_exec ,
381+ gko::dim<2 >{modified_expected.get_size (), 1 },
382+ modified_expected, 1 ));
383+ GKO_ASSERT_MTX_NEAR (x->get_local_vector (), expected_vec->get_local_vector (),
384+ 0.0 );
385+ }
386+
387+
230388TYPED_TEST (RowGatherer, ThrowsOnNonMatchingExecutor)
231389{
232390 if (this ->mpi_exec == this ->exec ) {
0 commit comments