21 #include <stk_util/diag/Env.hpp>
22 #include <stk_util/diag/Platform.hpp>
24 #include <stk_util/parallel/ExceptionReport.hpp>
27 #include <stk_util/diag/Trace.hpp>
38 ParallelThrowRegistry &
43 return s_parallelThrowRegistry;
47 ParallelThrowRegistry::Registry::Registry()
51 ParallelThrowRegistry::Registry::~Registry()
56 for (iterator it = begin(); it != end(); ++it, ++it)
62 ParallelThrowRegistry::register_exception_a(
63 const std::type_info & exception_type,
64 ExParallel * exception)
67 m_registry.push_back(Registry::value_type(&exception_type, exception));
68 mpih::Add_Handle(*exception);
75 const std::type_info & exception_type)
77 for (Registry::iterator it = m_registry.begin(); it != m_registry.end(); ++it)
78 if (*(*it).first == exception_type)
92 const std::exception & x,
93 const std::string & append_message)
100 *exception << x.
what() << append_message;
110 x <<
"Unknown exception";
121 if (!registered_exception)
131 mpih::Set_Local_Handle(const_cast<ExParallel &>(*registered_exception));
141 if (!registered_exception)
151 mpih::Set_Local_Handle(const_cast<ExParallel &>(*registered_exception));
164 LogicError::registerException();
165 DomainError::registerException();
166 InvalidArgument::registerException();
167 LengthError::registerException();
168 OutOfRange::registerException();
169 RuntimeError::registerException();
170 RangeError::registerException();
171 OverflowError::registerException();
172 UnderflowError::registerException();
175 mpih::Activate_Handles();
184 MPI_Comm_size(mpi_comm, &nprocs);
188 mpih::Get_Global_Handles(handles);
190 MPIH_Handler_compete handler_compete_fn;
191 MPIH_Handler_execute handler_execute_fn;
192 mpih::Get_Functions(&handler_compete_fn ,
193 &handler_execute_fn);
200 mpih::Reset_Local_Handle();
212 for (
int i = 0; i < nprocs; ++i) {
214 ExParallel *x = dynamic_cast<ExParallel *>(handles[i]);
226 int originating_processor = -1;
228 for (
int i = 0; i < nprocs; ++i) {
230 ExParallel *x = dynamic_cast<ExParallel *>(handles[i]);
232 if (handler_compete_fn)
233 (handler_compete_fn) (reinterpret_cast<void **>(&handles[i]), the_exception);
234 if ( handles[i] != the_exception ) {
236 originating_processor = i;
257 int description_len = description.length();
258 MPI_Bcast(&description_len,
261 originating_processor,
264 char *description_buf =
new char[description_len];
265 description.copy(description_buf, description_len);
267 MPI_Bcast(description_buf,
270 originating_processor,
274 const std::string &traceback(the_exception->
getTraceback());
275 int traceback_len = traceback.length();
276 MPI_Bcast(&traceback_len,
279 originating_processor,
282 char *traceback_buf =
new char[traceback_len];
283 traceback.copy(traceback_buf, traceback_len);
285 MPI_Bcast(traceback_buf,
288 originating_processor,
292 the_exception->
setDescription(std::string(description_buf, description_len));
293 the_exception->
setTraceback(std::string(traceback_buf, traceback_len));
300 #ifdef SIERRA_MPIH_VERBOSE
302 <<
"*************** Exception handling ***************"<<endl
303 <<
" A parallel exception of type "<<
typeid(*the_exception).name()<<endl
304 <<
" will be thrown on all processors."<<endl;
307 delete [] traceback_buf;
308 delete [] description_buf;
312 #ifdef SIERRA_MPIH_VERBOSE
314 <<
"*************** Exception handling ***************"<<endl
315 <<
" A parallel exception of type Unknown_Exception"<<endl
316 <<
" will be thrown on all processors."<<endl;