Parallel Programming with O2scl

Thread safety

Generally, O2scl objects are thread-safe in the same way that classes like std::vector<double> are thread-safe: reads are safe and writes are unsafe. It may be useful to make objects const to ensure that one is reading data in a thread-safe way. O2scl is designed to ensure const methods are thread-safe, unless noted. (A few classes contain mutable internal members which mean that const methods are not thread-safe, and this is noted in the class documentation.)

OpenMP and O2scl

OpenMP support may be enabled during installation by –enable-openmp. All OpenMP functionality is headers only, but enabling OpenMP support during installation allows O2scl to test the multithreaded behavior of o2scl::anneal_para, o2scl::mcmc_para_base, and o2scl::mcmc_para_table.

On some systems, code similar to the following may be required to ensure that the error handler is valid on each OpenMP thread.

int main(int argc, char *argv[]) {
cout.setf(ios::scientific);
MPI_Init(&argc,&argv);
// Create a new error handler for this thread
// Do stuff here
MPI_Finalize();
return 0;
}

You can test to see if OpenMP support was enabled during installation in the o2scl::o2scl_settings object of type o2scl::lib_settings_class or with acol -v.

OpenMP and O2scl

Currently, all MPI calls are in header classes, except for some support for parallel HDF5 which is currently being developed and not yet enabled. MPI functions are used in o2scl::anneal_para, o2scl::mcmc_para_base, and o2scl::mcmc_para_table .

You can test to see if MPI support was enabled during installation in the o2scl::o2scl_settings object of type o2scl::lib_settings_class or with acol -v.

o2scl::err_hnd
err_hnd_type * err_hnd
The global error handler pointer.
o2scl::err_hnd_cpp
Error handler to throw C++ exceptions.
Definition: exception.h:258

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).