1
1

Moving the Message Log framework to the trunk. Protocol example (simple

showcase) and sender based are provided for now.

Ignored by default except for utk folks. 

This commit was SVN r15539.
Этот коммит содержится в:
Aurelien Bouteiller 2007-07-20 21:36:11 +00:00
родитель 78d214fec8
Коммит 70bb44d7a9
49 изменённых файлов: 2790 добавлений и 0 удалений

0
ompi/mca/pml/v/.ompi_ignore Обычный файл
Просмотреть файл

3
ompi/mca/pml/v/.ompi_unignore Обычный файл
Просмотреть файл

@ -0,0 +1,3 @@
bouteill
bosilca
coti

53
ompi/mca/pml/v/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,53 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
# 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_pml_v_DSO
component_noinst =
component_install = mca_pml_v.la
else
component_noinst = libmca_pml_v.la
component_install =
endif
SUBDIRS = $(MCA_pml_v_PROTOCOLS)
local_sources = \
pml_v.c \
pml_v.h \
pml_v_component.c \
pml_v_protocol.h \
pml_v_protocol_base.h \
pml_v_protocol_base.c
mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component_install)
mca_pml_v_la_SOURCES = $(local_sources)
mca_pml_v_la_LIBADD =
mca_pml_v_la_CFLAGS = -Wno-variadic-macros
mca_pml_v_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_pml_v_la_SOURCES = $(local_sources)
libmca_pml_v_la_LIBADD =
libmca_pml_v_la_CFLAGS = -Wno-variadic-macros
libmca_pml_v_la_LDFLAGS = -module -avoid-version

9
ompi/mca/pml/v/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,9 @@
AC_DEFUN([MCA_pml_v_CONFIG],[
protocol_subdirs=""
while read protocol; do
echo "Adding $protocol to pml_v subdirs"
protocol_subdirs="$protocol $protocol_subdirs"
done <ompi/mca/pml/v/autogen.vprotocols
AC_SUBST(MCA_pml_v_PROTOCOLS, [$protocol_subdirs])
])

29
ompi/mca/pml/v/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,29 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_INIT_FILE=pml_v.c
PARAM_CONFIG_HEADER_FILE="v_config.h"
PARAM_CONFIG_FILES="Makefile"
>autogen.vprotocols
for protocol in protocol_*; do
( cd $pd_ompi_topdir
process_dir "$pd_dir/$protocol" $pd_ompi_topdir
)
done

18
ompi/mca/pml/v/pml_v.c Обычный файл
Просмотреть файл

@ -0,0 +1,18 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "pml_v.h"
mca_pml_v_t mca_pml_v =
{
-1, /* PML_V output */
{{0,0,0,""}} /* MCA_VPROTOCOL, type is "" to know when no protocol is selected */
};

48
ompi/mca/pml/v/pml_v.h Обычный файл
Просмотреть файл

@ -0,0 +1,48 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PML_V_H_HAS_BEEN_INCLUDED
#define PML_V_H_HAS_BEEN_INCLUDED
#include "ompi_config.h"
#include "ompi/mca/pml/pml.h"
#include "pml_v_protocol.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/* TODO: Fix that crappy variadic stuff for non GNU C compilers */
#ifdef __GNUC__
# define V_OUTPUT(...) OPAL_OUTPUT((mca_pml_v.output, __VA_ARGS__))
# define V_OUTPUT_VERBOSE(V, ...) OPAL_OUTPUT_VERBOSE((V, mca_pml_v.output, __VA_ARGS__))
#else
static inline void V_OUTPUT(char *format, ...) { OPAL_OUTPUT((mca_pml_v.output, "%s", format)); }
static inline void V_OUTPUT_VERBOSE(V, char * format, ...) {OPAL_OUTPUT_VERBOSE((V, mca_pml_v.output, "%s", format)); }
#endif
struct mca_pml_v_t {
int output;
mca_pml_v_protocol_base_component_t protocol_component;
mca_pml_v_protocol_base_module_t protocol;
mca_pml_base_component_t host_pml_component;
mca_pml_base_module_t host_pml;
size_t host_pml_req_recv_size;
size_t host_pml_req_send_size;
};
typedef struct mca_pml_v_t mca_pml_v_t;
OMPI_DECLSPEC extern mca_pml_v_t mca_pml_v;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* PML_V_H_HAS_BEEN_INCLUDED */

294
ompi/mca/pml/v/pml_v_component.c Обычный файл
Просмотреть файл

@ -0,0 +1,294 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD
# include <unistd.h>
#endif
#include "opal/event/event.h"
#include "opal/mca/base/mca_base_param.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h"
#include "ompi/mca/pml/base/base.h"
#include "pml_v.h"
#include "pml_v_protocol_base.h"
#include "ompi/mca/pml/ob1/pml_ob1.h"
static int mca_pml_v_component_open(void);
static int mca_pml_v_component_close(void);
static int mca_pml_v_component_parasite_close(void);
static mca_pml_base_module_t *mca_pml_v_component_init(int* priority, bool, bool);
static int mca_pml_v_component_finalize(void);
static int mca_pml_v_component_parasite_finalize(void);
static inline int mca_pml_v_param_register_int( const char* param_name, int default_value);
static inline char *mca_pml_v_param_register_string( const char* param_name, char *default_value);
mca_pml_base_component_1_0_0_t mca_pml_v_component =
{
/* First, the mca_base_component_t struct containing meta
* information about the component itself */
{
MCA_PML_BASE_VERSION_1_0_0, /* Indicate that we are a pml v1.0.0 component (which also implies a specific MCA version) */
"v", /* MCA component name */
1, /* MCA component major version */
0, /* MCA component minor version */
0, /* MCA component release version */
mca_pml_v_component_open,
mca_pml_v_component_close
},
/* Next the MCA v1.0.0 component meta data */
{
false /* Whether the component is checkpointable or not */
},
mca_pml_v_component_init, /* component init */
mca_pml_v_component_finalize /* component finalize */
};
/******************************************************************************/
/* MCA level functions */
/* Gather some informations about the environment and selects the best protocol
* considering environment and priority */
static int mca_pml_v_component_open(void)
{
char *output;
int verbose;
opal_output_stream_t lds;
char hostname[32] = "NA";
output = mca_pml_v_param_register_string("output", "stderr");
verbose = mca_pml_v_param_register_int("verbose", 0);
OBJ_CONSTRUCT(&lds, opal_output_stream_t);
if(!output)
{
mca_pml_v.output = 0;
}
else
{
if(!strcmp(output, "stdout"))
{
lds.lds_want_stdout = true;
}
else if(!strcmp(output, "stderr"))
{
lds.lds_want_stderr = true;
}
else
{
lds.lds_want_file = true;
lds.lds_file_suffix = output;
}
lds.lds_is_debugging = true;
gethostname(hostname, 32);
asprintf(&lds.lds_prefix, "[%s:%05d] pml_v: ", hostname, getpid());
lds.lds_verbose_level = verbose;
mca_pml_v.output = opal_output_open(&lds);
free(lds.lds_prefix);
}
V_OUTPUT_VERBOSE(10, "pml_v.open: opening pml_v");
return mca_pml_v_protocol_base_load_all();
}
/*
* As any parasit, I dont want to die, so I will grab the mca_pml interface and put mine instead.
* Once this is done, I will do my stuff and call the real func and die only when my host pml
* will.
*/
static int mca_pml_v_component_close(void)
{
/* choose one protocol (ignoring errors as we will be discarded soon if some occured) */
/* TODO: dirty trick until pml_base_select gets fixed - have to be moved back to finalize */
/* TODO: check for bozo case: no selected PML */
/* mca_pml_v_protocol_base_select(enable_progress_threads, enable_mpi_threads); */
mca_pml_v_protocol_base_select(0, 0);
if(!strcmp(mca_pml_v.protocol_component.pmlm_version.mca_type_name, "vprotocol"))
{
/* ok, we have loaded a fault tolerant protocol, lets go */
V_OUTPUT_VERBOSE(10, "pml_v.close: I don't want to die, I will parasite %s host component %s",
mca_pml_base_selected_component.pmlm_version.mca_type_name,
mca_pml_base_selected_component.pmlm_version.mca_component_name);
/* setting selected vprotocol mpi functions instead of host's one */
mca_pml_v.host_pml = mca_pml; /* saving */
/* protocol stuff */
if(mca_pml_v.protocol.add_procs) mca_pml.pml_add_procs = mca_pml_v.protocol.add_procs;
if(mca_pml_v.protocol.del_procs) mca_pml.pml_del_procs = mca_pml_v.protocol.del_procs;
if(mca_pml_v.protocol.enable) mca_pml.pml_enable = mca_pml_v.protocol.enable;
if(mca_pml_v.protocol.progress) mca_pml.pml_progress = mca_pml_v.protocol.progress;
if(mca_pml_v.protocol.add_comm) mca_pml.pml_add_comm = mca_pml_v.protocol.add_comm;
if(mca_pml_v.protocol.del_comm) mca_pml.pml_del_comm = mca_pml_v.protocol.del_comm;
if(mca_pml_v.protocol.irecv_init) mca_pml.pml_irecv_init = mca_pml_v.protocol.irecv_init;
if(mca_pml_v.protocol.irecv) mca_pml.pml_irecv = mca_pml_v.protocol.irecv;
if(mca_pml_v.protocol.recv) mca_pml.pml_recv = mca_pml_v.protocol.recv;
if(mca_pml_v.protocol.isend_init) mca_pml.pml_isend_init = mca_pml_v.protocol.isend_init;
if(mca_pml_v.protocol.isend) mca_pml.pml_isend = mca_pml_v.protocol.isend;
if(mca_pml_v.protocol.send) mca_pml.pml_send = mca_pml_v.protocol.send;
if(mca_pml_v.protocol.iprobe) mca_pml.pml_iprobe = mca_pml_v.protocol.iprobe;
if(mca_pml_v.protocol.probe) mca_pml.pml_probe = mca_pml_v.protocol.probe;
if(mca_pml_v.protocol.start) mca_pml.pml_start = mca_pml_v.protocol.start;
if(mca_pml_v.protocol.dump) mca_pml.pml_dump = mca_pml_v.protocol.dump;
/* Add some extra space for Vprotocol at the end of each PML request
* build a custom request obj class from the original PML request class
* with enough trailing space and rebuild the request pool
*/
if(mca_pml_v.protocol.req_recv_class)
{
ompi_free_list_t pml_fl_save = mca_pml_base_recv_requests;
mca_pml_v.host_pml_req_recv_size = pml_fl_save.fl_elem_class->cls_sizeof;
V_OUTPUT_VERBOSE(300, "req_rebuild: recv\tsize %ld+%ld\talignment=%ld", (long) mca_pml_v.host_pml_req_recv_size, (long) mca_pml_v.protocol.req_recv_class->cls_sizeof, (long) pml_fl_save.fl_alignment);
mca_pml_v.protocol.req_recv_class->cls_parent = pml_fl_save.fl_elem_class;
mca_pml_v.protocol.req_recv_class->cls_sizeof += pml_fl_save.fl_elem_class->cls_sizeof;
/* rebuild the requests free list with the right size */
OBJ_DESTRUCT(&mca_pml_base_recv_requests);
OBJ_CONSTRUCT(&mca_pml_base_recv_requests, ompi_free_list_t);
ompi_free_list_init_ex(&mca_pml_base_recv_requests,
mca_pml_v.protocol.req_recv_class->cls_sizeof,
pml_fl_save.fl_alignment,
mca_pml_v.protocol.req_recv_class,
pml_fl_save.fl_num_allocated,
pml_fl_save.fl_max_to_alloc,
pml_fl_save.fl_num_per_alloc,
pml_fl_save.fl_mpool,
pml_fl_save.item_init,
pml_fl_save.ctx);
}
if(mca_pml_v.protocol.req_send_class)
{
ompi_free_list_t pml_fl_save = mca_pml_base_send_requests;
mca_pml_v.host_pml_req_send_size = pml_fl_save.fl_elem_class->cls_sizeof;
V_OUTPUT_VERBOSE(300, "req_rebuild: send\tsize %ld+%ld\talignment=%ld", (long) mca_pml_v.host_pml_req_send_size, (long) mca_pml_v.protocol.req_send_class->cls_sizeof, (long) pml_fl_save.fl_alignment);
mca_pml_v.protocol.req_send_class->cls_parent = pml_fl_save.fl_elem_class;
mca_pml_v.protocol.req_send_class->cls_sizeof += pml_fl_save.fl_elem_class->cls_sizeof;
/* rebuild the requests free list with the right size */
OBJ_DESTRUCT(&mca_pml_base_send_requests);
OBJ_CONSTRUCT(&mca_pml_base_send_requests, ompi_free_list_t);
ompi_free_list_init_ex(&mca_pml_base_send_requests,
mca_pml_v.protocol.req_send_class->cls_sizeof,
pml_fl_save.fl_alignment,
mca_pml_v.protocol.req_send_class,
pml_fl_save.fl_num_allocated,
pml_fl_save.fl_max_to_alloc,
pml_fl_save.fl_num_per_alloc,
pml_fl_save.fl_mpool,
pml_fl_save.item_init,
pml_fl_save.ctx);
}
/* setting own close and finalize instead of host's one */
mca_pml_v.host_pml_component = mca_pml_base_selected_component;
snprintf(mca_pml_base_selected_component.pmlm_version.mca_component_name,
MCA_BASE_MAX_TYPE_NAME_LEN, "%s]v%s",
mca_pml_v.host_pml_component.pmlm_version.mca_component_name,
mca_pml_v.protocol_component.pmlm_version.mca_component_name);
mca_pml_base_selected_component.pmlm_version.mca_close_component = mca_pml_v_component_parasite_close;
mca_pml_base_selected_component.pmlm_finalize = mca_pml_v_component_parasite_finalize;
#if 0
/* may be useless ? If not have to parse the entire PML available list to find currently selected */
component->pmlm_version.mca_close_component = mca_pml_v_component_parasite_close;
component->pmlm_finalize = mca_pml_v_component_parasite_finalize;
#endif
V_OUTPUT_VERBOSE(10, "pml_v.close: I don't want to be unloaded. Referencing myself as using myself");
if(OPAL_SUCCESS != mca_base_component_repository_retain_component("pml", "v"))
{
opal_output(0, "pml_v.close: can't retain myself !");
return OMPI_ERROR;
}
return OMPI_SUCCESS;
}
V_OUTPUT_VERBOSE(10, "pml_v.close: no fault tolerant protocol selected, ok, I let them kill me");
return OMPI_SUCCESS;
}
/* MCA replacement close for host parasited pml component */
static int mca_pml_v_component_parasite_close(void)
{
V_OUTPUT_VERBOSE(10, "pml_v.parasite_close: Ok, host component %s is closing, so I accept to die",
mca_pml_v.host_pml_component.pmlm_version.mca_component_name);
mca_pml = mca_pml_v.host_pml;
mca_pml_base_selected_component = mca_pml_v.host_pml_component;
/* TODO: close the vprotocol component opened in open */
/* TODO: I have to dlclose myself, but if I do it from my own code it crashes.
waiting for somebody else to give me tools to do a cleaner stuff
for now, the closed component stays in memory
if(dlclose(myself_dlhandler)) opal_output(mca_pml_v_output, "pml_v.parasite_close: dlclose failed %s", dlerror());
*/
opal_output_close(mca_pml_v.output);
return mca_pml_v.host_pml_component.pmlm_version.mca_close_component();
}
/******************************************************************************/
/* MCA_PML level functions */
static mca_pml_base_module_t *mca_pml_v_component_init(int *priority,
bool enable_progress_threads,
bool enable_mpi_threads)
{
V_OUTPUT_VERBOSE(10, "pml_v.init: I'm not supposed to be here until BTL loading stuff gets fixed!? That's bad...");
/* I NEVER want to be the selected PML, so I report less than possible
* priority and a NULL module */
*priority = -1;
return NULL;
}
static int mca_pml_v_component_finalize(void)
{
V_OUTPUT_VERBOSE(10, "pml_v.finalize: I'm not supposed to be here until BTL loading stuff gets fixed!? That's bad...");
return OMPI_SUCCESS;
}
static int mca_pml_v_component_parasite_finalize(void)
{
V_OUTPUT_VERBOSE(10, "pml_v.parasite_finalize");
/* finalize vprotocol component */
mca_pml_v.protocol_component.pmlm_finalize();
if(mca_pml_v.host_pml_component.pmlm_finalize != NULL)
return mca_pml_v.host_pml_component.pmlm_finalize();
else
return OMPI_SUCCESS;
}
/******************************************************************************/
/* utilities */
static inline int mca_pml_v_param_register_int( const char* param_name,
int default_value )
{
int id = mca_base_param_register_int("pml", "v", param_name, NULL, default_value);
int param_value = default_value;
mca_base_param_lookup_int(id, &param_value);
return param_value;
}
static inline char *mca_pml_v_param_register_string( const char* param_name,
char *default_value )
{
int id = mca_base_param_register_string("pml", "v", param_name, NULL, default_value);
char *param_value = default_value;
mca_base_param_lookup_string(id, &param_value);
return param_value;
}

