Commit 1679ba2a authored by Masamichi Takagi's avatar Masamichi Takagi Committed by Pavan Balaji
Browse files

Add Hatanaka version of MTR netmod files (tofu/*)

parent c38c3c79
## -*- Mode: Makefile; -*-
## vim: set ft=automake :
##
## (C) 2011 by Argonne National Laboratory.
## See COPYRIGHT in top-level directory.
##
if BUILD_NEMESIS_NETMOD_TOFU
# AM_CPPFLAGS += -I...
lib_lib@MPILIBNAME@_la_SOURCES += \
src/mpid/ch3/channels/nemesis/netmod/tofu/tofu_init.c \
src/mpid/ch3/channels/nemesis/netmod/tofu/tofu_fini.c \
src/mpid/ch3/channels/nemesis/netmod/tofu/tofu_vc.c \
src/mpid/ch3/channels/nemesis/netmod/tofu/tofu_poll.c \
src/mpid/ch3/channels/nemesis/netmod/tofu/tofu_send.c \
$(EOA)
noinst_HEADERS += \
src/mpid/ch3/channels/nemesis/netmod/tofu/tofu_impl.h \
$(EOA)
endif BUILD_NEMESIS_NETMOD_TOFU
[#] start of __file__
dnl MPICH_SUBCFG_AFTER=src/mpid/ch3/channels/nemesis
AC_DEFUN([PAC_SUBCFG_PREREQ_]PAC_SUBCFG_AUTO_SUFFIX,[
AM_COND_IF([BUILD_CH3_NEMESIS],[
for net in $nemesis_networks ; do
AS_CASE([$net],[tofu],[build_nemesis_netmod_tofu=yes])
done
])
AM_CONDITIONAL([BUILD_NEMESIS_NETMOD_TOFU],[test "X$build_nemesis_netmod_tofu" = "Xyes"])
])dnl
AC_DEFUN([PAC_SUBCFG_BODY_]PAC_SUBCFG_AUTO_SUFFIX,[
AM_COND_IF([BUILD_NEMESIS_NETMOD_TOFU],[
AC_MSG_NOTICE([RUNNING CONFIGURE FOR ch3:nemesis:tofu])
PAC_SET_HEADER_LIB_PATH(libmemcached)
PAC_SET_HEADER_LIB_PATH(ibverbs)
PAC_SET_HEADER_LIB_PATH(llc)
PAC_CHECK_HEADER_LIB(libmemcached/memcached.h,memcached,memcached,libmemcached_found=yes,libmemcached_found=no)
if test "${libmemcached_found}" = "yes" ; then
AC_MSG_NOTICE([libmemcached is going to be linked.])
else
AC_MSG_ERROR([Internal error: libmemcached was not found])
fi
PAC_CHECK_HEADER_LIB([infiniband/verbs.h],ibverbs,ibv_open_device,ibverbs_found=yes,ibverbs_found=no)
if test "${ibverbs_found}" = "yes" ; then
AC_MSG_NOTICE([libibverbs is going to be linked.])
else
AC_MSG_ERROR([Internal error: ibverbs was not found])
fi
PAC_CHECK_HEADER_LIB(llc.h,llc,LLC_init,llc_found=yes,llc_found=no)
if test "${llc_found}" = "yes" ; then
AC_MSG_NOTICE([libllc is going to be linked.])
else
AC_MSG_ERROR([Internal error: llc was not found])
fi
#AC_CHECK_HEADERS([stdlib.h dlfcn.h])
#AC_CHECK_FUNCS([dlopen])
#AC_SEARCH_LIBS([dlopen], [dl])
dnl AC_TRY_COMPILE([
dnl #include <stdio.h>
dnl #include <dlfcn.h>
dnl ],[
dnl dlopen(NULL, RTLD_LAZY)
dnl ],[ac_cv_func_dlopen=yes],[ac_cv_func_dlopen=no])
AC_DEFINE([ENABLE_COMM_OVERRIDES], 1, [define to add per-vc function pointers to override send and recv functions])
])dnl end AM_COND_IF(BUILD_NEMESIS_NETMOD_TOFU,...)
])dnl end _BODY
[#] end of __file__
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/* vim: set ts=8 sts=4 sw=4 noexpandtab : */
/*
*
*/
#include "mpid_nem_impl.h"
#include "tofu_impl.h"
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_finalize
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int
MPID_nem_tofu_finalize(void)
{
int mpi_errno = MPI_SUCCESS;
int rc;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_FINALIZE);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_FINALIZE);
rc = LLC_finalize();
MPIU_ERR_CHKANDJUMP(rc != 0, mpi_errno, MPI_ERR_OTHER, "**fail");
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_FINALIZE);
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/* vim: set ts=8 sts=4 sw=4 noexpandtab : */
#ifndef TOFU_MODULE_IMPL_H
#define TOFU_MODULE_IMPL_H
#ifdef USE_PMI2_API
#include "pmi2.h"
#else
#include "pmi.h"
#endif
#include "mpid_nem_impl.h"
#include "llc.h"
/* The vc provides a generic buffer in which network modules can store
* private fields This removes all dependencies from the VC struction
* on the network module, facilitating dynamic module loading. */
/*
* GENERIC_Q_*:
* src/mpid/ch3/channels/nemesis/include/mpid_nem_generic_queue.h
*/
typedef GENERIC_Q_DECL(struct MPID_Request) rque_t;
/*
typedef GENERIC_Q_DECL(struct MPID_Request) MPIDI_nem_tofu_request_queue_t;
*/
typedef struct
{
uint64_t remote_endpoint_addr;
void *endpoint;
rque_t send_queue; /* MPID_Request Queue */
} MPID_nem_tofu_vc_area;
/* macro for tofu private in VC */
#define VC_TOFU(vc) ((MPID_nem_tofu_vc_area *)(vc)->ch.netmod_area.padding)
typedef struct
{
void *cmds;
void *pack_buf; /* to pack non-contiguous data */
} MPID_nem_tofu_req_area;
#define REQ_TOFU(req) \
((MPID_nem_tofu_req_area *)(&(req)->ch.netmod_area.padding))
#define REQ_FIELD(reqp, field) (((MPID_nem_tofu_req_area *)((reqp)->ch.netmod_area.padding))->field)
/* functions */
int MPID_nem_tofu_init (MPIDI_PG_t *pg_p, int pg_rank, char **bc_val_p, int *val_max_sz_p);
int MPID_nem_tofu_finalize (void);
int MPID_nem_tofu_poll(int in_blocking_progress);
int MPID_nem_tofu_get_business_card (int my_rank, char **bc_val_p, int *val_max_sz_p);
int MPID_nem_tofu_connect_to_root (const char *business_card, MPIDI_VC_t *new_vc);
int MPID_nem_tofu_vc_init (MPIDI_VC_t *vc);
int MPID_nem_tofu_vc_destroy(MPIDI_VC_t *vc);
int MPID_nem_tofu_vc_terminate (MPIDI_VC_t *vc);
int MPID_nem_tofu_anysource_iprobe(int tag, MPID_Comm *comm, int context_offset, int *flag, MPI_Status *status);
int MPID_nem_tofu_anysource_improbe(int tag, MPID_Comm *comm, int context_offset, int *flag,
MPID_Request **message,MPI_Status *status);
int MPID_nem_tofu_iSendContig(MPIDI_VC_t *vc, MPID_Request *sreq, void *hdr, MPIDI_msg_sz_t hdr_sz, void *data, MPIDI_msg_sz_t data_sz);
int MPID_nem_tofu_iStartContigMsg(MPIDI_VC_t *vc, void *hdr, MPIDI_msg_sz_t hdr_sz, void *data, MPIDI_msg_sz_t data_sz, MPID_Request **sreq_ptr);
int MPID_nem_tofu_SendNoncontig(MPIDI_VC_t *vc, MPID_Request *sreq, void *hdr, MPIDI_msg_sz_t hdr_sz);
int MPIDI_nem_tofu_Rqst_iov_update(MPID_Request *mreq, MPIDI_msg_sz_t consume);
int MPID_nem_tofu_send_queued(MPIDI_VC_t * vc, rque_t *send_queue);
int MPID_nem_tofu_isend(struct MPIDI_VC *vc, const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPID_Comm *comm, int context_offset,
struct MPID_Request **request );
int MPID_nem_tofu_recv_posted(struct MPIDI_VC *vc, struct MPID_Request *req);
/*
* temporary llctofu api
*/
typedef void (*llctofu_send_f)(void *cba, uint64_t *reqid);
typedef void (*llctofu_recv_f)
(void *cba, uint64_t addr, void *buf, size_t bsz);
extern ssize_t llctofu_writev(void *endpt, uint64_t raddr,
const struct iovec *iovs, int niov, void *cbarg, void **vpp_reqid);
extern int llctofu_bind(void **vpp_endpt, uint64_t raddr, void *cbarg);
extern int llctofu_unbind(void *endpt);
extern int llctofu_poll(int in_blocking_poll,
llctofu_send_f sfnc, llctofu_recv_f rfnc);
typedef struct MPID_nem_tofu_netmod_hdr {
int initiator_pg_rank;
} MPID_nem_tofu_netmod_hdr_t;
#define MPID_nem_tofu_segv printf("%d\n", *(int32_t*)0);
#endif /* TOFU_MODULE_IMPL_H */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/* vim: set ts=8 sts=4 sw=4 noexpandtab : */
/*
*
*/
#include "mpid_nem_impl.h"
#include "tofu_impl.h"
/* global variables */
/* src/mpid/ch3/channels/nemesis/include/mpid_nem_nets.h */
MPID_nem_netmod_funcs_t MPIDI_nem_tofu_funcs = {
.init = MPID_nem_tofu_init,
.finalize = MPID_nem_tofu_finalize,
#ifdef ENABLE_CHECKPOINTING
.ckpt_precheck = NULL,
.ckpt_restart = NULL,
.ckpt_continue = NULL,
#endif
.poll = MPID_nem_tofu_poll,
.get_business_card = MPID_nem_tofu_get_business_card,
.connect_to_root = MPID_nem_tofu_connect_to_root,
.vc_init = MPID_nem_tofu_vc_init,
.vc_destroy = MPID_nem_tofu_vc_destroy,
.vc_terminate = MPID_nem_tofu_vc_terminate,
.anysource_iprobe = MPID_nem_tofu_anysource_iprobe,
.anysource_improbe = MPID_nem_tofu_anysource_improbe,
};
static MPIDI_Comm_ops_t comm_ops = {
.recv_posted = MPID_nem_tofu_recv_posted,
.send = MPID_nem_tofu_isend, /* wait is performed separately after calling this */
.rsend = NULL,
.ssend = NULL,
.isend = MPID_nem_tofu_isend,
.irsend = NULL,
.issend = NULL,
.send_init = NULL,
.bsend_init = NULL,
.rsend_init = NULL,
.ssend_init = NULL,
.start_all = NULL,
.cancel_send = NULL,
.cancel_recv = NULL,
.prove = NULL,
.iprove = NULL,
.improve = NULL
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_init
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int
MPID_nem_tofu_init (MPIDI_PG_t *pg_p, int pg_rank,
char **bc_val_p, int *val_max_sz_p)
{
int mpi_errno = MPI_SUCCESS;
int rc;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_INIT);
rc = LLC_init();
MPIU_ERR_CHKANDJUMP(rc != 0, mpi_errno, MPI_ERR_OTHER, "**fail");
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_INIT);
return mpi_errno;
fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_get_business_card
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int
MPID_nem_tofu_get_business_card (int my_rank, char **bc_val_p, int *val_max_sz_p)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_GET_BUSINESS_CARD);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_GET_BUSINESS_CARD);
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_GET_BUSINESS_CARD);
return mpi_errno;
//fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_connect_to_root
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int
MPID_nem_tofu_connect_to_root (const char *business_card, MPIDI_VC_t *new_vc)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_CONNECT_TO_ROOT);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_CONNECT_TO_ROOT);
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_CONNECT_TO_ROOT);
return mpi_errno;
//fn_fail:
goto fn_exit;
}
/* ============================================== */
/* ================ tofu_probe.c ================ */
/* ============================================== */
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_anysource_iprobe
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_nem_tofu_anysource_iprobe(int tag, MPID_Comm *comm, int context_offset, int *flag, MPI_Status *status)
{
return MPI_SUCCESS;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_anysource_improbe
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_nem_tofu_anysource_improbe(int tag, MPID_Comm *comm, int context_offset, int *flag, MPID_Request **message, MPI_Status *status)
{
return MPI_SUCCESS;
}
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/* vim: set ts=8 sts=4 sw=4 noexpandtab : */
/*
*
*/
#include "mpid_nem_impl.h"
#include "tofu_impl.h"
/* function prototypes */
static void MPID_nem_tofu_send_handler(void *cba,
uint64_t *p_reqid);
static void MPID_nem_tofu_recv_handler(void *vp_vc,
uint64_t raddr, void *buf, size_t bsz);
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_poll
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int
MPID_nem_tofu_poll(int in_blocking_progress)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_POLL);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_POLL);
{
int rc;
rc = llctofu_poll(in_blocking_progress,
MPID_nem_tofu_send_handler,
MPID_nem_tofu_recv_handler);
if (rc != 0) {
mpi_errno = MPI_ERR_OTHER;
MPIU_ERR_POP(mpi_errno);
}
}
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_POLL);
return mpi_errno;
fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_send_handler
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static void MPID_nem_tofu_send_handler(void *cba,
uint64_t *p_reqid)
{
/* int mpi_errno = 0; */
MPID_Request *sreq = cba; /* from llctofu_writev(,,,,cbarg,) */
MPID_Request_kind_t kind;
/* MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_SEND_HANDLER); */
/* MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_SEND_HANDLER); */
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "tofu_send_handler");
MPIU_Assert(sreq != NULL);
if (sreq == (void *)0xdeadbeefUL) {
MPIDI_VC_t *vc = (void *)p_reqid[0];
MPID_nem_tofu_vc_area *vc_tofu;
MPIU_Assert(vc != NULL);
/* printf("from credit %p (pg_rank %d)\n", vc, vc->pg_rank); */
vc_tofu = VC_TOFU(vc);
MPID_nem_tofu_send_queued(vc, &vc_tofu->send_queue);
p_reqid[0] = ! MPIDI_CH3I_Sendq_empty(vc_tofu->send_queue);
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "tofu_send_handler");
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE,
"send queue %d", (unsigned int)p_reqid[0]);
goto fn_exit;
}
kind = sreq->kind;
switch (kind) {
unsigned int reqtype;
case MPID_REQUEST_SEND:
case MPID_PREQUEST_SEND: {
reqtype = MPIDI_Request_get_type(sreq);
MPIU_Assert(reqtype != MPIDI_REQUEST_TYPE_GET_RESP);
int is_contig;
MPID_Datatype_is_contig(sreq->dev.datatype, &is_contig);
if (!is_contig && REQ_FIELD(sreq, pack_buf)) {
dprintf("tofu_send_handler,non-contiguous,free pack_buf\n");
MPIU_Free(REQ_FIELD(req, pack_buf));
}
/* sreq: src/mpid/ch3/include/mpidpre.h */
{
MPIDI_VC_t *vc;
int (*reqFn)(MPIDI_VC_t *vc, MPID_Request *sreq, int *complete);
int complete;
int r_mpi_errno;
p_reqid[0] = 0 /* REQ_TOFU(sreq)->woff */;
vc = sreq->ch.vc; /* before callback */
reqFn = sreq->dev.OnDataAvail;
if (reqFn == 0) {
MPIDI_CH3U_Request_complete(sreq);
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, ".... complete");
}
else {
complete = 0;
r_mpi_errno = reqFn(vc, sreq, &complete);
if (r_mpi_errno) MPIU_ERR_POP(r_mpi_errno);
if (complete == 0) {
MPIU_Assert(complete == TRUE);
}
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, ".... complete2");
}
/* push queued messages */
{
MPID_nem_tofu_vc_area *vc_tofu = VC_TOFU(vc);
MPID_nem_tofu_send_queued(vc, &vc_tofu->send_queue);
}
}
break; }
default:
break;
}
fn_exit:
/* MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_SEND_HANDLER); */
return /* mpi_errno */;
fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_recv_handler
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static void MPID_nem_tofu_recv_handler(
void *vp_vc,
uint64_t raddr,
void *buf,
size_t bsz
)
{
int mpi_errno = 0;
MPIDI_VC_t *vc = vp_vc;
/* MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_RECV_HANDLER); */
/* MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_RECV_HANDLER); */
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "tofu_recv_handler");
{
int pg_rank = (int) raddr;
MPIDI_PG_t *pg = MPIDI_Process.my_pg;
MPIDI_VC_t *vc_from_pg = 0;
if (
(pg != 0)
&& ((pg_rank >= 0) && (pg_rank < MPIDI_PG_Get_size(pg)))
) {
/*
* MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
*/
MPIDI_PG_Get_vc_set_active(pg, pg_rank, &vc_from_pg);
}
else {
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "bad vc %p or", pg);
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "bad pg_rank %d", pg_rank);
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "bad pg_rank < %d",
MPIDI_PG_Get_size(pg));
vc_from_pg = vc; /* XXX */
}
if (vc != vc_from_pg) {
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "bad vc for pg_rank %d", pg_rank);
}
if (vc == 0) {
vc = vc_from_pg;
}
}
if (vc != 0) {
mpi_errno = MPID_nem_handle_pkt(vc, buf, bsz);
if (mpi_errno != 0) {
MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE,
"MPID_nem_handle_pkt() = %d", mpi_errno);
}
}
fn_exit:
/* MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TOFU_RECV_HANDLER); */
return ;
//fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_tofu_recv_posted
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPID_nem_tofu_recv_posted(struct MPIDI_VC *vc, struct MPID_Request *req)
{
int mpi_errno = MPI_SUCCESS;
int dt_contig;
MPIDI_msg_sz_t data_sz;
MPID_Datatype *dt_ptr;
MPI_Aint dt_true_lb;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TOFU_RECV_POSTED);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TOFU_RECV_POSTED);
/* req->dev.datatype is set in MPIDI_CH3U_Recvq_FDU_or_AEP (in src/mpid/ch3/src/ch3u_recvq.c) */
MPIDI_Datatype_get_info(req->dev.user_count, req->dev.datatype, dt_contig, data_sz, dt_ptr,
dt_true_lb);
/* stash vc for ib_poll */
req->ch.vc = vc;
void *write_to_buf;
if (dt_contig) {
write_to_buf = (void *) ((char *) req->dev.user_buf /*+ REQ_FIELD(req, lmt_dt_true_lb) */);
}
else {
REQ_FIELD(req, pack_buf) = MPIU_Malloc(data_sz);
MPIU_ERR_CHKANDJUMP(!REQ_FIELD(req, pack_buf), mpi_errno, MPI_ERR_OTHER,
"**outofmemory");
write_to_buf = REQ_FIELD(req, pack_buf);
}
cmd[0].opcode = LLC_OPCODE_RECV;
cmd[0].comm = LLC_COMM_WORLD;
cmd[0].rank = VC_FIELD(vc, remote_endpoint_addr);
((MPIDI_Message_match_parts_t*)(&cmd[0].match.bits))->rank = comm->rank;
((MPIDI_Message_match_parts_t*)(&cmd[0].match.bits))->tag = tag;
((MPIDI_Message_match_parts_t*)(&cmd[0].match.bits))->context_id = comm->context_id + context_offset;