|
37 | 37 | #endif |
38 | 38 |
|
39 | 39 |
|
| 40 | +#if defined( DM_PARALLEL ) && ! defined( STUBMPI ) |
| 41 | +void |
| 42 | +temp_errhandler( MPI_Comm *comm_ptr, int *errcode, ... ) |
| 43 | +{ |
| 44 | + // do nothing... |
| 45 | +} |
| 46 | + |
| 47 | +MPI_Datatype |
| 48 | +get_datatype_from_typesize( int *typesize ) |
| 49 | +{ |
| 50 | + MPI_Errhandler errhandler; |
| 51 | + MPI_Errhandler previous; |
| 52 | + MPI_Datatype dtype; |
| 53 | + int ierr = -1; |
| 54 | + |
| 55 | + // MPI critically aborts on trivial errors caused by this call so replace error |
| 56 | + // handler temporarily |
| 57 | + ierr = MPI_Comm_create_errhandler( &temp_errhandler, &errhandler ); |
| 58 | + ierr = MPI_Comm_get_errhandler( MPI_COMM_WORLD, &previous ); |
| 59 | + ierr = MPI_Comm_set_errhandler( MPI_COMM_WORLD, errhandler ); |
| 60 | + |
| 61 | + /* handle different sized data types appropriately. */ |
| 62 | + ierr = MPI_Type_match_size (MPI_TYPECLASS_REAL, *typesize, &dtype); |
| 63 | + if (MPI_SUCCESS != ierr) { |
| 64 | + ierr = MPI_Type_match_size (MPI_TYPECLASS_INTEGER, *typesize, &dtype); |
| 65 | + if (MPI_SUCCESS != ierr) { |
| 66 | +#ifndef MS_SUA |
| 67 | + fprintf(stderr,"%s %d FATAL ERROR: unhandled typesize = %d!!\n", __FILE__,__LINE__,*typesize) ; |
| 68 | +#endif |
| 69 | + MPI_Abort(MPI_COMM_WORLD,1) ; |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + // Reinstate the previous error handler and clear ours |
| 74 | + ierr = MPI_Comm_set_errhandler( MPI_COMM_WORLD, previous ); |
| 75 | + ierr = MPI_Errhandler_free( &errhandler ); |
| 76 | + |
| 77 | + return dtype; |
| 78 | +} |
| 79 | +#endif |
| 80 | + |
40 | 81 | int col_on_comm ( int *, int *, void *, int *, void *, int *, int); |
41 | 82 | int dst_on_comm ( int *, int *, void *, int *, void *, int *, int); |
42 | 83 |
|
@@ -115,17 +156,7 @@ col_on_comm ( int * Fcomm, int * typesize , |
115 | 156 |
|
116 | 157 | } |
117 | 158 |
|
118 | | - /* handle different sized data types appropriately. */ |
119 | | - ierr = MPI_Type_match_size (MPI_TYPECLASS_REAL, *typesize, &dtype); |
120 | | - if (MPI_SUCCESS != ierr) { |
121 | | - ierr = MPI_Type_match_size (MPI_TYPECLASS_INTEGER, *typesize, &dtype); |
122 | | - if (MPI_SUCCESS != ierr) { |
123 | | -#ifndef MS_SUA |
124 | | - fprintf(stderr,"%s %d FATAL ERROR: unhandled typesize = %d!!\n", __FILE__,__LINE__,*typesize) ; |
125 | | -#endif |
126 | | - MPI_Abort(MPI_COMM_WORLD,1) ; |
127 | | - } |
128 | | - } |
| 159 | + dtype = get_datatype_from_typesize( typesize ); |
129 | 160 |
|
130 | 161 | ierr = MPI_Gatherv( inbuf , *ninbuf, dtype, |
131 | 162 | outbuf , recvcounts , displace, dtype, |
@@ -204,17 +235,7 @@ dst_on_comm ( int * Fcomm, int * typesize , |
204 | 235 | } |
205 | 236 | } |
206 | 237 |
|
207 | | - /* handle different sized data types appropriately. */ |
208 | | - ierr = MPI_Type_match_size (MPI_TYPECLASS_REAL, *typesize, &dtype); |
209 | | - if (MPI_SUCCESS != ierr) { |
210 | | - ierr = MPI_Type_match_size (MPI_TYPECLASS_INTEGER, *typesize, &dtype); |
211 | | - if (MPI_SUCCESS != ierr) { |
212 | | -#ifndef MS_SUA |
213 | | - fprintf(stderr,"%s %d FATAL ERROR: unhandled typesize = %d!!\n", __FILE__,__LINE__,*typesize) ; |
214 | | -#endif |
215 | | - MPI_Abort(MPI_COMM_WORLD,1) ; |
216 | | - } |
217 | | - } |
| 238 | + dtype = get_datatype_from_typesize( typesize ); |
218 | 239 |
|
219 | 240 | MPI_Scatterv( inbuf, sendcounts, displace, dtype, |
220 | 241 | outbuf, *noutbuf, dtype, |
|
0 commit comments