96
ompi/mca/pml/v/pml_v_protocol.h Обычный файл
Просмотреть файл

@ -0,0 +1,96 @@
#ifndef __INCLUDE_V_PROTOCOL_H_
#define __INCLUDE_V_PROTOCOL_H_
#include "ompi_config.h"
#include "opal/mca/mca.h"
#include "ompi/request/request.h"
#include "ompi/mca/pml/pml.h"
#include "ompi/mca/btl/btl.h"
#include "ompi/mca/pml/base/pml_base_recvreq.h"
#include "ompi/mca/pml/base/pml_base_sendreq.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/**
* PML_V->PROTOCOL Called by MCA_PML_V framework to initialize the component.
*
* @param priority (OUT) Relative priority or ranking used by MCA to
* select a component.
*
* @param enable_progress_threads (IN) Whether this component is
* allowed to run a hidden/progress thread or not.
*
* @param enable_mpi_threads (IN) Whether support for multiple MPI
* threads is enabled or not (i.e., MPI_THREAD_MULTIPLE), which
* indicates whether multiple threads may invoke this component
* simultaneously or not.
*/
typedef struct mca_pml_v_protocol_base_module_1_0_0_t * (*mca_pml_v_protocol_base_component_init_fn_t)(
int *priority,
bool enable_progress_threads,
bool enable_mpi_threads);
typedef int (*mca_pml_v_protocol_base_component_finalize_fn_t)(void);
/**
* PML_V->PROTOCOL Called by VPROTOCOL to get the actual address of the
* protocol specific part of the request
*
* @param request (IN) the address of an ompi_request
* @return address of the mca_vprotocol_base_request_t associated with the request
*/
#define VPROTOCOL_REQ(req) \
((((mca_pml_base_request_t *) req)->req_type == MCA_PML_REQUEST_SEND) \
? VPROTOCOL_SEND_REQ(req) \
: VPROTOCOL_RECV_REQ(req))
#define VPROTOCOL_RECV_REQ(req) \
(((char *) req) + mca_pml_v.host_pml_req_recv_size)
#define VPROTOCOL_SEND_REQ(req) \
(((char *) req) + mca_pml_v.host_pml_req_send_size)
/**
* PML_V_PROTOCOL component version and interface functions.
*/
typedef struct mca_pml_v_protocol_base_1_0_0_t
{
mca_base_component_t pmlm_version;
mca_base_component_data_1_0_0_t pmlm_data;
mca_pml_v_protocol_base_component_init_fn_t pmlm_init;
mca_pml_v_protocol_base_component_finalize_fn_t pmlm_finalize;
} mca_pml_v_protocol_base_component_1_0_0_t;
typedef mca_pml_v_protocol_base_component_1_0_0_t mca_pml_v_protocol_base_component_t;
typedef struct mca_pml_v_protocol_base_module_1_0_0_t
{
/* PML module stuff */
mca_pml_base_module_add_procs_fn_t add_procs;
mca_pml_base_module_del_procs_fn_t del_procs;
mca_pml_base_module_enable_fn_t enable;
mca_pml_base_module_progress_fn_t progress;
mca_pml_base_module_add_comm_fn_t add_comm;
mca_pml_base_module_del_comm_fn_t del_comm;
mca_pml_base_module_irecv_init_fn_t irecv_init;
mca_pml_base_module_irecv_fn_t irecv;
mca_pml_base_module_recv_fn_t recv;
mca_pml_base_module_isend_init_fn_t isend_init;
mca_pml_base_module_isend_fn_t isend;
mca_pml_base_module_send_fn_t send;
mca_pml_base_module_iprobe_fn_t iprobe;
mca_pml_base_module_probe_fn_t probe;
mca_pml_base_module_start_fn_t start;
mca_pml_base_module_dump_fn_t dump;
/* Request extra data */
opal_class_t * req_recv_class;
opal_class_t * req_send_class;
} mca_pml_v_protocol_base_module_1_0_0_t;
typedef mca_pml_v_protocol_base_module_1_0_0_t mca_pml_v_protocol_base_module_t;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_V_PROTOCOL_H_ */

133
ompi/mca/pml/v/pml_v_protocol_base.c Обычный файл
Просмотреть файл

@ -0,0 +1,133 @@
#include "ompi_config.h"
#include "opal/event/event.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/mca_base_param.h"
#include "pml_v_protocol.h"
#include "pml_v_protocol_base.h"
#include "pml_v.h"
#include "static-components.h"
static opal_list_t mca_pml_v_protocol_base_components_available;
/**
* Load any vprotocol MCA component, stored in available_vprotocol_components
* call open function of all those components.
*/
int mca_pml_v_protocol_base_load_all(void)
{
OBJ_CONSTRUCT(&mca_pml_v_protocol_base_components_available, opal_list_t);
return mca_base_components_open("vprotocol", 0, mca_pml_v_protocol_base_static_components,
&mca_pml_v_protocol_base_components_available, true);
}
typedef struct opened_component_t {
opal_list_item_t super;
mca_pml_v_protocol_base_component_t *om_component;
} opened_component_t;
/**
* Function for selecting one component from all those that are
* available.
*
* Call the init function on all available components and get their
* priorities. Select the component with the highest priority. All
* other components will be closed and unloaded. The selected component
* will have all of its function pointers saved and returned to the
* caller.
*/
int mca_pml_v_protocol_base_select(bool enable_progress_threads, bool enable_mpi_threads)
{
int priority = 0, best_priority = -1;
opal_list_item_t *item = NULL;
mca_base_component_list_item_t *cli = NULL;
mca_pml_v_protocol_base_component_t *component = NULL, *best_component = NULL;
mca_pml_v_protocol_base_module_t *module = NULL, *best_module = NULL;
opal_list_t opened;
opened_component_t *om = NULL;
/* Traverse the list of available components; call their init
functions. */
OBJ_CONSTRUCT(&opened, opal_list_t);
for(item = opal_list_get_first(&mca_pml_v_protocol_base_components_available);
opal_list_get_end(&mca_pml_v_protocol_base_components_available) != item;
item = opal_list_get_next(item)) {
cli = (mca_base_component_list_item_t *) item;
component = (mca_pml_v_protocol_base_component_t *) cli->cli_component;
V_OUTPUT_VERBOSE(15, "vprotocol select: initializing %s component %s", component->pmlm_version.mca_type_name, component->pmlm_version.mca_component_name);
if (NULL == component->pmlm_init) {
V_OUTPUT_VERBOSE(1, "vprotocol select: no init function; ignoring component %s", component->pmlm_version.mca_component_name);
}
else
{
module = component->pmlm_init(&priority, enable_progress_threads, enable_mpi_threads);
if (NULL == module) {
V_OUTPUT_VERBOSE(1, "vprotocol select: init returned failure for component %s", component->pmlm_version.mca_component_name);
}
else
{
V_OUTPUT_VERBOSE(15, "vprotocol select: component %s init returned priority %d", component->pmlm_version.mca_component_name, priority);
if (priority > best_priority)
{
best_priority = priority;
best_component = component;
best_module = module;
}
om = malloc(sizeof(opened_component_t));
if (NULL == om) return OMPI_ERR_OUT_OF_RESOURCE;
OBJ_CONSTRUCT(om, opal_list_item_t);
om->om_component = component;
opal_list_append(&opened, (opal_list_item_t*) om);
}
}
}
/* Finished querying all components. Check for the bozo case. */
if (NULL == best_component) {
V_OUTPUT_VERBOSE(1, "vprotocol select: no protocol has returned a positive priority, user don't want fault tolerance");
}
else
{
/* Save the winner */
mca_pml_v.protocol_component = *best_component;
mca_pml_v.protocol = *best_module;
}
/* Finalize all non-selected components */
for (item = opal_list_remove_first(&opened);
NULL != item;
item = opal_list_remove_first(&opened)) {
om = (opened_component_t *) item;
if (om->om_component != best_component) {
/* Finalize */
V_OUTPUT_VERBOSE(15, "vprotocol select: component %s not selected / finalized", om->om_component->pmlm_version.mca_component_name);
if (NULL != om->om_component->pmlm_finalize) {
/* Blatently ignore the return code (what would we do to
recover, anyway? This component is going away, so errors
don't matter anymore) */
om->om_component->pmlm_finalize();
}
}
OBJ_DESTRUCT(om);
free(om);
}
/* This base function closes, unloads, and removes from the
available list all unselected components. The available list will
contain only the selected component (if one). */
mca_base_components_close(mca_pml_v.output,
&mca_pml_v_protocol_base_components_available,
(mca_base_component_t *) best_component);
/* All done */
if(best_component != NULL)
{
V_OUTPUT_VERBOSE(10, "vprotocol select: component %s selected", mca_pml_v.protocol_component.pmlm_version.mca_component_name);
return OMPI_SUCCESS;
}
else
return OMPI_ERR_NOT_FOUND;
}

