From 46cc347633e82520f60dd3d163bab878959a6516 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 2 Nov 2021 23:51:51 +0100 Subject: [PATCH 1/7] sched_getaffinity will not return all accessible cores with OMP_PROC_BIND --- driver/others/memory.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/driver/others/memory.c b/driver/others/memory.c index 0185fa683e..477efd6641 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -249,6 +249,10 @@ int get_num_procs(void) { #if !defined(OS_LINUX) return nums; #endif +#if defined(USE_OPENMP) + if (omp_get_proc_bind() != omp_proc_bind_false) + return nums; +#endif #if !defined(__GLIBC_PREREQ) return nums; @@ -1809,6 +1813,10 @@ int get_num_procs(void) { #if !defined(OS_LINUX) return nums; #endif +#if defined(USE_OPENMP) + if (omp_get_proc_bind() != omp_proc_bind_false) + return nums; +#endif #if !defined(__GLIBC_PREREQ) return nums; From 9249259cd070bc0fc0acf928bfed92c77bed196a Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 3 Nov 2021 12:04:35 +0100 Subject: [PATCH 2/7] return OMP places for thread count when built with OpenMP --- driver/others/memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index 477efd6641..541da3d763 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -250,7 +250,8 @@ int get_num_procs(void) { return nums; #endif #if defined(USE_OPENMP) - if (omp_get_proc_bind() != omp_proc_bind_false) +/* if (omp_get_proc_bind() != omp_proc_bind_false)*/ + nums = omp_get_num_places(); return nums; #endif @@ -1814,7 +1815,8 @@ int get_num_procs(void) { return nums; #endif #if defined(USE_OPENMP) - if (omp_get_proc_bind() != omp_proc_bind_false) +/* if (omp_get_proc_bind() != omp_proc_bind_false) */ + nums = omp_get_num_places(); return nums; #endif From 85401a0addc03db1a17a9bb67649d02f92fa07e5 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 3 Nov 2021 12:56:15 +0100 Subject: [PATCH 3/7] old OpenMP versions lack omp_get_num_places --- driver/others/memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/driver/others/memory.c b/driver/others/memory.c index 541da3d763..c3f6269cd5 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -251,7 +251,9 @@ int get_num_procs(void) { #endif #if defined(USE_OPENMP) /* if (omp_get_proc_bind() != omp_proc_bind_false)*/ +#if _OPENMP >= 201307 nums = omp_get_num_places(); +#endif return nums; #endif @@ -1816,7 +1818,9 @@ int get_num_procs(void) { #endif #if defined(USE_OPENMP) /* if (omp_get_proc_bind() != omp_proc_bind_false) */ +#if_OPENMP >= 201307 nums = omp_get_num_places(); +#endif return nums; #endif From 0e6639d0fad0ba99bb3d001c5fb853906386b949 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 3 Nov 2021 20:37:31 +0100 Subject: [PATCH 4/7] Fix missing endif and rearrange for non-Linux OpenMP --- driver/others/memory.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index c3f6269cd5..becde694c0 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -246,16 +246,18 @@ int get_num_procs(void) { #endif if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF); -#if !defined(OS_LINUX) - return nums; -#endif + #if defined(USE_OPENMP) -/* if (omp_get_proc_bind() != omp_proc_bind_false)*/ #if _OPENMP >= 201307 nums = omp_get_num_places(); #endif return nums; #endif +#endif + +#if !defined(OS_LINUX) + return nums; +#endif #if !defined(__GLIBC_PREREQ) return nums; @@ -1813,9 +1815,7 @@ int get_num_procs(void) { #endif if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF); -#if !defined(OS_LINUX) - return nums; -#endif + #if defined(USE_OPENMP) /* if (omp_get_proc_bind() != omp_proc_bind_false) */ #if_OPENMP >= 201307 @@ -1823,7 +1823,12 @@ int get_num_procs(void) { #endif return nums; #endif +#endif +#if !defined(OS_LINUX) + return nums; +#endif + #if !defined(__GLIBC_PREREQ) return nums; #else From e53408ca175a7eeafe591e8ef0959ccb4b85fef9 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 3 Nov 2021 21:54:31 +0100 Subject: [PATCH 5/7] remove extraneous endif --- driver/others/memory.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index becde694c0..74870e498f 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -253,7 +253,6 @@ int get_num_procs(void) { #endif return nums; #endif -#endif #if !defined(OS_LINUX) return nums; @@ -1823,7 +1822,6 @@ int get_num_procs(void) { #endif return nums; #endif -#endif #if !defined(OS_LINUX) return nums; From 36c7b841141a0a7af5935560be287392abc3daf5 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 3 Nov 2021 22:12:35 +0100 Subject: [PATCH 6/7] Update memory.c --- driver/others/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index 74870e498f..99ddd11f54 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -1817,7 +1817,7 @@ int get_num_procs(void) { #if defined(USE_OPENMP) /* if (omp_get_proc_bind() != omp_proc_bind_false) */ -#if_OPENMP >= 201307 +#if _OPENMP >= 201307 nums = omp_get_num_places(); #endif return nums; From faa066c22f47d2200e904edb0c722f43afcce4f0 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 4 Nov 2021 08:34:55 +0100 Subject: [PATCH 7/7] need openmp 4.5 for get_num_places --- driver/others/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index 99ddd11f54..8e601099c6 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -248,7 +248,7 @@ int get_num_procs(void) { if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF); #if defined(USE_OPENMP) -#if _OPENMP >= 201307 +#if _OPENMP >= 201511 nums = omp_get_num_places(); #endif return nums; @@ -1817,7 +1817,7 @@ int get_num_procs(void) { #if defined(USE_OPENMP) /* if (omp_get_proc_bind() != omp_proc_bind_false) */ -#if _OPENMP >= 201307 +#if _OPENMP >= 201511 nums = omp_get_num_places(); #endif return nums;