Parallel Programming with O2scl

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.

MPI programming with O2scl is also straightforward. The sole exception is O2scl has two global objects, the library settings object and the error handler object, which may need to be separately instantiated by the user on each thread.

For example, on some systems, the following may be required to ensure that the error handler is valid on each 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;
}

O2scl also may support OpenMP in the future, enabled during installation by –enable-openmp. The o2scl::mcmc_para_base class supports OpenMP but is header only and thus does not require that O2scl was installed with OpenMP support.

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