30
ompi/mca/pml/v/pml_v_protocol_base.h Обычный файл
Просмотреть файл

@ -0,0 +1,30 @@
#ifndef __INCLUDE_V_PROTOCOL_BASE_H_
#define __INCLUDE_V_PROTOCOL_BASE_H_
#include "ompi_config.h"
#include "ompi/request/request.h"
#include "opal/mca/mca.h"
#include "ompi/mca/pml/pml.h"
#include "pml_v_protocol.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
OMPI_DECLSPEC int mca_pml_v_protocol_base_load_all(void);
OMPI_DECLSPEC int mca_pml_v_protocol_base_select(bool enable_progress_threads, bool enable_mpi_threads);
/*
* Macro for use in components that are of type vprotocol v1.0.0
*/
#define MCA_VPROTOCOL_BASE_VERSION_1_0_0 \
/* vprotocol v1.0 is chained to MCA v1.0 */ \
MCA_BASE_VERSION_1_0_0, \
/* vprotocol v1.0 */ \
"vprotocol", 1, 0, 0
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_V_PROTOCOL_BASE_H_ */

55
ompi/mca/pml/v/protocol_example/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
# Make the output library in this directory, and name it either
# protocol_<name>.la (for DSO builds) or libprotocol_<name>.la
# (for static builds).
if OMPI_BUILD_pml_v_DSO
component_noinst =
component_install = mca_vprotocol_example.la
else
component_noinst = libmca_vprotocol_example.la
component_install =
endif
local_sources = \
vprotocol_example.h \
vprotocol_example.c \
vprotocol_example_component.c \
vprotocol_example_proc.c \
vprotocol_example_comm.c \
vprotocol_example_progress.c \
vprotocol_example_start.c \
vprotocol_example_recv.c \
vprotocol_example_send.c \
vprotocol_example_probe.c \
vprotocol_example_wait.h \
vprotocol_example_wait.c
mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component_install)
mca_vprotocol_example_la_SOURCES = $(local_sources)
mca_vprotocol_example_la_LIBADD =
mca_vprotocol_example_la_CFLAGS = -Wno-variadic-macros
mca_vprotocol_example_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_vprotocol_example_la_SOURCES = $(local_sources)
libmca_vprotocol_example_la_LIBADD =
libmca_vprotocol_example_la_CFLAGS = -Wno-variadic-macros
libmca_vprotocol_example_la_LDFLAGS = -module -avoid-version

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

@ -0,0 +1,24 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_INIT_FILE=vprotocol_example.c
PARAM_CONFIG_HEADER_FILE="vprotocol_example_config.h"
PARAM_CONFIG_FILES="Makefile"
# Mandatory for all vprotocol
echo `basename \`pwd\`` >> ../autogen.vprotocols

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

@ -0,0 +1,48 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "vprotocol_example.h"
mca_vprotocol_example_module_t mca_vprotocol_example =
{
{
/* mca_pml_base_module_add_procs_fn_t */ mca_vprotocol_example_add_procs,
/* mca_pml_base_module_del_procs_fn_t */ mca_vprotocol_example_del_procs,
/* mca_pml_base_module_enable_fn_t */ mca_vprotocol_example_enable,
/* mca_pml_base_module_progress_fn_t */ mca_vprotocol_example_progress,
/* mca_pml_base_module_add_comm_fn_t */ mca_vprotocol_example_add_comm,
/* mca_pml_base_module_del_comm_fn_t */ mca_vprotocol_example_del_comm,
/* mca_pml_base_module_irecv_init_fn_t */ mca_vprotocol_example_irecv_init,
/* mca_pml_base_module_irecv_fn_t */ mca_vprotocol_example_irecv,
/* mca_pml_base_module_recv_fn_t */ mca_vprotocol_example_recv,
/* mca_pml_base_module_isend_init_fn_t */ mca_vprotocol_example_isend_init,
/* mca_pml_base_module_isend_fn_t */ mca_vprotocol_example_isend,
/* mca_pml_base_module_send_fn_t */ mca_vprotocol_example_send,
/* mca_pml_base_module_iprobe_fn_t */ mca_vprotocol_example_iprobe,
/* mca_pml_base_module_probe_fn_t */ mca_vprotocol_example_probe,
/* mca_pml_base_module_start_fn_t */ mca_vprotocol_example_start,
/* mca_pml_base_module_dump_fn_t */ mca_vprotocol_example_dump,
/* opal_class_t * */ NULL,
},
/**
* Insert here your own protocol structures
*/
};
OMPI_DECLSPEC int mca_vprotocol_example_dump(struct ompi_communicator_t* comm, int verbose)
{
V_OUTPUT("vprotocol_example dump for comm %d", comm->c_contextid);
return mca_pml_v.host_pml.pml_dump(comm, verbose);
}

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

@ -0,0 +1,96 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef __INCLUDE_VPROTOCOL_EXAMPLE_H__
#define __INCLUDE_VPROTOCOL_EXAMPLE_H__
#include "ompi_config.h"
#include "../pml_v.h"
#include "../pml_v_protocol.h"
#include "vprotocol_example_wait.h"
#include "ompi/communicator/communicator.h"
typedef struct mca_vprotocol_example_module_t {
mca_pml_v_protocol_base_module_t super;
/**
* Insert here your own protocol structures
*/
} mca_vprotocol_example_module_t;
extern mca_vprotocol_example_module_t mca_vprotocol_example;
OMPI_DECLSPEC int mca_vprotocol_example_add_procs(struct ompi_proc_t **procs, size_t nprocs);
OMPI_DECLSPEC int mca_vprotocol_example_del_procs(struct ompi_proc_t **procs, size_t nprocs);
OMPI_DECLSPEC int mca_vprotocol_example_enable(bool enable);
OMPI_DECLSPEC int mca_vprotocol_example_progress(void);
OMPI_DECLSPEC int mca_vprotocol_example_add_comm(struct ompi_communicator_t* comm);
OMPI_DECLSPEC int mca_vprotocol_example_del_comm(struct ompi_communicator_t* comm);
OMPI_DECLSPEC int mca_vprotocol_example_irecv_init(void *buf,
size_t count,
struct ompi_datatype_t *datatype,
int src,
int tag,
struct ompi_communicator_t* comm,
struct ompi_request_t **request );
OMPI_DECLSPEC int mca_vprotocol_example_irecv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
struct ompi_request_t **request );
OMPI_DECLSPEC int mca_vprotocol_example_recv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status );
OMPI_DECLSPEC int mca_vprotocol_example_isend_init(void *buf,
size_t count,
struct ompi_datatype_t *datatype,
int dst,
int tag,
mca_pml_base_send_mode_t mode,
struct ompi_communicator_t* comm,
struct ompi_request_t **request );
OMPI_DECLSPEC int mca_vprotocol_example_isend(void *buf,
size_t count,
ompi_datatype_t* datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
ompi_communicator_t* comm,
ompi_request_t** request );
OMPI_DECLSPEC int mca_vprotocol_example_send(void *buf,
size_t count,
ompi_datatype_t* datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
ompi_communicator_t* comm );
OMPI_DECLSPEC int mca_vprotocol_example_iprobe(int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status );
OMPI_DECLSPEC int mca_vprotocol_example_probe(int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status );
OMPI_DECLSPEC int mca_vprotocol_example_start(size_t count,
struct ompi_request_t** requests );
OMPI_DECLSPEC int mca_vprotocol_example_dump(struct ompi_communicator_t* comm,
int verbose );
#endif /* __INCLUDE_VPROTOCOL_EXAMPLE_H__ */

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

@ -0,0 +1,24 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "../pml_v.h"
#include "vprotocol_example.h"
int mca_vprotocol_example_add_comm(struct ompi_communicator_t* comm)
{
V_OUTPUT_VERBOSE(30, "vprotocol_example_add_comm(%d)", comm->c_contextid);
return mca_pml_v.host_pml.pml_add_comm(comm);
}
int mca_vprotocol_example_del_comm(struct ompi_communicator_t* comm)
{
V_OUTPUT_VERBOSE(30, "vprotocol_example_del_comm(%d)", comm->c_contextid);
return mca_pml_v.host_pml.pml_del_comm(comm);
}

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

@ -0,0 +1,124 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/mca_base_param.h"
#include "../pml_v.h"
#include "../pml_v_protocol_base.h"
#include "vprotocol_example.h"
static inline int mca_param_register_int( const char* param_name, int default_value);
static int mca_vprotocol_example_component_open(void);
static int mca_vprotocol_example_component_close(void);
static mca_pml_v_protocol_base_module_t *mca_vprotocol_example_component_init( int* priority,
bool, bool);
static int mca_vprotocol_example_component_finalize(void);
static int _priority;
mca_pml_v_protocol_base_component_1_0_0_t mca_vprotocol_example_component =
{
/* First, the mca_base_component_t struct containing meta
* information about the component itself */
{
/* Indicate that we are a pml v1.0.0 component (which also implies
a specific MCA version) */
MCA_VPROTOCOL_BASE_VERSION_1_0_0,
"example", /* MCA component name */
1, /* MCA component major version */
0, /* MCA component minor version */
0, /* MCA component release version */
mca_vprotocol_example_component_open, /* component open */
mca_vprotocol_example_component_close /* component close */
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
false
},
mca_vprotocol_example_component_init, /* component init */
mca_vprotocol_example_component_finalize /* component finalize */
};
/** MCA level functions
*/
int mca_vprotocol_example_component_open(void)
{
_priority = mca_param_register_int( "priority", -1);
V_OUTPUT_VERBOSE(10, "vprotocol_example_open, read priority %d", _priority);
return OMPI_SUCCESS;
}
int mca_vprotocol_example_component_close(void)
{
V_OUTPUT_VERBOSE(10, "vprotocol_example_close");
return OMPI_SUCCESS;
}
/** VPROTOCOL level functions (same as PML one)
*/
mca_pml_v_protocol_base_module_t *mca_vprotocol_example_component_init( int* priority,
bool enable_progress_threads,
bool enable_mpi_threads)
{
V_OUTPUT_VERBOSE(10, "vprotocol_example_init");
*priority = _priority;
/**
* Some protocols requires sanity check about thread support (those making piecewise deterministic assumption)
if(enable_mpi_threads)
{
OPAL_OUTPUT_VERBOSE( mca_pml_v_verbose, mca_pml_v_output, "vprotocol_example.init: threads are enabled, and not supported by vprotocol example fault tolerant layer, will not load"));
return NULL;
}
*/
/**
* Insert your own protocol initialization here
*/
return &mca_vprotocol_example.super;
}
int mca_vprotocol_example_component_finalize(void)
{
V_OUTPUT_VERBOSE(10, "vprotocol_example_finalize");
/**
* Insert your own garbage collecting here
*/
return OMPI_SUCCESS;
}
/**
* Helper function to set int type mca parameter
*/
static inline int mca_param_register_int( const char* param_name,
int default_value )
{
int id = mca_base_param_register_int("vprotocol", "example", param_name, NULL, default_value);
int param_value = default_value;
mca_base_param_lookup_int(id, &param_value);
return param_value;
}

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

@ -0,0 +1,29 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "../pml_v.h"
#include "vprotocol_example.h"
int mca_vprotocol_example_probe( int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status )
{
V_OUTPUT_VERBOSE(50, "mca_vprotocol_example_probe(%d, %d, %d)", src, tag, comm->c_contextid);
return mca_pml_v.host_pml.pml_probe(src, tag, comm, status);
}
int mca_vprotocol_example_iprobe( int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status )
{
V_OUTPUT_VERBOSE(60, "mca_vprotocol_example_iprobe(%d, %d, %d)", src, tag, comm->c_contextid);
return mca_pml_v.host_pml.pml_iprobe(src, tag, comm, matched, status);
}

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

