11//! Distributed evaluation of sources and targets.
22
3- use green_kernels:: traits:: * ;
4- use green_kernels:: { laplace_3d:: Laplace3dKernel , types:: GreenKernelEvalType } ;
3+ use green_kernels:: {
4+ laplace_3d:: Laplace3dKernel ,
5+ traits:: { DistributedKernelEvaluator , Kernel } ,
6+ types:: GreenKernelEvalType ,
7+ } ;
58use mpi:: traits:: { Communicator , Root } ;
69use rand:: prelude:: * ;
710use rand_chacha:: ChaCha8Rng ;
8- use rlst:: prelude:: * ;
9- use rlst:: { assert_array_relative_eq, rlst_dynamic_array1, RawAccess , RawAccessMut } ;
11+ use rlst:: { assert_array_relative_eq, rlst_dynamic_array} ;
1012
1113fn main ( ) {
1214 // Create the MPI communicator
@@ -24,23 +26,23 @@ fn main() {
2426 // Create a Laplace kernel.
2527 let kernel = Laplace3dKernel :: < f64 > :: default ( ) ;
2628
27- let mut sources = rlst_dynamic_array1 ! ( f64 , [ 3 * n_sources] ) ;
28- let mut targets = rlst_dynamic_array1 ! ( f64 , [ 3 * n_targets] ) ;
29- let mut charges = rlst_dynamic_array1 ! ( f64 , [ n_sources] ) ;
29+ let mut sources = rlst_dynamic_array ! ( f64 , [ 3 * n_sources] ) ;
30+ let mut targets = rlst_dynamic_array ! ( f64 , [ 3 * n_targets] ) ;
31+ let mut charges = rlst_dynamic_array ! ( f64 , [ n_sources] ) ;
3032
3133 sources. fill_from_equally_distributed ( & mut rng) ;
3234 targets. fill_from_equally_distributed ( & mut rng) ;
3335 charges. fill_from_equally_distributed ( & mut rng) ;
3436
3537 // Create the result vector.
36- let mut result = rlst_dynamic_array1 ! ( f64 , [ n_targets] ) ;
38+ let mut result = rlst_dynamic_array ! ( f64 , [ n_targets] ) ;
3739
3840 kernel. evaluate_distributed (
3941 GreenKernelEvalType :: Value ,
40- sources. data ( ) ,
41- targets. data ( ) ,
42- charges. data ( ) ,
43- result. data_mut ( ) ,
42+ sources. data ( ) . unwrap ( ) ,
43+ targets. data ( ) . unwrap ( ) ,
44+ charges. data ( ) . unwrap ( ) ,
45+ result. data_mut ( ) . unwrap ( ) ,
4446 false ,
4547 & world,
4648 ) ;
@@ -50,51 +52,51 @@ fn main() {
5052 if world. rank ( ) != 0 {
5153 let root_process = world. process_at_rank ( 0 ) ;
5254
53- root_process. gather_into ( sources. data ( ) ) ;
54- root_process. gather_into ( targets. data ( ) ) ;
55- root_process. gather_into ( charges. data ( ) ) ;
56- root_process. gather_into ( result. data ( ) ) ;
55+ root_process. gather_into ( sources. data ( ) . unwrap ( ) ) ;
56+ root_process. gather_into ( targets. data ( ) . unwrap ( ) ) ;
57+ root_process. gather_into ( charges. data ( ) . unwrap ( ) ) ;
58+ root_process. gather_into ( result. data ( ) . unwrap ( ) ) ;
5759 } else {
5860 let sources = {
59- let mut tmp = rlst_dynamic_array1 ! ( f64 , [ 3 * n_sources * world. size( ) as usize ] ) ;
61+ let mut tmp = rlst_dynamic_array ! ( f64 , [ 3 * n_sources * world. size( ) as usize ] ) ;
6062 world
6163 . this_process ( )
62- . gather_into_root ( sources. data ( ) , tmp. data_mut ( ) ) ;
64+ . gather_into_root ( sources. data ( ) . unwrap ( ) , tmp. data_mut ( ) . unwrap ( ) ) ;
6365 tmp
6466 } ;
6567
6668 let targets = {
67- let mut tmp = rlst_dynamic_array1 ! ( f64 , [ 3 * n_targets * world. size( ) as usize ] ) ;
69+ let mut tmp = rlst_dynamic_array ! ( f64 , [ 3 * n_targets * world. size( ) as usize ] ) ;
6870 world
6971 . this_process ( )
70- . gather_into_root ( targets. data ( ) , tmp. data_mut ( ) ) ;
72+ . gather_into_root ( targets. data ( ) . unwrap ( ) , tmp. data_mut ( ) . unwrap ( ) ) ;
7173 tmp
7274 } ;
7375
7476 let charges = {
75- let mut tmp = rlst_dynamic_array1 ! ( f64 , [ n_sources * world. size( ) as usize ] ) ;
77+ let mut tmp = rlst_dynamic_array ! ( f64 , [ n_sources * world. size( ) as usize ] ) ;
7678 world
7779 . this_process ( )
78- . gather_into_root ( charges. data ( ) , tmp. data_mut ( ) ) ;
80+ . gather_into_root ( charges. data ( ) . unwrap ( ) , tmp. data_mut ( ) . unwrap ( ) ) ;
7981 tmp
8082 } ;
8183
8284 let result = {
83- let mut tmp = rlst_dynamic_array1 ! ( f64 , [ n_targets * world. size( ) as usize ] ) ;
85+ let mut tmp = rlst_dynamic_array ! ( f64 , [ n_targets * world. size( ) as usize ] ) ;
8486 world
8587 . this_process ( )
86- . gather_into_root ( result. data ( ) , tmp. data_mut ( ) ) ;
88+ . gather_into_root ( result. data ( ) . unwrap ( ) , tmp. data_mut ( ) . unwrap ( ) ) ;
8789 tmp
8890 } ;
8991
90- let mut expected = rlst_dynamic_array1 ! ( f64 , [ n_targets * world. size( ) as usize ] ) ;
92+ let mut expected = rlst_dynamic_array ! ( f64 , [ n_targets * world. size( ) as usize ] ) ;
9193
9294 kernel. evaluate_mt (
9395 GreenKernelEvalType :: Value ,
94- sources. data ( ) ,
95- targets. data ( ) ,
96- charges. data ( ) ,
97- expected. data_mut ( ) ,
96+ sources. data ( ) . unwrap ( ) ,
97+ targets. data ( ) . unwrap ( ) ,
98+ charges. data ( ) . unwrap ( ) ,
99+ expected. data_mut ( ) . unwrap ( ) ,
98100 ) ;
99101
100102 assert_array_relative_eq ! ( result, expected, 1e-13 ) ;
0 commit comments