From 987e865c9923ee207e62773759c28ab34f0baf4f Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Wed, 24 Jun 2015 23:08:08 -0600 Subject: [PATCH] mtl/psm2: add support for dynamic add_procs Add an accessor for the proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL] member of the ompi_proc_t structure. This accessort calls add_procs with the ompi_proc_t if the member is NULL. Signed-off-by: Nathan Hjelm --- ompi/mca/mtl/psm2/mtl_psm2.h | 4 ++++ ompi/mca/mtl/psm2/mtl_psm2_endpoint.h | 9 +++++++++ ompi/mca/mtl/psm2/mtl_psm2_send.c | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ompi/mca/mtl/psm2/mtl_psm2.h b/ompi/mca/mtl/psm2/mtl_psm2.h index b48e07a039..44152656bf 100644 --- a/ompi/mca/mtl/psm2/mtl_psm2.h +++ b/ompi/mca/mtl/psm2/mtl_psm2.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana * University Research and Technology @@ -11,6 +12,8 @@ * All rights reserved. * Copyright (c) 2006 QLogic Corporation. All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +27,7 @@ #include "ompi/mca/pml/pml.h" #include "ompi/mca/mtl/mtl.h" #include "ompi/mca/mtl/base/base.h" +#include "ompi/proc/proc.h" #include "opal/datatype/opal_convertor.h" #include #include diff --git a/ompi/mca/mtl/psm2/mtl_psm2_endpoint.h b/ompi/mca/mtl/psm2/mtl_psm2_endpoint.h index e3233db352..aeb6bccadc 100644 --- a/ompi/mca/mtl/psm2/mtl_psm2_endpoint.h +++ b/ompi/mca/mtl/psm2/mtl_psm2_endpoint.h @@ -55,5 +55,14 @@ struct mca_mtl_psm2_endpoint_t { typedef struct mca_mtl_psm2_endpoint_t mca_mtl_psm2_endpoint_t; OBJ_CLASS_DECLARATION(mca_mtl_psm2_endpoint); +static inline mca_mtl_psm_endpoint_t *ompi_mtl_psm2_get_endpoint (struct mca_mtl_base_module_t* mtl, ompi_proc_t *ompi_proc) +{ + if (OPAL_UNLIKELY(NULL == ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL])) { + ompi_mtl_psm2_add_procs (mtl, 1, &ompi_proc); + } + + return ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL]; +} + END_C_DECLS #endif diff --git a/ompi/mca/mtl/psm2/mtl_psm2_send.c b/ompi/mca/mtl/psm2/mtl_psm2_send.c index 76fb5a1cd0..73cf769873 100644 --- a/ompi/mca/mtl/psm2/mtl_psm2_send.c +++ b/ompi/mca/mtl/psm2/mtl_psm2_send.c @@ -43,7 +43,7 @@ ompi_mtl_psm2_send(struct mca_mtl_base_module_t* mtl, int ret; size_t length; ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest ); - mca_mtl_psm2_endpoint_t* psm_endpoint = (mca_mtl_psm2_endpoint_t*) ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL]; + mca_mtl_psm2_endpoint_t* psm_endpoint = ompi_mtl_psm2_get_endpoint (mtl, ompi_proc); assert(mtl == &ompi_mtl_psm2.super); @@ -95,7 +95,7 @@ ompi_mtl_psm2_isend(struct mca_mtl_base_module_t* mtl, mca_mtl_psm2_request_t * mtl_psm2_request = (mca_mtl_psm2_request_t*) mtl_request; size_t length; ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest ); - mca_mtl_psm2_endpoint_t* psm_endpoint = (mca_mtl_psm2_endpoint_t*)ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL]; + mca_mtl_psm2_endpoint_t* psm_endpoint = ompi_mtl_psm2_get_endpoint (mtl, ompi_proc); assert(mtl == &ompi_mtl_psm2.super);