Log the pre-mapping memory budget. Always logs the host-side
allocation growth (ADVISORY — includes host-only I/O buffers +
library pages, NOT a device estimate); when the device queries
succeed it also logs the device number + free/total and latches
the free-memory snapshot that mem_log_device_actuals turns
into the measured mapping delta. Warns when the host growth
(a conservative upper bound on what enter_data can map)
exceeds 95% of free device memory — the regime where
enter_data is likely to abort.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | label | |||
| integer(kind=int64), | intent(in) | :: | host_growth_bytes |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | devnum | ||||
| integer(kind=int64), | private | :: | free_b | ||||
| integer(kind=int64), | private | :: | total_b |
subroutine mem_log_state_budget(label, host_growth_bytes) !! Log the pre-mapping memory budget. Always logs the host-side !! allocation growth (ADVISORY — includes host-only I/O buffers + !! library pages, NOT a device estimate); when the device queries !! succeed it also logs the device number + free/total and latches !! the free-memory snapshot that `mem_log_device_actuals` turns !! into the measured mapping delta. Warns when the host growth !! (a conservative upper bound on what `enter_data` can map) !! exceeds 95% of free device memory — the regime where !! `enter_data` is likely to abort. character(len=*), intent(in) :: label integer(int64), intent(in) :: host_growth_bytes integer(int64) :: free_b, total_b integer :: devnum call logger%info("Memory budget ("//trim(label)//"): host allocations across setup ~ "// & mem_format_bytes(host_growth_bytes)// & " (RSS growth; advisory, not a device estimate)") free_b = mem_device_free_bytes() total_b = mem_device_total_bytes() if (free_b < 0_int64 .or. total_b < 0_int64) return ! CPU build. ! Baseline for the measured mapping delta. The property query ! above already forced CUDA context creation, so the delta across ! enter_data excludes the ~300-500 MB context cost. free_before_map = free_b devnum = device_num() call logger%info(" device "//to_string(devnum)//" free before mapping: "// & mem_format_bytes(free_b)//" of "//mem_format_bytes(total_b)// & " (host-growth upper bound: "// & mem_format_bytes(host_growth_bytes)//")") if (real(host_growth_bytes, wp) > 0.95_wp*real(free_b, wp)) then call logger%warning("device memory likely insufficient — mapping <= "// & mem_format_bytes(host_growth_bytes)//" with only "// & mem_format_bytes(free_b)//" free") end if end subroutine mem_log_state_budget