From e25d65a139805c8b2279c42ad3fc1179da2b9461 Mon Sep 17 00:00:00 2001 From: carcava Date: Wed, 11 Mar 2020 09:43:06 +0100 Subject: [PATCH] - fix for CPU only compilation --- CPV/src/chargedensity.f90 | 6 +++--- CPV/src/cp_interfaces.f90 | 2 -- CPV/src/cplib.f90 | 2 +- UtilXlib/device_helper.f90 | 22 ++++++++++++++++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CPV/src/chargedensity.f90 b/CPV/src/chargedensity.f90 index 3a8631150..d8f75221c 100644 --- a/CPV/src/chargedensity.f90 +++ b/CPV/src/chargedensity.f90 @@ -1136,12 +1136,13 @@ CONTAINS END SUBROUTINE END SUBROUTINE rhov -#if defined (__CUDA) SUBROUTINE rhoofr_host & ( nfi, c_bgrp, irb, eigrb, bec_bgrp, dbec, rhovan, rhor, drhor, rhog, drhog, rhos, & enl, denl, ekin, dekin, tstress, ndwwf ) USE kinds, ONLY: DP +#if defined (__CUDA) USE cudafor +#endif USE cp_interfaces IMPLICIT NONE INTEGER nfi @@ -1160,10 +1161,9 @@ SUBROUTINE rhoofr_host & REAL(DP) denl(3,3), dekin(6) LOGICAL, OPTIONAL, INTENT(IN) :: tstress INTEGER, OPTIONAL, INTENT(IN) :: ndwwf - COMPLEX(DP), ALLOCATABLE, DEVICE :: c(:,:) + COMPLEX(DP), ALLOCATABLE DEVICEATTR :: c(:,:) ALLOCATE( c, SOURCE=c_bgrp ) CALL rhoofr(nfi, c_bgrp, c, bec_bgrp, dbec, rhovan, rhor, & drhor, rhog, drhog, rhos, enl, denl, ekin, dekin, tstress, ndwwf ) DEALLOCATE( c ) END SUBROUTINE rhoofr_host -#endif diff --git a/CPV/src/cp_interfaces.f90 b/CPV/src/cp_interfaces.f90 index 03695a38b..2492f08e6 100644 --- a/CPV/src/cp_interfaces.f90 +++ b/CPV/src/cp_interfaces.f90 @@ -271,7 +271,6 @@ LOGICAL, OPTIONAL, INTENT(IN) :: tstress INTEGER, OPTIONAL, INTENT(IN) :: ndwwf END SUBROUTINE rhoofr_cp -#if defined (__CUDA) SUBROUTINE rhoofr_host & ( nfi, c_bgrp, irb, eigrb, bec, dbec, rhovan, rhor, drhor, rhog, drhog, rhos, enl, denl, ekin, dekin, tstress, ndwwf ) USE kinds, ONLY: DP @@ -293,7 +292,6 @@ LOGICAL, OPTIONAL, INTENT(IN) :: tstress INTEGER, OPTIONAL, INTENT(IN) :: ndwwf END SUBROUTINE rhoofr_host -#endif END INTERFACE INTERFACE checkrho diff --git a/CPV/src/cplib.f90 b/CPV/src/cplib.f90 index 2f4659dc0..37baba962 100644 --- a/CPV/src/cplib.f90 +++ b/CPV/src/cplib.f90 @@ -1644,7 +1644,7 @@ end subroutine dylmr2_ ! sk = 0.0d0 !$omp parallel do reduction(+:sk) default(none) & -!$omp shared(sk,c,g2kin,gstart,ngw,n,f) private(i,ig,rsum) +!$omp shared(c,g2kin,gstart,ngw,n,f) private(i,ig,rsum) DO i=1,n rsum = 0.0d0 DO ig=gstart,ngw diff --git a/UtilXlib/device_helper.f90 b/UtilXlib/device_helper.f90 index f476a7ac3..99c725f77 100644 --- a/UtilXlib/device_helper.f90 +++ b/UtilXlib/device_helper.f90 @@ -35,35 +35,49 @@ MODULE device_helper CONTAINS SUBROUTINE sync_to_device_c2d( h, d ) +#if defined(__CUDA) COMPLEX(DP), INTENT(IN) :: d(:,:) COMPLEX(DP), INTENT(OUT) :: h(:,:) -#if defined(__CUDA) ATTRIBUTES(DEVICE) :: d h = d +#else + COMPLEX(DP) :: d(:,:) + COMPLEX(DP) :: h(:,:) + ! do nothing #endif END SUBROUTINE SUBROUTINE sync_to_host_c2d( h, d ) +#if defined(__CUDA) COMPLEX(DP), INTENT(OUT) :: d(:,:) COMPLEX(DP), INTENT(IN) :: h(:,:) -#if defined(__CUDA) ATTRIBUTES(DEVICE) :: d d = h +#else + COMPLEX(DP) :: d(:,:) + COMPLEX(DP) :: h(:,:) + ! do nothing #endif END SUBROUTINE SUBROUTINE sync_to_device_r2d( h, d ) +#if defined(__CUDA) REAL(DP), INTENT(IN) :: d(:,:) REAL(DP), INTENT(OUT) :: h(:,:) -#if defined(__CUDA) ATTRIBUTES(DEVICE) :: d h = d +#else + REAL(DP) :: d(:,:) + REAL(DP) :: h(:,:) #endif END SUBROUTINE SUBROUTINE sync_to_host_r2d( h, d ) +#if defined(__CUDA) REAL(DP), INTENT(OUT) :: d(:,:) REAL(DP), INTENT(IN) :: h(:,:) -#if defined(__CUDA) ATTRIBUTES(DEVICE) :: d d = h +#else + REAL(DP) :: d(:,:) + REAL(DP) :: h(:,:) #endif END SUBROUTINE