1
1

Add darwin paffinity component to handle the difference between Tiger and Leopard. Although both are POSIX compatible, Tiger is a tad different in this regard and requires a different interface to get the #processor data.

This commit was SVN r19117.
Этот коммит содержится в:
Ralph Castain 2008-08-01 00:15:10 +00:00
родитель 4bdc093746
Коммит e1501f2c9c
6 изменённых файлов: 394 добавлений и 0 удалений

43
opal/mca/paffinity/darwin/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,43 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
sources = \
paffinity_darwin.h \
paffinity_darwin_component.c \
paffinity_darwin_module.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if OMPI_BUILD_paffinity_darwin_DSO
component_noinst =
component_install = mca_paffinity_darwin.la
else
component_noinst = libmca_paffinity_darwin.la
component_install =
endif
mcacomponentdir = $(pkglibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_paffinity_darwin_la_SOURCES = $(sources)
mca_paffinity_darwin_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_paffinity_darwin_la_SOURCES =$(sources)
libmca_paffinity_darwin_la_LDFLAGS = -module -avoid-version

39
opal/mca/paffinity/darwin/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,39 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Cisco, Inc. All rights reserved.
# Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# MCA_paffinity_darwin_CONFIG([action-if-found], [action-if-not-found])
# -----------------------------------------------------------
AC_DEFUN([MCA_paffinity_darwin_CONFIG],[
# check to see if we have <mach/mach_host.h>
# as this is a Darwin-specific thing
AC_CHECK_HEADER([mach/mach_host.h], [happy=yes], [happy=no])
if test "$happy" = "yes"; then
AC_MSG_RESULT([$happy ])
fi
if test "$happy" = "yes"; then
$1
else
$2
fi
])dnl

22
opal/mca/paffinity/darwin/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,22 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Los Alamos National Security, LLC. All rights
# reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
PARAM_CONFIG_FILES="Makefile"

Просмотреть файл

@ -0,0 +1,41 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef MCA_PAFFINITY_DARWIN_EXPORT_H
#define MCA_PAFFINITY_DARWIN_EXPORT_H
#include "opal_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/paffinity/paffinity.h"
BEGIN_C_DECLS
/*
* Globally exported variable
*/
OPAL_DECLSPEC extern const opal_paffinity_base_component_2_0_0_t mca_paffinity_darwin_component;
/* query function */
int opal_paffinity_darwin_component_query(mca_base_module_t **module, int *priority);
END_C_DECLS
#endif /* MCA_PAFFINITY_DARWIN_EXPORT_H */

Просмотреть файл

@ -0,0 +1,83 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* These symbols are in a file by themselves to provide nice linker
* semantics. Since linkers generally pull in symbols by object
* files, keeping these symbols as the only symbols in this file
* prevents utility programs such as "ompi_info" from having to import
* entire components just to query their version and parameters.
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/mca/paffinity/paffinity.h"
#include "paffinity_darwin.h"
/*
* Public string showing the paffinity ompi_darwin component version number
*/
const char *opal_paffinity_darwin_component_version_string =
"OPAL darwin paffinity MCA component version " OPAL_VERSION;
/*
* Local function
*/
static int darwin_open(void);
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
const opal_paffinity_base_component_2_0_0_t mca_paffinity_darwin_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a paffinity v1.1.0 component (which also
implies a specific MCA version) */
OPAL_PAFFINITY_BASE_VERSION_2_0_0,
/* Component name and version */
"darwin",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
darwin_open,
NULL,
opal_paffinity_darwin_component_query
},
/* Next the MCA v1.0.0 component meta data */
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
};
static int darwin_open(void)
{
return OPAL_SUCCESS;
}

Просмотреть файл

@ -0,0 +1,166 @@
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
/* This component will only be compiled on Solaris, where we are
guaranteed to have these headers */
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <mach/mach_host.h>
#include <mach/host_info.h>
#include "opal/constants.h"
#include "opal/mca/base/mca_base_param.h"
#include "opal/mca/paffinity/paffinity.h"
#include "opal/mca/paffinity/base/base.h"
#include "opal/util/output.h"
#include "paffinity_darwin.h"
/*
* 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);
/*
* Solaris paffinity module
*/
static const opal_paffinity_base_module_1_1_0_t loc_module = {
/* Initialization function */
darwin_module_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
};
int opal_paffinity_darwin_component_query(mca_base_module_t **module, int *priority)
{
/* set this priority high enough to override posix */
*priority = 30;
*module = (mca_base_module_t *)&loc_module;
return OPAL_SUCCESS;
}
/* 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)
{
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)
{
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)
{
return OPAL_ERR_NOT_SUPPORTED;
}
static int darwin_module_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)
{
return OPAL_ERR_NOT_SUPPORTED;
}
static int darwin_module_get_processor_info(int *num_processors, int *max_processor_id)
{
int rc=OPAL_SUCCESS, num_cores;
#if !OPAL_HAVE__SC_NPROCESSORS_ONLN
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
#endif
#if OPAL_HAVE__SC_NPROCESSORS_ONLN
/* this must be Leopard - get the number of active processors */
if (0 > (num_cores = sysconf(_SC_NPROCESSORS_ONLN))) {
/* system was unable to provide a number, so return
* an error and set the values to something negative
*/
num_cores = -1;
rc = OPAL_ERR_NOT_FOUND;
}
#else
/* this must be Tiger - unlike Leopard, Tiger doesn't allow
* users to turn processors on/off on-the-fly. So we have
* to query the #processors in a different way
*/
infoCount = HOST_BASIC_INFO_COUNT;
if (KERN_SUCCESS != (host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount))) {
num_cores = -1;
rc = OPAL_ERR_NOT_FOUND;
} else {
num_cores = hostInfo.max_cpus;
}
#endif
/* rc will contain the number of processors
* that are currently online - return that value
*/
*num_processors = *max_processor_id = num_cores;
return rc;
}
static int darwin_module_get_socket_info(int *num_sockets, int *max_socket_num)
{
return OPAL_ERR_NOT_SUPPORTED;
}
static int darwin_module_get_core_info(int socket, int *num_cores, int *max_core_num)
{
return OPAL_ERR_NOT_SUPPORTED;
}
static int darwin_module_finalize(void)
{
return OPAL_SUCCESS;
}