alpaka icon indicating copy to clipboard operation
alpaka copied to clipboard

replace reading from `/proc/meminfo` with call to `sysconf()`

Open fwyzard opened this issue 2 years ago • 2 comments

On Linux, getFreeGlobalMemSizeBytes() is implemented parsing /proc/meminfo: https://github.com/alpaka-group/alpaka/blob/f27d78c23c22f4eb5044a39cbfa60360ad1cd129/include/alpaka/dev/cpu/SysInfo.hpp#L220-L245

I would suggest replacing it with reading the number of free pages from sysconf(), for example:

#    if defined(_SC_AVPHYS_PAGES)
                return static_cast<std::size_t>(sysconf(_SC_AVPHYS_PAGES)) * getPageSize();
#    else       
                // this is legacy and only used as fallback
                return static_cast<std::size_t>(get_avphys_pages()) * getPageSize();
#    endif      

fwyzard avatar Aug 09 '22 07:08 fwyzard

To clarify: if people tell me it's OK to make this change, I'm happy to provide the pull request.

fwyzard avatar Aug 09 '22 08:08 fwyzard

See #1776.

fwyzard avatar Aug 09 '22 14:08 fwyzard