Revamp the opal mca paffinity interface. We ran into a problem when we encountered machines that had "holes" in their physical processor layout - e.g., machines that supported "hotplugging", or that had unpopulated sockets. To solve that problem, we had to clarify at the API level where we were describing physical vs logical processor info, and then translate accordingly in the underlying implementation.
See opal/mca/paffinity/paffinity.h for explanation as to the physical vs logical nature of the params used in the API. Fixes trac:1435 This commit was SVN r19391. The following Trac tickets were found above: Ticket 1435 --> https://svn.open-mpi.org/trac/ompi/ticket/1435
Этот коммит содержится в:
родитель
7b61e02841
Коммит
4ef9d15d97
@ -1847,11 +1847,12 @@ static int get_ib_dev_distance(struct ibv_device *dev)
|
||||
{
|
||||
opal_paffinity_base_cpu_set_t cpus;
|
||||
opal_carto_base_node_t *device_node;
|
||||
int min_distance = -1, i, max_proc_id, num_processors;
|
||||
int min_distance = -1, i, num_processors;
|
||||
const char *device = ibv_get_device_name(dev);
|
||||
|
||||
if(opal_paffinity_base_get_processor_info(&num_processors, &max_proc_id) != OMPI_SUCCESS)
|
||||
max_proc_id = 100; /* Choose something big enough */
|
||||
if(opal_paffinity_base_get_processor_info(&num_processors) != OMPI_SUCCESS) {
|
||||
num_processors = 100; /* Choose something big enough */
|
||||
}
|
||||
|
||||
device_node = opal_carto_base_find_node(host_topo, device);
|
||||
|
||||
@ -1862,7 +1863,7 @@ static int get_ib_dev_distance(struct ibv_device *dev)
|
||||
OPAL_PAFFINITY_CPU_ZERO(cpus);
|
||||
opal_paffinity_base_get(&cpus);
|
||||
|
||||
for (i = 0; i < max_proc_id; i++) {
|
||||
for (i = 0; i < num_processors; i++) {
|
||||
opal_carto_base_node_t *slot_node;
|
||||
int distance, socket, core;
|
||||
char *slot;
|
||||
@ -1870,7 +1871,7 @@ static int get_ib_dev_distance(struct ibv_device *dev)
|
||||
if(!OPAL_PAFFINITY_CPU_ISSET(i, cpus))
|
||||
continue;
|
||||
|
||||
opal_paffinity_base_map_to_socket_core(i, &socket, &core);
|
||||
opal_paffinity_base_get_map_to_socket_core(i, &socket, &core);
|
||||
asprintf(&slot, "slot%d", socket);
|
||||
|
||||
slot_node = opal_carto_base_find_node(host_topo, slot);
|
||||
|
@ -138,7 +138,7 @@ static void init_maffinity(int *my_mem_node, int *max_mem_node)
|
||||
{
|
||||
static opal_carto_graph_t *topo;
|
||||
opal_value_array_t dists;
|
||||
int i, num_core, max_core, socket, rc;
|
||||
int i, num_core, socket, rc;
|
||||
opal_paffinity_base_cpu_set_t cpus;
|
||||
char *myslot = NULL;
|
||||
opal_carto_node_distance_t *dist;
|
||||
@ -153,19 +153,19 @@ static void init_maffinity(int *my_mem_node, int *max_mem_node)
|
||||
OBJ_CONSTRUCT(&dists, opal_value_array_t);
|
||||
opal_value_array_init(&dists, sizeof(opal_carto_node_distance_t));
|
||||
|
||||
if(opal_paffinity_base_get_processor_info(&num_core, &max_core) !=
|
||||
OMPI_SUCCESS)
|
||||
max_core = 100;
|
||||
if(opal_paffinity_base_get_processor_info(&num_core) != OMPI_SUCCESS) {
|
||||
num_core = 100; /* set something large */
|
||||
}
|
||||
|
||||
OPAL_PAFFINITY_CPU_ZERO(cpus);
|
||||
opal_paffinity_base_get(&cpus);
|
||||
|
||||
/* find core we are running on */
|
||||
for(i = 0; i < max_core; i++)
|
||||
for(i = 0; i < num_core; i++)
|
||||
if(OPAL_PAFFINITY_CPU_ISSET(i, cpus))
|
||||
break;
|
||||
|
||||
rc = opal_paffinity_base_map_to_socket_core(i, &socket, &i);
|
||||
rc = opal_paffinity_base_get_map_to_socket_core(i, &socket, &i);
|
||||
asprintf(&myslot, "slot%d", socket);
|
||||
|
||||
slot_node = opal_carto_base_find_node(topo, myslot);
|
||||
|
@ -384,9 +384,14 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
|
||||
/* Otherwise, if mpi_paffinity_alone was set, use that scheme */
|
||||
else if (ompi_mpi_paffinity_alone) {
|
||||
opal_paffinity_base_cpu_set_t mask;
|
||||
int phys_cpu;
|
||||
OPAL_PAFFINITY_CPU_ZERO(mask);
|
||||
OPAL_PAFFINITY_CPU_SET(orte_ess.get_node_rank(ORTE_PROC_MY_NAME),
|
||||
mask);
|
||||
phys_cpu = opal_paffinity_base_get_physical_processor_id(orte_ess.get_node_rank(ORTE_PROC_MY_NAME));
|
||||
if (0 > phys_cpu) {
|
||||
error = "Could not get physical processor id - cannot set processor affinity";
|
||||
goto error;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(phys_cpu, mask);
|
||||
ret = opal_paffinity_base_set(mask);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
error = "Setting processor affinity failed";
|
||||
|
@ -29,205 +29,221 @@
|
||||
* Global functions for MCA overall paffinity open and close
|
||||
*/
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* Initialize the paffinity MCA framework
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failure
|
||||
*
|
||||
* This must be the first function invoked in the paffinity MCA
|
||||
* framework. It initializes the paffinity MCA framework, finds
|
||||
* and opens paffinity components, etc.
|
||||
*
|
||||
* This function is invoked during opal_init().
|
||||
*
|
||||
* This function fills in the internal global variable
|
||||
* opal_paffinity_base_components_opened, which is a list of all
|
||||
* paffinity components that were successfully opened. This
|
||||
* variable should \em only be used by other paffinity base
|
||||
* functions -- it is not considered a public interface member --
|
||||
* and is only mentioned here for completeness.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_open(void);
|
||||
|
||||
/**
|
||||
* Select an available component.
|
||||
*
|
||||
* @return OPAL_SUCCESS Upon success.
|
||||
* @return OPAL_NOT_FOUND If no component can be selected.
|
||||
* @return OPAL_ERROR Upon other failure.
|
||||
*
|
||||
* This function invokes the selection process for paffinity components,
|
||||
* which works as follows:
|
||||
*
|
||||
* - If the \em paffinity MCA parameter is not specified, the
|
||||
* selection set is all available paffinity components.
|
||||
* - If the \em paffinity MCA parameter is specified, the
|
||||
* selection set is just that component.
|
||||
* - All components in the selection set are queried to see if
|
||||
* they want to run. All components that want to run are ranked
|
||||
* by their priority and the highest priority component is
|
||||
* selected. All non-selected components have their "close"
|
||||
* function invoked to let them know that they were not selected.
|
||||
* - The selected component will have its "init" function invoked to
|
||||
* let it know that it was selected.
|
||||
*
|
||||
* If we fall through this entire process and no component is
|
||||
* selected, then return OPAL_NOT_FOUND (this is not a fatal
|
||||
* error).
|
||||
*
|
||||
* At the end of this process, we'll either have a single
|
||||
* component that is selected and initialized, or no component was
|
||||
* selected. If no component was selected, subsequent invocation
|
||||
* of the paffinity wrapper functions will return an error.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_select(void);
|
||||
/**
|
||||
* Initialize the paffinity MCA framework
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failure
|
||||
*
|
||||
* This must be the first function invoked in the paffinity MCA
|
||||
* framework. It initializes the paffinity MCA framework, finds
|
||||
* and opens paffinity components, etc.
|
||||
*
|
||||
* This function is invoked during opal_init().
|
||||
*
|
||||
* This function fills in the internal global variable
|
||||
* opal_paffinity_base_components_opened, which is a list of all
|
||||
* paffinity components that were successfully opened. This
|
||||
* variable should \em only be used by other paffinity base
|
||||
* functions -- it is not considered a public interface member --
|
||||
* and is only mentioned here for completeness.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_open(void);
|
||||
|
||||
/**
|
||||
* Set this process' affinity.
|
||||
*
|
||||
* @param cpumask Virtual processor bitmask
|
||||
*
|
||||
* @retval OPAL_SUCCESS upon success
|
||||
* @retval OPAL_NOT_FOUND if no paffinity components are available.
|
||||
* @retval OPAL_ERROR upon other error.
|
||||
*
|
||||
* Set this process' affinity to the CPU's specified in \em cpumask
|
||||
*
|
||||
* If no paffinity components were available, or if the
|
||||
* opal_paffinity_base_select() was never invoked, OPAL_NOT_FOUND
|
||||
* is returned.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
/**
|
||||
* Select an available component.
|
||||
*
|
||||
* @return OPAL_SUCCESS Upon success.
|
||||
* @return OPAL_NOT_FOUND If no component can be selected.
|
||||
* @return OPAL_ERROR Upon other failure.
|
||||
*
|
||||
* This function invokes the selection process for paffinity components,
|
||||
* which works as follows:
|
||||
*
|
||||
* - If the \em paffinity MCA parameter is not specified, the
|
||||
* selection set is all available paffinity components.
|
||||
* - If the \em paffinity MCA parameter is specified, the
|
||||
* selection set is just that component.
|
||||
* - All components in the selection set are queried to see if
|
||||
* they want to run. All components that want to run are ranked
|
||||
* by their priority and the highest priority component is
|
||||
* selected. All non-selected components have their "close"
|
||||
* function invoked to let them know that they were not selected.
|
||||
* - The selected component will have its "init" function invoked to
|
||||
* let it know that it was selected.
|
||||
*
|
||||
* If we fall through this entire process and no component is
|
||||
* selected, then return OPAL_NOT_FOUND (this is not a fatal
|
||||
* error).
|
||||
*
|
||||
* At the end of this process, we'll either have a single
|
||||
* component that is selected and initialized, or no component was
|
||||
* selected. If no component was selected, subsequent invocation
|
||||
* of the paffinity wrapper functions will return an error.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_select(void);
|
||||
|
||||
/**
|
||||
* Get this process' affinity.
|
||||
*
|
||||
* @param cpumask Pointer to virtual processor bitmask
|
||||
*
|
||||
* @retval OPAL_SUCCESS upon success
|
||||
* @retval OPAL_NOT_FOUND if no paffinity components are available.
|
||||
* @retval OPAL_ERROR upon other error.
|
||||
*
|
||||
* Get this process' CPU affinity virtual bitmask and assign
|
||||
* it to \em cpumask.
|
||||
*
|
||||
* If no paffinity components were available, or if the
|
||||
* opal_paffinity_base_select() was never invoked, OPAL_NOT_FOUND
|
||||
* is returned and cpumask is zeroed out.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
/**
|
||||
* Set this process' affinity.
|
||||
*
|
||||
* @param cpumask PHYSICAL processor bitmask
|
||||
*
|
||||
* @retval OPAL_SUCCESS upon success
|
||||
* @retval OPAL_NOT_FOUND if no paffinity components are available.
|
||||
* @retval OPAL_ERROR upon other error.
|
||||
*
|
||||
* Set this process' affinity to the PHYSICAL CPU's specified in \em cpumask
|
||||
*
|
||||
* If no paffinity components were available, or if the
|
||||
* opal_paffinity_base_select() was never invoked, OPAL_NOT_FOUND
|
||||
* is returned.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
|
||||
/**
|
||||
* Shut down the paffinity MCA framework.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Always
|
||||
*
|
||||
* This function shuts down everything in the paffinity MCA
|
||||
* framework, and is called during opal_finalize().
|
||||
*
|
||||
* It must be the last function invoked on the paffinity MCA
|
||||
* framework.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_close(void);
|
||||
/**
|
||||
* Get this process' affinity.
|
||||
*
|
||||
* @param cpumask Pointer to PHYSICAL processor bitmask
|
||||
*
|
||||
* @retval OPAL_SUCCESS upon success
|
||||
* @retval OPAL_NOT_FOUND if no paffinity components are available.
|
||||
* @retval OPAL_ERROR upon other error.
|
||||
*
|
||||
* Get this process' CPU affinity PHYSICAL bitmask and assign
|
||||
* it to \em cpumask.
|
||||
*
|
||||
* If no paffinity components were available, or if the
|
||||
* opal_paffinity_base_select() was never invoked, OPAL_NOT_FOUND
|
||||
* is returned and cpumask is zeroed out.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
|
||||
/**
|
||||
* Map (socket,core) tuple to virtual processor ID
|
||||
*
|
||||
* @param socket
|
||||
* @param core
|
||||
* @param processor_id
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
/**
|
||||
* Shut down the paffinity MCA framework.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Always
|
||||
*
|
||||
* This function shuts down everything in the paffinity MCA
|
||||
* framework, and is called during opal_finalize().
|
||||
*
|
||||
* It must be the last function invoked on the paffinity MCA
|
||||
* framework.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_close(void);
|
||||
|
||||
/**
|
||||
* Map processor_id to (socket,core) tuple
|
||||
*
|
||||
* @param processor_id
|
||||
* @param socket
|
||||
* @param core
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
/**
|
||||
* Get map of (socket,core) tuple to virtual processor ID
|
||||
*
|
||||
* @param socket
|
||||
* @param core
|
||||
* @param processor_id
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
|
||||
/**
|
||||
* Return the max processor ID
|
||||
*
|
||||
* @param max_processor_id
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
/**
|
||||
* Get map of processor_id to (socket,core) tuple
|
||||
*
|
||||
* @param processor_id
|
||||
* @param socket
|
||||
* @param core
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
|
||||
/**
|
||||
* Return the max socket number
|
||||
*
|
||||
* @param max_socket
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
/**
|
||||
* Return the number of LOGICAL processors
|
||||
*
|
||||
* @param max_processor_id
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_processor_info(int *num_logical_processors);
|
||||
|
||||
/**
|
||||
* Return the max core number for a given socket
|
||||
*
|
||||
* @param socket
|
||||
* @param max_core
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
/**
|
||||
* Return the number of LOGICAL sockets
|
||||
*
|
||||
* @param max_socket
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_socket_info(int *num_logical_sockets);
|
||||
|
||||
/**
|
||||
* Indication of whether a component was successfully selected or
|
||||
* not
|
||||
*/
|
||||
OPAL_DECLSPEC extern bool opal_paffinity_base_selected;
|
||||
/**
|
||||
* Return the number of LOGICAL cores for a given PHYSICAL socket
|
||||
*
|
||||
* @param socket
|
||||
* @param max_core
|
||||
*
|
||||
* @return int - OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_core_info(int physical_socket, int *num_logical_cores);
|
||||
|
||||
/**
|
||||
* Global component struct for the selected component
|
||||
*/
|
||||
OPAL_DECLSPEC extern const opal_paffinity_base_component_2_0_0_t
|
||||
*opal_paffinity_base_component;
|
||||
/**
|
||||
* Global module struct for the selected module
|
||||
*/
|
||||
OPAL_DECLSPEC extern const opal_paffinity_base_module_1_1_0_t
|
||||
*opal_paffinity_base_module;
|
||||
/**
|
||||
* Indicator as to whether the list of opened paffinity components
|
||||
* is valid or not.
|
||||
*/
|
||||
OPAL_DECLSPEC extern bool opal_paffinity_base_components_opened_valid;
|
||||
/**
|
||||
* List of all opened components; created when the paffinity
|
||||
* framework is initialized and destroyed when we reduce the list
|
||||
* to all available paffinity components.
|
||||
*/
|
||||
OPAL_DECLSPEC extern opal_list_t opal_paffinity_base_components_opened;
|
||||
/**
|
||||
* Assigning slot_list to proccess
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_slot_list_set(long rank);
|
||||
/**
|
||||
* Return the PHYSICAL processor id that corresponds to the
|
||||
* given LOGICAL processor id
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_physical_processor_id(int logical_processor_id);
|
||||
|
||||
/**
|
||||
* Debugging output stream
|
||||
*/
|
||||
extern int opal_paffinity_base_output;
|
||||
/**
|
||||
* Return the PHYSICAL socket id that corresponds to the given
|
||||
* LOGICAL socket id
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_physical_socket_id(int logical_socket_id);
|
||||
|
||||
/**
|
||||
* Return the PHYSICAL core id that corresponds to the given LOGICAL
|
||||
* core id on the given PHYSICAL socket id
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_get_physical_core_id(int physical_socket_id, int logical_core_id);
|
||||
|
||||
|
||||
/**
|
||||
* Indication of whether a component was successfully selected or
|
||||
* not
|
||||
*/
|
||||
OPAL_DECLSPEC extern bool opal_paffinity_base_selected;
|
||||
|
||||
/**
|
||||
* Global component struct for the selected component
|
||||
*/
|
||||
OPAL_DECLSPEC extern const opal_paffinity_base_component_2_0_0_t
|
||||
*opal_paffinity_base_component;
|
||||
/**
|
||||
* Global module struct for the selected module
|
||||
*/
|
||||
OPAL_DECLSPEC extern const opal_paffinity_base_module_1_1_0_t
|
||||
*opal_paffinity_base_module;
|
||||
/**
|
||||
* Indicator as to whether the list of opened paffinity components
|
||||
* is valid or not.
|
||||
*/
|
||||
OPAL_DECLSPEC extern bool opal_paffinity_base_components_opened_valid;
|
||||
/**
|
||||
* List of all opened components; created when the paffinity
|
||||
* framework is initialized and destroyed when we reduce the list
|
||||
* to all available paffinity components.
|
||||
*/
|
||||
OPAL_DECLSPEC extern opal_list_t opal_paffinity_base_components_opened;
|
||||
/**
|
||||
* Assigning slot_list to process
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_paffinity_base_slot_list_set(long rank);
|
||||
|
||||
/**
|
||||
* Debugging output stream
|
||||
*/
|
||||
extern int opal_paffinity_base_output;
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* OPAL_BASE_PAFFINITY_H */
|
||||
|
@ -28,69 +28,107 @@
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/util/output.h"
|
||||
|
||||
static int opal_paffinity_base_socket_to_cpu_set(char **socket_list, int socket_cnt, long rank)
|
||||
static bool diag_requested;
|
||||
|
||||
static int opal_paffinity_base_socket_to_cpu_set(char **socket_list, int socket_cnt, long rank, bool logical_map)
|
||||
{
|
||||
int i;
|
||||
char **range;
|
||||
int range_cnt;
|
||||
int lower_range, upper_range;
|
||||
int processor_id, num_processors, socket=-1, core=-1;
|
||||
int max_processor_id;
|
||||
int processor_id, num_processors;
|
||||
int rc;
|
||||
int phys_processor;
|
||||
opal_paffinity_base_cpu_set_t cpumask;
|
||||
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_get_processor_info(&num_processors, &max_processor_id))) {
|
||||
/* get the number of LOGICAL processors on this node */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_get_processor_info(&num_processors))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_ZERO(cpumask);
|
||||
for (i=0; i<socket_cnt; i++) {
|
||||
if (0 == strcmp("*", socket_list[i])) {
|
||||
for ( processor_id=0; processor_id<=max_processor_id; processor_id++) {
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if (OPAL_SUCCESS != ( rc = opal_paffinity_base_set(cpumask))) {
|
||||
/* bind to all available logical processors - first set the bits in the cpu mask */
|
||||
for ( processor_id=0; processor_id<=num_processors; processor_id++) {
|
||||
if (0 > (phys_processor = opal_paffinity_base_get_physical_processor_id(processor_id))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical processor id for logical processor %ld",
|
||||
rank, (long)processor_id);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_paffinity_base_map_to_socket_core(processor_id, &socket, &core);
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d )",rank, processor_id, socket, core);
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d (#%d)",
|
||||
rank, phys_processor, processor_id);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != ( rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
continue;
|
||||
} /* end if * */
|
||||
|
||||
range = opal_argv_split(socket_list[i],'-');
|
||||
range_cnt = opal_argv_count(range);
|
||||
switch (range_cnt) {
|
||||
case 1:
|
||||
case 1: /* no - was present, so just one processor given */
|
||||
processor_id = atoi(range[0]);
|
||||
if (processor_id > max_processor_id) {
|
||||
opal_output(0, "ERROR !!! processor_id (%d) > max_processor_id(%d), modify rankfile and run again\n",processor_id, max_processor_id);
|
||||
return OPAL_ERROR;
|
||||
if (logical_map) {
|
||||
/* need to convert this to physical processor id */
|
||||
if (0 > (phys_processor = opal_paffinity_base_get_physical_processor_id(processor_id))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical processor id for logical processor %ld",
|
||||
rank, (long)processor_id);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_processor = processor_id;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
/* set the bit for this physical processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != ( rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
return rc;
|
||||
}
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on cpu #%d (#%d)",
|
||||
rank, phys_processor, processor_id);
|
||||
}
|
||||
opal_paffinity_base_map_to_socket_core(processor_id, &socket, &core);
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d )",
|
||||
rank, processor_id, socket, core);
|
||||
break;
|
||||
case 2:
|
||||
|
||||
case 2: /* range of processor id's was given */
|
||||
lower_range = atoi(range[0]);
|
||||
upper_range = atoi(range[1]);
|
||||
if (max_processor_id < upper_range || lower_range >= upper_range ) {
|
||||
opal_output(0,"Error !!! Check your boundaries %d < %d(max_cpu) < %d, modify rankfile and run again\n",
|
||||
lower_range, max_processor_id, upper_range);
|
||||
if (num_processors < (upper_range - lower_range) ||
|
||||
upper_range <= lower_range) {
|
||||
opal_output(0,"Rank %ld: PAFFINITY Error !!! Check your boundaries lower %d upper %d #processors %d",
|
||||
rank, lower_range, upper_range, num_processors);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
for (processor_id=lower_range; processor_id<=upper_range; processor_id++) {
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
if (logical_map) {
|
||||
/* need to convert this to physical processor id */
|
||||
if (0 > (phys_processor = opal_paffinity_base_get_physical_processor_id(processor_id))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical processor id for logical processor %d",
|
||||
rank, processor_id);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_processor = processor_id;
|
||||
}
|
||||
opal_paffinity_base_map_to_socket_core(processor_id, &socket, &core);
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d )",
|
||||
rank, processor_id, socket, core);
|
||||
/* set the bit for this physical processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on cpu #%d (#%d)",
|
||||
rank, phys_processor, processor_id);
|
||||
}
|
||||
}
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -102,234 +140,367 @@ static int opal_paffinity_base_socket_to_cpu_set(char **socket_list, int socket_
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int opal_paffinity_base_socket_core_to_cpu_set(char **socket_core_list, int socket_core_list_cnt, long rank)
|
||||
static int opal_paffinity_base_socket_core_to_cpu_set(char **socket_core_list, int socket_core_list_cnt, long rank, bool logical_map)
|
||||
{
|
||||
int rc, i;
|
||||
char **socket_core;
|
||||
int socket_core_cnt;
|
||||
char **range;
|
||||
int range_cnt;
|
||||
int lower_range, upper_range;
|
||||
int socket, core, processor_id ;
|
||||
int max_socket_num, max_core_num;
|
||||
int num_sockets, num_cores;
|
||||
opal_paffinity_base_cpu_set_t cpumask;
|
||||
|
||||
socket_core = opal_argv_split (socket_core_list[0], ':');
|
||||
socket_core_cnt = opal_argv_count(socket_core);
|
||||
OPAL_PAFFINITY_CPU_ZERO(cpumask);
|
||||
socket = atoi(socket_core[0]);
|
||||
|
||||
if ( OPAL_SUCCESS != ( rc = opal_paffinity_base_get_socket_info(&num_sockets, &max_socket_num))) {
|
||||
int rc, i;
|
||||
char **socket_core;
|
||||
int socket_core_cnt;
|
||||
char **range;
|
||||
int range_cnt;
|
||||
int lower_range, upper_range;
|
||||
int socket, core;
|
||||
int num_sockets, num_cores;
|
||||
int phys_socket, phys_core, phys_processor;
|
||||
opal_paffinity_base_cpu_set_t cpumask;
|
||||
|
||||
socket_core = opal_argv_split (socket_core_list[0], ':');
|
||||
socket_core_cnt = opal_argv_count(socket_core);
|
||||
OPAL_PAFFINITY_CPU_ZERO(cpumask);
|
||||
socket = atoi(socket_core[0]);
|
||||
|
||||
/* get the number of LOGICAL sockets on this node */
|
||||
if ( OPAL_SUCCESS != ( rc = opal_paffinity_base_get_socket_info(&num_sockets))) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (logical_map) {
|
||||
/* need to convert provided socket to a PHYSICAL socket id */
|
||||
phys_socket = opal_paffinity_base_get_physical_socket_id(socket);
|
||||
if (0 > phys_socket) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical socket id for logical socket %ld",
|
||||
rank, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
if ( socket > max_socket_num) {
|
||||
opal_output(0,"ERROR !!! socket(%d) > max_socket_num(%d), modify rankfile and run again",
|
||||
socket, max_socket_num);
|
||||
return OPAL_ERROR;
|
||||
} else {
|
||||
phys_socket = socket;
|
||||
}
|
||||
|
||||
/* get the LOGICAL core info for this socket */
|
||||
if ( OPAL_SUCCESS != ( rc = opal_paffinity_base_get_core_info(phys_socket, &num_cores))) {
|
||||
opal_output(0,"Rank %ld: PAFFINITY Error !!! Could not get core info for physical socket number %d (%d)",
|
||||
rank, phys_socket, socket);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (0 == strcmp("*",socket_core[1])) {
|
||||
/* bind to all available LOGICAL cores */
|
||||
for (core = 0; core <= num_cores; core++) {
|
||||
/* convert to PHYSICAL core id */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
/* get the PHYSICAL processor id for the PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
}
|
||||
if ( OPAL_SUCCESS != ( rc = opal_paffinity_base_get_core_info(socket, &num_cores, &max_core_num))) {
|
||||
opal_output(0,"Error !!! Invalid socket number (%d) in rankfile, modify rankfile and run again\n",
|
||||
socket);
|
||||
return OPAL_ERROR;
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (0 == strcmp("*",socket_core[1])) {
|
||||
for (core = 0; core <= max_core_num; core++) {
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
return OPAL_ERROR;
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical processor #%d ( %d : %d)",
|
||||
rank, phys_processor, socket, core);
|
||||
}
|
||||
} else {
|
||||
range = opal_argv_split(socket_core[1], '-');
|
||||
range_cnt = opal_argv_count(range);
|
||||
switch (range_cnt) {
|
||||
case 1: /* only one core specified */
|
||||
core = atoi(range[0]);
|
||||
if (logical_map) {
|
||||
/* convert to physical core */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_core = core;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
/* get the PHYSICAL processor id for this PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* range of core id's was given */
|
||||
lower_range = atoi(range[0]);
|
||||
upper_range = atoi(range[1]);
|
||||
if ( 0 > lower_range || num_cores < (upper_range - lower_range) || lower_range >= upper_range ) {
|
||||
opal_output(0,"Rank %ld: PAFFINITY Error !!! Check your boundaries lower %d upper %d num_cores %d",
|
||||
rank, lower_range, upper_range, num_cores);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
}
|
||||
} else {
|
||||
range = opal_argv_split(socket_core[1], '-');
|
||||
range_cnt = opal_argv_count(range);
|
||||
switch (range_cnt) {
|
||||
case 1:
|
||||
core = atoi(range[0]);
|
||||
if ( core > max_core_num ) {
|
||||
opal_output(0,"Error!!! core(%d)>max_core(%d) on socket %d, modify rankfile and run again\n",
|
||||
core, max_core_num, socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
break;
|
||||
case 2:
|
||||
lower_range = atoi(range[0]);
|
||||
upper_range = atoi(range[1]);
|
||||
if ( 0 > lower_range || max_core_num < upper_range || lower_range >= upper_range ) {
|
||||
opal_output(0,"Error !!! Check your boundaries %d < %d(max_core) < %d ,modify rankfile and run again\n",
|
||||
lower_range, max_core_num, upper_range);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
for (core=lower_range; core<=upper_range; core++) {
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
for (core=lower_range; core<=upper_range; core++) {
|
||||
if (logical_map) {
|
||||
/* convert to physical core */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
} else {
|
||||
phys_core = core;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
/* get the PHYSICAL processor id for this PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0,"paffinity slot assignment: rank %ld runs on cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
}
|
||||
/* tell paffinity to bind us */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
for (i=1; i<socket_core_list_cnt; i++) {
|
||||
socket_core = opal_argv_split (socket_core_list[i], ':');
|
||||
socket_core_cnt = opal_argv_count(socket_core);
|
||||
switch (socket_core_cnt) {
|
||||
case 1:
|
||||
range = opal_argv_split(socket_core[0], '-');
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
}
|
||||
|
||||
for (i=1; i<socket_core_list_cnt; i++) {
|
||||
socket_core = opal_argv_split (socket_core_list[i], ':');
|
||||
socket_core_cnt = opal_argv_count(socket_core);
|
||||
switch (socket_core_cnt) {
|
||||
case 1:
|
||||
/* no colon => these cores are on the same socket as the last one specified,
|
||||
* so we map them on that same physical socket
|
||||
*/
|
||||
range = opal_argv_split(socket_core[0], '-');
|
||||
range_cnt = opal_argv_count(range);
|
||||
switch (range_cnt) {
|
||||
case 1: /* only one core provided */
|
||||
core = atoi(range[0]);
|
||||
if (logical_map) {
|
||||
/* convert to physical core */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_core = core;
|
||||
}
|
||||
/* get the PHYSICAL processor id for this PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* range of core id's was given */
|
||||
if ( 0 > lower_range || num_cores < (upper_range - lower_range) || lower_range >= upper_range ) {
|
||||
opal_output(0,"Rank %ld: PAFFINITY Error !!! Check your boundaries lower %d upper %d num_cores %d",
|
||||
rank, lower_range, upper_range, num_cores);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
for (core=lower_range; core<=upper_range; core++) {
|
||||
if (logical_map) {
|
||||
/* convert to physical core */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_core = core;
|
||||
}
|
||||
/* get the PHYSICAL processor id for this PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
}
|
||||
/* tell paffinity to bind us */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(range);
|
||||
break;
|
||||
|
||||
case 2: /* colon was given => refers to a new socket! */
|
||||
socket = atoi(socket_core[0]);
|
||||
if (logical_map) {
|
||||
/* need to convert provided socket to a PHYSICAL socket id */
|
||||
phys_socket = opal_paffinity_base_get_physical_socket_id(socket);
|
||||
if (0 > phys_socket) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical socket id for logical socket %ld",
|
||||
rank, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_socket = socket;
|
||||
}
|
||||
|
||||
/* get the LOGICAL core info for this socket */
|
||||
if ( OPAL_SUCCESS != ( rc = opal_paffinity_base_get_core_info(phys_socket, &num_cores))) {
|
||||
opal_output(0,"Rank %ld: PAFFINITY Error !!! Could not get core info for physical socket number %d (%d)",
|
||||
rank, phys_socket, socket);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (0 == strcmp("*",socket_core[1])) {
|
||||
/* bind to all available LOGICAL cores */
|
||||
for (core = 0; core <= num_cores; core++) {
|
||||
/* convert to PHYSICAL core id */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
/* get the PHYSICAL processor id for the PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
}
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
} else {
|
||||
range = opal_argv_split(socket_core[1], '-');
|
||||
range_cnt = opal_argv_count(range);
|
||||
socket = atoi(socket_core[0]);
|
||||
switch (range_cnt) {
|
||||
case 1:
|
||||
case 1: /* only one core specified */
|
||||
core = atoi(range[0]);
|
||||
/* use PLPA to construct the child->cpu_set */
|
||||
if ( core > max_core_num ) {
|
||||
opal_output(0,"Error !!! core(%d) > max_core(%d), modify rankfile and run again\n",
|
||||
core, max_core_num);
|
||||
return OPAL_ERROR;
|
||||
if (logical_map) {
|
||||
/* convert to physical core */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_core = core;
|
||||
}
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
opal_output(0,"Error !!! Invalid socket:core pair (%d:%d), modify rankfile and run again\n",
|
||||
socket, core);
|
||||
return OPAL_ERROR;
|
||||
/* get the PHYSICAL processor id for this PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* tell paffinity to bind us */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
break;
|
||||
case 2:
|
||||
|
||||
case 2: /* range of core id's was given */
|
||||
lower_range = atoi(range[0]);
|
||||
upper_range = atoi(range[1]);
|
||||
if ( 0 > lower_range || max_core_num < upper_range || lower_range >= upper_range) {
|
||||
opal_output(0,"Error !!! Check your boundaries %d < %d(max_core) < %d, modify rankfile and run again\n",
|
||||
lower_range, max_core_num, upper_range);
|
||||
if ( 0 > lower_range || num_cores < (upper_range - lower_range) || lower_range >= upper_range ) {
|
||||
opal_output(0,"Rank %ld: PAFFINITY Error !!! Check your boundaries lower %d upper %d num_cores %d",
|
||||
rank, lower_range, upper_range, num_cores);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
for (core=lower_range; core<=upper_range; core++) {
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
return OPAL_ERROR;
|
||||
if (logical_map) {
|
||||
/* convert to physical core */
|
||||
if (0 > (phys_core = opal_paffinity_base_get_physical_core_id(phys_socket, core))) {
|
||||
opal_output(0, "Rank %ld: PAFFINITY cannot get physical core id for logical core %ld in physical socket %ld (%ld)",
|
||||
rank, (long)core, (long)phys_socket, (long)socket);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
phys_core = core;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
/* get the PHYSICAL processor id for this PHYSICAL socket/core */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_get_map_to_processor_id (phys_socket, phys_core, &phys_processor))) {
|
||||
return rc;
|
||||
}
|
||||
/* set the bit for this processor */
|
||||
OPAL_PAFFINITY_CPU_SET(phys_processor, cpumask);
|
||||
/* output diagnostic if requested */
|
||||
if (diag_requested) {
|
||||
opal_output(0, "paffinity slot assignment: rank %ld runs on physical cpu #%d ( %d[%d] : %d[%d])",
|
||||
rank, phys_processor, phys_socket, socket, phys_core, core);
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
}
|
||||
break;
|
||||
/* tell paffinity to bind us */
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
default:
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(range);
|
||||
break;
|
||||
case 2:
|
||||
socket = atoi(socket_core[0]);
|
||||
if (0 == strcmp("*",socket_core[1])) {
|
||||
for (core=0; core<=max_core_num; core++) {
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id ( socket, core, &processor_id))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
}
|
||||
} else {
|
||||
range = opal_argv_split(socket_core[1], '-');
|
||||
range_cnt = opal_argv_count(range);
|
||||
socket = atoi(socket_core[0]);
|
||||
switch (range_cnt) {
|
||||
case 1:
|
||||
core = atoi(range[0]);
|
||||
if ( core > max_core_num ) {
|
||||
opal_output(0,"Error !!! max_core(%d) < core(%d), modify rankfile and run again\n",
|
||||
core, max_core_num);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
break;
|
||||
case 2:
|
||||
lower_range = atoi(range[0]);
|
||||
upper_range = atoi(range[1]);
|
||||
if ( 0 > lower_range || max_core_num < upper_range || lower_range > upper_range) {
|
||||
opal_output(0,"Error !!! Check your boundaries %d < %d(max_core) < %d, modify rankfile and run again\n",
|
||||
lower_range, max_core_num, upper_range);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
for ( core = lower_range; core <= upper_range; core++) {
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_map_to_processor_id (socket, core, &processor_id))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
OPAL_PAFFINITY_CPU_SET(processor_id, cpumask);
|
||||
if ( OPAL_SUCCESS != (rc = opal_paffinity_base_set(cpumask))) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity slot assignment: rank %ld runs on cpu #%d ( %d : %d)",
|
||||
rank, processor_id, socket, core);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
opal_argv_free(range);
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(range);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(socket_core);
|
||||
opal_argv_free(socket_core);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
opal_argv_free(socket_core);
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int opal_paffinity_base_slot_list_set(long rank)
|
||||
@ -338,14 +509,15 @@ int opal_paffinity_base_slot_list_set(long rank)
|
||||
char **item;
|
||||
char **socket_core;
|
||||
int item_cnt, socket_core_cnt, rc;
|
||||
|
||||
bool logical_map;
|
||||
|
||||
rc = mca_base_param_find("opal", NULL, "paffinity_base_slot_list");
|
||||
/* If there was not slot list specified, return a specific error
|
||||
code indicating that */
|
||||
code indicating that */
|
||||
if (rc <= 0) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
if (OPAL_SUCCESS == mca_base_param_lookup_string(rc, &slot_str)) {
|
||||
if (NULL == slot_str) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
@ -354,30 +526,45 @@ int opal_paffinity_base_slot_list_set(long rank)
|
||||
if (0 == strcmp("", slot_str)){
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
opal_output_verbose(5, opal_paffinity_base_output, "paffinity slot assignment: slot_list == %s", slot_str);
|
||||
|
||||
/* check for diag request to avoid repeatedly doing so */
|
||||
if (4 < opal_output_get_verbosity(opal_paffinity_base_output)) {
|
||||
diag_requested = true;
|
||||
} else {
|
||||
diag_requested = false;
|
||||
}
|
||||
|
||||
opal_output_verbose(5, opal_paffinity_base_output, "paffinity slot assignment: slot_list == %s", slot_str);
|
||||
|
||||
if ('P' == slot_str[0] || 'p' == slot_str[0]) {
|
||||
/* user has specified physical mapping */
|
||||
logical_map = false;
|
||||
item = opal_argv_split (&slot_str[1], ',');
|
||||
} else {
|
||||
logical_map = true; /* default to logical mapping */
|
||||
item = opal_argv_split (slot_str, ',');
|
||||
item_cnt = opal_argv_count (item);
|
||||
socket_core = opal_argv_split (item[0], ':');
|
||||
socket_core_cnt = opal_argv_count(socket_core);
|
||||
opal_argv_free(socket_core);
|
||||
switch (socket_core_cnt) {
|
||||
case 1:
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_socket_to_cpu_set(item, item_cnt, rank))) {
|
||||
opal_argv_free(item);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_socket_core_to_cpu_set(item, item_cnt, rank))) {
|
||||
opal_argv_free(item);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
item_cnt = opal_argv_count (item);
|
||||
socket_core = opal_argv_split (item[0], ':');
|
||||
socket_core_cnt = opal_argv_count(socket_core);
|
||||
opal_argv_free(socket_core);
|
||||
switch (socket_core_cnt) {
|
||||
case 1: /* binding to cpu's */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_socket_to_cpu_set(item, item_cnt, rank, logical_map))) {
|
||||
opal_argv_free(item);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(item);
|
||||
return OPAL_SUCCESS;
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
case 2: /* binding to socket/core specification */
|
||||
if (OPAL_SUCCESS != (rc = opal_paffinity_base_socket_core_to_cpu_set(item, item_cnt, rank, logical_map))) {
|
||||
opal_argv_free(item);
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
opal_argv_free(item);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
opal_argv_free(item);
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -51,44 +51,68 @@ int opal_paffinity_base_get(opal_paffinity_base_cpu_set_t *cpumask)
|
||||
return opal_paffinity_base_module->paff_module_get(cpumask);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_map_to_processor_id(int socket, int core, int *processor_id)
|
||||
int opal_paffinity_base_get_map_to_processor_id(int socket, int core, int *processor_id)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_map_to_processor_id(socket, core, processor_id);
|
||||
return opal_paffinity_base_module->paff_get_map_to_processor_id(socket, core, processor_id);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_map_to_socket_core(int processor_id, int *socket, int *core)
|
||||
int opal_paffinity_base_get_map_to_socket_core(int processor_id, int *socket, int *core)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_map_to_socket_core(processor_id, socket, core);
|
||||
return opal_paffinity_base_module->paff_get_map_to_socket_core(processor_id, socket, core);
|
||||
}
|
||||
|
||||
|
||||
int opal_paffinity_base_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
int opal_paffinity_base_get_processor_info(int *num_processors)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_processor_info(num_processors, max_processor_id);
|
||||
return opal_paffinity_base_module->paff_get_processor_info(num_processors);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
int opal_paffinity_base_get_socket_info(int *num_sockets)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_socket_info(num_sockets, max_socket_num);
|
||||
return opal_paffinity_base_module->paff_get_socket_info(num_sockets);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
int opal_paffinity_base_get_core_info(int socket, int *num_cores)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_core_info(socket, num_cores, max_core_num);
|
||||
return opal_paffinity_base_module->paff_get_core_info(socket, num_cores);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_physical_processor_id(int logical_processor_id)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_physical_processor_id(logical_processor_id);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_physical_socket_id(int logical_socket_id)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_physical_socket_id(logical_socket_id);
|
||||
}
|
||||
|
||||
int opal_paffinity_base_get_physical_core_id(int physical_socket_id, int logical_core_id)
|
||||
{
|
||||
if (!opal_paffinity_base_selected) {
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
return opal_paffinity_base_module->paff_get_physical_core_id(physical_socket_id, logical_core_id);
|
||||
}
|
||||
|
||||
|
@ -41,32 +41,38 @@
|
||||
/*
|
||||
* Local functions
|
||||
*/
|
||||
static int darwin_module_init(void);
|
||||
static int darwin_module_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int darwin_module_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int darwin_module_finalize(void);
|
||||
static int darwin_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int darwin_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int darwin_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int darwin_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int darwin_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int init(void);
|
||||
static int set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int finalize(void);
|
||||
static int map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int get_processor_info(int *num_processors);
|
||||
static int get_socket_info(int *num_sockets);
|
||||
static int get_core_info(int socket, int *num_cores);
|
||||
static int get_physical_processor_id(int logical_processor_id);
|
||||
static int get_physical_socket_id(int logical_socket_id);
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id);
|
||||
|
||||
/*
|
||||
* Solaris paffinity module
|
||||
*/
|
||||
static const opal_paffinity_base_module_1_1_0_t loc_module = {
|
||||
/* Initialization function */
|
||||
darwin_module_init,
|
||||
init,
|
||||
|
||||
/* Module function pointers */
|
||||
darwin_module_set,
|
||||
darwin_module_get,
|
||||
darwin_module_map_to_processor_id,
|
||||
darwin_module_map_to_socket_core,
|
||||
darwin_module_get_processor_info,
|
||||
darwin_module_get_socket_info,
|
||||
darwin_module_get_core_info,
|
||||
darwin_module_finalize
|
||||
set,
|
||||
get,
|
||||
map_to_processor_id,
|
||||
map_to_socket_core,
|
||||
get_processor_info,
|
||||
get_socket_info,
|
||||
get_core_info,
|
||||
get_physical_processor_id,
|
||||
get_physical_socket_id,
|
||||
get_physical_core_id,
|
||||
finalize
|
||||
};
|
||||
|
||||
int opal_paffinity_darwin_component_query(mca_base_module_t **module, int *priority)
|
||||
@ -79,36 +85,36 @@ int opal_paffinity_darwin_component_query(mca_base_module_t **module, int *prior
|
||||
}
|
||||
|
||||
/* do nothing here. both mpirun and processes would run init(), but
|
||||
* only processes would run the darwin_module_set function */
|
||||
static int darwin_module_init(void)
|
||||
* only processes would run the set function */
|
||||
static int init(void)
|
||||
{
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/* this gives us a cpumask which tells which CPU to bind */
|
||||
static int darwin_module_set(opal_paffinity_base_cpu_set_t cpumask)
|
||||
static int set(opal_paffinity_base_cpu_set_t cpumask)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* This get function returns the CPU id that's currently binded,
|
||||
* and then sets the cpumask. */
|
||||
static int darwin_module_get(opal_paffinity_base_cpu_set_t *cpumask)
|
||||
static int get(opal_paffinity_base_cpu_set_t *cpumask)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int darwin_module_map_to_processor_id(int socket, int core, int *processor_id)
|
||||
static int map_to_processor_id(int socket, int core, int *processor_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int darwin_module_map_to_socket_core(int processor_id, int *socket, int *core)
|
||||
static int map_to_socket_core(int processor_id, int *socket, int *core)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int darwin_module_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
static int get_processor_info(int *num_processors)
|
||||
{
|
||||
int rc=OPAL_SUCCESS, num_cores;
|
||||
#if !OPAL_HAVE__SC_NPROCESSORS_ONLN
|
||||
@ -143,23 +149,37 @@ static int darwin_module_get_processor_info(int *num_processors, int *max_proces
|
||||
/* rc will contain the number of processors
|
||||
* that are currently online - return that value
|
||||
*/
|
||||
*num_processors = *max_processor_id = num_cores;
|
||||
*num_processors = num_cores;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int darwin_module_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
static int get_socket_info(int *num_sockets)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int darwin_module_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
static int get_core_info(int socket, int *num_cores)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_processor_id(int logical_processor_id)
|
||||
{
|
||||
return logical_processor_id;
|
||||
}
|
||||
|
||||
static int darwin_module_finalize(void)
|
||||
static int get_physical_socket_id(int logical_socket_id)
|
||||
{
|
||||
return logical_socket_id;
|
||||
}
|
||||
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id)
|
||||
{
|
||||
return logical_core_id;
|
||||
}
|
||||
|
||||
static int finalize(void)
|
||||
{
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
@ -36,6 +36,10 @@
|
||||
#include "paffinity_linux.h"
|
||||
#include "plpa/src/libplpa/plpa.h"
|
||||
|
||||
/*
|
||||
* Local static variables
|
||||
*/
|
||||
opal_paffinity_linux_plpa_cpu_set_t global_paff_mask;
|
||||
|
||||
/*
|
||||
* Local functions
|
||||
@ -45,9 +49,12 @@ static int linux_module_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int linux_module_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int linux_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int linux_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int linux_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int linux_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int linux_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int linux_module_get_processor_info(int *num_processors);
|
||||
static int linux_module_get_socket_info(int *num_sockets);
|
||||
static int linux_module_get_core_info(int socket, int *num_cores);
|
||||
static int get_physical_processor_id(int logical_processor_id);
|
||||
static int get_physical_socket_id(int logical_socket_id);
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id);
|
||||
|
||||
/*
|
||||
* Linux paffinity module
|
||||
@ -64,6 +71,9 @@ static const opal_paffinity_base_module_1_1_0_t loc_module = {
|
||||
linux_module_get_processor_info,
|
||||
linux_module_get_socket_info,
|
||||
linux_module_get_core_info,
|
||||
get_physical_processor_id,
|
||||
get_physical_socket_id,
|
||||
get_physical_core_id,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -98,8 +108,46 @@ int opal_paffinity_linux_component_query(mca_base_module_t **module, int *priori
|
||||
|
||||
static int linux_module_init(void)
|
||||
{
|
||||
/* Nothing to do */
|
||||
int supported;
|
||||
opal_paffinity_linux_plpa_cpu_set_t tmp;
|
||||
int i;
|
||||
|
||||
/* ensure the global mask is clean */
|
||||
OPAL_PAFFINITY_CPU_ZERO(global_paff_mask);
|
||||
|
||||
/* check if PLPA supports topology */
|
||||
opal_paffinity_linux_plpa_have_topology_information(&supported);
|
||||
|
||||
if (!supported) {
|
||||
/* do a little dance to give us some info we can
|
||||
* use to support at least binding processors
|
||||
*/
|
||||
OPAL_PAFFINITY_CPU_ZERO(tmp); /* ensure this is clean */
|
||||
/* get our current affinity so we can return to it later */
|
||||
opal_paffinity_linux_plpa_sched_getaffinity(getpid(), sizeof(tmp), &tmp);
|
||||
/* set all the bits in the global mask */
|
||||
for (i=0; i < OPAL_PAFFINITY_BITMASK_CPU_MAX; i++) {
|
||||
OPAL_PAFFINITY_CPU_SET(i, global_paff_mask);
|
||||
}
|
||||
/* set the affinity, but don't check the return code as
|
||||
* it may return an error. This is a simple method
|
||||
* for probing which processors actually exist
|
||||
*/
|
||||
opal_paffinity_linux_plpa_sched_setaffinity(getpid(),
|
||||
sizeof(global_paff_mask),
|
||||
&global_paff_mask);
|
||||
/* now do a get and find out where we actually are bound */
|
||||
opal_paffinity_linux_plpa_sched_getaffinity(getpid(),
|
||||
sizeof(global_paff_mask),
|
||||
&global_paff_mask);
|
||||
/* the mask now contains a map of the actual physical processors
|
||||
* Set ourselves back to our original affinity
|
||||
*/
|
||||
opal_paffinity_linux_plpa_sched_setaffinity(getpid(),
|
||||
sizeof(tmp),
|
||||
&tmp);
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
@ -185,10 +233,13 @@ static int linux_module_map_to_socket_core(int processor_id, int *socket, int *c
|
||||
return convert(ret);
|
||||
}
|
||||
|
||||
static int linux_module_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
static int linux_module_get_processor_info(int *num_processors)
|
||||
{
|
||||
int ret = opal_paffinity_linux_plpa_get_processor_info(num_processors,
|
||||
max_processor_id);
|
||||
int max_processor_id;
|
||||
|
||||
int ret = opal_paffinity_linux_plpa_get_processor_data(OPAL_PAFFINITY_LINUX_PLPA_COUNT_ONLINE,
|
||||
num_processors,
|
||||
&max_processor_id);
|
||||
|
||||
/* If we're on a kernel that does not support the topology
|
||||
functionality, PLPA will return ENOSYS and not try to calculate
|
||||
@ -198,7 +249,7 @@ static int linux_module_get_processor_info(int *num_processors, int *max_process
|
||||
if (ENOSYS == ret) {
|
||||
ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (ret > 0) {
|
||||
*num_processors = *max_processor_id = ret;
|
||||
*num_processors = ret;
|
||||
return OPAL_SUCCESS;
|
||||
} else {
|
||||
return OPAL_ERR_IN_ERRNO;
|
||||
@ -208,17 +259,85 @@ static int linux_module_get_processor_info(int *num_processors, int *max_process
|
||||
}
|
||||
}
|
||||
|
||||
static int linux_module_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
static int linux_module_get_socket_info(int *num_sockets)
|
||||
{
|
||||
int max_socket_num;
|
||||
|
||||
int ret = opal_paffinity_linux_plpa_get_socket_info(num_sockets,
|
||||
max_socket_num);
|
||||
&max_socket_num);
|
||||
return convert(ret);
|
||||
}
|
||||
|
||||
static int linux_module_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
static int linux_module_get_core_info(int socket, int *num_cores)
|
||||
{
|
||||
int max_core_num;
|
||||
|
||||
int ret = opal_paffinity_linux_plpa_get_core_info(socket, num_cores,
|
||||
max_core_num);
|
||||
&max_core_num);
|
||||
return convert(ret);
|
||||
}
|
||||
|
||||
static int get_physical_processor_id(int logical_processor_id)
|
||||
{
|
||||
int ret, phys_id;
|
||||
int i, count;
|
||||
|
||||
ret = opal_paffinity_linux_plpa_get_processor_id(logical_processor_id,
|
||||
OPAL_PAFFINITY_LINUX_PLPA_COUNT_ONLINE,
|
||||
&phys_id);
|
||||
if (0 == ret) {
|
||||
/* PLPA was able to return a value, so pass it along */
|
||||
return phys_id;
|
||||
}
|
||||
|
||||
ret = convert(ret);
|
||||
if (OPAL_ERR_NOT_SUPPORTED == ret) {
|
||||
/* if it isn't supported, then we may be able
|
||||
* to use our global_paff_mask to compute the
|
||||
* mapping
|
||||
*/
|
||||
count = 0;
|
||||
for (i=0; i < OPAL_PAFFINITY_BITMASK_CPU_MAX; i++) {
|
||||
if (OPAL_PAFFINITY_CPU_ISSET(i, global_paff_mask)) {
|
||||
if (count == logical_processor_id) {
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if we executed the above loop and didn't find anything,
|
||||
* this will still be set to OPAL_ERR_NOT_SUPPORTED, which
|
||||
* is what we want in that case
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int get_physical_socket_id(int logical_socket_id)
|
||||
{
|
||||
int ret, phys_id;
|
||||
|
||||
ret = opal_paffinity_linux_plpa_get_socket_id(logical_socket_id,
|
||||
&phys_id);
|
||||
if (0 == ret) {
|
||||
return phys_id;
|
||||
} else {
|
||||
return convert(ret);
|
||||
}
|
||||
}
|
||||
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id)
|
||||
{
|
||||
int ret, phys_id;
|
||||
|
||||
ret = opal_paffinity_linux_plpa_get_core_id(physical_socket_id,
|
||||
logical_core_id, &phys_id);
|
||||
if (0 == ret) {
|
||||
return phys_id;
|
||||
} else {
|
||||
return convert(ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,17 +41,45 @@
|
||||
* selected component before invoking function pointers). If there is
|
||||
* no selected component, they return an appropriate error code.
|
||||
*
|
||||
* In the paffinity interface, we make the distinction between LOGICAL
|
||||
* and PHYSICAL processors. LOGICAL processors are defined to have
|
||||
* some corresponding PHYSICAL processor that both exists and is
|
||||
* currently online. LOGICAL processors numbered countiguously
|
||||
* starting with 0. PHYSICAL processors are numbered according to the
|
||||
* underlying operating system; they are represented by integers, but
|
||||
* no guarantees are made about their values.
|
||||
*
|
||||
* Hence, LOGICAL processor IDs are convenient for humans and are in
|
||||
* the range of [0,N-1] (assuming N processors are currently online).
|
||||
* Each LOGICAL processor has a 1:1 relationship with a PHYSICAL
|
||||
* processor, but the PHYSICAL processor's ID can be any unique
|
||||
* integer value.
|
||||
*
|
||||
* ***NOTE*** Obtaining information about socket/core IDs is not well
|
||||
* supported in many OS's. Programmers using this paffinity interface
|
||||
* should fully expect to sometimes get OPAL_ERR_NOT_SUPPORTED back
|
||||
* when calling such functions.
|
||||
|
||||
* General scheme
|
||||
*
|
||||
* The component has one function: query(). It simply returns a
|
||||
* priority (for the unlikely event where there are multiple
|
||||
* components available on a given platform).
|
||||
*
|
||||
* The module has three functions:
|
||||
* The module has the following functions:
|
||||
*
|
||||
* - module_init: initialze the module
|
||||
* - set: set this process's affinity to a specific processor set
|
||||
* - get: get this process's processor affinity set
|
||||
* - map physical (socket ID, core ID) -> physical processor ID
|
||||
* - map physical processor ID -> physical (socket ID, core ID)
|
||||
* - get the number of logical processors
|
||||
* - get the number of logical sockets
|
||||
* - get the number of logical cores on a specific socket
|
||||
* - map logical processor ID -> physical processor ID
|
||||
* - map logical socket ID -> physical socket ID
|
||||
* - map physical socket ID, logical core ID -> physical core ID
|
||||
* - module_finalize: finalize the module
|
||||
*/
|
||||
|
||||
#ifndef OPAL_PAFFINITY_H
|
||||
@ -145,63 +173,90 @@ typedef int (*opal_paffinity_base_module_init_1_1_0_fn_t)(void);
|
||||
|
||||
/**
|
||||
* Module function to set this process' affinity to a specific set of
|
||||
* [virtual] CPUs.
|
||||
* PHYSICAL CPUs.
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_set_fn_t)(opal_paffinity_base_cpu_set_t cpumask);
|
||||
|
||||
|
||||
/**
|
||||
* Module function to get this process' affinity to a specific set of
|
||||
* [virtual] CPUs. Returns OPAL_ERR_NOT_FOUND if
|
||||
* PHYSICAL CPUs. Returns OPAL_ERR_NOT_FOUND if
|
||||
* opal_paffinity_base_module_set_fn_t() was not previously invoked in
|
||||
* this process.
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_fn_t)(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
|
||||
/**
|
||||
* Provides mapping socket:core -> processor id. currently
|
||||
* supported only in Linux hosts
|
||||
* Returns mapping of PHYSICAL socket:core -> PHYSICAL processor id.
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
* supported
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_map_to_processor_id_fn_t)(int socket, int core, int *processor_id);
|
||||
typedef int (*opal_paffinity_base_module_get_map_to_processor_id_fn_t)(int physical_socket,
|
||||
int physical_core,
|
||||
int *physical_processor_id);
|
||||
|
||||
/**
|
||||
* Provides mapping processor id -> socket:core. currently
|
||||
* supported only in Linux hosts
|
||||
* Provides mapping of PHYSICAL processor id -> PHYSICAL socket:core.
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
* supported
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_map_to_socket_core_fn_t)(int processor_id, int *socket, int *core);
|
||||
typedef int (*opal_paffinity_base_module_get_map_to_socket_core_fn_t)(int physical_processor_id,
|
||||
int *physical_socket,
|
||||
int *physical_core);
|
||||
|
||||
/**
|
||||
* Provides highest processor id number in a host. currently
|
||||
* supported only in Linux hosts
|
||||
* Provides number of LOGICAL processors in a host.
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
* supported
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_processor_info_fn_t)(int *num_processors, int *max_processor_id);
|
||||
typedef int (*opal_paffinity_base_module_get_processor_info_fn_t)(int *num_processors);
|
||||
|
||||
/**
|
||||
* Provides the number of sockets in a host. currently supported
|
||||
* Provides the number of LOGICAL sockets in a host.
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supported
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_socket_info_fn_t)(int *num_sockets);
|
||||
|
||||
/**
|
||||
* Provides the number of LOGICAL cores in a PHYSICAL socket. currently supported
|
||||
* only in Linux hosts
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_socket_info_fn_t)(int *num_sockets, int *max_socket_num);
|
||||
typedef int (*opal_paffinity_base_module_get_core_info_fn_t)(int physical_socket, int *num_cores);
|
||||
|
||||
/**
|
||||
* Provides the number of cores in a socket. currently supported
|
||||
* only in Linux hosts
|
||||
* Return the PHYSICAL processor id that corresponds to the
|
||||
* given LOGICAL processor id
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_physical_processor_id_fn_t)(int logical_processor_id);
|
||||
|
||||
/**
|
||||
* Return the PHYSICAL socket id that corresponds to the given
|
||||
* LOGICAL socket id
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_core_info_fn_t)(int socket, int *num_cores, int *max_core_num);
|
||||
typedef int (*opal_paffinity_base_module_get_physical_socket_id_fn_t)(int logical_socket_id);
|
||||
|
||||
/**
|
||||
* Return the PHYSICAL core id that corresponds to the given LOGICAL
|
||||
* core id on the given PHYSICAL socket id
|
||||
*
|
||||
* return OPAL_SUCCESS or OPAL_ERR_NOT_SUPPORTED if not
|
||||
* supporeted (solaris, windows, etc...)
|
||||
*/
|
||||
typedef int (*opal_paffinity_base_module_get_physical_core_id_fn_t)(int physical_socket_id, int logical_core_id);
|
||||
|
||||
|
||||
/**
|
||||
@ -232,31 +287,40 @@ typedef struct opal_paffinity_base_component_2_0_0_t opal_paffinity_base_compone
|
||||
*/
|
||||
struct opal_paffinity_base_module_1_1_0_t {
|
||||
/** Module initialization function */
|
||||
opal_paffinity_base_module_init_1_1_0_fn_t paff_module_init;
|
||||
opal_paffinity_base_module_init_1_1_0_fn_t paff_module_init;
|
||||
|
||||
/** Set this process' affinity */
|
||||
opal_paffinity_base_module_set_fn_t paff_module_set;
|
||||
opal_paffinity_base_module_set_fn_t paff_module_set;
|
||||
|
||||
/** Get this process' affinity */
|
||||
opal_paffinity_base_module_get_fn_t paff_module_get;
|
||||
opal_paffinity_base_module_get_fn_t paff_module_get;
|
||||
|
||||
/** Map socket:core to processor ID */
|
||||
opal_paffinity_base_module_map_to_processor_id_fn_t paff_map_to_processor_id;
|
||||
opal_paffinity_base_module_get_map_to_processor_id_fn_t paff_get_map_to_processor_id;
|
||||
|
||||
/** Map processor ID to socket:core */
|
||||
opal_paffinity_base_module_map_to_socket_core_fn_t paff_map_to_socket_core;
|
||||
opal_paffinity_base_module_get_map_to_socket_core_fn_t paff_get_map_to_socket_core;
|
||||
|
||||
/** Return the max processor ID */
|
||||
opal_paffinity_base_module_get_processor_info_fn_t paff_get_processor_info;
|
||||
opal_paffinity_base_module_get_processor_info_fn_t paff_get_processor_info;
|
||||
|
||||
/** Return the max socket number */
|
||||
opal_paffinity_base_module_get_socket_info_fn_t paff_get_socket_info;
|
||||
opal_paffinity_base_module_get_socket_info_fn_t paff_get_socket_info;
|
||||
|
||||
/** Return the max core number */
|
||||
opal_paffinity_base_module_get_core_info_fn_t paff_get_core_info;
|
||||
opal_paffinity_base_module_get_core_info_fn_t paff_get_core_info;
|
||||
|
||||
/* Return physical processor id */
|
||||
opal_paffinity_base_module_get_physical_processor_id_fn_t paff_get_physical_processor_id;
|
||||
|
||||
/* Return physical socket id */
|
||||
opal_paffinity_base_module_get_physical_socket_id_fn_t paff_get_physical_socket_id;
|
||||
|
||||
/* Return physical core id */
|
||||
opal_paffinity_base_module_get_physical_core_id_fn_t paff_get_physical_core_id;
|
||||
|
||||
/** Shut down this module */
|
||||
opal_paffinity_base_module_finalize_fn_t paff_module_finalize;
|
||||
opal_paffinity_base_module_finalize_fn_t paff_module_finalize;
|
||||
};
|
||||
/**
|
||||
* Convenience typedef
|
||||
|
@ -44,9 +44,12 @@ static int posix_module_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int posix_module_finalize(void);
|
||||
static int posix_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int posix_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int posix_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int posix_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int posix_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int posix_module_get_processor_info(int *num_processors);
|
||||
static int posix_module_get_socket_info(int *num_sockets);
|
||||
static int posix_module_get_core_info(int socket, int *num_cores);
|
||||
static int get_physical_processor_id(int logical_processor_id);
|
||||
static int get_physical_socket_id(int logical_socket_id);
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id);
|
||||
|
||||
/*
|
||||
* Solaris paffinity module
|
||||
@ -63,6 +66,9 @@ static const opal_paffinity_base_module_1_1_0_t loc_module = {
|
||||
posix_module_get_processor_info,
|
||||
posix_module_get_socket_info,
|
||||
posix_module_get_core_info,
|
||||
get_physical_processor_id,
|
||||
get_physical_socket_id,
|
||||
get_physical_core_id,
|
||||
posix_module_finalize
|
||||
};
|
||||
|
||||
@ -107,7 +113,7 @@ static int posix_module_map_to_socket_core(int processor_id, int *socket, int *c
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int posix_module_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
static int posix_module_get_processor_info(int *num_processors)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@ -116,23 +122,38 @@ static int posix_module_get_processor_info(int *num_processors, int *max_process
|
||||
/* system was unable to provide a number, so return
|
||||
* an error and set the values to something negative
|
||||
*/
|
||||
*num_processors = *max_processor_id = -1;
|
||||
*num_processors = -1;
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
/* rc will contain the number of processors
|
||||
* that are currently online - return that value
|
||||
*/
|
||||
*num_processors = *max_processor_id = rc;
|
||||
*num_processors = rc;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int posix_module_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
static int posix_module_get_socket_info(int *num_sockets)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int posix_module_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
static int posix_module_get_core_info(int socket, int *num_cores)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_processor_id(int logical_processor_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_socket_id(int logical_socket_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
@ -46,9 +46,12 @@ static int solaris_module_finalize(void);
|
||||
static int cpumask_to_id(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int solaris_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int solaris_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int solaris_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int solaris_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int solaris_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int solaris_module_get_processor_info(int *num_processors);
|
||||
static int solaris_module_get_socket_info(int *num_sockets);
|
||||
static int solaris_module_get_core_info(int socket, int *num_cores);
|
||||
static int solaris_module_get_physical_processor_id(int logical_processor_id);
|
||||
static int solaris_module_get_physical_socket_id(int logical_socket_id);
|
||||
static int solaris_module_get_physical_core_id(int physical_socket_id, int logical_core_id);
|
||||
|
||||
/*
|
||||
* Solaris paffinity module
|
||||
@ -65,6 +68,9 @@ static const opal_paffinity_base_module_1_1_0_t loc_module = {
|
||||
solaris_module_get_processor_info,
|
||||
solaris_module_get_socket_info,
|
||||
solaris_module_get_core_info,
|
||||
solaris_module_get_physical_processor_id,
|
||||
solaris_module_get_physical_socket_id,
|
||||
solaris_module_get_physical_core_id,
|
||||
solaris_module_finalize
|
||||
};
|
||||
|
||||
@ -90,46 +96,24 @@ static int solaris_module_init(void)
|
||||
/* this gives us a cpumask which tells which CPU to bind */
|
||||
static int solaris_module_set(opal_paffinity_base_cpu_set_t cpumask)
|
||||
{
|
||||
int index, *cpuid_list, cpuid_loc=0;
|
||||
processorid_t currid, cpuid_max;
|
||||
processor_info_t pinfo;
|
||||
processorid_t cpuid;
|
||||
|
||||
/* cpuid_max is the max number available for a system arch. It is
|
||||
* an inclusive list. e.g. If cpuid_max=31, cpuid would be 0-31 */
|
||||
cpuid_max = sysconf(_SC_CPUID_MAX);
|
||||
cpuid_list = (int*)malloc((cpuid_max+1)*sizeof(int));
|
||||
|
||||
/* Because not all CPU ID in cpuid_max are actually valid,
|
||||
* and CPU ID may also not be contiguous. Therefore we
|
||||
* need to run through processor_info to ensure the validity.
|
||||
* Then find out which are actually online */
|
||||
for (currid=0; currid<=cpuid_max; currid++) {
|
||||
if (0 == processor_info(currid, &pinfo)) {
|
||||
if (P_ONLINE == pinfo.pi_state || P_NOINTR == pinfo.pi_state) {
|
||||
cpuid_list[cpuid_loc++] = currid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Find out where in the cpumask is the location of the current CPU.
|
||||
* Once the index position of the CPU is located, then the set index
|
||||
* We will use the same index in cpuid_list to locate the CPU ID */
|
||||
index = cpumask_to_id(cpumask);
|
||||
if (-1 == index) {
|
||||
/* Find out where in the cpumask is the location of the current CPU. */
|
||||
cpuid = cpumask_to_id(cpumask);
|
||||
if (-1 == cpuid) {
|
||||
opal_output(0, "paffinity:solaris: Error when coverting cpumask to id");
|
||||
return OPAL_ERR_IN_ERRNO;
|
||||
}
|
||||
|
||||
if (0 != processor_bind(P_PID, P_MYID, cpuid_list[index], NULL)) {
|
||||
if (0 != processor_bind(P_PID, P_MYID, cpuid, NULL)) {
|
||||
opal_output(0, "paffinity:solaris: Error when binding to CPU #%d: %s",
|
||||
cpuid_list[index], strerror(errno));
|
||||
free(cpuid_list);
|
||||
cpuid, strerror(errno));
|
||||
return OPAL_ERR_IN_ERRNO;
|
||||
}
|
||||
|
||||
opal_output_verbose(5, opal_paffinity_base_output,
|
||||
"paffinity:solaris: Successfully bind to CPU #%d", cpuid_list[index]);
|
||||
free(cpuid_list);
|
||||
"paffinity:solaris: Successfully bind to CPU #%d", cpuid);
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
@ -175,7 +159,7 @@ static int solaris_module_map_to_socket_core(int processor_id, int *socket, int
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
static int solaris_module_get_processor_info(int *num_processors)
|
||||
{
|
||||
processorid_t currid, cpuid_max;
|
||||
processor_info_t pinfo;
|
||||
@ -195,19 +179,54 @@ static int solaris_module_get_processor_info(int *num_processors, int *max_proce
|
||||
if (0 == processor_info(currid, &pinfo)) {
|
||||
if (P_ONLINE == pinfo.pi_state || P_NOINTR == pinfo.pi_state) {
|
||||
(*num_processors)++;
|
||||
*max_processor_id = currid;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int solaris_module_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
static int solaris_module_get_socket_info(int *num_sockets)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
static int solaris_module_get_core_info(int socket, int *num_cores)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_physical_processor_id(int logical_processor_id)
|
||||
{
|
||||
processorid_t currid, cpuid_max, cpuid_log=0;
|
||||
processor_info_t pinfo;
|
||||
|
||||
/* cpuid_max is the max number available for a system arch. It is
|
||||
* an inclusive list. e.g. If cpuid_max=31, cpuid would be 0-31 */
|
||||
cpuid_max = sysconf(_SC_CPUID_MAX);
|
||||
|
||||
/* Because not all CPU ID in cpuid_max are actually valid,
|
||||
* and CPU ID may also not be contiguous. Therefore we
|
||||
* need to run through processor_info to ensure the validity.
|
||||
* Then find out which are actually online */
|
||||
for (currid=0; currid<=cpuid_max; currid++) {
|
||||
if (0 == processor_info(currid, &pinfo)) {
|
||||
if (P_ONLINE == pinfo.pi_state || P_NOINTR == pinfo.pi_state) {
|
||||
if (cpuid_log == logical_processor_id) {
|
||||
break;
|
||||
}
|
||||
cpuid_log++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return currid;
|
||||
}
|
||||
|
||||
static int solaris_module_get_physical_socket_id(int logical_socket_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int solaris_module_get_physical_core_id(int physical_socket_id, int logical_core_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
@ -34,9 +34,12 @@ static int windows_module_set(opal_paffinity_base_cpu_set_t cpumask);
|
||||
static int windows_module_get(opal_paffinity_base_cpu_set_t *cpumask);
|
||||
static int windows_module_map_to_processor_id(int socket, int core, int *processor_id);
|
||||
static int windows_module_map_to_socket_core(int processor_id, int *socket, int *core);
|
||||
static int windows_module_get_processor_info(int *num_processors, int *max_processor_id);
|
||||
static int windows_module_get_socket_info(int *num_sockets, int *max_socket_num);
|
||||
static int windows_module_get_core_info(int socket, int *num_cores, int *max_core_num);
|
||||
static int windows_module_get_processor_info(int *num_processors);
|
||||
static int windows_module_get_socket_info(int *num_sockets);
|
||||
static int windows_module_get_core_info(int socket, int *num_cores);
|
||||
static int get_physical_processor_id(int logical_processor_id);
|
||||
static int get_physical_socket_id(int logical_socket_id);
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id);
|
||||
|
||||
static SYSTEM_INFO sys_info;
|
||||
|
||||
@ -55,6 +58,9 @@ static const opal_paffinity_base_module_1_1_0_t loc_module = {
|
||||
windows_module_get_processor_info,
|
||||
windows_module_get_socket_info,
|
||||
windows_module_get_core_info,
|
||||
get_physical_processor_id,
|
||||
get_physical_socket_id,
|
||||
get_physical_core_id,
|
||||
windows_module_finalize
|
||||
};
|
||||
|
||||
@ -132,21 +138,34 @@ static int windows_module_map_to_socket_core(int processor_id, int *socket, int
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int windows_module_get_processor_info(int *num_processors, int *max_processor_id)
|
||||
static int windows_module_get_processor_info(int *num_processors)
|
||||
{
|
||||
*num_processors = *max_processor_id = sys_info.dwNumberOfProcessors;
|
||||
*num_processors = sys_info.dwNumberOfProcessors;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int windows_module_get_socket_info(int *num_sockets, int *max_socket_num)
|
||||
static int windows_module_get_socket_info(int *num_sockets)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int windows_module_get_core_info(int socket, int *num_cores, int *max_core_num)
|
||||
static int windows_module_get_core_info(int socket, int *num_cores)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_processor_id(int logical_processor_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_socket_id(int logical_socket_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static int get_physical_core_id(int physical_socket_id, int logical_core_id)
|
||||
{
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -843,7 +843,7 @@ int orte_odls_base_default_launch_local(orte_jobid_t job,
|
||||
orte_app_context_t *app, **apps;
|
||||
orte_std_cntr_t num_apps;
|
||||
orte_odls_child_t *child=NULL;
|
||||
int i, num_processors, max_processor_id;
|
||||
int i, num_processors;
|
||||
bool oversubscribed;
|
||||
int rc=ORTE_SUCCESS, ret;
|
||||
bool launch_failed=true;
|
||||
@ -898,7 +898,7 @@ int orte_odls_base_default_launch_local(orte_jobid_t job,
|
||||
}
|
||||
}
|
||||
|
||||
if (ORTE_SUCCESS != opal_paffinity_base_get_processor_info(&num_processors, &max_processor_id)) {
|
||||
if (ORTE_SUCCESS != opal_paffinity_base_get_processor_info(&num_processors)) {
|
||||
/* if we cannot find the number of local processors, we have no choice
|
||||
* but to default to conservative settings
|
||||
*/
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user