[Rd] RcppProgress: progress monitoring and interrupting c++ code, request for comments

From: Karl Forner <karl.forner_at_gmail.com>
Date: Thu, 23 Feb 2012 19:06:39 +0100


I just created a little package, RcppProgress, to display a progress bar to monitor the execution status of a C++ code loop, possibly multihreaded with OpenMP.
I also implemented the possibility to check for user interruption, using the work-around by Simon Urbanek.

I just uploaded the package on my R-forge project, so you should be able to get the package from

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
            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() )
        for (int j = 0; j < nb; ++j) {
            sum += Rf_dlnorm(i+j, 0.0, 1.0, 0);


I provided two small R test functions so that you can see how it looks, please see the doc.

 I would be extremely grateful if you could give me comments, criticisms and other suggestions.

I try to release this in order to reuse this functionality in my other packages.

Best regards,
Karl Forner

        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 23 Feb 2012 - 18:14:37 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 24 Feb 2012 - 05:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive