
WHAT: Merge the PMIx branch into the devel repo, creating a new OPAL “lmix” framework to abstract PMI support for all RTEs. Replace the ORTE daemon-level collectives with a new PMIx server and update the ORTE grpcomm framework to support server-to-server collectives WHY: We’ve had problems dealing with variations in PMI implementations, and need to extend the existing PMI definitions to meet exascale requirements. WHEN: Mon, Aug 25 WHERE: https://github.com/rhc54/ompi-svn-mirror.git Several community members have been working on a refactoring of the current PMI support within OMPI. Although the APIs are common, Slurm and Cray implement a different range of capabilities, and package them differently. For example, Cray provides an integrated PMI-1/2 library, while Slurm separates the two and requires the user to specify the one to be used at runtime. In addition, several bugs in the Slurm implementations have caused problems requiring extra coding. All this has led to a slew of #if’s in the PMI code and bugs when the corner-case logic for one implementation accidentally traps the other. Extending this support to other implementations would have increased this complexity to an unacceptable level. Accordingly, we have: * created a new OPAL “pmix” framework to abstract the PMI support, with separate components for Cray, Slurm PMI-1, and Slurm PMI-2 implementations. * Replaced the current ORTE grpcomm daemon-based collective operation with an integrated PMIx server, and updated the grpcomm APIs to provide more flexible, multi-algorithm support for collective operations. At this time, only the xcast and allgather operations are supported. * Replaced the current global collective id with a signature based on the names of the participating procs. The allows an unlimited number of collectives to be executed by any group of processes, subject to the requirement that only one collective can be active at a time for a unique combination of procs. Note that a proc can be involved in any number of simultaneous collectives - it is the specific combination of procs that is subject to the constraint * removed the prior OMPI/OPAL modex code * added new macros for executing modex send/recv to simplify use of the new APIs. The send macros allow the caller to specify whether or not the BTL supports async modex operations - if so, then the non-blocking “fence” operation is used, if the active PMIx component supports it. Otherwise, the default is a full blocking modex exchange as we currently perform. * retained the current flag that directs us to use a blocking fence operation, but only to retrieve data upon demand This commit was SVN r32570.
311 строки
8.5 KiB
C
311 строки
8.5 KiB
C
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
/*
|
|
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
|
|
* reserved.
|
|
* Copyright (c) 2011 UT-Battelle, LLC. All rights reserved.
|
|
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
|
|
#include "common_ugni.h"
|
|
|
|
#include "opal/class/opal_list.h"
|
|
#include "opal/dss/dss.h"
|
|
#include "opal/mca/pmix/pmix.h"
|
|
|
|
/* NTH: we need some options from the btl */
|
|
#include "opal/mca/btl/ugni/btl_ugni.h"
|
|
|
|
static int opal_common_ugni_module_ref_count = 0;
|
|
opal_common_ugni_module_t opal_common_ugni_module;
|
|
|
|
mca_base_component_t opal_common_ugni_component = {
|
|
MCA_BASE_VERSION_2_0_0,
|
|
"common",
|
|
MCA_BASE_VERSION_2_0_0,
|
|
"ugni",
|
|
MCA_BASE_VERSION_2_0_0,
|
|
NULL,
|
|
NULL
|
|
};
|
|
|
|
static inline int
|
|
get_ptag(uint8_t *out_ptag)
|
|
{
|
|
/* TODO no need for tmp */
|
|
char *ptr;
|
|
uint8_t tmp_ptag;
|
|
|
|
if (NULL == (ptr = getenv("PMI_GNI_PTAG"))) {
|
|
/* TODO add err msg - better rc? */
|
|
return OPAL_ERR_NOT_FOUND;
|
|
}
|
|
errno = 0;
|
|
tmp_ptag = (uint8_t)strtoul (ptr, (char **)NULL, 10);
|
|
if (0 != errno) {
|
|
/* TODO add err msg - better rc? */
|
|
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
|
}
|
|
*out_ptag = tmp_ptag;
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
static inline int get_cookie (uint32_t *out_cookie)
|
|
{
|
|
/* TODO no need for tmp */
|
|
char *ptr;
|
|
uint32_t tmp_cookie;
|
|
|
|
if (NULL == (ptr = getenv("PMI_GNI_COOKIE"))) {
|
|
/* TODO add err msg - better rc? */
|
|
return OPAL_ERR_NOT_FOUND;
|
|
}
|
|
errno = 0;
|
|
tmp_cookie = (uint32_t) strtoul (ptr, NULL, 10);
|
|
if (0 != errno) {
|
|
/* TODO add err msg - better rc? */
|
|
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
|
}
|
|
|
|
*out_cookie = tmp_cookie;
|
|
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
static unsigned int
|
|
opal_common_ugni_get_nic_address(int device_id)
|
|
{
|
|
unsigned int address, cpu_id;
|
|
gni_return_t status;
|
|
int i, alps_dev_id = -1;
|
|
char *token,*p_ptr;
|
|
|
|
p_ptr = getenv("PMI_GNI_DEV_ID");
|
|
if (!p_ptr) {
|
|
status = GNI_CdmGetNicAddress(device_id, &address, &cpu_id);
|
|
if(status != GNI_RC_SUCCESS) {
|
|
opal_output (0, "FAILED:GNI_CdmGetNicAddress returned error %d", status);
|
|
return (unsigned int)-1;
|
|
}
|
|
return address;
|
|
}
|
|
|
|
while (NULL != (token = strtok(p_ptr, ":"))) {
|
|
alps_dev_id = atoi(token);
|
|
if (alps_dev_id == device_id) {
|
|
break;
|
|
}
|
|
p_ptr = NULL;
|
|
}
|
|
|
|
if (OPAL_UNLIKELY(-1 == alps_dev_id)) {
|
|
return (unsigned int)-1;
|
|
}
|
|
|
|
p_ptr = getenv("PMI_GNI_LOC_ADDR");
|
|
if (OPAL_UNLIKELY(NULL == p_ptr)) {
|
|
return (unsigned int)-1;
|
|
}
|
|
|
|
i = 0;
|
|
while (NULL != (token = strtok(p_ptr, ":"))) {
|
|
if (i == alps_dev_id) {
|
|
return strtoul (token, NULL, 10);
|
|
}
|
|
p_ptr = NULL;
|
|
++i;
|
|
}
|
|
|
|
return (unsigned int)-1;
|
|
}
|
|
|
|
static int opal_common_ugni_device_init (opal_common_ugni_device_t *device,
|
|
int device_id)
|
|
{
|
|
int rc;
|
|
|
|
/* Create a NIC Adress */
|
|
device->dev_id = device_id; /* Minor number of the Gemini NIC */
|
|
|
|
device->dev_addr = opal_common_ugni_get_nic_address (device->dev_id);
|
|
|
|
OPAL_OUTPUT((-1, "Got NIC Addr: 0x%08x, CPU ID: %d", device->dev_addr, device->dev_id));
|
|
|
|
/* Attach device to the communication domain */
|
|
rc = GNI_CdmAttach (opal_common_ugni_module.cd_handle, device->dev_id,
|
|
&device->dev_pe_addr, &device->dev_handle);
|
|
if (GNI_RC_SUCCESS != rc) {
|
|
OPAL_OUTPUT((0, "Error: Creating communication domain %d\n", rc));
|
|
return opal_common_rc_ugni_to_opal (rc);
|
|
}
|
|
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
static int opal_common_ugni_device_fini (opal_common_ugni_device_t *dev)
|
|
{
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
/*
|
|
* Send local device information and other information
|
|
* required for setup
|
|
*/
|
|
static int opal_common_ugni_send_modex (int my_cdm_id)
|
|
{
|
|
uint32_t modex_size, total_msg_size, msg_offset;
|
|
struct opal_common_ugni_modex_t modex;
|
|
char *modex_msg;
|
|
int rc, i;
|
|
|
|
modex_size = sizeof (struct opal_common_ugni_modex_t);
|
|
total_msg_size = opal_common_ugni_module.device_count * modex_size;
|
|
|
|
modex_msg = (char *) malloc (total_msg_size);
|
|
if (NULL == modex_msg) {
|
|
OPAL_OUTPUT((-1, "Error allocating memory for modex @ %s:%d",
|
|
__FILE__, __LINE__));
|
|
return OPAL_ERR_OUT_OF_RESOURCE;
|
|
}
|
|
|
|
/* pack modex for all available devices */
|
|
for (i = 0, msg_offset = 0; i < opal_common_ugni_module.device_count ; ++i) {
|
|
opal_common_ugni_device_t *dev = opal_common_ugni_module.devices + i;
|
|
|
|
modex.addr = dev->dev_addr;
|
|
modex.id = my_cdm_id;
|
|
|
|
memcpy ((void *)((uintptr_t) modex_msg + msg_offset),
|
|
(void *)&modex, modex_size);
|
|
|
|
msg_offset += modex_size;
|
|
}
|
|
|
|
OPAL_MODEX_SEND(rc, PMIX_ASYNC_RDY, PMIX_REMOTE,
|
|
&opal_common_ugni_component,
|
|
modex_msg, total_msg_size);
|
|
|
|
free(modex_msg);
|
|
|
|
return rc;
|
|
}
|
|
|
|
int opal_common_ugni_fini (void)
|
|
{
|
|
int i, rc;
|
|
|
|
if (0 == opal_common_ugni_module_ref_count) {
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
if (1 == opal_common_ugni_module_ref_count) {
|
|
/* tear down component */
|
|
if (opal_common_ugni_module.devices) {
|
|
/* finalize devices */
|
|
for (i = 0 ; i < opal_common_ugni_module.device_count ; ++i) {
|
|
opal_common_ugni_device_fini (opal_common_ugni_module.devices + i);
|
|
}
|
|
|
|
free (opal_common_ugni_module.devices);
|
|
opal_common_ugni_module.devices = NULL;
|
|
}
|
|
|
|
/* finally, tear down the communication domain */
|
|
rc = GNI_CdmDestroy (opal_common_ugni_module.cd_handle);
|
|
if (GNI_RC_SUCCESS != rc) {
|
|
OPAL_OUTPUT((-1, "error destroying cdm"));
|
|
}
|
|
}
|
|
|
|
opal_common_ugni_module_ref_count--;
|
|
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
int opal_common_ugni_init (void)
|
|
{
|
|
#if 0
|
|
opal_proc_t *my_proc;
|
|
#endif
|
|
int modes, rc, i;
|
|
uint32_t my_cdm_id, *ptr;
|
|
|
|
opal_common_ugni_module_ref_count ++;
|
|
|
|
if (opal_common_ugni_module_ref_count > 1) {
|
|
return OPAL_SUCCESS;
|
|
}
|
|
|
|
/* get a unique id from the runtime */
|
|
/* the code below is unnecessary. The cdm_id only needs to be unique
|
|
within a node for a given ptag/cookie tuple */
|
|
#if 0
|
|
#if defined(OMPI_DB_GLOBAL_RANK)
|
|
{
|
|
ptr = &my_rank;
|
|
OPAL_MODEX_RECV_VALUE(rc, (opal_identifier_t *)&my_proc->proc_name,
|
|
OMPI_DB_GLOBAL_RANK, (void**)&ptr, OPAL_UINT32);
|
|
if (OPAL_SUCCESS != rc) {
|
|
my_rank = my_proc->proc_name.vpid;
|
|
}
|
|
OPAL_LIST_DESTRUCT(&myvals);
|
|
}
|
|
#else
|
|
my_rank = my_proc->proc_name.vpid;
|
|
#endif
|
|
#else
|
|
my_cdm_id = getpid(); /*TODO: eventually need something else for thread-hot support */
|
|
#endif
|
|
|
|
/* pull settings from ugni btl */
|
|
opal_common_ugni_module.rdma_max_retries =
|
|
mca_btl_ugni_component.rdma_max_retries;
|
|
|
|
/* Create a communication domain */
|
|
modes = GNI_CDM_MODE_FORK_FULLCOPY | GNI_CDM_MODE_CACHED_AMO_ENABLED |
|
|
GNI_CDM_MODE_ERR_NO_KILL | GNI_CDM_MODE_FAST_DATAGRAM_POLL;
|
|
|
|
/* collect uGNI information */
|
|
rc = get_ptag(&opal_common_ugni_module.ptag);
|
|
if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
|
|
return rc;
|
|
}
|
|
|
|
rc = get_cookie(&opal_common_ugni_module.cookie);
|
|
if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
|
|
return rc;
|
|
}
|
|
|
|
/* create a communication domain */
|
|
rc = GNI_CdmCreate (my_cdm_id, opal_common_ugni_module.ptag,
|
|
opal_common_ugni_module.cookie, modes,
|
|
&opal_common_ugni_module.cd_handle);
|
|
if (OPAL_UNLIKELY(GNI_RC_SUCCESS != rc)) {
|
|
OPAL_OUTPUT((0, "Error: Creating communication domain %d\n",rc));
|
|
return opal_common_rc_ugni_to_opal (rc);
|
|
}
|
|
|
|
/* setup uGNI devices. we only support one device atm */
|
|
opal_common_ugni_module.device_count = 1;
|
|
opal_common_ugni_module.devices = calloc (opal_common_ugni_module.device_count,
|
|
sizeof (opal_common_ugni_device_t));
|
|
|
|
for (i = 0 ; i < opal_common_ugni_module.device_count ; ++i) {
|
|
rc = opal_common_ugni_device_init (opal_common_ugni_module.devices + i, i);
|
|
if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
|
|
OPAL_OUTPUT((-1, "error initializing uGNI device"));
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
/* send ugni modex */
|
|
opal_common_ugni_send_modex (my_cdm_id);
|
|
|
|
return OPAL_SUCCESS;
|
|
}
|