Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/aoloso/hybrid openmp #1655

Merged
merged 47 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7a65d1d
Added changes to MAPL develop to support the Component level OpenMP c…
aoloso Jan 7, 2022
df00fca
Added file OpenMP_Support.F90
aoloso Jan 7, 2022
6b9c9e6
Initial additions of changes for componet level OpenMP threading
aoloso Jan 27, 2022
ed98091
some cleaning up
aoloso Feb 4, 2022
8f0e802
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Feb 4, 2022
28b8a41
Remove Null() from MAPL_GridCompSpecs_ACG.py to fix the pointer corr…
aoloso Feb 11, 2022
f1d7dd5
Added the use of ESMF_InternalStateGet to obtain the list of the name…
aoloso Feb 17, 2022
db6bf62
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Mar 7, 2022
125ce44
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Mar 25, 2022
c81514c
Addedd entry point for phase 2 run method
aoloso Mar 29, 2022
5ac112d
Added chnages to divide local GOCART2 3D arrays among threads and cha…
aoloso Apr 18, 2022
77f23ef
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Apr 18, 2022
c2b781a
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Apr 19, 2022
627e370
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso May 9, 2022
fba525f
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Jun 7, 2022
ca88cb7
Removed => Null() from declaration in MAPL_GetHorzIJIndex to avoid ra…
aoloso Jun 7, 2022
6dc4a4b
Updated with develop
aoloso Jul 21, 2022
c371f8b
Added ranges for indices for pointer subsetting in OpenMP_Support.F90…
aoloso Aug 22, 2022
01a8848
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Aug 22, 2022
d6cf2e0
Added routine omp_driver for components to be run with OpenMP
aoloso Sep 2, 2022
bb68b9d
Moved OpenMP driver for component level threading into MAPL_Generic. …
aoloso Sep 2, 2022
7503cbd
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Sep 2, 2022
009ede1
Cleaned up omp_driver routine to remove the use of use_threads becaus…
aoloso Sep 2, 2022
cc566b9
Update base/MaplGrid.F90
aoloso Sep 6, 2022
8c090ac
Update generic/MAPL_Generic.F90
aoloso Sep 6, 2022
2d0bea2
Update generic/MaplComponent.F90
aoloso Sep 6, 2022
8b6f34a
Update generic/BaseFrameworkComponent.F90
aoloso Sep 6, 2022
664ff71
Update generic/MaplGenericComponent.F90
aoloso Sep 6, 2022
c45c48e
Modified MaplGrid.F90 to use __RC__ instead of rc=status and _VERIFY(…
aoloso Sep 6, 2022
5411291
Minor typo correction - added a missing closing parenthesis ')'
aoloso Sep 6, 2022
6405df0
Removed redundant code. Addedd accessprs for num threads and thread i…
aoloso Sep 7, 2022
e5aca34
Changes made to remove hardwiring of number of phases for mini grid c…
aoloso Sep 12, 2022
76cb2d9
Moved procedure make_subgridcomps from MaplGenericComponent.F90 to Op…
aoloso Sep 13, 2022
2b3a614
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Sep 13, 2022
d403bbc
Update base/MaplGrid.F90
aoloso Sep 13, 2022
89dd7de
Replaced all '__RC--' with '-RC'
aoloso Sep 13, 2022
5ee948c
Further clean up to remove commented code
aoloso Sep 13, 2022
d907ef5
Removed ESMFL_UnitsRadians from ESMFL_Mod.F90 and replaced it with MA…
aoloso Sep 14, 2022
2c84336
Modified CHANGELOG to capture ESMFL_UnitsRadians to MAPL_UnitsRadians…
aoloso Sep 14, 2022
d7f4c1f
Build with OpenMP by default. Move 'ASSERT' outside of master/end mas…
aoloso Sep 15, 2022
184fc36
Edits to MAPL_Generic to match develop
aoloso Sep 15, 2022
fbc3be9
Merge branch 'develop' into feature/aoloso/hybrid-openmp
mathomp4 Sep 16, 2022
8766224
Merge branch 'develop' into feature/aoloso/hybrid-openmp
aoloso Sep 20, 2022
b092514
Minor edits to BaseProfiler.F90 to to make variables checked by _ASSE…
aoloso Sep 22, 2022
33a048c
Added description about the changes made to support the component lev…
aoloso Sep 22, 2022
c486592
Updated CHANGELOG with descrition of changes made for hybrid
aoloso Sep 23, 2022
d986ecd
Update CHANGELOG.md
mathomp4 Sep 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Apps/MAPL_GridCompSpecs_ACG.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def emit_declare_pointers(self):
text = text + type
if kind:
text = text + '(kind=' + str(kind) + ')'
text = text +', pointer, ' + dimension + ' :: ' + MAPL_DataSpec.internal_name(self.args['short_name']) + ' => null()'
text = text +', pointer, ' + dimension + ' :: ' + MAPL_DataSpec.internal_name(self.args['short_name'])
return text

def emit_get_pointers(self):
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Removed ESMFL_UnitsRadians from ESMFL_Mod.F90 and replaced it with MAPL_UnitsRadians in InternalConstants.F90. Did a global search/replace. This avoid the circular dependency build error when ESMF_UnitsRadians is used in MaplGrid.F90

## [hybrid-openmp] - 2022-09-14

### Fixed

- Removed unnecessary DSO extension assert
Expand Down
2 changes: 1 addition & 1 deletion Tests/ExtDataDriverGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ subroutine run(this, rc)
integer :: status
integer :: userRc

call ESMF_GridCompRun(this%gc, userRC=userRC,__RC__)
call ESMF_GridCompRun(this%gc, userRC=userRC,_RC)
_VERIFY(userRC)
_RETURN(ESMF_SUCCESS)

Expand Down
80 changes: 40 additions & 40 deletions Tests/ExtDataRoot_GridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ SUBROUTINE Run_ ( GC, IMPORT, EXPORT, CLOCK, rc )
call ESMF_UserCompGetInternalState(gc,wrap_name,synthWrap,status)
_VERIFY(status)
synth => synthWrap%ptr
call ESMF_GridCompGet(GC,grid=grid,__RC__)
call MAPL_GetPointer(internal,ptrR4,'lons',__RC__)
call ESMF_GridCompGet(GC,grid=grid,_RC)
call MAPL_GetPointer(internal,ptrR4,'lons',_RC)
call ESMF_GridGetCoord (Grid, coordDim=1, localDE=0, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
farrayPtr=ptrR8, rc=status)
ptrR4=ptrR8
call MAPL_GetPointer(internal,ptrR4,'lats',__RC__)
call MAPL_GetPointer(internal,ptrR4,'lats',_RC)
call ESMF_GridGetCoord (Grid, coordDim=2, localDE=0, &
staggerloc=ESMF_STAGGERLOC_CENTER, &
farrayPtr=ptrR8, rc=status)
Expand All @@ -355,17 +355,17 @@ SUBROUTINE Run_ ( GC, IMPORT, EXPORT, CLOCK, rc )

case(RunModeGenerateExports)

call FillState(internal,export,currTime,grid,synth,__RC__)
call FillState(internal,export,currTime,grid,synth,_RC)

case(runModecompareImports)
call FillState(internal,export,currTime,grid,synth,__RC__)
call CompareState(import,export,0.001,__RC__)
call FillState(internal,export,currTime,grid,synth,_RC)
call CompareState(import,export,0.001,_RC)

case(runModeFillImport)
! Nothing to do, we are just letting ExtData run

case(runModeFillExportFromImport)
call CopyState(import,export,__RC__)
call CopyState(import,export,_RC)

end select

Expand Down Expand Up @@ -516,29 +516,29 @@ subroutine CopyState(inState,outState,rc)
character(len=ESMF_MAXSTR), allocatable :: outNameList(:)
type(ESMF_Field) :: expf,impf

call ESMF_StateGet(inState,itemcount=itemCountIn,__RC__)
call ESMF_StateGet(inState,itemcount=itemCountIn,_RC)
allocate(InNameList(itemCountIn),stat=status)
_VERIFY(status)
call ESMF_StateGet(inState,itemNameList=InNameList,__RC__)
call ESMF_StateGet(inState,itemNameList=InNameList,_RC)

call ESMF_StateGet(outState,itemcount=ItemCountOut,__RC__)
call ESMF_StateGet(outState,itemcount=ItemCountOut,_RC)
allocate(outNameList(ItemCountOut),stat=status)
_VERIFY(status)
call ESMF_StateGet(outState,itemNameList=outNameList,__RC__)
call ESMF_StateGet(outState,itemNameList=outNameList,_RC)

_ASSERT(itemCountIn == itemCountOut,'needs informative message')
call ESMF_StateGet(inState,itemNameList=inNameList,__RC__)
call ESMF_StateGet(inState,itemNameList=inNameList,_RC)
do i=1,itemCountIn
call ESMF_StateGet(inState,trim(inNameList(i)),impf,__RC__)
call ESMF_StateGet(outState,trim(outNameList(i)),expf,__RC__)
call ESMF_FieldGet(impf,rank=rank,__RC__)
call ESMF_StateGet(inState,trim(inNameList(i)),impf,_RC)
call ESMF_StateGet(outState,trim(outNameList(i)),expf,_RC)
call ESMF_FieldGet(impf,rank=rank,_RC)
if (rank==2) then
call MAPL_GetPointer(inState,IMptr2,inNameList(i),__RC__)
call MAPL_GetPointer(outState,Exptr2,inNameList(i),alloc=.true.,__RC__)
call MAPL_GetPointer(inState,IMptr2,inNameList(i),_RC)
call MAPL_GetPointer(outState,Exptr2,inNameList(i),alloc=.true.,_RC)
EXptr2=IMptr2
else if (rank==3) then
call MAPL_GetPointer(inState,IMptr3,inNameList(i),__RC__)
call MAPL_GetPointer(outState,EXptr3,inNameList(i),alloc=.true.,__RC__)
call MAPL_GetPointer(inState,IMptr3,inNameList(i),_RC)
call MAPL_GetPointer(outState,EXptr3,inNameList(i),alloc=.true.,_RC)
EXptr3=IMptr3
end if
end do
Expand Down Expand Up @@ -566,25 +566,25 @@ subroutine FillState(inState,outState,time,grid,Synth,rc)
character(len=:), pointer :: fexpr
integer :: i1,in,j1,jn,ldims(3),i,j

call MAPL_GridGet(grid,localcellcountperdim=ldims,__RC__)
call MAPL_GridGet(grid,localcellcountperdim=ldims,_RC)
call MAPL_Grid_Interior(grid,i1,in,j1,jn)
call ESMF_StateGet(outState,itemcount=itemCount,__RC__)
call ESMF_StateGet(outState,itemcount=itemCount,_RC)
allocate(outNameList(itemCount),stat=status)
_VERIFY(status)
call ESMF_StateGet(outState,itemNameList=outNameList,__RC__)
call ESMF_StateGet(outState,itemNameList=outNameList,_RC)

call MAPL_GetPointer(inState,exPtr2,'time',rc=status)
_VERIFY(status)
exPtr2=synth%tFunc%evaluateTime(Time,rc=status)
_VERIFY(status)

call MAPL_GetPointer(inState,exPtr2,'i_index',__RC__)
call MAPL_GetPointer(inState,exPtr2,'i_index',_RC)
do j = 1,ldims(2)
do i=1,ldims(1)
exPtr2(i,j)=i1+i-1
enddo
enddo
call MAPL_GetPointer(inState,exPtr2,'j_index',__RC__)
call MAPL_GetPointer(inState,exPtr2,'j_index',_RC)
do i = 1,ldims(1)
do j=1,ldims(2)
exPtr2(i,j)=j1+j-1
Expand Down Expand Up @@ -636,22 +636,22 @@ subroutine CompareState(State1,State2,tol,rc)
logical, allocatable :: foundDiff(:)
type(ESMF_Field) :: Field1,Field2

call ESMF_StateGet(State1,itemcount=itemCount,__RC__)
call ESMF_StateGet(State1,itemcount=itemCount,_RC)
allocate(NameList(itemCount),stat=status)
_VERIFY(status)
allocate(foundDiff(itemCount),stat=status)
_VERIFY(status)
call ESMF_StateGet(State1,itemNameList=NameList,__RC__)
call ESMF_StateGet(State1,itemNameList=NameList,_RC)
do ii=1,itemCount
call ESMF_StateGet(State1,trim(nameList(ii)),field1,__RC__)
call ESMF_StateGet(State2,trim(nameList(ii)),field2,__RC__)
call ESMF_FieldGet(field1,rank=rank1,__RC__)
call ESMF_FieldGet(field1,rank=rank2,__RC__)
call ESMF_StateGet(State1,trim(nameList(ii)),field1,_RC)
call ESMF_StateGet(State2,trim(nameList(ii)),field2,_RC)
call ESMF_FieldGet(field1,rank=rank1,_RC)
call ESMF_FieldGet(field1,rank=rank2,_RC)
_ASSERT(rank1==rank2,'needs informative message')
foundDiff(ii)=.false.
if (rank1==2) then
call MAPL_GetPointer(state1,ptr2_1,trim(nameList(ii)),__RC__)
call MAPL_GetPointer(state2,ptr2_2,trim(nameList(ii)),__RC__)
call MAPL_GetPointer(state1,ptr2_1,trim(nameList(ii)),_RC)
call MAPL_GetPointer(state2,ptr2_2,trim(nameList(ii)),_RC)
do i=1,size(ptr2_1,1)
do j=1,size(ptr2_1,2)
if (abs(ptr2_1(i,j)-ptr2_2(i,j)) .gt. tol) then
Expand All @@ -661,8 +661,8 @@ subroutine CompareState(State1,State2,tol,rc)
enddo
enddo
else if (rank1==3) then
call MAPL_GetPointer(state1,ptr3_1,trim(nameList(ii)),__RC__)
call MAPL_GetPointer(state2,ptr3_2,trim(nameList(ii)),__RC__)
call MAPL_GetPointer(state1,ptr3_1,trim(nameList(ii)),_RC)
call MAPL_GetPointer(state2,ptr3_2,trim(nameList(ii)),_RC)
lb=lbound(ptr3_1)
ub=ubound(ptr3_1)
do i=1,size(ptr3_1,1)
Expand Down Expand Up @@ -700,23 +700,23 @@ subroutine ForceAllocation(state,rc)
type (ESMF_StateItem_Flag), allocatable :: itemTypeList(:)
type(ESMF_Field) :: Field

call ESMF_StateGet(State,itemcount=itemCount,__RC__)
call ESMF_StateGet(State,itemcount=itemCount,_RC)
allocate(NameList(itemCount),stat=status)
_VERIFY(status)
allocate(itemTypeList(itemCount),stat=status)
_VERIFY(status)
call ESMF_StateGet(State,itemNameList=NameList,itemTypeList=itemTypeList,__RC__)
call ESMF_StateGet(State,itemNameList=NameList,itemTypeList=itemTypeList,_RC)
if (itemCount == 0) then
_RETURN(ESMF_SUCCESS)
end if
do ii=1,itemCount
if (itemTypeList(ii)==ESMF_STATEITEM_FIELD) then
call ESMF_StateGet(State,trim(nameList(ii)),field,__RC__)
call ESMF_AttributeGet(field,name='DIMS',value=dims,__RC__)
call ESMF_StateGet(State,trim(nameList(ii)),field,_RC)
call ESMF_AttributeGet(field,name='DIMS',value=dims,_RC)
if (dims==MAPL_DimsHorzOnly) then
call MAPL_GetPointer(state,ptr2d,trim(nameList(ii)),alloc=.true.,__RC__)
call MAPL_GetPointer(state,ptr2d,trim(nameList(ii)),alloc=.true.,_RC)
else if (dims==MAPL_DimsHorzVert) then
call MAPL_GetPointer(state,ptr3d,trim(nameList(ii)),alloc=.true.,__RC__)
call MAPL_GetPointer(state,ptr3d,trim(nameList(ii)),alloc=.true.,_RC)
end if
end if
enddo
Expand Down
6 changes: 4 additions & 2 deletions base/Base/Base_Base_implementation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,6 @@ module subroutine MAPL_StateAddField(State, Field, RC)
type(ESMF_Field) :: Fields(1)
logical :: haveAttr


fields(1) = field
call ESMF_StateAdd(state, fields, RC=status)
_VERIFY(STATUS)
Expand Down Expand Up @@ -3021,6 +3020,7 @@ module subroutine MAPL_GetHorzIJIndex(npts,II,JJ,lon,lat,lonR8,latR8,Grid, rc)
real(ESMF_KIND_R8), allocatable :: target_lons(:),target_lats(:)
real(ESMF_KIND_R8), allocatable :: corner_lons(:,:),corner_lats(:,:),center_lats(:,:),center_lons(:,:)
type(ESMF_CoordSys_Flag) :: coordSys
character(len=ESMF_MAXSTR) :: grid_type

! if the grid is present then we can just get the prestored edges and the dimensions of the grid
! this also means we are running on a distributed grid
Expand Down Expand Up @@ -3049,7 +3049,9 @@ module subroutine MAPL_GetHorzIJIndex(npts,II,JJ,lon,lat,lonR8,latR8,Grid, rc)

_ASSERT(localSearch,"Global Search for IJ not implemented")

if (im_world*6==jm_world) then
!AOO change tusing GridType atribute if (im_world*6==jm_world) then
call ESMF_AttributeGet(grid, name='GridType', value=grid_type, _RC)
if(trim(grid_type) == "Cubed-Sphere") then
call ESMF_GridGetCoord(grid,coordDim=1, localDe=0, &
staggerloc=ESMF_STAGGERLOC_CENTER, fArrayPtr = lons, rc=status)
_VERIFY(STATUS)
Expand Down
11 changes: 4 additions & 7 deletions base/ESMFL_Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ module ESMFL_MOD
!ALT These need to be changed!!! values here are just to compile
!

!DEFINED PARAMETERS:
integer, parameter, public :: ESMFL_UnitsRadians = 99

!PUBLIC MEMBER FUNCTIONS:
public ESMFL_StateGetField
public ESMFL_StateGetFieldArray
Expand Down Expand Up @@ -1070,14 +1067,14 @@ subroutine ESMFL_FieldRegrid(src, dst, RC)
call ESMFL_GridCoordGet( DSTGRID, LATS , &
Name = "Latitude" , &
Location = ESMF_CELL_CENTER , &
Units = ESMFL_UnitsRadians , &
Units = MAPL_UnitsRadians , &
RC = STATUS )
_VERIFY(STATUS)

call ESMFL_GridCoordGet( DSTGRID, LONS , &
Name = "Longitude" , &
Location = ESMF_CELL_CENTER , &
Units = ESMFL_UnitsRadians , &
Units = MAPL_UnitsRadians , &
RC = STATUS )
_VERIFY(STATUS)

Expand Down Expand Up @@ -2131,7 +2128,7 @@ subroutine Bundle_Prep_ (srcBUN, dstBUN, only_vars)
call ESMFL_GridCoordGet( srcGrid, llats , &
Name = "Latitude" , &
Location = ESMF_STAGGERLOC_CENTER , &
Units = ESMFL_UnitsRadians , &
Units = MAPL_UnitsRadians , &
RC = STATUS )
if (status /= ESMF_SUCCESS) call ESMFL_FailedRC(mype,Iam)
allocate(gLats(ims_world,jms_world), stat=status)
Expand All @@ -2148,7 +2145,7 @@ subroutine Bundle_Prep_ (srcBUN, dstBUN, only_vars)
call ESMFL_GridCoordGet( srcGrid, llons , &
Name = "Longitude" , &
Location = ESMF_STAGGERLOC_CENTER , &
Units = ESMFL_UnitsRadians , &
Units = MAPL_UnitsRadians , &
RC = STATUS )
if (status /= ESMF_SUCCESS) call ESMFL_FailedRC(mype,Iam)
allocate(gLons(ims_world,jms_world), stat=status)
Expand Down
9 changes: 6 additions & 3 deletions base/GetPointer.H
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,28 @@
_VERIFY(STATUS)
endif
endif

!ALT I dont think the next lines are needed anymore
#if 0
block
integer :: DIMS
call ESMF_AttributeGet(field, name='VLOCATION', value=DIMS, rc=status)
if (STATUS==ESMF_SUCCESS) then
if (DIMS == MAPL_VLocationEdge .and. associated(ptr)) then
#if RANK_ == 3
call AdjustPtrBounds(ptr, ptr, 1, size(ptr,1), 1, size(ptr,2), 0, size(ptr,3)-1)
#elif RANK_ == 1
call AdjustPtrBounds(ptr, ptr, 0, size(ptr,1)-1)
#endif
end if
end if
end block
#endif

_RETURN(ESMF_SUCCESS)

end subroutine SUB_

#undef DIMENSIONS_
#undef RANK_
#undef RANKSTR_

8 changes: 4 additions & 4 deletions base/HorizontalFluxRegridder.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ logical function supports(spec, unusable, rc)
supports = (spec%regrid_method == REGRID_METHOD_CONSERVE_HFLUX)
if (.not. supports) return

call MAPL_GridGet(spec%grid_in, localCellCountPerDim=counts_in, __RC__)
call MAPL_GridGet(spec%grid_out, localCellCountPerDim=counts_out, __RC__)
call MAPL_GridGet(spec%grid_in, localCellCountPerDim=counts_in, _RC)
call MAPL_GridGet(spec%grid_out, localCellCountPerDim=counts_out, _RC)

supports = all(mod(counts_in(1:2), counts_out(1:2)) == 0) .or. all(mod(counts_out, counts_in) == 0)

Expand All @@ -78,11 +78,11 @@ subroutine initialize_subclass(this, unusable, rc)

associate (IM_in => this%IM_in, JM_in => this%JM_in, IM_out => this%IM_out, JM_out => this%JM_out)

call MAPL_GridGet(grid_in, localCellCountPerDim=counts, __RC__)
call MAPL_GridGet(grid_in, localCellCountPerDim=counts, _RC)
IM_in = counts(1)
JM_in = counts(2)

call MAPL_GridGet(grid_out, localCellCountPerDim=counts, __RC__)
call MAPL_GridGet(grid_out, localCellCountPerDim=counts, _RC)
IM_out = counts(1)
JM_out = counts(2)

Expand Down
Loading