Displaying 1 result from an estimated 1 matches for "long_computation".
2012 Feb 23
0
RcppProgress: progress monitoring and interrupting c++ code, request for comments
...the package, but
basically you use it like this:
The main loop:
Progress p(max, display_progress); // create the progress monitor
#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < max; ++i) {
if ( ! p.is_aborted() ) { // the only way to exit an OpenMP loop
long_computation(nb);
p.increment(); // update the progress
}
}
and in your computation intensive function:
void long_computation(int nb) {
double sum = 0;
for (int i = 0; i < nb; ++i) {
if ( Progress::check_abort() )
return;
for (int j = 0; j < nb...