root/opal/mca/hwloc/base/hwloc_base_proc_mempolicy.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. opal_hwloc_base_set_process_membind_policy

   1 /*
   2  * Copyright (c) 2011-2017 Cisco Systems, Inc.  All rights reserved
   3  * $COPYRIGHT$
   4  *
   5  * Additional copyrights may follow
   6  *
   7  * $HEADER$
   8  */
   9 
  10 
  11 #include "opal_config.h"
  12 
  13 #include "opal/constants.h"
  14 
  15 #include "opal/mca/hwloc/hwloc-internal.h"
  16 #include "opal/mca/hwloc/base/base.h"
  17 
  18 
  19 /*
  20  * Don't use show_help() here (or print any error message at all).
  21  * Let the upper layer output a relevant message, because doing so may
  22  * be complicated (e.g., this might be called from the ORTE ODLS,
  23  * which has to do some extra steps to get error messages to be
  24  * displayed).
  25  */
  26 int opal_hwloc_base_set_process_membind_policy(void)
  27 {
  28     int rc = 0, flags;
  29     hwloc_membind_policy_t policy;
  30     hwloc_cpuset_t cpuset;
  31 
  32     /* Make sure opal_hwloc_topology has been set by the time we've
  33        been called */
  34     if (NULL == opal_hwloc_topology) {
  35         return OPAL_ERR_BAD_PARAM;
  36     }
  37 
  38     /* Set the default memory allocation policy according to MCA
  39        param */
  40     switch (opal_hwloc_base_map) {
  41     case OPAL_HWLOC_BASE_MAP_LOCAL_ONLY:
  42         policy = HWLOC_MEMBIND_BIND;
  43         flags = HWLOC_MEMBIND_STRICT;
  44         break;
  45 
  46     case OPAL_HWLOC_BASE_MAP_NONE:
  47     default:
  48         policy = HWLOC_MEMBIND_DEFAULT;
  49         flags = 0;
  50         break;
  51     }
  52 
  53     cpuset = hwloc_bitmap_alloc();
  54     if (NULL == cpuset) {
  55         rc = OPAL_ERR_OUT_OF_RESOURCE;
  56     } else {
  57         int e;
  58         hwloc_get_cpubind(opal_hwloc_topology, cpuset, 0);
  59         rc = hwloc_set_membind(opal_hwloc_topology,
  60                                cpuset, policy, flags);
  61         e = errno;
  62         hwloc_bitmap_free(cpuset);
  63 
  64         /* See if hwloc was able to do it.  If hwloc failed due to
  65            ENOSYS, but the base_map == NONE, then it's not really an
  66            error. */
  67         if (0 != rc && ENOSYS == e &&
  68             OPAL_HWLOC_BASE_MAP_NONE == opal_hwloc_base_map) {
  69             rc = 0;
  70         }
  71     }
  72 
  73     return (0 == rc) ? OPAL_SUCCESS : OPAL_ERROR;
  74 }

/* [<][>][^][v][top][bottom][index][help] */