[solved] [maybe OT] FFTW + OpenMP3 + ifort

[solved] [maybe OT] FFTW + OpenMP3 + ifort

I apologize if this is off-topic - it could be that this is an fftw-related issue. Still, this may benefit other ifort users.

The following test program runs without errors when OMP_NUM_THREADS == 1, but aborts when multiple threads are used (with "fftw: alloc.c:187: assertion failed [...]"). The program also gives expected results when DIM = (/256,256,256/), even with multiple threads.

This is with ifort 11.1.069, fftw 3.2.2 (configured with --enable-shared --enable-float --enable-openmp --enable-debug and built with gcc 4.4.3).

MODULE FFTW_INCLUDE
      INTEGER FFTW_MEASURE
      PARAMETER (FFTW_MEASURE=0)
      INTEGER FFTW_UNALIGNED
      PARAMETER (FFTW_UNALIGNED=2)
      INTEGER FFTW_ESTIMATE
      PARAMETER (FFTW_ESTIMATE=64)
END MODULE FFTW_INCLUDE

PROGRAM FFTW_OPENMP_TEST
	USE FFTW_INCLUDE
	USE OMP_LIB
	IMPLICIT NONE
	! VARIABLES
	INTEGER :: I
	REAL, ALLOCATABLE :: RARRAY(:,:,:)
	COMPLEX, ALLOCATABLE :: CARRAY(:,:,:)
	INTEGER(KIND=8) :: PLAN
	INTEGER :: DIM(3)

	! START WORK
	DIM = (/254,254,254/)

	!$OMP PARALLEL PRIVATE(RARRAY,CARRAY,I,PLAN) SHARED(DIM)
	ALLOCATE(RARRAY(DIM(1)+2,DIM(2),DIM(3)),CARRAY(DIM(1)/2+1,DIM(2),DIM(3)))
	!$OMP SINGLE
	CALL SFFTW_PLAN_DFT_R2C_3D(PLAN, DIM(1), DIM(2), DIM(3), RARRAY, CARRAY, FFTW_ESTIMATE, FFTW_UNALIGNED )
	print '(a,i1)', '**debug(): planning done for thread ', omp_get_thread_num()+1
	!$OMP	END SINGLE COPYPRIVATE(PLAN)

	print '(a,i1,a,i)', '**debug(): about to start do loop on thread ', omp_get_thread_num()+1, ' with plan ', plan

	!$OMP	DO
	DO I=1,4
		CALL SFFTW_EXECUTE_DFT_R2C(PLAN,RARRAY,CARRAY)
		!PRINT '(A,I1,A,I1)', '**DEBUG(): THREAD', OMP_GET_THREAD_NUM()+1, ' JUST FINISHED ITERATION ', I
	ENDDO
	!$OMP	END DO
	!$OMP	END PARALLEL
END PROGRAM

The compile & linking line I use is:

ifort -L/where/fftw/is -O0 -openmp -static test.f90 -lfftw3f

And this is what I see when I run it with OMP_NUM_THREADS = 4:

**debug(): planning done for thread 1
**debug(): about to start do loop on thread 1 with plan          46912652832512
**debug(): about to start do loop on thread 3 with plan          46912652832512
**debug(): about to start do loop on thread 4 with plan          46912652832512
fftw: alloc.c:187: assertion failed: (stat->cnt == 0 && stat->siz == 0) || (stat->cnt > 0 && stat->siz > 0)
fftw: alloc.c:187: assertion failed: (stat->cnt == 0 && stat->siz == 0) || (stat->cnt > 0 && stat->siz > 0)
Abort

Any pointers as to what is going on would be much appreciated. Again, I apologise that this is OT for this forum.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Steven G. Johnson has pointed out to me that the flag --enable-debug-malloc is not threadsafe and is meant for development use only. Removing "--enable-debug" from the configure options when building fftw solved my problem.

So this really wasn't anything to do with ifort.

Leave a Comment

Please sign in to add a comment. Not a member? Join today