From 8e43c64ca96a0dc8f49ccd3b04dc2df696fa7aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 12 May 2022 18:25:52 +0200 Subject: [PATCH 1/3] #1513: use `mallinfo2` when available --- cmake/check_system_functions.cmake | 1 + cmake_config.h.in | 1 + src/vt/utils/memory/memory_usage.cc | 18 +++++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmake/check_system_functions.cmake b/cmake/check_system_functions.cmake index b29083333b..14aa261bed 100644 --- a/cmake/check_system_functions.cmake +++ b/cmake/check_system_functions.cmake @@ -22,6 +22,7 @@ check_function_exists(sysconf vt_has_sysconf) set(CMAKE_REQUIRED_INCLUDES "malloc.h") check_function_exists(mallinfo vt_has_mallinfo) +check_function_exists(mallinfo2 vt_has_mallinfo2) set(CMAKE_REQUIRED_INCLUDES "sys/resource.h") check_function_exists(getrusage vt_has_getrusage) diff --git a/cmake_config.h.in b/cmake_config.h.in index a71513913a..686c98e95e 100644 --- a/cmake_config.h.in +++ b/cmake_config.h.in @@ -82,6 +82,7 @@ #cmakedefine vt_has_pclose #cmakedefine vt_has_sbrk #cmakedefine vt_has_mallinfo +#cmakedefine vt_has_mallinfo2 #cmakedefine vt_has_getrusage #cmakedefine vt_has_sysinfo #cmakedefine vt_has_mach_task_self diff --git a/src/vt/utils/memory/memory_usage.cc b/src/vt/utils/memory/memory_usage.cc index 92bf78e672..2f2ce79de1 100644 --- a/src/vt/utils/memory/memory_usage.cc +++ b/src/vt/utils/memory/memory_usage.cc @@ -145,13 +145,17 @@ std::string PS::getName() { } std::size_t Mallinfo::getUsage() { -# if defined(vt_has_mallinfo) && defined(vt_has_malloc_h) && !vt_check_enabled(mimalloc) - struct mallinfo mi = mallinfo(); - unsigned int blocks = mi.uordblks; - return static_cast(blocks); -# else - return 0; -# endif +#if vt_check_enabled(mimalloc) || \ + !defined(vt_has_mallinfo) && !defined(vt_has_mallinfo2) + return 0; +#else +#if defined(vt_has_mallinfo2) + auto mi = mallinfo2(); +#elif defined(vt_has_mallinfo) + auto mi = mallinfo(); +#endif + return static_cast(mi.uordblks); +#endif } std::string Mallinfo::getName() { From 985e3882d7c3a2be30ffbf92d1fd9da8c80356a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 12 May 2022 18:43:31 +0200 Subject: [PATCH 2/3] #1513: CI: enable -Werror flag in Ubuntu 22.04 builds --- ci/azure/azure-clang-11-ubuntu-mpich.yml | 2 +- ci/azure/azure-clang-12-ubuntu-mpich.yml | 2 +- ci/azure/azure-clang-13-ubuntu-mpich.yml | 2 +- ci/azure/azure-clang-14-ubuntu-mpich.yml | 2 +- ci/azure/azure-gcc-11-ubuntu-mpich.yml | 2 +- ci/azure/azure-gcc-12-ubuntu-mpich.yml | 2 +- scripts/workflows-azure.ini | 6 ------ 7 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ci/azure/azure-clang-11-ubuntu-mpich.yml b/ci/azure/azure-clang-11-ubuntu-mpich.yml index 870d2a1be3..26882a6e9b 100644 --- a/ci/azure/azure-clang-11-ubuntu-mpich.yml +++ b/ci/azure/azure-clang-11-ubuntu-mpich.yml @@ -37,7 +37,7 @@ variables: VT_DOCS: 0 VT_ASAN: 0 VT_UBSAN: 0 - VT_WERROR: 0 + VT_WERROR: 1 VT_POOL: 1 VT_EXTENDED_TESTS: 1 VT_TESTS_NUM_NODES: 2 diff --git a/ci/azure/azure-clang-12-ubuntu-mpich.yml b/ci/azure/azure-clang-12-ubuntu-mpich.yml index 041ab12d49..47a1ae62bd 100644 --- a/ci/azure/azure-clang-12-ubuntu-mpich.yml +++ b/ci/azure/azure-clang-12-ubuntu-mpich.yml @@ -37,7 +37,7 @@ variables: VT_DOCS: 0 VT_ASAN: 0 VT_UBSAN: 0 - VT_WERROR: 0 + VT_WERROR: 1 VT_POOL: 1 VT_EXTENDED_TESTS: 1 VT_TESTS_NUM_NODES: 2 diff --git a/ci/azure/azure-clang-13-ubuntu-mpich.yml b/ci/azure/azure-clang-13-ubuntu-mpich.yml index 5f972e2b81..364c7aab8e 100644 --- a/ci/azure/azure-clang-13-ubuntu-mpich.yml +++ b/ci/azure/azure-clang-13-ubuntu-mpich.yml @@ -37,7 +37,7 @@ variables: VT_DOCS: 0 VT_ASAN: 0 VT_UBSAN: 0 - VT_WERROR: 0 + VT_WERROR: 1 VT_POOL: 1 VT_EXTENDED_TESTS: 1 VT_TESTS_NUM_NODES: 2 diff --git a/ci/azure/azure-clang-14-ubuntu-mpich.yml b/ci/azure/azure-clang-14-ubuntu-mpich.yml index f806a330f8..2cee722d4f 100644 --- a/ci/azure/azure-clang-14-ubuntu-mpich.yml +++ b/ci/azure/azure-clang-14-ubuntu-mpich.yml @@ -37,7 +37,7 @@ variables: VT_DOCS: 0 VT_ASAN: 0 VT_UBSAN: 0 - VT_WERROR: 0 + VT_WERROR: 1 VT_POOL: 1 VT_EXTENDED_TESTS: 1 VT_TESTS_NUM_NODES: 2 diff --git a/ci/azure/azure-gcc-11-ubuntu-mpich.yml b/ci/azure/azure-gcc-11-ubuntu-mpich.yml index a2691c5c84..27fb5b2b00 100644 --- a/ci/azure/azure-gcc-11-ubuntu-mpich.yml +++ b/ci/azure/azure-gcc-11-ubuntu-mpich.yml @@ -37,7 +37,7 @@ variables: VT_DOCS: 0 VT_ASAN: 0 VT_UBSAN: 0 - VT_WERROR: 0 + VT_WERROR: 1 VT_POOL: 1 VT_EXTENDED_TESTS: 1 VT_TESTS_NUM_NODES: 2 diff --git a/ci/azure/azure-gcc-12-ubuntu-mpich.yml b/ci/azure/azure-gcc-12-ubuntu-mpich.yml index eab46413d0..4095a24693 100644 --- a/ci/azure/azure-gcc-12-ubuntu-mpich.yml +++ b/ci/azure/azure-gcc-12-ubuntu-mpich.yml @@ -37,7 +37,7 @@ variables: VT_DOCS: 0 VT_ASAN: 0 VT_UBSAN: 0 - VT_WERROR: 0 + VT_WERROR: 1 VT_POOL: 1 VT_EXTENDED_TESTS: 1 VT_TESTS_NUM_NODES: 2 diff --git a/scripts/workflows-azure.ini b/scripts/workflows-azure.ini index c2d50c6fe1..e394bea4e4 100644 --- a/scripts/workflows-azure.ini +++ b/scripts/workflows-azure.ini @@ -178,7 +178,6 @@ compiler_type = gnu compiler = gcc-11 distro = 22.04 output_name = ci/azure/azure-gcc-11-ubuntu-mpich.yml -vt_werror = 0 [PR-tests-gcc-12] test_configuration = "gcc-12, ubuntu, mpich" @@ -186,7 +185,6 @@ compiler_type = gnu compiler = gcc-12 distro = 22.04 output_name = ci/azure/azure-gcc-12-ubuntu-mpich.yml -vt_werror = 0 [PR-tests-clang-39] test_configuration = "clang-3.9, ubuntu, mpich" @@ -241,7 +239,6 @@ compiler_type = clang compiler = clang-11 distro = 22.04 output_name = ci/azure/azure-clang-11-ubuntu-mpich.yml -vt_werror = 0 [PR-tests-clang-12] test_configuration = "clang-12, ubuntu, mpich" @@ -249,7 +246,6 @@ compiler_type = clang compiler = clang-12 distro = 22.04 output_name = ci/azure/azure-clang-12-ubuntu-mpich.yml -vt_werror = 0 [PR-tests-clang-13] test_configuration = "clang-13, ubuntu, mpich" @@ -257,7 +253,6 @@ compiler_type = clang compiler = clang-13 distro = 22.04 output_name = ci/azure/azure-clang-13-ubuntu-mpich.yml -vt_werror = 0 [PR-tests-clang-14] test_configuration = "clang-14, ubuntu, mpich" @@ -265,4 +260,3 @@ compiler_type = clang compiler = clang-14 distro = 22.04 output_name = ci/azure/azure-clang-14-ubuntu-mpich.yml -vt_werror = 0 From 2749a65b97db33bdea84e7abae1020c4f7a9becc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Tue, 17 May 2022 16:38:03 +0200 Subject: [PATCH 3/3] #1513: improve readability (operator precedence) --- src/vt/utils/memory/memory_usage.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/utils/memory/memory_usage.cc b/src/vt/utils/memory/memory_usage.cc index 2f2ce79de1..66b0e52e53 100644 --- a/src/vt/utils/memory/memory_usage.cc +++ b/src/vt/utils/memory/memory_usage.cc @@ -146,7 +146,7 @@ std::string PS::getName() { std::size_t Mallinfo::getUsage() { #if vt_check_enabled(mimalloc) || \ - !defined(vt_has_mallinfo) && !defined(vt_has_mallinfo2) + (!defined(vt_has_mallinfo) && !defined(vt_has_mallinfo2)) return 0; #else #if defined(vt_has_mallinfo2)