20 return MPI_Finalize();
25 return MPI_Buffer_attach(buffer,
32 return MPI_Buffer_detach(buffer,
38 MPI_Datatype* newtype) {
40 rc = MPI_Type_contiguous (count,
43 assert(rc==MPI_SUCCESS);
44 MPI_Datatype type, temp_packed_type, packed_type;
45 MPI_Aint array_of_displacements[1] = {(MPI_Aint)0};
46 int s=0, is_active, dt_idx;
47 MPI_Aint p_mapsize, extent, lb;
61 if (oldtype==MPI_DOUBLE) s =
sizeof(double);
62 else if (oldtype==MPI_INT) s =
sizeof(int);
63 else if (oldtype==MPI_FLOAT) s =
sizeof(float);
64 else if (oldtype==MPI_CHAR) s =
sizeof(char);
68 MPI_Type_get_extent(*newtype,&lb,&extent);
69 rc = MPI_Type_contiguous (count,
72 assert(rc==MPI_SUCCESS);
73 rc = MPI_Type_create_resized (temp_packed_type,
80 array_of_displacements,
85 array_of_displacements,
94 int array_of_blocklengths[],
95 MPI_Aint array_of_displacements[],
96 MPI_Datatype array_of_types[],
97 MPI_Datatype *newtype) {
99 rc = MPI_Type_create_struct (count,
100 array_of_blocklengths,
101 array_of_displacements,
104 assert(rc==MPI_SUCCESS);
105 MPI_Datatype temp_packed_type, packed_type;
106 int array_of_p_blocklengths[count];
107 MPI_Aint array_of_p_displacements[count];
108 MPI_Datatype array_of_p_types[count], datatype;
109 int s=0, is_active, is_derived, dt_idx;
110 MPI_Aint p_mapsize=0, extent, lb;
112 for (i=0;i<count;i++) {
113 datatype = array_of_types[i];
117 array_of_p_blocklengths[i] = array_of_blocklengths[i];
118 array_of_p_displacements[i] = p_mapsize;
120 array_of_p_types[i] = MPI_DOUBLE;
123 else if (is_derived) {
128 array_of_p_types[i] = array_of_types[i];
129 if (array_of_types[i]==MPI_DOUBLE) s =
sizeof(double);
130 else if (array_of_types[i]==MPI_INT) s =
sizeof(int);
131 else if (array_of_types[i]==MPI_FLOAT) s =
sizeof(float);
132 else if (array_of_types[i]==MPI_CHAR) s =
sizeof(char);
135 p_mapsize += array_of_blocklengths[i]*s;
137 MPI_Type_get_extent(*newtype,&lb,&extent);
138 rc = MPI_Type_create_struct (count,
139 array_of_p_blocklengths,
140 array_of_p_displacements,
143 assert(rc==MPI_SUCCESS);
144 rc = MPI_Type_create_resized (temp_packed_type,
150 array_of_blocklengths,
151 array_of_displacements,
155 array_of_p_blocklengths,
156 array_of_p_displacements,
161 MPI_Type_free(&temp_packed_type);
168 return MPI_Type_commit(datatype);
174 MPI_Datatype *newtype) {
176 rc = MPI_Type_create_resized(oldtype,
183 dtd->
lbs[dt_idx] = lb;
194 rc = MPI_Op_create(
function,
197 if (!(rc==MPI_SUCCESS)) assert(0);
209 return MPI_Type_free(datatype);
213 return MPI_Op_free(op);