Skip to content

Commit

Permalink
Vectorize a section of VariousWaves_Init (#602)
Browse files Browse the repository at this point in the history
* Add Intel profiling flag stubs to CMake
* Vectorize VariousWaves_Init
  • Loading branch information
rafmudaf authored Nov 24, 2020
1 parent ee38ce8 commit f4e1192
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 35 deletions.
16 changes: 16 additions & 0 deletions cmake/OpenfastFortranOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ macro(set_fast_intel_fortran_posix)
endif()

check_f2008_features()

### Intel profiling flags

# https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/optimization-report-options/qopt-report-qopt-report.html
# phases: vec, par, openmp
# set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -qopt-report-phase=vec,openmp -qopt-report=5")
# set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -qopt-report-routine=Create_Augmented_Ln2_Src_Mesh") # Create_Augmented_Ln2_Src_Mesh, Morison_CalcOutput, VariousWaves_Init

# https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/output-debug-and-precompiled-header-pch-options/debug-linux-and-macos.html
# set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -debug all")
# set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -debug inline-debug-info")

# Intel processor feature sets
# https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/code-generation-options/xhost-qxhost.html
# set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -xHOST") # Use feature set for CPU used to compile
# set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -xSKYLAKE-AVX512") # Use Eagle processor feature set
endmacro(set_fast_intel_fortran_posix)

#
Expand Down
60 changes: 25 additions & 35 deletions modules/hydrodyn/src/Waves.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1922,44 +1922,34 @@ SUBROUTINE VariousWaves_Init ( InitInp, InitOut, ErrStat, ErrMsg )
! the mean sea level are left unchanged; below the seabed or above the
! mean sea level, the wave kinematics are zero:


DO I = 0,InitOut%NStepWave-1 ! Loop through all time steps
K = 1
DO J = 1,InitInp%NWaveKin ! Loop through all points where the incident wave kinematics will be computed

InitOut%PWaveDynP0(I,J ) = 0.0 ! PWaveDynP0BPz0 (I,J)
InitOut%PWaveVel0 (I,J,1) = 0.0 !PWaveVel0HxiPz0(I,J)
InitOut%PWaveVel0 (I,J,2) = 0.0 !PWaveVel0HyiPz0(I,J)
InitOut%PWaveVel0 (I,J,3) = 0.0 !PWaveVel0VPz0 (I,J)
InitOut%PWaveAcc0 (I,J,1) = 0.0 !PWaveAcc0HxiPz0(I,J)
InitOut%PWaveAcc0 (I,J,2) = 0.0 !PWaveAcc0HyiPz0(I,J)
InitOut%PWaveAcc0 (I,J,3) = 0.0 !PWaveAcc0VPz0 (I,J)


! NOTE: We test to 0 instead of MSL2SWL because the locations of WaveKinzi and WtrDpth have already been adjusted using MSL2SWL
IF ( ( InitInp%WaveKinzi(J) < -InitInp%WtrDpth ) .OR. ( InitInp%WaveKinzi(J) > 0.0 ) ) THEN ! .TRUE. if the elevation of the point defined by WaveKinzi(J) lies below the seabed or above mean sea level (exclusive)

InitOut%WaveDynP(I,J ) = 0.0
InitOut%WaveVel (I,J,:) = 0.0
InitOut%WaveAcc (I,J,:) = 0.0

ELSE ! The elevation of the point defined by WaveKinzi(J) must lie between the seabed and the mean sea level (inclusive)

InitOut%WaveDynP(I,J ) = WaveDynP0B (I,K)
InitOut%WaveVel (I,J,1) = WaveVel0Hxi(I,K)
InitOut%WaveVel (I,J,2) = WaveVel0Hyi(I,K)
InitOut%WaveVel (I,J,3) = WaveVel0V (I,K)
InitOut%WaveAcc (I,J,1) = WaveAcc0Hxi(I,K)
InitOut%WaveAcc (I,J,2) = WaveAcc0Hyi(I,K)
InitOut%WaveAcc (I,J,3) = WaveAcc0V (I,K)

K = K + 1
END IF
InitOut%PWaveDynP0(:,:) = 0.0
InitOut%PWaveVel0 (:,:,:) = 0.0
InitOut%PWaveAcc0 (:,:,:) = 0.0
K = 1
DO J = 1,InitInp%NWaveKin ! Loop through all points where the incident wave kinematics will be computed

IF ( ( InitInp%WaveKinzi(J) < -InitInp%WtrDpth ) .OR. ( InitInp%WaveKinzi(J) > 0.0 ) ) THEN
! .TRUE. if the elevation of the point defined by WaveKinzi(J) lies below the seabed or above mean sea level (exclusive)
! NOTE: We test to 0 instead of MSL2SWL because the locations of WaveKinzi and WtrDpth have already been adjusted using MSL2SWL

END DO ! J - All points where the incident wave kinematics will be computed
InitOut%WaveDynP(:,J ) = 0.0
InitOut%WaveVel (:,J,:) = 0.0
InitOut%WaveAcc (:,J,:) = 0.0

END DO ! I - All time steps
ELSE
! The elevation of the point defined by WaveKinzi(J) must lie between the seabed and the mean sea level (inclusive)

InitOut%WaveDynP(:,J ) = WaveDynP0B(:,K)
InitOut%WaveVel (:,J,1) = WaveVel0Hxi(:,K)
InitOut%WaveVel (:,J,2) = WaveVel0Hyi(:,K)
InitOut%WaveVel (:,J,3) = WaveVel0V(:,K)
InitOut%WaveAcc (:,J,1) = WaveAcc0Hxi(:,K)
InitOut%WaveAcc (:,J,2) = WaveAcc0Hyi(:,K)
InitOut%WaveAcc (:,J,3) = WaveAcc0V(:,K)
K = K + 1
END IF

END DO ! J - All points where the incident wave kinematics will be computed

! CASE ( 1 ) ! Vertical stretching.

Expand Down

0 comments on commit f4e1192

Please sign in to comment.