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]

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


On Mon, 11 May 2009 19:00:54 +0300 Mikolaj Golub wrote:

> 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.

The problem is observed also for constructions like this one:

#pragma omp parallel for num_threads(m)
...
#pragma omp parallel for num_threads(n)
...

Adding some sleep() code I see in top that during the program run m or n
threads are run in turn. So it looks like memory leaks when thread is
removed. It might be FreeBSD problem, not gcc.

-- 
Mikolaj Golub


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