@ -0,0 +1,25 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "../pml_v.h"
#include "vprotocol_example.h"
int mca_vprotocol_example_add_procs(struct ompi_proc_t **procs, size_t nprocs)
{
V_OUTPUT_VERBOSE(30, "adding %d procs", nprocs);
return mca_pml_v.host_pml.pml_add_procs(procs, nprocs);
}
int mca_vprotocol_example_del_procs(struct ompi_proc_t **procs, size_t nprocs)
{
V_OUTPUT_VERBOSE(30, "removing %d procs", nprocs);
return mca_pml_v.host_pml.pml_del_procs(procs, nprocs);
}

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

@ -0,0 +1,24 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "../pml_v.h"
#include "vprotocol_example.h"
int mca_vprotocol_example_enable(bool enable)
{
V_OUTPUT_VERBOSE(15, "enable=%d", enable);
return mca_pml_v.host_pml.pml_enable(enable);
}
int mca_vprotocol_example_progress(void)
{
V_OUTPUT_VERBOSE(100, "progress...");
return mca_pml_v.host_pml.pml_progress();
}

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

@ -0,0 +1,64 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "../pml_v.h"
#include "vprotocol_example.h"
int mca_vprotocol_example_irecv_init(void *addr,
size_t count,
struct ompi_datatype_t *datatype,
int src,
int tag,
struct ompi_communicator_t* comm,
struct ompi_request_t **request )
{
int ret;
ret = mca_pml_v.host_pml.pml_irecv_init(addr, count, datatype, src, tag, comm, request);
V_OUTPUT_VERBOSE(50, "posted\tirecv_init %ld\tcomm %d\tfrom %d\ttag %d\tsize %d", ((mca_pml_base_request_t *)*request)->req_sequence, comm->c_contextid, src, tag, count);
return ret;
}
int mca_vprotocol_example_irecv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
struct ompi_request_t **request)
{
int ret;
ompi_status_public_t *status;
ret = mca_pml_v.host_pml.pml_irecv(addr, count, datatype, src, tag, comm, request);
V_OUTPUT_VERBOSE(50, "posted\tirecv %ld\tcomm %d\tfrom %d\ttag %d\tsize %d", ((mca_pml_base_request_t *)*request)->req_sequence, comm->c_contextid, src, tag, count);
return ret;
}
int mca_vprotocol_example_recv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status )
{
int ret;
V_OUTPUT_VERBOSE(50, "posted\trecv \tcomm %d\tfrom %d\ttag %d\tsize %d", comm->c_contextid, src, tag, count);
ret = mca_pml_v.host_pml.pml_recv(addr, count, datatype, src, tag, comm, status);
# ifdef OMPI_ENABLE_DEBUG
if(status)
V_OUTPUT_VERBOSE(75, "deliver\trecv \tcomm %d\tfrom %d(%d)\ttag %d(%d)\tsize %d(%d)\tstatus %d", comm->c_contextid, src, status->MPI_SOURCE, tag, status->MPI_TAG, count, status->_count, status->MPI_ERROR);
else
V_OUTPUT_VERBOSE(75, "deliver\trecv \tcomm %d\tfrom %d\ttag %d\tsize %d", comm->c_contextid, src, tag, count);
# endif
return ret;
}

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

@ -0,0 +1,51 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "../pml_v.h"
#include "vprotocol_example.h"
int mca_vprotocol_example_isend_init(void *addr,
size_t count,
struct ompi_datatype_t *datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
struct ompi_communicator_t* comm,
struct ompi_request_t **request )
{
V_OUTPUT_VERBOSE(50, "request\tpisend \tcomm %d\tto %d\ttag %d\tsize %d", comm->c_contextid, dst, tag, count);
return mca_pml_v.host_pml.pml_isend_init(addr, count, datatype, dst, tag, sendmode, comm, request);
}
int mca_vprotocol_example_isend(void *addr,
size_t count,
ompi_datatype_t * datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
struct ompi_communicator_t *comm,
struct ompi_request_t **request)
{
V_OUTPUT_VERBOSE(50, "request\tisend \tcomm %d\tto %d\ttag %d\tsize %d", comm->c_contextid, dst, tag, count);
return mca_pml_v.host_pml.pml_isend(addr, count, datatype, dst, tag, sendmode, comm, request);
}
int mca_vprotocol_example_send(void *addr,
size_t count,
ompi_datatype_t * datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
struct ompi_communicator_t *comm)
{
V_OUTPUT_VERBOSE(50, "request\tsend \tcomm %d\tto %d\ttag %d\tsize %d", comm->c_contextid, dst, tag, count);
return mca_pml_v.host_pml.pml_send(addr, count, datatype, dst, tag, sendmode, comm);
}

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

@ -0,0 +1,14 @@
#include "ompi_config.h"
#include "vprotocol_example.h"
#include "vprotocol_example_start.h"
OMPI_DECLSPEC int mca_vprotocol_example_start(size_t count, ompi_request_t **requests)
{
V_OUTPUT_VERBOSE(50, "starting %d requests", count);
# ifdef OMPI_ENABLE_DEBUG
#endif
return mca_pml_v.host_pml.pml_start(count, requests);
}

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

@ -0,0 +1,9 @@
#ifndef __VPROTOCOL_EXAMPLE_START_H__
#define __VPROTOCOL_EXAMPLE_START_H__
#include "ompi_config.h"
#include "vprotocol_example.h"
#endif /* __VPROTOCOL_EXAMPLE_START_H__ */
OMPI_DECLSPEC int mca_vprotocol_example_start(size_t count, ompi_request_t **requests);

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

@ -0,0 +1,21 @@
#include "ompi_config.h"
#include "vprotocol_example.h"
#include "vprotocol_example_wait.h"
int mca_vprotocol_example_wait_any(size_t count, ompi_request_t ** requests, int *index, ompi_status_public_t * status)
{
return OMPI_ERROR;
}
int mca_vprotocol_example_wait_some(size_t count, ompi_request_t ** requests, int *indexes, ompi_status_public_t * statuses)
{
return mca_vprotocol_example_wait_any(count, requests, indexes, statuses);
}
int mca_vprotocol_example_wait_all(size_t count, ompi_request_t ** requests, ompi_status_public_t * statuses)
{
return OMPI_ERROR;
}

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

@ -0,0 +1,11 @@
#ifndef __VPROTOCOL_EXAMPLE_WAIT_H__
#define __VPROTOCOL_EXAMPLE_WAIT_H__
#include "ompi_config.h"
#include "vprotocol_example.h"
OMPI_DECLSPEC int mca_vprotocol_example_wait_any(size_t count, ompi_request_t ** requests, int *index, ompi_status_public_t * status);
OMPI_DECLSPEC int mca_vprotocol_example_wait_some(size_t count, ompi_request_t ** requests, int *indexes, ompi_status_public_t * statuses);
OMPI_DECLSPEC int mca_vprotocol_example_wait_all(size_t count, ompi_request_t ** requests, ompi_status_public_t * statuses);
#endif /* __VPROTOCOL_EXAMPLE_WAIT_H__ */

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

@ -0,0 +1,64 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
# Make the output library in this directory, and name it either
# protocol_<name>.la (for DSO builds) or libprotocol_<name>.la
# (for static builds).
if OMPI_BUILD_pml_v_DSO
component_noinst =
component_install = mca_vprotocol_pessimist.la
else
component_noinst = libmca_vprotocol_pessimist.la
component_install =
endif
local_sources = \
vprotocol_pessimist.h \
vprotocol_pessimist.c \
vprotocol_pessimist_component.c \
vprotocol_pessimist_request.c \
vprotocol_pessimist_request.h \
vprotocol_pessimist_proc.c \
vprotocol_pessimist_comm.c \
vprotocol_pessimist_progress.c \
vprotocol_pessimist_start.h \
vprotocol_pessimist_start.c \
vprotocol_pessimist_recv.c \
vprotocol_pessimist_send.c \
vprotocol_pessimist_probe.c \
vprotocol_pessimist_wait.h \
vprotocol_pessimist_wait.c \
vprotocol_pessimist_event.h \
vprotocol_pessimist_event.c \
vprotocol_pessimist_eventlog.h \
vprotocol_pessimist_eventlog.c \
vprotocol_pessimist_sender_based.h \
vprotocol_pessimist_sender_based.c
mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component_install)
mca_vprotocol_pessimist_la_SOURCES = $(local_sources)
mca_vprotocol_pessimist_la_LIBADD =
mca_vprotocol_pessimist_la_CFLAGS = -Wno-variadic-macros
mca_vprotocol_pessimist_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_vprotocol_pessimist_la_SOURCES = $(local_sources)
libmca_vprotocol_pessimist_la_LIBADD =
libmca_vprotocol_pessimist_la_CFLAGS = -Wno-variadic-macros
libmca_vprotocol_pessimist_la_LDFLAGS = -module -avoid-version

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

@ -0,0 +1,24 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# All rights reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_INIT_FILE=vprotocol_pessimist.c
PARAM_CONFIG_HEADER_FILE="vprotocol_pessimist_config.h"
PARAM_CONFIG_FILES="Makefile"
# Mandatory for all vprotocol
echo `basename \`pwd\`` >> ../autogen.vprotocols

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

@ -0,0 +1,35 @@
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
mca_vprotocol_pessimist_module_t mca_vprotocol_pessimist =
{
{
/* mca_pml_base_module_add_procs_fn_t */ NULL,
/* mca_pml_base_module_del_procs_fn_t */ NULL,
/* mca_pml_base_module_enable_fn_f */ NULL,
/* mca_pml_base_module_progress_fn_t */ NULL, /*mca_vprotocol_pessimist_progress,*/
/* mca_pml_base_module_add_comm_fn_t */ NULL,
/* mca_pml_base_module_del_comm_fn_t */ NULL,
/* mca_pml_base_module_irecv_init_fn_t */ NULL,
/* mca_pml_base_module_irecv_fn_t */ mca_vprotocol_pessimist_irecv,
/* mca_pml_base_module_recv_fn_t */ mca_vprotocol_pessimist_recv,
/* mca_pml_base_module_isend_init_fn_t */ NULL,
/* mca_pml_base_module_isend_fn_t */ mca_vprotocol_pessimist_isend,
/* mca_pml_base_module_send_fn_t */ mca_vprotocol_pessimist_send,
/* mca_pml_base_module_iprobe_fn_t */ mca_vprotocol_pessimist_iprobe,
/* mca_pml_base_module_probe_fn_t */ mca_vprotocol_pessimist_probe,
/* mca_pml_base_module_start_fn_t */ mca_vprotocol_pessimist_start,
/* mca_pml_base_module_dump_fn_t */ mca_vprotocol_pessimist_dump,
/* opal_class_t * */ OBJ_CLASS(mca_vprotocol_pessimist_recv_request_t),
/* opal_class_t * */ OBJ_CLASS(mca_vprotocol_pessimist_send_request_t),
},
};
int mca_vprotocol_pessimist_dump(struct ompi_communicator_t* comm, int verbose)
{
V_OUTPUT("vprotocol_example dump for comm %d", comm->c_contextid);
return mca_pml_v.host_pml.pml_dump(comm, verbose);
}

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

@ -0,0 +1,90 @@
#ifndef __INCLUDE_VPROTOCOL_PESSIMIST_H__
#define __INCLUDE_VPROTOCOL_PESSIMIST_H__
#include "ompi_config.h"
#include "../pml_v.h"
#include "../pml_v_protocol.h"
#include "ompi/communicator/communicator.h"
#include "vprotocol_pessimist_event.h"
#include "vprotocol_pessimist_sender_based.h"
typedef struct mca_vprotocol_pessimist_module_t {
mca_pml_v_protocol_base_module_t super;
/* event tagging clock */
vprotocol_pessimist_clock_t clock;
/* list of events to send to Event Logger */
opal_list_t pending_events;
/* output buffer for messages to event logger */
vprotocol_pessimist_mem_event_t *event_buffer;
size_t event_buffer_length;
size_t event_buffer_max_length;
/* space for allocating events */
ompi_free_list_t events_pool;
/* Sender Based repository */
vprotocol_pessimist_sender_based_t sender_based;
/* replay mode variables */
bool replay;
opal_list_t replay_events;
} mca_vprotocol_pessimist_module_t;
extern mca_vprotocol_pessimist_module_t mca_vprotocol_pessimist;
int mca_vprotocol_pessimist_dump(struct ompi_communicator_t* comm, int verbose);
int mca_vprotocol_pessimist_add_procs(struct ompi_proc_t **procs, size_t nprocs);
int mca_vprotocol_pessimist_del_procs(struct ompi_proc_t **procs, size_t nprocs);
int mca_vprotocol_pessimist_progress(void);
int mca_vprotocol_pessimist_add_comm(struct ompi_communicator_t* comm);
int mca_vprotocol_pessimist_del_comm(struct ompi_communicator_t* comm);
int mca_vprotocol_pessimist_irecv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
struct ompi_request_t **request );
int mca_vprotocol_pessimist_recv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status );
int mca_vprotocol_pessimist_isend(void *buf,
size_t count,
ompi_datatype_t* datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
ompi_communicator_t* comm,
ompi_request_t** request );
int mca_vprotocol_pessimist_send(void *buf,
size_t count,
ompi_datatype_t* datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
ompi_communicator_t* comm );
int mca_vprotocol_pessimist_iprobe(int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status );
int mca_vprotocol_pessimist_probe(int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status );
#include "vprotocol_pessimist_request.h"
#include "vprotocol_pessimist_start.h"
#include "vprotocol_pessimist_wait.h"
#include "vprotocol_pessimist_eventlog.h"
#endif /* __INCLUDE_VPROTOCOL_PESSIMIST_H__ */

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

