Segmentation fault at runtime with OpenMP
Tobias Burnus
burnus@net-b.de
Thu Feb 7 12:04:00 GMT 2008
Ignacio Fernández Galván wrote:
> Is there anything wrong with this code? It compiles fine with
> gfortran-20080206, but when I run the output I get a segmentation
> fault.
>
Using gfortran it does not crash here, but valgrind shows:
==10362== Use of uninitialised value of size 8
==10362== at 0x400926: inner.902 (aa.f90:15)
==10362== by 0x4008FA: MAIN__.omp_fn.0 (aa.f90:8)
==10362== by 0x400875: MAIN__ (aa.f90:8)
==10362== by 0x40095B: main (fmain.c:21)
The problem seems to be the variable k, which is uninitialized in the
subroutine "inner". Jakub, is the code valid or not?
PROGRAM Outer
IMPLICIT NONE
REAL, DIMENSION(100) :: A
INTEGER :: k
!$OMP PARALLEL DO PRIVATE(k)
DO k=1,SIZE(A)
CALL Inner()
END DO
!$OMP END PARALLEL DO
CONTAINS
SUBROUTINE Inner
IMPLICIT NONE
A(k)=0.0D0
END SUBROUTINE Inner
END PROGRAM Outer
The 010t.omplower tree looks as follows:
;; Function inner (inner.902)
inner ()
{
integer(kind=4) k [value-expr: CHAIN.2->k];
real(kind=4) a[100] [value-expr: CHAIN.2->a];
integer(kind=4) D.915;
integer(kind=8) D.909;
integer(kind=8) D.910;
D.915 = CHAIN.2->k;
D.909 = (integer(kind=8)) D.915;
D.910 = D.909 + -1;
CHAIN.2->a[D.910] = 0.0;
}
;; Function outer (MAIN__)
outer ()
{
struct .omp_data_s.3 .omp_data_o.4;
struct FRAME.outer * D.927;
_gfortran_set_options (7, &options.0);
{
.omp_data_o.4.FRAME.1 = &FRAME.1;
#pragma omp parallel shared(FRAME.1) private(k) [child fn: MAIN__.omp_fn.0 (.omp_data_o.4)]
{
.omp_data_i = &.omp_data_o.4;
{
#pragma omp for nowait
for (k = 1; k <= 100; k = k + 1)
{
D.927 = .omp_data_i->FRAME.1;
inner () [static-chain: D.927];
}
<D.926>:;
OMP_CONTINUE <k <- k>
OMP_RETURN [nowait]
}
OMP_RETURN
}
}
}
More information about the Fortran
mailing list