[Omp] A problem with guard objects and exceptions on Intel
Michael Suess
mike_ml at suessnetz.de
Tue Aug 22 08:54:31 PDT 2006
Hi,
I have just published a blog entry comparing the merits of guard objects vs.
the critical construct (with C++ and OpenMP). The problem I have now is: My
test programs with exceptions and guard objects do not work for the Intel
Compiler. Since this would not be the first time I missed something, I
figured I would double check here before filing a bug with Intel.
So if you find the time, please take a look at the code for the guard object,
enclosed in the following article:
http://www.thinkingparallel.com/2006/08/21/scoped-locking-vs-critical-in-openmp-a-personal-shootout/
Combining this with the following short test program,
test_omp_guard_exceptions.cpp:
#include <omp.h>
#include <cassert>
#include "omp_guard.hpp"
int main (void)
{
omp_lock_t my_lock;
// how many exceptions have been thrown (should be one for each thread)
int ex_count = 0;
// how many threads will be created (most likely)
int numthreads = omp_get_max_threads ();
omp_init_lock (&my_lock);
#pragma omp parallel
{
try {
omp_guard my_guard (my_lock);
throw omp_get_thread_num ();
}
catch(int e) {
#pragma omp atomic
++ex_count;
}
}
assert (ex_count == numthreads);
omp_destroy_lock (&my_lock);
return 0;
}
Running this program on the Intel Compiler, I get a segmentation fault. The
Sun and Portland compilers run it just fine, so I think it may be a bug in
the compiler. But since I have had this thought one too many times in the
past and usually it is me and not the compiler who is wrong, I thought I
would double-check.
Thanks for any insights,
Michael Suess
--
My blog on parallel programming: http://www.thinkingparallel.com
Michael Suess
Public PGP key: http://www.suessnetz.de/michael/michaelsuess.gpg
PGP key fingerprint: A744 AFBA CA93 620B 8701 AB98 D4CF 4F3C 945A 61FE
More information about the Omp
mailing list