[Openmp-commits] [openmp] r248209 - Use sysconf for the number of cores on FreeBSD too.

Joerg Sonnenberger via Openmp-commits openmp-commits at lists.llvm.org
Mon Sep 21 13:29:12 PDT 2015


Author: joerg
Date: Mon Sep 21 15:29:12 2015
New Revision: 248209

URL: http://llvm.org/viewvc/llvm-project?rev=248209&view=rev
Log:
Use sysconf for the number of cores on FreeBSD too.

Modified:
    openmp/trunk/runtime/src/z_Linux_util.c

Modified: openmp/trunk/runtime/src/z_Linux_util.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/z_Linux_util.c?rev=248209&r1=248208&r2=248209&view=diff
==============================================================================
--- openmp/trunk/runtime/src/z_Linux_util.c (original)
+++ openmp/trunk/runtime/src/z_Linux_util.c Mon Sep 21 15:29:12 2015
@@ -51,7 +51,6 @@
 # include <sys/sysctl.h>
 # include <mach/mach.h>
 #elif KMP_OS_FREEBSD
-# include <sys/sysctl.h>
 # include <pthread_np.h>
 #endif
 
@@ -2067,7 +2066,7 @@ __kmp_get_xproc( void ) {
 
     int r = 0;
 
-    #if KMP_OS_LINUX || KMP_OS_NETBSD
+    #if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD
 
         r = sysconf( _SC_NPROCESSORS_ONLN );
 
@@ -2089,16 +2088,6 @@ __kmp_get_xproc( void ) {
             KMP_INFORM( AssumedNumCPU );
         }; // if
 
-    #elif KMP_OS_FREEBSD
-
-        int mib[] = { CTL_HW, HW_NCPU };
-        size_t len = sizeof( r );
-        if ( sysctl( mib, 2, &r, &len, NULL, 0 ) < 0 ) {
-             r = 0;
-             KMP_WARNING( CantGetNumAvailCPU );
-             KMP_INFORM( AssumedNumCPU );
-        }
-
     #else
 
         #error "Unknown or unsupported OS."
@@ -2275,7 +2264,7 @@ __kmp_is_address_mapped( void * addr ) {
     int found = 0;
     int rc;
 
-    #if KMP_OS_LINUX
+    #if KMP_OS_LINUX || KMP_OS_FREEBSD
 
         /*
             On Linux* OS, read the /proc/<pid>/maps pseudo-file to get all the address ranges mapped




More information about the Openmp-commits mailing list