2
2
3
3
#include "config.h"
4
4
5
+ #include "tst_comm.h"
6
+
5
7
#include <assert.h>
6
8
#include <stdio.h>
7
9
#include <stdlib.h>
@@ -55,21 +57,25 @@ static int num_registered_comms = 0;
55
57
static struct comm comms [COMM_NUM ];
56
58
57
59
58
- int tst_comm_register (char * description , MPI_Comm mpi_comm , int class , int size , int * mapping , int other_size , int * other_mapping ) {
59
- assert (num_registered_comms < COMM_NUM );
60
+ int tst_comm_init (struct comm * comm ) {
60
61
int i ;
61
62
int num_threads = tst_thread_num_threads ();
62
- comms [num_registered_comms ].mpi_comm = mpi_comm ;
63
- comms [num_registered_comms ].mpi_thread_comms = (MPI_Comm * ) malloc (num_threads * sizeof (MPI_Comm ));
63
+ comm -> mpi_thread_comms = (MPI_Comm * ) malloc (num_threads * sizeof (MPI_Comm ));
64
64
for (i = 0 ; i < num_threads ; i ++ ) {
65
- if (mpi_comm != MPI_COMM_NULL ) {
66
- MPI_CHECK (MPI_Comm_dup (mpi_comm , & comms [ num_registered_comms ]. mpi_thread_comms [i ]));
65
+ if (comm -> mpi_comm != MPI_COMM_NULL ) {
66
+ MPI_CHECK (MPI_Comm_dup (comm -> mpi_comm , & comm -> mpi_thread_comms [i ]));
67
67
}
68
68
else {
69
- comms [ num_registered_comms ]. mpi_thread_comms [i ] = MPI_COMM_NULL ;
69
+ comm -> mpi_thread_comms [i ] = MPI_COMM_NULL ;
70
70
}
71
71
}
72
+ return 0 ;
73
+ }
74
+
75
+ int tst_comm_register (char * description , MPI_Comm mpi_comm , int class , int size , int * mapping , int other_size , int * other_mapping ) {
76
+ assert (num_registered_comms < COMM_NUM );
72
77
strncpy (comms [num_registered_comms ].description , description , TST_DESCRIPTION_LEN );
78
+ comms [num_registered_comms ].mpi_comm = mpi_comm ;
73
79
comms [num_registered_comms ].class = class ;
74
80
comms [num_registered_comms ].size = size ;
75
81
comms [num_registered_comms ].mapping = mapping ;
@@ -425,7 +431,15 @@ int tst_comm_register_split_type_shared() {
425
431
}
426
432
427
433
428
- int tst_comms_init (int * num_comms ) {
434
+ int tst_comms_init () {
435
+ int i ;
436
+ for (i = 0 ; i < num_registered_comms ; i ++ ) {
437
+ tst_comm_init (& comms [i ]);
438
+ }
439
+ return num_registered_comms ;
440
+ }
441
+
442
+ int tst_comms_register () {
429
443
430
444
tst_comm_register_comm_world ();
431
445
tst_comm_register_comm_null ();
@@ -441,14 +455,14 @@ int tst_comms_init(int * num_comms) {
441
455
tst_comm_register_merged_inter_comm ();
442
456
tst_comm_register_split_type_shared ();
443
457
444
- * num_comms = num_registered_comms ;
445
- return 0 ;
458
+ return num_registered_comms ;
446
459
447
460
int count_comms = num_registered_comms ;
448
461
int comm_size ;
449
462
int comm_rank ;
450
463
MPI_Comm tmp_comm = MPI_COMM_NULL ;
451
464
int i ;
465
+ int * num_comms ;
452
466
453
467
MPI_Comm_size (MPI_COMM_WORLD , & comm_size );
454
468
MPI_Comm_rank (MPI_COMM_WORLD , & comm_rank );
0 commit comments