This source file includes following definitions.
- OMPI_CR_Migrate
1
2
3
4
5
6
7
8
9
10
11
12 #include "ompi_config.h"
13 #include <stdio.h>
14
15 #include "opal/util/string_copy.h"
16
17 #include "ompi/mpi/c/bindings.h"
18 #include "ompi/info/info.h"
19 #include "ompi/runtime/params.h"
20 #include "ompi/communicator/communicator.h"
21 #include "orte/mca/snapc/snapc.h"
22
23 #include "ompi/mpiext/cr/c/mpiext_cr_c.h"
24
25 static const char FUNC_NAME[] = "OMPI_CR_Migrate";
26
27 int OMPI_CR_Migrate(MPI_Comm comm, char *hostname, int rank, MPI_Info *info)
28 {
29 int ret = MPI_SUCCESS;
30 orte_snapc_base_request_op_t *datum = NULL;
31 int my_rank, my_size, i;
32 char loc_hostname[MPI_MAX_PROCESSOR_NAME];
33 int my_vpid;
34 int info_flag;
35 char info_value[6];
36 int my_off_node = (int)false;
37
38
39 if (MPI_PARAM_CHECK) {
40 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
41 }
42
43
44
45
46 datum = OBJ_NEW(orte_snapc_base_request_op_t);
47 datum->event = ORTE_SNAPC_OP_MIGRATE;
48 datum->is_active = true;
49
50 MPI_Comm_rank(comm, &my_rank);
51 MPI_Comm_size(comm, &my_size);
52 if( 0 == my_rank ) {
53 datum->leader = OMPI_PROC_MY_NAME->vpid;
54 } else {
55 datum->leader = -1;
56 }
57
58
59
60
61 if( NULL == hostname ) {
62 loc_hostname[0] = '\0';
63 } else {
64 opal_string_copy(loc_hostname, hostname, sizeof(loc_hostname));
65 }
66 my_vpid = (int) OMPI_PROC_MY_NAME->vpid;
67
68 if( 0 == my_rank ) {
69 datum->mig_num = my_size;
70 datum->mig_vpids = (int *) malloc(sizeof(int) * my_size);
71 datum->mig_host_pref = (char (*)[OPAL_MAX_PROCESSOR_NAME]) malloc(sizeof(char) * my_size * MPI_MAX_PROCESSOR_NAME);
72 datum->mig_vpid_pref = (int *) malloc(sizeof(int) * my_size);
73 datum->mig_off_node = (int *) malloc(sizeof(int) * my_size);
74
75 for( i = 0; i < my_size; ++i ) {
76 (datum->mig_vpids)[i] = 0;
77 (datum->mig_host_pref)[i][0] = '\0';
78 (datum->mig_vpid_pref)[i] = 0;
79 (datum->mig_off_node)[i] = (int)false;
80 }
81 }
82
83 my_off_node = (int)false;
84 if( NULL != info ) {
85 MPI_Info_get(*info, "CR_OFF_NODE", 5, info_value, &info_flag);
86 if( info_flag ) {
87 if( 0 == strncmp(info_value, "true", strlen("true")) ) {
88 my_off_node = (int)true;
89 }
90 }
91 }
92
93 MPI_Gather(&my_vpid, 1, MPI_INT,
94 (datum->mig_vpids), 1, MPI_INT, 0, comm);
95 MPI_Gather(loc_hostname, MPI_MAX_PROCESSOR_NAME, MPI_CHAR,
96 (datum->mig_host_pref), MPI_MAX_PROCESSOR_NAME, MPI_CHAR, 0, comm);
97 MPI_Gather(&my_vpid, 1, MPI_INT,
98 (datum->mig_vpid_pref), 1, MPI_INT, 0, comm);
99 MPI_Gather(&my_off_node, 1, MPI_INT,
100 (datum->mig_off_node), 1, MPI_INT, 0, comm);
101
102
103
104
105 OPAL_CR_ENTER_LIBRARY();
106 ret = orte_snapc.request_op(datum);
107 if( OMPI_SUCCESS != ret ) {
108 OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OTHER,
109 FUNC_NAME);
110 }
111 OPAL_CR_EXIT_LIBRARY();
112
113 datum->is_active = false;
114 OBJ_RELEASE(datum);
115
116
117
118
119 MPI_Barrier(comm);
120
121 return ret;
122 }