aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/z_Linux_util.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-01-17 20:45:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-01-17 20:45:01 +0000
commit706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch)
tree4adf86a776049cbf7f69a1929c4babcbbef925eb /openmp/runtime/src/z_Linux_util.cpp
parent7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff)
downloadsrc-706b4fc47bbc608932d3b491ae19a3b9cde9497b.tar.gz
src-706b4fc47bbc608932d3b491ae19a3b9cde9497b.zip
Vendor import of llvm-project master e26a78e70, the last commit beforevendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085
the llvmorg-11-init tag, from which release/10.x was branched.
Notes
Notes: svn path=/vendor/llvm-project/master/; revision=356843 svn path=/vendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085/; revision=356844; tag=vendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.cpp')
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 0ee12927e4bf..1daa3d31047e 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -54,7 +54,7 @@
#include <sys/sysctl.h>
#include <sys/user.h>
#include <pthread_np.h>
-#elif KMP_OS_NETBSD
+#elif KMP_OS_NETBSD || KMP_OS_OPENBSD
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
@@ -1287,7 +1287,7 @@ static void __kmp_atfork_child(void) {
++__kmp_fork_count;
#if KMP_AFFINITY_SUPPORTED
-#if KMP_OS_LINUX
+#if KMP_OS_LINUX || KMP_OS_FREEBSD
// reset the affinity in the child to the initial thread
// affinity in the parent
kmp_set_thread_affinity_mask_initial();
@@ -2130,9 +2130,36 @@ int __kmp_is_address_mapped(void *addr) {
}
}
KMP_INTERNAL_FREE(kiv);
-#elif KMP_OS_DRAGONFLY || KMP_OS_OPENBSD
+#elif KMP_OS_OPENBSD
+
+ int mib[3];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC_VMMAP;
+ mib[2] = getpid();
+
+ size_t size;
+ uint64_t end;
+ rc = sysctl(mib, 3, NULL, &size, NULL, 0);
+ KMP_ASSERT(!rc);
+ KMP_ASSERT(size);
+ end = size;
+
+ struct kinfo_vmentry kiv = {.kve_start = 0};
+
+ while ((rc = sysctl(mib, 3, &kiv, &size, NULL, 0)) == 0) {
+ KMP_ASSERT(size);
+ if (kiv.kve_end == end)
+ break;
+
+ if (kiv.kve_start >= (uint64_t)addr && kiv.kve_end <= (uint64_t)addr) {
+ found = 1;
+ break;
+ }
+ kiv.kve_start += 1;
+ }
+#elif KMP_OS_DRAGONFLY
- // FIXME(DragonFly, OpenBSD): Implement this
+ // FIXME(DragonFly): Implement this
found = 1;
#else
@@ -2187,7 +2214,7 @@ int __kmp_get_load_balance(int max) {
int __kmp_get_load_balance(int max) {
static int permanent_error = 0;
static int glb_running_threads = 0; // Saved count of the running threads for
- // the thread balance algortihm
+ // the thread balance algorithm
static double glb_call_time = 0; /* Thread balance algorithm call time */
int running_threads = 0; // Number of running threads in the system.
@@ -2295,7 +2322,7 @@ int __kmp_get_load_balance(int max) {
if (proc_entry->d_type == DT_DIR && isdigit(task_entry->d_name[0])) {
++total_threads;
- // Consruct complete stat file path. Easiest way would be:
+ // Construct complete stat file path. Easiest way would be:
// __kmp_str_buf_print( & stat_path, "%s/%s/stat", task_path.str,
// task_entry->d_name );
// but seriae of __kmp_str_buf_cat works a bit faster.