@ -0,0 +1,12 @@
#include "../pml_v.h"
#include "vprotocol_pessimist.h"
int mca_vprotocol_pessimist_add_comm(struct ompi_communicator_t* comm)
{
return mca_pml_v.host_pml.pml_add_comm(comm);
}
int mca_vprotocol_pessimist_del_comm(struct ompi_communicator_t* comm)
{
return mca_pml_v.host_pml.pml_del_comm(comm);
}

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

@ -0,0 +1,142 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/mca_base_param.h"
#include "../pml_v.h"
#include "../pml_v_protocol_base.h"
#include "vprotocol_pessimist.h"
static inline int mca_param_register_int( const char* param_name, int default_value);
static int mca_vprotocol_pessimist_component_open(void);
static int mca_vprotocol_pessimist_component_close(void);
static mca_pml_v_protocol_base_module_t *mca_vprotocol_pessimist_component_init( int* priority, bool, bool);
static int mca_vprotocol_pessimist_component_finalize(void);
static int _priority;
static int _free_list_num;
static int _free_list_max;
static int _free_list_inc;
static int _sender_based_size;
static int _event_buffer_size;
static char *_mmap_file_name;
mca_pml_v_protocol_base_component_1_0_0_t mca_vprotocol_pessimist_component =
{
/* First, the mca_base_component_t struct containing meta
* information about the component itself */
{
/* Indicate that we are a pml v1.0.0 component (which also implies
a specific MCA version) */
MCA_VPROTOCOL_BASE_VERSION_1_0_0,
"pessimist", /* MCA component name */
1, /* MCA component major version */
0, /* MCA component minor version */
0, /* MCA component release version */
mca_vprotocol_pessimist_component_open, /* component open */
mca_vprotocol_pessimist_component_close /* component close */
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
false
},
mca_vprotocol_pessimist_component_init, /* component init */
mca_vprotocol_pessimist_component_finalize /* component finalize */
};
/** MCA level functions
*/
static int mca_vprotocol_pessimist_component_open(void)
{
_priority = mca_param_register_int("priority", -1);
_free_list_num = mca_param_register_int("free_list_num", 16);
_free_list_max = mca_param_register_int("free_list_max", -1);
_free_list_inc = mca_param_register_int("free_list_inc", 64);
_sender_based_size = mca_param_register_int("sender_based_chunk", 100 * 1024 * 1024);
_event_buffer_size = mca_param_register_int("event_buffer_size", 1024);
_mmap_file_name = "vprotocol_pessimist-senderbased";
V_OUTPUT_VERBOSE(10, "vprotocol_pessimist: open: read priority %d", _priority);
return OMPI_SUCCESS;
}
static int mca_vprotocol_pessimist_component_close(void)
{
V_OUTPUT_VERBOSE(10, "vprotocol_pessimist: close");
return OMPI_SUCCESS;
}
/** VPROTOCOL level functions (same as PML one)
*/
static mca_pml_v_protocol_base_module_t *mca_vprotocol_pessimist_component_init( int* priority,
bool enable_progress_threads,
bool enable_mpi_threads)
{
V_OUTPUT_VERBOSE(10, "vprotocol_pessimist: component_init");
*priority = _priority;
/* sanity check */
if(enable_mpi_threads)
{
opal_output(0, "vprotocol_pessimist: component_init: threads are enabled, and not supported by vprotocol pessimist fault tolerant layer, will not load");
return NULL;
}
mca_vprotocol_pessimist.clock = 1;
mca_vprotocol_pessimist.replay = false;
OBJ_CONSTRUCT(&mca_vprotocol_pessimist.replay_events, opal_list_t);
OBJ_CONSTRUCT(&mca_vprotocol_pessimist.pending_events, opal_list_t);
OBJ_CONSTRUCT(&mca_vprotocol_pessimist.events_pool, ompi_free_list_t);
ompi_free_list_init(&mca_vprotocol_pessimist.events_pool,
sizeof(mca_vprotocol_pessimist_event_t),
OBJ_CLASS(mca_vprotocol_pessimist_event_t),
_free_list_num,
_free_list_max,
_free_list_inc,
NULL);
mca_vprotocol_pessimist.event_buffer_max_length =
_event_buffer_size / sizeof(vprotocol_pessimist_mem_event_t);
mca_vprotocol_pessimist.event_buffer_length = 0;
mca_vprotocol_pessimist.event_buffer =
(vprotocol_pessimist_mem_event_t *) malloc(_event_buffer_size);
if(vprotocol_pessimist_sender_based_init(_mmap_file_name, _sender_based_size) == -1) return NULL;
return &mca_vprotocol_pessimist.super;
}
static int mca_vprotocol_pessimist_component_finalize(void)
{
V_OUTPUT_VERBOSE(10, "vprotocol_pessimist_finalize");
/** TODO: fix memleak... */
vprotocol_pessimist_sender_based_finalize();
return OMPI_SUCCESS;
}
static inline int mca_param_register_int( const char* param_name,
int default_value )
{
int id = mca_base_param_register_int("vprotocol", "pessimist", param_name, NULL, default_value);
int param_value = default_value;
mca_base_param_lookup_int(id, &param_value);
return param_value;
}

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

@ -0,0 +1,4 @@
#include "ompi_config.h"
#include "vprotocol_pessimist_event.h"
OBJ_CLASS_INSTANCE(mca_vprotocol_pessimist_event_t, opal_list_item_t, NULL, NULL);

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

@ -0,0 +1,61 @@
#ifndef __INCLUDE_VPROTOCOL_PESSIMIST_EVENT_H__
#define __INCLUDE_VPROTOCOL_PESSIMIST_EVENT_H__
#include "ompi_config.h"
#include "opal/mca/base/mca_base_param.h"
#include "ompi/mca/pml/base/pml_base_request.h"
typedef uint64_t vprotocol_pessimist_clock_t;
typedef enum {
VPROTOCOL_PESSIMIST_EVENT_TYPE_MATCHING,
VPROTOCOL_PESSIMIST_EVENT_TYPE_DELIVERY
} vprotocol_pessimist_event_type_t;
typedef struct vprotocol_pessimist_matching_event_t {
vprotocol_pessimist_clock_t reqid; /* recv request post "clock" */
int src; /* matched src */
} vprotocol_pessimist_matching_event_t;
typedef struct vprotocol_pessimist_delivery_event_t {
vprotocol_pessimist_clock_t probeid; /* operation "clock" (for waits, tests, probes) */
vprotocol_pessimist_clock_t reqid; /* delivered request (recv or send) -TODO: SUPPORT FOR WaitSome/TestSome- */
} vprotocol_pessimist_delivery_event_t;
typedef union vprotocol_pessimist_mem_event_t {
vprotocol_pessimist_matching_event_t e_matching;
vprotocol_pessimist_delivery_event_t e_delivery;
} vprotocol_pessimist_mem_event_t;
typedef struct mca_vprotocol_pessimist_event_t {
ompi_free_list_item_t super;
vprotocol_pessimist_event_type_t type;
mca_pml_base_request_t *req;
vprotocol_pessimist_mem_event_t u_event;
} mca_vprotocol_pessimist_event_t;
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_vprotocol_pessimist_event_t);
#define VPESSIMIST_MATCHING_EVENT_NEW(event) do { \
ompi_free_list_item_t *item; \
int rc; \
OMPI_FREE_LIST_WAIT(&mca_vprotocol_pessimist.events_pool, item, rc); \
event = (mca_vprotocol_pessimist_event_t *) item; \
event->type = VPROTOCOL_PESSIMIST_EVENT_TYPE_MATCHING; \
event->u_event.e_matching.src = -1; \
} while(0)
#define VPESSIMIST_DELIVERY_EVENT_NEW(event) do { \
ompi_free_list_item_t *item; \
int rc; \
OMPI_FREE_LIST_WAIT(&mca_vprotocol_pessimist.events_pool, item, rc); \
event = (mca_vprotocol_pessimist_event_t *) item; \
event->type = VPROTOCOL_PESSIMIST_EVENT_TYPE_DELIVERY; \
} while(0)
#define VPESSIMIST_EVENT_RETURN(event) \
OMPI_FREE_LIST_RETURN(&mca_vprotocol_pessimist.events_pool, \
(ompi_free_list_item_t *) event)
#endif /* INCLUDE_VPROTOCOL_PESSIMIST_EVENT_H__ */

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

@ -0,0 +1,76 @@
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
#if 0
static inline void replay_delivery_order(
struct mca_ptl_base_module_t* ptl,
mca_ptl_base_recv_request_t* req,
size_t bytes_received,
size_t bytes_delivered)
{
vprotocol_pessimist_delivery_pending_t *delivery;
vprotocol_pessimist_event_t *event;
/* store it as finished but not delivered message in the list */
delivery = OBJ_NEW(vprotocol_pessimist_delivery_pending_t);
delivery->ptl = ptl;
delivery->req = req;
delivery->bytes_received = bytes_received;
delivery->bytes_delivered = bytes_delivered;
opal_list_append(&mca_vprotocol_pessimist.replay_delivery_pendings, (opal_list_item_t *) delivery);
/* deliver as many message as possible in the delivery pending list */
scanpendings:
if(opal_list_is_empty(&mca_vprotocol_pessimist.replay_events))
{
/* there is no more events to be replayed, leaving replay mode */
OPAL_OUTPUT((mca_pml_v_output, "Leaving replay mode"));
mca_vprotocol_pessimist.replay = false;
/* deliver (and log) any message still waiting in delivery_pendings */
while(! opal_list_is_empty(&mca_vprotocol_pessimist.replay_delivery_pendings))
{
delivery = (vprotocol_pessimist_delivery_pending_t *) opal_list_remove_first(&mca_vprotocol_pessimist.replay_delivery_pendings);
log_event(delivery->req);
OPAL_OUTPUT((mca_pml_v_output, "deliver\trecv %d:%lx\tfrom %d\ttag %d\tsize %d\tmatched src %d",
delivery->req->req_recv.req_base.req_comm->c_contextid, (long) delivery->req->req_recv.req_base.req_sequence,
delivery->req->req_recv.req_base.req_peer, delivery->req->req_recv.req_base.req_tag, delivery->req->req_recv.req_base.req_count,
delivery->req->req_recv.req_base.req_ompi.req_status.MPI_SOURCE));
mca_pml_v.host_pml_recv_progress(delivery->ptl, delivery->req, delivery->bytes_received, delivery->bytes_delivered);
OBJ_RELEASE(delivery);
}
}
else
{
/* search the event to replay in the delivery pending list */
event = (vprotocol_pessimist_event_t *) opal_list_get_first(&mca_vprotocol_pessimist.replay_events);
for(delivery = (vprotocol_pessimist_delivery_pending_t *) opal_list_get_first(&mca_vprotocol_pessimist.replay_delivery_pendings);
delivery != (vprotocol_pessimist_delivery_pending_t *) opal_list_get_end(&mca_vprotocol_pessimist.replay_delivery_pendings);
delivery = (vprotocol_pessimist_delivery_pending_t *) opal_list_get_next(delivery))
{
if((delivery->req->req_recv.req_base.req_comm->c_contextid == event->contextid) &&
(delivery->req->req_recv.req_base.req_sequence == event->rclock))
{
/* this is the request matching the first event to be replayed, let's go */
OPAL_OUTPUT((mca_pml_v_output, "deliver\trecv %d:%lx\tfrom %d\ttag %d\tsize %d\tmatched src %d",
delivery->req->req_recv.req_base.req_comm->c_contextid, (long) delivery->req->req_recv.req_base.req_sequence,
delivery->req->req_recv.req_base.req_peer, delivery->req->req_recv.req_base.req_tag, delivery->req->req_recv.req_base.req_count,
delivery->req->req_recv.req_base.req_ompi.req_status.MPI_SOURCE));
mca_pml_v.host_pml_recv_progress(delivery->ptl, delivery->req, delivery->bytes_received, delivery->bytes_delivered);
opal_list_remove_first(&mca_vprotocol_pessimist.replay_events);
OBJ_RELEASE(event);
opal_list_remove_item(&mca_vprotocol_pessimist.replay_delivery_pendings, (opal_list_item_t *) delivery);
OBJ_RELEASE(delivery);
/* the first event has been delivered, let's see if the second can be delivered now */
goto scanpendings;
}
}
/* the event to be replayed is not in the delivery_pendings list, we've delivered as much as we can for now */
}
}
#endif /* 0 */

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

