@@ -215,13 +215,10 @@ PointSearch<DeviceType>::PointSearch(
215
215
// Perform the distributed search. At the end of the distributed search the
216
216
// points are moved from the "source processors" to the "target processors".
217
217
std::array<Kokkos::View<int *, DeviceType>, DTK_N_TOPO> per_topo_ranks;
218
- Kokkos::View<ArborX::Point *, DeviceType> imported_points (
219
- " imported_points" , 0 );
220
- Kokkos::View<int *, DeviceType> imported_query_ids ( " imported_query_ids" ,
221
- 0 );
222
- Kokkos::View<int *, DeviceType> imported_cell_indices ( " imported_indices" ,
223
- 0 );
224
- Kokkos::View<int *, DeviceType> imported_ranks ( " imported_ranks" , 0 );
218
+ Kokkos::View<ArborX::Point *, DeviceType> imported_points;
219
+ Kokkos::View<int *, DeviceType> imported_query_ids;
220
+ Kokkos::View<int *, DeviceType> imported_cell_indices;
221
+ Kokkos::View<int *, DeviceType> imported_ranks;
225
222
std::tie ( imported_points, imported_cell_indices, imported_query_ids,
226
223
imported_ranks ) =
227
224
performDistributedSearch (
@@ -251,41 +248,19 @@ PointSearch<DeviceType>::PointSearch(
251
248
filtered_per_topo_point_in_cell;
252
249
std::array<Kokkos::View<int *, DeviceType>, DTK_N_TOPO>
253
250
filtered_per_topo_ranks;
254
- for ( unsigned int i = 0 ; i < DTK_N_TOPO; ++i )
255
- {
256
- filtered_per_topo_cell_indices[i] = Kokkos::View<int *, DeviceType>(
257
- " filtered_per_topo_cell_indices_" + std::to_string ( i ),
258
- topo_size_host ( i ) );
259
- filtered_per_topo_query_ids[i] = Kokkos::View<int *, DeviceType>(
260
- " filtered_per_topo_query_ids_" + std::to_string ( i ),
261
- topo_size_host ( i ) );
262
- filtered_per_topo_reference_points[i] =
263
- Kokkos::View<double **, DeviceType>(
264
- " filtered_per_topo_reference_points_" + std::to_string ( i ),
265
- topo_size_host ( i ), _dim );
266
- filtered_per_topo_point_in_cell[i] = Kokkos::View<bool *, DeviceType>(
267
- " filtered_per_topo_point_in_cell_" + std::to_string ( i ),
268
- topo_size_host ( i ) );
269
- filtered_per_topo_ranks[i] = Kokkos::View<int *, DeviceType>(
270
- " filtered_per_topo_ranks_" + std::to_string ( i ),
271
- topo_size_host ( i ) );
272
- }
273
-
274
251
// Check if the points are in the cells
275
252
for ( unsigned int topo_id = 0 ; topo_id < DTK_N_TOPO; ++topo_id )
276
253
if ( block_cells[topo_id].extent ( 0 ) != 0 )
277
254
{
278
- Kokkos::View<double **, DeviceType> filtered_points (
279
- " filtered_points" , topo_size_host ( topo_id ), _dim );
280
- performPointInCell ( block_cells[topo_id], bounding_box_to_cell,
281
- imported_cell_indices, imported_points,
282
- imported_query_ids, imported_ranks, topo,
283
- topo_id, filtered_points,
284
- filtered_per_topo_cell_indices[topo_id],
285
- filtered_per_topo_query_ids[topo_id],
286
- filtered_per_topo_reference_points[topo_id],
287
- filtered_per_topo_point_in_cell[topo_id],
288
- filtered_per_topo_ranks[topo_id] );
255
+ std::tie ( filtered_per_topo_cell_indices[topo_id],
256
+ filtered_per_topo_query_ids[topo_id],
257
+ filtered_per_topo_reference_points[topo_id],
258
+ filtered_per_topo_point_in_cell[topo_id],
259
+ filtered_per_topo_ranks[topo_id] ) =
260
+ performPointInCell ( block_cells[topo_id], bounding_box_to_cell,
261
+ imported_cell_indices, imported_points,
262
+ imported_query_ids, imported_ranks, topo,
263
+ topo_id, topo_size_host ( topo_id ) );
289
264
}
290
265
291
266
// Filter the points. Only keep the points that are in cell
@@ -457,17 +432,16 @@ PointSearch<DeviceType>::performDistributedSearch(
457
432
}
458
433
459
434
template <typename DeviceType>
460
- void PointSearch<DeviceType>::filterTopology(
435
+ std::tuple<Kokkos::View<int *, DeviceType>, Kokkos::View<double **, DeviceType>,
436
+ Kokkos::View<int *, DeviceType>, Kokkos::View<int *, DeviceType>>
437
+ PointSearch<DeviceType>::filterTopology(
461
438
Kokkos::View<unsigned int *, DeviceType> topo, unsigned int topo_id,
439
+ unsigned int size,
462
440
Kokkos::View<unsigned int **, DeviceType> bounding_box_to_cell,
463
441
Kokkos::View<int *, DeviceType> cell_indices,
464
442
Kokkos::View<ArborX::Point *, DeviceType> points,
465
443
Kokkos::View<int *, DeviceType> query_ids,
466
- Kokkos::View<int *, DeviceType> ranks,
467
- Kokkos::View<int *, DeviceType> filtered_cell_indices,
468
- Kokkos::View<double **, DeviceType> filtered_points,
469
- Kokkos::View<int *, DeviceType> filtered_query_ids,
470
- Kokkos::View<int *, DeviceType> filtered_ranks )
444
+ Kokkos::View<int *, DeviceType> ranks )
471
445
{
472
446
DTK_REQUIRE ( topo.extent ( 0 ) == ranks.extent ( 0 ) );
473
447
DTK_REQUIRE ( query_ids.extent ( 0 ) == ranks.extent ( 0 ) );
@@ -481,22 +455,34 @@ void PointSearch<DeviceType>::filterTopology(
481
455
// Create Kokkos::View with the points and the cell indices associated
482
456
// with cells of topo_id topology. Also transform 3D points back to 2D
483
457
// points.
458
+ Kokkos::View<double **, DeviceType> filtered_per_topo_points (
459
+ " filtered_per_topo_points" , size, _dim );
460
+ Kokkos::View<int *, DeviceType> filtered_per_topo_cell_indices (
461
+ " filtered_per_topo_cell_indices_" + std::to_string ( topo_id ), size );
462
+ Kokkos::View<int *, DeviceType> filtered_per_topo_query_ids (
463
+ " filtered_per_topo_query_ids_" + std::to_string ( topo_id ), size );
464
+ Kokkos::View<int *, DeviceType> filtered_per_topo_ranks (
465
+ " filtered_per_topo_ranks_" + std::to_string ( topo_id ), size );
484
466
unsigned int dim = _dim;
485
467
Kokkos::parallel_for (
486
468
" filter_data" , Kokkos::RangePolicy<ExecutionSpace>( 0 , n_imports ),
487
469
KOKKOS_LAMBDA ( int const i ) {
488
470
if ( topo ( i ) == topo_id )
489
471
{
490
472
unsigned int const k = offset ( i );
491
- filtered_cell_indices ( k ) =
473
+ filtered_per_topo_cell_indices ( k ) =
492
474
bounding_box_to_cell ( cell_indices ( i ), topo_id );
493
475
for ( unsigned int j = 0 ; j < dim; ++j )
494
- filtered_points ( k, j ) = points ( i )[j];
495
- filtered_query_ids ( k ) = query_ids ( i );
496
- filtered_ranks ( k ) = ranks ( i );
476
+ filtered_per_topo_points ( k, j ) = points ( i )[j];
477
+ filtered_per_topo_query_ids ( k ) = query_ids ( i );
478
+ filtered_per_topo_ranks ( k ) = ranks ( i );
497
479
}
498
480
} );
499
481
Kokkos::fence ();
482
+
483
+ return std::make_tuple (
484
+ filtered_per_topo_cell_indices, filtered_per_topo_points,
485
+ filtered_per_topo_query_ids, filtered_per_topo_ranks );
500
486
}
501
487
502
488
template <typename DeviceType>
@@ -580,31 +566,46 @@ void PointSearch<DeviceType>::filterInCell(
580
566
}
581
567
582
568
template <typename DeviceType>
583
- void PointSearch<DeviceType>::performPointInCell(
569
+ std::tuple<Kokkos::View<int *, DeviceType>, Kokkos::View<int *, DeviceType>,
570
+ Kokkos::View<double **, DeviceType>,
571
+ Kokkos::View<bool *, DeviceType>, Kokkos::View<int *, DeviceType>>
572
+ PointSearch<DeviceType>::performPointInCell(
584
573
Kokkos::View<double ***, DeviceType> cells,
585
574
Kokkos::View<unsigned int **, DeviceType> bounding_box_to_cell,
586
575
Kokkos::View<int *, DeviceType> imported_cell_indices,
587
576
Kokkos::View<ArborX::Point *, DeviceType> imported_points,
588
577
Kokkos::View<int *, DeviceType> imported_query_ids,
589
578
Kokkos::View<int *, DeviceType> imported_ranks,
590
579
Kokkos::View<unsigned int *, DeviceType> topo, unsigned int topo_id,
591
- Kokkos::View<double **, DeviceType> filtered_points,
592
- Kokkos::View<int *, DeviceType> filtered_cell_indices,
593
- Kokkos::View<int *, DeviceType> filtered_query_ids,
594
- Kokkos::View<double **, DeviceType> reference_points,
595
- Kokkos::View<bool *, DeviceType> point_in_cell,
596
- Kokkos::View<int *, DeviceType> filtered_ranks )
580
+ unsigned int size )
597
581
{
598
- filterTopology ( topo, topo_id, bounding_box_to_cell, imported_cell_indices,
599
- imported_points, imported_query_ids, imported_ranks,
600
- filtered_cell_indices, filtered_points, filtered_query_ids,
601
- filtered_ranks );
582
+ Kokkos::View<double **, DeviceType> filtered_per_topo_points;
583
+ Kokkos::View<int *, DeviceType> filtered_per_topo_cell_indices;
584
+ Kokkos::View<int *, DeviceType> filtered_per_topo_query_ids;
585
+ Kokkos::View<int *, DeviceType> filtered_per_topo_ranks;
586
+
587
+ std::tie ( filtered_per_topo_cell_indices, filtered_per_topo_points,
588
+ filtered_per_topo_query_ids, filtered_per_topo_ranks ) =
589
+ filterTopology ( topo, topo_id, size, bounding_box_to_cell,
590
+ imported_cell_indices, imported_points,
591
+ imported_query_ids, imported_ranks );
602
592
603
593
// Perform the PointInCell search
604
594
Topologies topologies;
595
+ Kokkos::View<double **, DeviceType> filtered_per_topo_reference_points (
596
+ " filtered_per_topo_reference_points_" + std::to_string ( topo_id ), size,
597
+ _dim );
598
+ Kokkos::View<bool *, DeviceType> filtered_per_topo_point_in_cell (
599
+ " filtered_per_topo_point_in_cell_" + std::to_string ( topo_id ), size );
605
600
PointInCell<DeviceType>::search (
606
- filtered_points, cells, filtered_cell_indices, topologies[topo_id].topo ,
607
- reference_points, point_in_cell );
601
+ filtered_per_topo_points, cells, filtered_per_topo_cell_indices,
602
+ topologies[topo_id].topo , filtered_per_topo_reference_points,
603
+ filtered_per_topo_point_in_cell );
604
+
605
+ return std::make_tuple (
606
+ filtered_per_topo_cell_indices, filtered_per_topo_query_ids,
607
+ filtered_per_topo_reference_points, filtered_per_topo_point_in_cell,
608
+ filtered_per_topo_ranks );
608
609
}
609
610
610
611
template <typename DeviceType>
0 commit comments