Skip to content

Commit

Permalink
[fft backend] Fix an error when __MKL=0 but __FFTW3=1.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtaillefumier authored and oschuett committed Aug 30, 2023
1 parent ad1d17f commit 130ab16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ target_compile_definitions(
PRIVATE $<$<CONFIG:Release>:NDEBUG> $<$<BOOL:${CP2K_USE_LIBXSMM}>:__LIBXSMM>
$<$<STREQUAL:${CP2K_BLAS_VENDOR},"MKL">:__MKL>)

if(NOT CP2K_DISABLE_DBM_GPU)
if(CP2K_DISABLE_DBM_GPU)
target_compile_definitions(dbm_miniapp PRIVATE __NO_OFFLOAD_DBM)
else()
target_compile_definitions(dbm_miniapp PRIVATE ${CP2K_GPU_DFLAGS})
Expand Down
12 changes: 8 additions & 4 deletions src/pw/fft/fftw3_lib.F
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,17 @@ SUBROUTINE fftw3_do_init(wisdom_file)
INTEGER(KIND=C_INT) :: isuccess
LOGICAL :: exist

#if defined(__MKL)
!$ LOGICAL :: mkl_is_safe
#endif

! If using the Intel compiler then we need to declare
! a C interface to a global variable in MKL that sets
! the number of threads which can concurrently execute
! an FFT
! We need __INTEL_COMPILER so we can be sure that the compiler
! understands the !DEC$ version definitions
#if defined (__INTEL_COMPILER) && defined (__MKL) && defined (__FFTW3)
#if defined (__INTEL_COMPILER) && defined (__MKL)
!$ include "mkl.fi"
!DEC$ IF DEFINED (INTEL_MKL_VERSION)
!DEC$ IF INTEL_MKL_VERSION .EQ. 110100
Expand All @@ -198,7 +200,7 @@ SUBROUTINE fftw3_do_init(wisdom_file)
!$ BIND(c) :: /fftw3_mkl/
!DEC$ ENDIF
!DEC$ ENDIF
#elif defined (__MKL) && defined (__FFTW3)
#elif defined (__MKL)
! Preprocessing is enabled by default, and below header is not language specific
#include <mkl_version.h>
#endif
Expand All @@ -219,15 +221,16 @@ SUBROUTINE fftw3_do_init(wisdom_file)
END IF
END IF

#if defined (__MKL)
! Now check if we have a real FFTW3 library, or are using MKL wrappers

!$ IF (fftw3_is_mkl_wrapper() .and. omp_get_max_threads() .gt. 1) THEN
! If we are not using the Intel compiler, there is no way to tell which
! MKL version is in use, so fail safe...
!$ mkl_is_safe = .FALSE.
#if defined (__MKL) && defined (__FFTW3) && defined(INTEL_MKL_VERSION) && (110100 < INTEL_MKL_VERSION)
#if defined(INTEL_MKL_VERSION) && (110100 < INTEL_MKL_VERSION)
!$ mkl_is_safe = .TRUE.
#elif defined (__INTEL_COMPILER) && defined (__MKL) && defined (__FFTW3)
#elif defined (__INTEL_COMPILER)
! If we have an Intel compiler (__INTEL_COMPILER is defined) then check the
! MKL version and make the appropriate action
!DEC$ IF DEFINED (INTEL_MKL_VERSION)
Expand All @@ -247,6 +250,7 @@ SUBROUTINE fftw3_do_init(wisdom_file)
!$ "Now exiting..."
!$ END IF
!$ END IF
#endif
#else
MARK_USED(wisdom_file)
#endif
Expand Down

0 comments on commit 130ab16

Please sign in to comment.