@ -0,0 +1,256 @@
#ifndef __VPROTOCOL_PESSIMIST_EVENTLOG_H__
#define __VPROTOCOL_PESSIMIST_EVENTLOG_H__
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
#include "vprotocol_pessimist_request.h"
/*******************************************************************************
* ANY_SOURCE MATCHING
*/
/** Adds a matching event for this request in the event list for any ANY_SOURCE
* recv. This event have to be updated later by
* VPROTOCOL_PESSIMIST_MATCHING_LOG_FINALIZE
* req (IN/OUT): posted RECV request (mca_pml_base_request_t *)
* VPESSIMIST_REQ(req) is updated to keep track of the associated event
*/
#define VPROTOCOL_PESSIMIST_MATCHING_LOG_PREPARE(REQ) do { \
if(((mca_pml_base_request_t *) REQ)->req_peer == MPI_ANY_SOURCE) \
{ \
mca_vprotocol_pessimist_event_t *event; \
\
VPESSIMIST_MATCHING_EVENT_NEW(event); \
event->req = (mca_pml_base_request_t *) REQ; \
VPESSIMIST_RECV_REQ(REQ)->event = event; \
opal_list_append(&mca_vprotocol_pessimist.pending_events, \
(opal_list_item_t *) event); \
} \
} while(0)
/** Updates the actual value of a matching event
* req(IN/OUT): the matched recv request
* VPESSIMIST_REQ(req) is updated to remove link to event
*/
#define VPROTOCOL_PESSIMIST_MATCHING_LOG_FINALIZE(REQ) do { \
if(VPESSIMIST_REQ(REQ)->event) \
{ \
mca_vprotocol_pessimist_event_t *event; \
vprotocol_pessimist_matching_event_t *mevent; \
\
V_OUTPUT_VERBOSE(70, "pessimist:\tlog\tmatch\t%x\tsrc %d\tseq %llu", VPESSIMIST_REQ(REQ)->reqid, (REQ)->req_ompi.req_status.MPI_SOURCE, (long long) (REQ)->req_sequence); \
event = VPESSIMIST_RECV_REQ(REQ)->event; \
mevent = &(event->u_event.e_matching); \
mevent->reqid = VPESSIMIST_RECV_REQ(REQ)->reqid; \
mevent->src = (REQ)->req_ompi.req_status.MPI_SOURCE; \
VPESSIMIST_RECV_REQ(REQ)->event = NULL; \
event->req = NULL; \
} \
} while(0)
#define VPROTOCOL_PESSIMIST_SEND_BUFFER() do { \
if(mca_vprotocol_pessimist.event_buffer_length) \
{ \
/* write(2, mca_vprotocol_pessimist.event_buffer, \
mca_vprotocol_pessimist.event_buffer_length * \
sizeof(vprotocol_pessimist_mem_event_t)); */ \
mca_vprotocol_pessimist.event_buffer_length = 0; \
} \
} while(0)
#define VPROTOCOL_PESSIMIST_EVENT_FLUSH() do { \
if(!opal_list_is_empty(&mca_vprotocol_pessimist.pending_events)) \
{ \
mca_vprotocol_pessimist_event_t *event; \
mca_vprotocol_pessimist_event_t *prv_event; \
\
for( event = \
(mca_vprotocol_pessimist_event_t *) \
opal_list_get_first(&mca_vprotocol_pessimist.pending_events); \
event != \
(mca_vprotocol_pessimist_event_t *) \
opal_list_get_end(&mca_vprotocol_pessimist.pending_events); \
event = \
(mca_vprotocol_pessimist_event_t *) \
opal_list_get_next(event)) \
{ \
if(event->u_event.e_matching.src == -1) \
{ \
/* check if that request have been matched now and update the event */\
/* this assert make sure the negative source trick is fine */\
assert(event->type == VPROTOCOL_PESSIMIST_EVENT_TYPE_MATCHING); \
if(event->req->req_ompi.req_status.MPI_SOURCE == -1) \
{ \
V_OUTPUT_VERBOSE(101, "pessimist:\tlog\tel\t%x\tfrom %d\tnot matched yet", event->u_event.e_matching.reqid, event->u_event.e_matching.src); \
continue; \
} \
event->u_event.e_matching.src = \
event->req->req_ompi.req_status.MPI_SOURCE; \
} \
/* Send this event to EL */ \
V_OUTPUT_VERBOSE(100, "pessimist:\tlog\tel\t%x\tfrom %d\tsent to EL", event->u_event.e_matching.reqid, event->u_event.e_matching.src); \
mca_vprotocol_pessimist.event_buffer[mca_vprotocol_pessimist.event_buffer_length++] = \
event->u_event; \
if(mca_vprotocol_pessimist.event_buffer_length == \
mca_vprotocol_pessimist.event_buffer_max_length) \
VPROTOCOL_PESSIMIST_SEND_BUFFER(); \
prv_event = (mca_vprotocol_pessimist_event_t *) opal_list_remove_item( \
&mca_vprotocol_pessimist.pending_events, \
(opal_list_item_t *) event); \
VPESSIMIST_EVENT_RETURN(event); \
event = prv_event; \
} \
} \
VPROTOCOL_PESSIMIST_SEND_BUFFER(); \
} while(0)
/** Replay matching order according to event list during recovery
* src (IN/OUT): the requested source. If it is ANY_SOURCE it is changed to
* the matched source at first run.
* comm (IN): the communicator's context id is used to know the next unique
* request id that will be allocated by PML
*/
#define VPROTOCOL_PESSIMIST_MATCHING_REPLAY(src) do { \
if(mca_vprotocol_pessimist.replay && ((src) == MPI_ANY_SOURCE)) \
vprotocol_pessimist_matching_replay(&(src)); \
} while(0)
static inline void vprotocol_pessimist_matching_replay(int *src)
{
#if OMPI_ENABLE_DEBUG
uint32_t max = 0;
#endif
mca_vprotocol_pessimist_event_t *event;
/* searching this request in the event list */
for(event = (mca_vprotocol_pessimist_event_t *) opal_list_get_first(&mca_vprotocol_pessimist.replay_events);
event != (mca_vprotocol_pessimist_event_t *) opal_list_get_end(&mca_vprotocol_pessimist.replay_events);
event = (mca_vprotocol_pessimist_event_t *) opal_list_get_next(event))
{
vprotocol_pessimist_matching_event_t *mevent = &(event->u_event.e_matching);
if(mevent->reqid == mca_vprotocol_pessimist.clock)
{
/* this is the event to replay */
V_OUTPUT_VERBOSE(70, "pessimist: replay\tmatch\t%x\trecv is forced from %d", mevent->reqid, mevent->src);
(*src) = mevent->src;
opal_list_remove_item(&mca_vprotocol_pessimist.replay_events,
(opal_list_item_t *) event);
VPESSIMIST_EVENT_RETURN(event);
}
#if OMPI_ENABLE_DEBUG
else if(mevent->reqid > max)
max = mevent->reqid;
}
/* not forcing a ANY SOURCE event whose recieve clock is lower than max
* is a bug indicating we have missed an event during logging ! */
assert(((*src) != MPI_ANY_SOURCE) ||
(mca_vprotocol_pessimist.clock > max));
#else
}
#endif
}
/*******************************************************************************
* WAIT/TEST-SOME/ANY & PROBES
*/
/** Store the delivered request after a non deterministic delivery
* req (IN): the delivered request (pml_base_request_t *)
*/
#define VPROTOCOL_PESSIMIST_DELIVERY_LOG(req) do { \
mca_vprotocol_pessimist_event_t *event; \
vprotocol_pessimist_delivery_event_t *devent; \
\
if(req == NULL) \
{ \
V_OUTPUT_VERBOSE(70, "pessimist:\tlog\tdeliver\t%x\tnone", mca_vprotocol_pessimist.clock); \
event = opal_list_get_last(&mca_vprotocol_pessimist.pending_events); \
if(event->type == VPROTOCOL_PESSIMIST_EVENT_TYPE_DELIVERY && \
event->u_event.e_delivery.reqid == 0) \
{ \
/* consecutive probes not delivering anything are merged */ \
event->u_event.e_delivery.probeid = mca_vprotocol_pessimist.clock++; \
} \
else \
{ \
VPESSIMIST_DELIVERY_EVENT_NEW(event); \
devent = &(event->u_event.e_delivery); \
devent->probeid = mca_vprotocol_pessimist.clock++; \
devent->reqid = 0; \
opal_list_append(&mca_vprotocol_pessimist.pending_events, \
(opal_list_item_t *) event); \
} \
} \
else \
{ \
V_OUTPUT_VERBOSE(70, "pessimist:\tlog\tdeliver\t%x\treq %x", mca_vprotocol_pessimist.clock, VPESSIMIST_REQ(req)->reqid); \
VPESSIMIST_DELIVERY_EVENT_NEW(event); \
devent = &(event->u_event.e_delivery); \
devent->probeid = mca_vprotocol_pessimist.clock++; \
devent->reqid = VPESSIMIST_REQ(req)->reqid; \
opal_list_append(&mca_vprotocol_pessimist.pending_events, \
(opal_list_item_t *) event); \
} \
} while(0)
/** Enforces a particular request to be delivered considering the current
* event clock
* n (IN): the number of input requests
* reqs (IN): the set of considered requests (pml_base_request_t *)
* i (IN/OUT): index of the delivered request
* c (IN/OUT): counter for number of delivered requests (currently only 0 or 1)
* status (IN/OUT): status of the delivered request
*/
#define VPROTOCOL_PESSIMIST_DELIVERY_REPLAY(n, reqs, i, c, status) do { \
if(mca_vprotocol_pessimist.replay) \
{ \
mca_vprotocol_pessimist_event_t *event; \
\
for(event = (mca_vprotocol_pessimist_event_t *) opal_list_get_first(&mca_vprotocol_pessimist.replay_events); \
event != (mca_vprotocol_pessimist_event_t *) opal_list_get_end(&mca_vprotocol_pessimist.replay_events); \
event = (mca_vprotocol_pessimist_event_t *) opal_list_get_next(event)) \
{ \
vprotocol_pessimist_delivery_event_t *devent = &(event->u_event.e_delivery); \
\
if(event->type == VPROTOCOL_PESSIMIST_EVENT_TYPE_MATCHING) continue; \
if(devent->probeid < mca_vprotocol_pessimist.clock) \
{ \
/* this particular test have to return no request completed yet */ \
V_OUTPUT_VERBOSE(70, "pessimist:\treplay\tdeliver\t%x\tnone", mca_vprotocol_pessimist.clock); \
(i) = MPI_UNDEFINED; \
(c) = 0; \
mca_vprotocol_pessimist.clock++; \
return OMPI_SUCCESS; \
} \
else if(devent->probeid == mca_vprotocol_pessimist.clock) \
{ \
V_OUTPUT_VERBOSE(70, "pessimist:\treplay\tdeliver\t%x\t%x", devent->probeid, devent->reqid); \
for((i) = 0; (i) < (n); (i)++) \
{ \
if(VPESSIMIST_REQ(reqs[i])->reqid == devent->reqid) \
{ \
opal_list_remove_item(&mca_vprotocol_pessimist.replay_events, \
(opal_list_item_t *) event); \
VPESSIMIST_EVENT_RETURN(event); \
(c) = 1; \
mca_vprotocol_pessimist.clock++; \
return ompi_request_wait(&reqs[i], status); \
} \
} \
V_OUTPUT_VERBOSE(70, "pessimist:\treplay\tdeliver\t%x\tnone", mca_vprotocol_pessimist.clock); \
assert(devent->reqid == 0); \
(i) = MPI_UNDEFINED; \
(c) = 0; \
mca_vprotocol_pessimist.clock++; \
opal_list_remove_item(&mca_vprotocol_pessimist.replay_events, \
(opal_list_item_t *) event); \
VPESSIMIST_EVENT_RETURN(event); \
return OMPI_SUCCESS; \
} \
} \
V_OUTPUT_VERBOSE(50, "pessimist:\treplay\tdeliver\t%x\tnot forced", mca_vprotocol_pessimist.clock); \
} \
} while(0)
#endif /* __VPROTOCOL_PESSIMIST_EVENTLOG_H__ */

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

