This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Memory leak or incorrect use of '#pragma omp parallel'?


Hello,

If I run the following program

---------------

#include <omp.h>

int n = 4, m = 2;

int main () {
        for (;;) {
                int i;

#pragma omp parallel num_threads(m)
                {
                        int just_to_make_some_code_generated;
                        just_to_make_some_code_generated = 0;
                }
#pragma omp parallel for num_threads(n)
                for(i = 0; i < 1; i++) {}

        }

        return 0;
}

---------------

on FreeBSD6/7 (i386 and amd64) built with gcc42 or gcc43 -fopenmp (I have not
tried other gcc versions), the memory usage is constantly growing during the
run. The memory growth is observed in case n != m. If n == m, everything works
ok.

I have tried this code on CentOS5.2 i386 built with gcc41 and gcc43 and
constant memory growth is not observed here. Althogh memory usage looks a bit
strange. On the start the program uses much more memory (more then 60Mb) in
comparison with FreeBSD (several Mb). If n == m, the memory usage statistis is
not changing during the run, while when n != m the memory usage statistis
varies from 64Mb to 102Mb.

Should I report this as a bug? I am not familiar with openmp, we faced with
this problem running some real application. So I am not sure if this is gcc
bug or just incorrect use of '#pragma omp parallel'.

-- 
Mikolaj Golub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]