From 28ca14297cc524d053147a6351da00877ec4295f Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Mon, 21 Jul 2008 16:54:14 +0000 Subject: [PATCH] Add minimal support (#processors only) for OSX and other systems that don't have paffinity modules. This commit was SVN r18959. --- .../paffinity/base/paffinity_base_wrappers.c | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/opal/mca/paffinity/base/paffinity_base_wrappers.c b/opal/mca/paffinity/base/paffinity_base_wrappers.c index fb0c2919de..fb582c4057 100644 --- a/opal/mca/paffinity/base/paffinity_base_wrappers.c +++ b/opal/mca/paffinity/base/paffinity_base_wrappers.c @@ -21,6 +21,10 @@ #include "opal_config.h" +#if HAVE_UNISTD_H +#include +#endif + #include "opal/constants.h" #include "opal/mca/paffinity/paffinity.h" #include "opal/mca/paffinity/base/base.h" @@ -66,8 +70,27 @@ int opal_paffinity_base_map_to_socket_core(int processor_id, int *socket, int *c int opal_paffinity_base_get_processor_info(int *num_processors, int *max_processor_id) { + int rc; + if (!opal_paffinity_base_selected) { - return OPAL_ERR_NOT_FOUND; + /* since no module was available, we do the best we can + * with a POSIX-standard query + */ + if (0 > (rc = sysconf(_SC_NPROCESSORS_ONLN))) { + /* system was unable to provide a number, so return + * an error and set the values to something negative + */ + *num_processors = *max_processor_id = -1; + return OPAL_ERR_NOT_FOUND; + } + /* rc will contain a guess at the number of processors + * that are currently online - return that value + */ + *num_processors = *max_processor_id = rc; + /* since we found something and it is the best we can do, + * return success + */ + return OPAL_SUCCESS; } return opal_paffinity_base_module->paff_get_processor_info(num_processors, max_processor_id); }