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

Fixes from M1 work #1439

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed duration of the clock to be the smaller of the user specified duration and (END_DATE - currTime)
- Fixes for compiling on M1 Macs (remove REAL128)
- Fix for CMake when `esmf` is already a target

### Added
- New cmake option USE_EXTDATA2G to enable the next generation of ExtData for development, by default uses 1st generation ExtData

- New cmake option USE_EXTDATA2G to enable the next generation of ExtData for development, by default uses 1st generation ExtData
- MAPL_ESMFFieldBundleRead/Write modules are now available in when using MAPL

### Changed
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ if (NOT Baselibs_FOUND)
add_definitions(-DH5_HAVE_PARALLEL)
endif()

find_package(ESMF MODULE REQUIRED)
if (NOT TARGET esmf)
find_package(ESMF MODULE REQUIRED)
endif ()
endif ()

if (BUILD_WITH_PFLOGGER)
Expand Down
43 changes: 23 additions & 20 deletions profiler/MeterNode.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module MAPL_MeterNode
use, intrinsic :: iso_fortran_env, only: REAL64, REAL128
use, intrinsic :: iso_fortran_env, only: REAL64
use MAPL_AbstractMeter
use MAPL_AbstractMeterNode
use MAPL_MeterNodeVector
Expand Down Expand Up @@ -67,10 +67,10 @@ module MAPL_MeterNode
interface MeterNodeIterator
module procedure new_MeterNodeIterator
end interface MeterNodeIterator


integer, parameter :: NOT_FOUND = -1

contains


Expand All @@ -79,7 +79,7 @@ function new_MeterNode(name, meter, depth) result(tree)
character(*), intent(in) :: name
class(AbstractMeter), intent(in) :: meter
integer, optional, intent(in) :: depth

tree%name = name
tree%meter = meter

Expand All @@ -99,14 +99,14 @@ function get_meter(this) result(meter)
class (MeterNode), target, intent(in) :: this
meter => this%meter
end function get_meter


function get_name(this) result(name)
character(:), pointer :: name
class (MeterNode), target, intent(in) :: this
name => this%name
end function get_name


function get_inclusive(this) result(inclusive)
real(kind=REAL64) :: inclusive
Expand All @@ -121,11 +121,14 @@ function get_exclusive(this) result(exclusive)

type (MeterNodevectorIterator) :: iter
class (AbstractMeterNode), pointer :: child
real(kind=REAL128) :: tmp
real(kind=REAL64) :: tmp

! Subtract time of submeters from time of node meter.
! Previously, this used 128-bit precision to avoid negative
! exclusive times due to roundoff. But the GNU on M1 and NVHPC do
! not allow REAL128. So tmp is now 64-bit and we use a max(tmp,0)
! below to try and cap negatives

! Subtract time of submeters from time of node meter. Note the
! use of 128-bit precision to avoid negative exclusive times due
! to roundoff.
tmp = this%get_inclusive()

iter = this%children%begin()
Expand All @@ -135,7 +138,7 @@ function get_exclusive(this) result(exclusive)
call iter%next()
end do

exclusive = tmp
exclusive = max(tmp, 0.0_REAL64)
end function get_exclusive


Expand Down Expand Up @@ -178,7 +181,7 @@ function get_child(this, name) result(child)
character(*), intent(in) :: name

integer :: idx

idx = this%find_child(name)
if (idx /= NOT_FOUND) then
child => this%children%at(idx)
Expand Down Expand Up @@ -232,7 +235,7 @@ recursive integer function get_num_nodes(this) result(num_nodes)
type (MeterNodeVectorIterator) :: iter

class (AbstractMeterNode), pointer :: child

num_nodes = 1
iter = this%children%begin()
do while (iter /= this%children%end())
Expand Down Expand Up @@ -271,7 +274,7 @@ function begin(this) result(iterator)
allocate(iterator, source=MeterNodeIterator(this))

end function begin



function end(this) result(iterator)
Expand All @@ -293,7 +296,7 @@ function end(this) result(iterator)

end function end


recursive subroutine next(this)
class (MeterNodeIterator), intent(inout) :: this
class (AbstractMeterNode), pointer :: current_child
Expand All @@ -318,15 +321,15 @@ recursive subroutine next(this)
deallocate(this%iterator_of_current_child)
call this%iterator_over_children%next()
if (this%iterator_over_children == this%reference%children%end()) then ! done
deallocate(this%iterator_over_children)
deallocate(this%iterator_over_children)
else
current_child => this%iterator_over_children%get()
this%iterator_of_current_child = current_child%begin() ! always at least one node
this%current => this%iterator_of_current_child%get()
end if
end if
end if

end subroutine next


Expand Down Expand Up @@ -360,7 +363,7 @@ logical function equals(a, b)
type is (MeterNodeIterator)
equals = associated(a%reference, b%reference)
if (.not. equals) return

equals = associated(a%current) .eqv. associated(b%current)
if (.not. equals) return

Expand Down Expand Up @@ -423,7 +426,7 @@ recursive subroutine accumulate(this, other)
call t%reset()
end if
call t%accumulate(other%get_meter())

! recurse over children of other
iter = other%begin()
call iter%next() ! skip top node (already handled)
Expand All @@ -434,5 +437,5 @@ recursive subroutine accumulate(this, other)

end subroutine accumulate


end module MAPL_MeterNode