@ -0,0 +1,97 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "ompi/request/request.h"
#include "../pml_v.h"
#include "vprotocol_pessimist.h"
static inline int replay_iprobe(int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status );
static inline void log_iprobe(int ret, int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status);
static inline int replay_probe(int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status);
static inline void log_probe(int ret, int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status);
/*******************************************************************************
* MPI level functions
*/
int mca_vprotocol_pessimist_iprobe( int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status )
{
int ret;
if(mca_vprotocol_pessimist.replay)
{
ret = replay_iprobe(src, tag, comm, matched, status);
}
else
{
ret = mca_pml_v.host_pml.pml_iprobe(src, tag, comm, matched, status);
log_iprobe(ret, src, tag, comm, matched, status);
}
return ret;
}
int mca_vprotocol_pessimist_probe( int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status )
{
int ret;
if(mca_vprotocol_pessimist.replay)
{
ret = replay_probe(src, tag, comm, status);
}
else
{
ret = mca_pml_v.host_pml.pml_probe(src, tag, comm, status);
log_probe(ret, src, tag, comm, status);
}
return ret;
}
/*******************************************************************************
* message logging internals
*/
static inline int replay_iprobe(int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status )
{
return OMPI_ERROR;
}
static inline void log_iprobe(int ret, int src, int tag,
struct ompi_communicator_t *comm,
int *matched, ompi_status_public_t * status)
{
return;
}
static inline int replay_probe(int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status)
{
return OMPI_ERROR;
}
static inline void log_probe(int ret, int src, int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status)
{
return;
}

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

@ -0,0 +1,27 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "../pml_v.h"
#include "vprotocol_pessimist.h"
int mca_vprotocol_pessimist_add_procs(struct ompi_proc_t **procs, size_t nprocs)
{
/* TODO: for each proc, retrieve post send of sender based request, post recieve of list
block any other communications until we are up. To be determined how i manage to send (or resend) data to failed nodes
*/
return mca_pml_v.host_pml.pml_add_procs(procs, nprocs);
}
int mca_vprotocol_pessimist_del_procs(struct ompi_proc_t **procs, size_t nprocs)
{
/* TODO: I don't know, now... */
return mca_pml_v.host_pml.pml_del_procs(procs, nprocs);
}

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

@ -0,0 +1,7 @@
#include "../pml_v.h"
#include "vprotocol_pessimist.h"
int mca_vprotocol_pessimist_progress(void)
{
return mca_pml_v.host_pml.pml_progress();
}

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

@ -0,0 +1,69 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "ompi/request/request.h"
#include "ompi/mca/pml/base/pml_base_recvreq.h"
#include "../pml_v.h"
#include "vprotocol_pessimist.h"
int mca_vprotocol_pessimist_irecv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
struct ompi_request_t **request)
{
int ret;
V_OUTPUT_VERBOSE(50, "pessimist:\tirecv\trequest\t%x\tfrom %d\ttag %d\tsize %ld",
mca_vprotocol_pessimist.clock, src, tag, (long) count);
/* first, see if we have to enforce matching order */
VPROTOCOL_PESSIMIST_MATCHING_REPLAY(src);
/* now just let the host pml do its job */
ret = mca_pml_v.host_pml.pml_irecv(addr, count, datatype, src, tag, comm, request);
VPESSIMIST_REQ_INIT(*request);
VPROTOCOL_PESSIMIST_MATCHING_LOG_PREPARE(*request);
return ret;
}
int mca_vprotocol_pessimist_recv(void *addr,
size_t count,
ompi_datatype_t * datatype,
int src,
int tag,
struct ompi_communicator_t *comm,
ompi_status_public_t * status )
{
ompi_request_t *request = MPI_REQUEST_NULL;
int ret;
V_OUTPUT_VERBOSE(50, "pessimist:\trecv\tposted\t%x\tfrom %d\ttag %d\tsize %ld",
mca_vprotocol_pessimist.clock, src, tag, (long) count);
/* first, see if we have to enforce matching order */
VPROTOCOL_PESSIMIST_MATCHING_REPLAY(src);
/* now just let the pml do its job */
ret = mca_pml_v.host_pml.pml_irecv(addr, count, datatype, src, tag, comm, &request);
VPESSIMIST_REQ_INIT(request);
VPROTOCOL_PESSIMIST_MATCHING_LOG_PREPARE(request);
/* block until the request is completed */
VPROTOCOL_PESSIMIST_WAIT(&request, status, ret);
return ret;
}

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

@ -0,0 +1,33 @@
#include "ompi_config.h"
#include "vprotocol_pessimist_request.h"
#include "vprotocol_pessimist_eventlog.h"
#include "../../base/pml_base_request.h"
static void vprotocol_pessimist_request_construct(mca_pml_base_request_t *req);
OBJ_CLASS_INSTANCE(mca_vprotocol_pessimist_recv_request_t, mca_pml_base_request_t,
vprotocol_pessimist_request_construct, NULL);
OBJ_CLASS_INSTANCE(mca_vprotocol_pessimist_send_request_t, mca_pml_base_request_t,
vprotocol_pessimist_request_construct, NULL);
static void vprotocol_pessimist_request_construct(mca_pml_base_request_t *req)
{
V_OUTPUT_VERBOSE(250, "pessimist:\treq\tnew\treq=%p\tPreq=%p (aligned to %p)", (void *) req, (void *) VPESSIMIST_REQ(req), (void *) &(VPESSIMIST_REQ(req)->pml_req_free));
req->req_ompi.req_status.MPI_SOURCE = -1; /* no matching made flag */
VPESSIMIST_REQ(req)->pml_req_free = req->req_ompi.req_free;
VPESSIMIST_REQ(req)->event = NULL;
VPESSIMIST_REQ(req)->sb_reqs[0] = NULL;
assert(VPESSIMIST_REQ(req)->pml_req_free == req->req_ompi.req_free); /* detection of aligment issues on different arch */
req->req_ompi.req_free = mca_vprotocol_pessimist_request_free;
}
int mca_vprotocol_pessimist_request_free(ompi_request_t **req)
{
mca_pml_base_request_t *pml_req = (mca_pml_base_request_t *) *req;
V_OUTPUT_VERBOSE(50, "pessimist:\treq\tfree\t%x\tpeer %d\ttag %d\tsize %ld", VPESSIMIST_REQ(pml_req)->reqid, pml_req->req_peer, pml_req->req_tag, (long) pml_req->req_count);
VPROTOCOL_PESSIMIST_MATCHING_LOG_FINALIZE(pml_req);
pml_req->req_ompi.req_status.MPI_SOURCE = -1; /* no matching made flag */
VPROTOCOL_PESSIMIST_SENDER_BASED_FLUSH(pml_req);
return VPESSIMIST_REQ(pml_req)->pml_req_free(req);
}

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

@ -0,0 +1,43 @@
#ifndef __INCLUDE_VPROTOCOL_PESSIMIST_REQUEST_H_
#define __INCLUDE_VPROTOCOL_PESSIMIST_REQUEST_H_
#include "ompi_config.h"
#include "vprotocol_pessimist_event.h"
#include "ompi/request/request.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
typedef struct mca_vprotocol_pessimist_request_t {
ompi_request_free_fn_t pml_req_free;
vprotocol_pessimist_clock_t reqid;
ompi_request_t *sb_reqs[2];
mca_vprotocol_pessimist_event_t *event;
} mca_vprotocol_pessimist_request_t;
typedef mca_vprotocol_pessimist_request_t mca_vprotocol_pessimist_recv_request_t;
typedef mca_vprotocol_pessimist_request_t mca_vprotocol_pessimist_send_request_t;
OBJ_CLASS_DECLARATION(mca_vprotocol_pessimist_recv_request_t);
OBJ_CLASS_DECLARATION(mca_vprotocol_pessimist_send_request_t);
#define VPESSIMIST_REQ(req) \
((mca_vprotocol_pessimist_request_t *) VPROTOCOL_REQ(req))
#define VPESSIMIST_RECV_REQ(req) \
((mca_vprotocol_pessimist_recv_request_t *) VPROTOCOL_RECV_REQ(req))
#define VPESSIMIST_SEND_REQ(req) \
((mca_vprotocol_pessimist_send_request_t *) VPROTOCOL_SEND_REQ(req))
#define VPESSIMIST_REQ_INIT(req) do { \
VPESSIMIST_REQ(req)->reqid = mca_vprotocol_pessimist.clock++; \
} while(0)
int mca_vprotocol_pessimist_request_free(ompi_request_t **req);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_VPROTOCOL_PESSIMIST_REQUEST_H_ */

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

@ -0,0 +1,57 @@
/*
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "../pml_v.h"
#include "vprotocol_pessimist.h"
#include "vprotocol_pessimist_sender_based.h"
int mca_vprotocol_pessimist_isend(void *buf,
size_t count,
ompi_datatype_t* datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
ompi_communicator_t* comm,
ompi_request_t** request )
{
int ret;
V_OUTPUT_VERBOSE(50, "pessimist:\tisend\tposted\t%x\tto %d\ttag %d\tsize %ld",
mca_vprotocol_pessimist.clock, dst, tag, (long) count);
VPROTOCOL_PESSIMIST_EVENT_FLUSH();
ret = mca_pml_v.host_pml.pml_isend(buf, count, datatype, dst, tag, sendmode, comm, request);
VPESSIMIST_REQ_INIT(*request);
VPROTOCOL_PESSIMIST_SENDER_BASED_COPY(*request);
return ret;
}
int mca_vprotocol_pessimist_send(void *buf,
size_t count,
ompi_datatype_t* datatype,
int dst,
int tag,
mca_pml_base_send_mode_t sendmode,
ompi_communicator_t* comm )
{
ompi_request_t *request = MPI_REQUEST_NULL;
int rc;
V_OUTPUT_VERBOSE(110, "pessimist:\tsend\tposted\t%x\tto %d\ttag %d\tsize %ld",
mca_vprotocol_pessimist.clock, dst, tag, (long) count);
VPROTOCOL_PESSIMIST_EVENT_FLUSH();
mca_pml_v.host_pml.pml_isend(buf, count, datatype, dst, tag, sendmode, comm, &request);
VPESSIMIST_REQ_INIT(request);
VPROTOCOL_PESSIMIST_SENDER_BASED_COPY(request);
VPROTOCOL_PESSIMIST_WAIT(&request, MPI_STATUS_IGNORE, rc);
return rc;
}

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

@ -0,0 +1,101 @@
#include "vprotocol_pessimist_sender_based.h"
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#define sb mca_vprotocol_pessimist.sender_based
int vprotocol_pessimist_sender_based_init(const char *mmapfile, size_t size)
{
char path[PATH_MAX];
sb.sb_offset = 0;
sb.sb_length = size;
sb.sb_pagesize = getpagesize();
sb.sb_cursor = sb.sb_addr = NULL;
sb.sb_vacant = 0;
sb.sb_comm = MPI_COMM_NULL;
sprintf(path, "%s"OPAL_PATH_SEP"%s", orte_process_info.proc_session_dir,
mmapfile);
sb.sb_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
if(-1 == sb.sb_fd)
{
opal_output(1, "pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s",
path, strerror(errno));
return -1;
}
return sb.sb_fd;
}
void vprotocol_pessimist_sender_based_finalize(void)
{
int ret;
if(sb.sb_comm != MPI_COMM_NULL)
{
/* TODO: cleanup that works...
* ret = ompi_comm_free(&sb.sb_comm);
* if(MPI_SUCCESS != ret)
* opal_output(1, "pml_v: protocol_pessimist: sender_based_finalize: ompi_comm_free failed (%d)", ret);
*/
ret = munmap(sb.sb_addr, sb.sb_length);
if(-1 == ret)
opal_output(1, "pml_v: protocol_pessimsit: sender_based_finalize: munmap (%p): %s",
sb.sb_addr, strerror(errno));
}
ret = close(sb.sb_fd);
if(-1 == ret)
opal_output(1, "pml_v: protocol_pessimist: sender_based_finalize: close (%d): %s",
sb.sb_fd, strerror(errno));
}
/** Manage mmap floating window, allocating enough memory for the message to be
* asynchronously copied to disk.
*/
void vprotocol_pessimist_sender_based_alloc(size_t len)
{
if(sb.sb_comm == MPI_COMM_NULL)
ompi_comm_dup(MPI_COMM_SELF, &sb.sb_comm, 1);
else
munmap(sb.sb_addr, sb.sb_length);
/* Take care of alignement of sb_offset */
sb.sb_offset += (intptr_t) sb.sb_cursor - (intptr_t) sb.sb_addr;
sb.sb_cursor = (char *) (sb.sb_offset % sb.sb_pagesize); /* pos in window */
sb.sb_offset -= (off_t) sb.sb_cursor; /* position of window */
/* Adjusting sb_length for the largest application message to fit */
if(sb.sb_length < len)
sb.sb_length = len + (off_t) sb.sb_cursor;
if(-1 == lseek(sb.sb_fd, sb.sb_offset + sb.sb_length, SEEK_SET))
{
opal_output(1, "pml_v: vprotocol_pessimist: sender_based_alloc: lseek: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
if(1 != write(sb.sb_fd, "", 1))
{
opal_output(1, "pml_v: vprotocol_pessimist: sender_based_alloc: write: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
sb.sb_addr = mmap(sb.sb_addr, sb.sb_length, PROT_WRITE | PROT_READ,
MAP_SHARED, sb.sb_fd, sb.sb_offset);
if((void *) -1 == sb.sb_addr)
{
opal_output(1, "pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s",
strerror(errno));
close(sb.sb_fd);
ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false);
}
sb.sb_cursor += (intptr_t) sb.sb_addr; /* absolute addr of sender_based buffer */
sb.sb_vacant = sb.sb_length - sizeof(vprotocol_pessimist_sender_based_header_t);
V_OUTPUT_VERBOSE(1, "pessimist:\tsb\tgrow\toffset %lld\tlength %lld\tbase %p\tcursor %p", (long long) sb.sb_offset, (long long) sb.sb_length, sb.sb_addr, sb.sb_cursor);
}
#undef sb

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

@ -0,0 +1,118 @@
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
#ifndef __VPROTOCOL_PESSIMIST_SENDERBASED_H__
#define __VPROTOCOL_PESSIMIST_SENDERBASED_H__
#include "vprotocol_pessimist_request.h"
#include <sys/mman.h>
typedef struct vprotocol_pessimist_sender_based_t
{
int sb_pagesize; /* size of memory pages on this architecture */
ompi_communicator_t *sb_comm;
int sb_fd; /* file descriptor of mapped file */
off_t sb_offset; /* offset in mmaped file */
char *sb_addr; /* base address of mmaped segment */
size_t sb_length; /* length of mmaped segment */
char *sb_cursor; /* current pointer to writeable memory */
size_t sb_vacant; /* available space before end of segment */
} vprotocol_pessimist_sender_based_t;
typedef struct vprotocol_pessimist_sender_based_header_t
{
size_t size;
int dst;
int tag;
uint32_t contextid;
uint64_t sequence;
} vprotocol_pessimist_sender_based_header_t;
int vprotocol_pessimist_sender_based_init(const char *mmapfile, size_t size);
void vprotocol_pessimist_sender_based_finalize(void);
/** Manage mmap floating window, allocating enough memory for the message to be
* asynchronously copied to disk.
*/
void vprotocol_pessimist_sender_based_alloc(size_t len);
#define __SENDER_BASED_IOV_PACK(req) do { \
if( 0 != req->req_bytes_packed ) { \
ompi_convertor_t conv; \
size_t max_data; \
size_t zero = 0; \
unsigned int iov_count = 1; \
struct iovec iov; \
\
iov.iov_len = req->req_bytes_packed; \
iov.iov_base = \
(IOVBASE_TYPE *) mca_vprotocol_pessimist.sender_based.sb_cursor; \
ompi_convertor_clone_with_position( &req->req_base.req_convertor, \
&conv, 0, &zero ); \
ompi_convertor_pack(&conv, &iov, &iov_count, &max_data); \
} \
} while(0)
#define __SENDER_BASED_SENDRECV_PACK(req) do { \
mca_pml_v.host_pml.pml_irecv( \
mca_vprotocol_pessimist.sender_based.sb_cursor, \
req->req_bytes_packed, MPI_PACKED, 0, 0, \
mca_vprotocol_pessimist.sender_based.sb_comm, \
& VPESSIMIST_REQ(req)->sb_reqs[0]); \
mca_pml_v.host_pml.pml_isend(req->req_base.req_addr, \
req->req_base.req_count, req->req_base.req_datatype, 0, 0, \
MCA_PML_BASE_SEND_READY, \
mca_vprotocol_pessimist.sender_based.sb_comm, \
& VPESSIMIST_REQ(req)->sb_reqs[1]); \
} while(0);
#define __SENDER_BASED_PACK(req) do { \
vprotocol_pessimist_sender_based_header_t *sbhdr = \
(vprotocol_pessimist_sender_based_header_t *) \
mca_vprotocol_pessimist.sender_based.sb_cursor; \
sbhdr->size = req->req_bytes_packed; \
sbhdr->dst = req->req_base.req_peer; \
sbhdr->tag = req->req_base.req_tag; \
sbhdr->contextid = req->req_base.req_comm->c_contextid; \
sbhdr->sequence = req->req_base.req_sequence; \
mca_vprotocol_pessimist.sender_based.sb_cursor += \
sizeof(vprotocol_pessimist_sender_based_header_t); \
\
__SENDER_BASED_IOV_PACK(req); \
mca_vprotocol_pessimist.sender_based.sb_cursor += sbhdr->size; \
mca_vprotocol_pessimist.sender_based.sb_vacant -= (sbhdr->size + \
sizeof(vprotocol_pessimist_sender_based_header_t)); \
V_OUTPUT_VERBOSE(70, "pessimist:\tsb\twrite\t%x\tsize %ld", VPESSIMIST_REQ(&req->req_base)->reqid, sbhdr->size); \
} while(0)
/** Copy data associated to a pml_base_send_request_t to the sender based
* message payload buffer
*/
#define VPROTOCOL_PESSIMIST_SENDER_BASED_COPY(REQ) do { \
mca_pml_base_send_request_t *req = (mca_pml_base_send_request_t *) (REQ); \
if(req->req_bytes_packed >= \
mca_vprotocol_pessimist.sender_based.sb_vacant) \
{ \
vprotocol_pessimist_sender_based_alloc(req->req_bytes_packed); \
} \
__SENDER_BASED_PACK(req); \
} while(0)
/** Ensure sender based is finished before allowing user to touch send buffer
*/
#define VPROTOCOL_PESSIMIST_SENDER_BASED_FLUSH(REQ)
#define DUMMYCOMMENT do { \
if(VPESSIMIST_REQ(REQ)->sb_reqs[0]) \
{ \
ompi_request_wait_all(2, VPESSIMIST_REQ(REQ)->sb_reqs, \
MPI_STATUSES_IGNORE); \
VPESSIMIST_REQ(REQ)->sb_reqs[0] = NULL; \
} \
} while(0)
#endif

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

@ -0,0 +1,41 @@
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
OMPI_DECLSPEC int mca_vprotocol_pessimist_start(size_t count, ompi_request_t **requests)
{
int ret;
#if 0
size_t i;
for(i = 0; i < count; i++)
{
mca_pml_base_request_t *pml_request = (mca_pml_base_request_t *) requests[i];
if(NULL == pml_request) continue;
switch(pml_request->req_type)
{
case MCA_PML_REQUEST_RECV :
V_OUTPUT_VERBOSE(90, "pessimist:\tstart\trecv\t%d:%llx\tfrom %d\ttag %d\tsize %d", pml_request->req_comm->c_contextid, mca_vprotocol_pessimist.rclock[pml_request->req_comm->c_contextid], pml_request->req_peer, pml_request->req_tag, pml_request->req_count);
/* It's a persistent recv request, first, see if we have to enforce matching order */
VPROTOCOL_PESSIMIST_MATCHING_REPLAY(pml_request->req_peer, pml_request->req_comm);
break;
case MCA_PML_REQUEST_SEND :
V_OUTPUT_VERBOSE(90, "pessimist:\tstart\tsend\t%d:%llx\tto %d\ttag %d\tsize %d", pml_request->req_comm->c_contextid, mca_vprotocol_pessimist.rclock[pml_request->req_comm->c_contextid], pml_request->req_peer, pml_request->req_tag, pml_request->req_count);
/* It's a persistent send request, first, check if we are waiting ack
* for some older events */
VPROTOCOL_PESSIMIST_POSTPONE(&request[i]);
break;
default:
V_OUTPUT_VERBOSE(90, "pessimist:\tstart\trequest\t%d:%ld\tfrom/to %d\ttag %d\tsize %d", pml_request->req_comm->c_contextid, mca_vprotocol_pessimist.rclock[pml_request->req_comm->c_contextid], pml_request->req_peer, pml_request->req_tag, pml_request->req_count);
return OMPI_ERR_REQUEST;
}
}
#endif
ret = mca_pml_v.host_pml.pml_start(count, requests);
/* restore requests status */
return ret;
}

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

@ -0,0 +1,9 @@
#ifndef __VPROTOCOL_PESSIMIST_START_H__
#define __VPROTOCOL_PESSIMIST_START_H__
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
#endif /* __VPROTOCOL_PESSIMIST_START_H__ */
OMPI_DECLSPEC int mca_vprotocol_pessimist_start(size_t count, ompi_request_t **requests);

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

@ -0,0 +1,57 @@
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
#include "vprotocol_pessimist_wait.h"
int vprotocol_pessimist_request_null_free(ompi_request_t **req)
{
return OMPI_SUCCESS;
}
int mca_vprotocol_pessimist_wait_any(size_t count, ompi_request_t ** requests, int *index, ompi_status_public_t * status)
{
int ret;
size_t i;
int c;
VPROTOCOL_PESSIMIST_DELIVERY_REPLAY(count, requests, *index, c, status);
# define pml_req ((mca_pml_base_request_t *) requests[i])
/* Avoid the request to be disposed by waitall */
for(i = 0; i < count; i++)
{
if(requests[i] == MPI_REQUEST_NULL) continue;
requests[i]->req_free = vprotocol_pessimist_request_null_free;
}
ret = ompi_request_wait_any(count, requests, index, status);
/* Parse the result */
for(i = 0; i < count; i++)
{
if(requests[i] == MPI_REQUEST_NULL) continue;
/* Restore requests and store they've been probed for termination */
pml_req->req_ompi.req_free = mca_vprotocol_pessimist_request_free;
if(i == (size_t) *index)
{
VPROTOCOL_PESSIMIST_DELIVERY_LOG(pml_req);
/* only free request without error status */
if(pml_req->req_ompi.req_status.MPI_ERROR == MPI_SUCCESS)
ompi_request_free(&(requests[i]));
else
ret = pml_req->req_ompi.req_status.MPI_ERROR;
}
# undef pml_req
}
return ret;
}
int mca_vprotocol_pessimist_wait_some(size_t count, ompi_request_t ** requests, int *indexes, ompi_status_public_t * statuses)
{
return mca_vprotocol_pessimist_wait_any(count, requests, indexes, statuses);
}

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

@ -0,0 +1,35 @@
#ifndef __VPROTOCOL_PESSIMIST_WAIT_H__
#define __VPROTOCOL_PESSIMIST_WAIT_H__
#include "ompi_config.h"
#include "vprotocol_pessimist.h"
int vprotocol_pessimist_request_null_free(ompi_request_t **req);
#define VPROTOCOL_PESSIMIST_WAIT(req, status, rc) \
((rc) = ompi_request_wait(req, status))
#if 0
do { \
if(*(req) == MPI_REQUEST_NULL) (rc) = ompi_request_wait(req, status); \
else \
{ \
mca_pml_base_request_t *pml_req = (mca_pml_base_request_t *) *(req); \
ompi_request_free_fn_t free_fn = pml_req->req_ompi.req_free; \
pml_req->req_ompi.req_free = vprotocol_pessimist_request_null_free; \
V_OUTPUT_VERBOSE(50, "pessimist:\twait\tdeliver\t%d:%llx\tpeer %d\ttag %d\tsize %d", pml_req->req_comm->c_contextid, pml_req->req_sequence, pml_req->req_peer, pml_req->req_tag, pml_req->req_count); \
(rc) = ompi_request_wait(req, status); \
VPROTOCOL_PESSIMIST_MATCHING_LOG(pml_req); \
pml_req->req_ompi.req_free = free_fn; \
ompi_request_free(req); \
} \
} while(0)
OMPI_DECLSPEC int mca_vprotocol_pessimist_wait(ompi_request_t **request, ompi_status_public_t *status);
OMPI_DECLSPEC int mca_vprotocol_pessimist_wait_all(size_t count, ompi_request_t ** requests, ompi_status_public_t * statuses);
#endif
int mca_vprotocol_pessimist_wait_any(size_t count, ompi_request_t ** requests, int *index, ompi_status_public_t * status);
int mca_vprotocol_pessimist_wait_some(size_t count, ompi_request_t ** requests, int *indexes, ompi_status_public_t * statuses);
#endif /* __VPROTOCOL_PESSIMIST_WAIT_H__ */