Commit b7a189c3 authored by Jason Cope's avatar Jason Cope
Browse files

portals driver cleanup

removed dead code and consolidated files
parent 7f95de86
......@@ -13,7 +13,7 @@ ifneq (,$(BUILD_PORTALS))
# Local definitions.
#
DIR := src/io/bmi/bmi_portals
cfiles := portals.c dlmalloc.c portals_comm.c portals_conn.c portals_fc.c portals_helpers.c portals_wrappers.c
cfiles := portals.c dlmalloc.c portals_conn.c portals_helpers.c portals_wrappers.c
#
# Export these to the top Makefile to tell it what to build.
......
......@@ -4,7 +4,6 @@
#include <signal.h>
#include "portals_conn.h"
#include "portals_comm.h"
#include "portals_helpers.h"
#include "src/common/quicklist/quicklist.h"
......
#include "portals_comm.h"
#include <stdio.h>
const char * bmip_ptl_ev_type(ptl_event_t * ev)
{
switch(ev->type)
{
case PTL_EVENT_SEND_START:
return "PTL_EVENT_SEND_START";
case PTL_EVENT_SEND_END:
return "PTL_EVENT_SEND_END";
case PTL_EVENT_PUT_START:
return "PTL_EVENT_PUT_START";
case PTL_EVENT_PUT_END:
return "PTL_EVENT_PUT_END";
case PTL_EVENT_ACK:
return "PTL_EVENT_ACK";
case PTL_EVENT_GET_START:
return "PTL_EVENT_GET_START";
case PTL_EVENT_GET_END:
return "PTL_EVENT_GET_END";
case PTL_EVENT_REPLY_START:
return "PTL_EVENT_REPLY_START";
case PTL_EVENT_REPLY_END:
return "PTL_EVENT_REPLY_END";
case PTL_EVENT_UNLINK:
return "PTL_EVENT_UNLINK";
default:
return "UNKNOWN";
};
out:
return NULL;
}
int bmip_unex_handler(ptl_event_t * ev)
{
int ret = ev->type;
//fprintf(stderr, "%s: event type %s, nid %i, pid %i, match_bits %llx, rlength %i, mlength %i, offset %i hdr data = %llu\n", __func__, bmip_ptl_ev_type(ev), ev->initiator.nid, ev->initiator.pid, ev->match_bits, ev->rlength, ev->mlength, ev->offset, ev->hdr_data);
switch(ev->type)
{
case PTL_EVENT_SEND_START:
break;
case PTL_EVENT_SEND_END:
break;
case PTL_EVENT_PUT_START:
break;
case PTL_EVENT_PUT_END:
break;
case PTL_EVENT_ACK:
break;
case PTL_EVENT_GET_START:
break;
case PTL_EVENT_GET_END:
break;
case PTL_EVENT_REPLY_START:
break;
case PTL_EVENT_REPLY_END:
break;
case PTL_EVENT_UNLINK:
break;
default:
ret = -1;
break;
};
out:
return ret;
}
int bmip_wait_event(int timeout, ptl_handle_eq_t * eq, ptl_event_t * ev)
{
int ret = -1;
int i = 0;
const int numhandles = 1;
ptl_event_t sev;
ptl_event_t * lev;
/* detect if we want a copy of the event data or not */
if(ev == NULL)
{
lev = &sev;
}
else
{
lev = ev;
}
/* wait for an unexpected message */
#ifndef BMIP_USE_TIMEOUT
ret = bmip_ptl_eq_wait(*eq, lev);
#else
ret = bmip_ptl_eq_poll(eq, numhandles, timeout, lev, &i);
#endif
if(ret != PTL_EQ_EMPTY)
{
if(ret != PTL_OK)
{
fprintf(stderr, "eq wait failure\n");
ret = -1;
goto out;
}
else
{
ret = bmip_unex_handler(lev);
if(ret == -1)
{
ret = -1;
fprintf(stderr, "ev handler failure\n");
goto out;
}
}
}
else
{
ret = -2;
}
out:
return ret;
}
int bmip_msg_send()
{
int ret = 0;
ret = bmip_ptl_put();
if(ret != PTL_OK)
{
goto out;
}
out:
return ret;
}
#ifndef PORTALS_COMM_H
#define PORTALS_COMM_H
#include <portals/portals3.h>
#include <sys/utsname.h>
int bmip_wait_event(int timeout, ptl_handle_eq_t * eq, ptl_event_t * ev);
#endif
#include "portals_conn.h"
#include "portals_comm.h"
#include "portals_wrappers.h"
#include "portals_helpers.h"
......@@ -180,6 +179,123 @@ static unsigned int bmip_client_seq = 0;
/* server data allocation space */
static mspace portals_data_space = NULL;
const char * bmip_ptl_ev_type(ptl_event_t * ev)
{
switch(ev->type)
{
case PTL_EVENT_SEND_START:
return "PTL_EVENT_SEND_START";
case PTL_EVENT_SEND_END:
return "PTL_EVENT_SEND_END";
case PTL_EVENT_PUT_START:
return "PTL_EVENT_PUT_START";
case PTL_EVENT_PUT_END:
return "PTL_EVENT_PUT_END";
case PTL_EVENT_ACK:
return "PTL_EVENT_ACK";
case PTL_EVENT_GET_START:
return "PTL_EVENT_GET_START";
case PTL_EVENT_GET_END:
return "PTL_EVENT_GET_END";
case PTL_EVENT_REPLY_START:
return "PTL_EVENT_REPLY_START";
case PTL_EVENT_REPLY_END:
return "PTL_EVENT_REPLY_END";
case PTL_EVENT_UNLINK:
return "PTL_EVENT_UNLINK";
default:
return "UNKNOWN";
};
out:
return NULL;
}
int bmip_unex_handler(ptl_event_t * ev)
{
int ret = ev->type;
//fprintf(stderr, "%s: event type %s, nid %i, pid %i, match_bits %llx, rlength %i, mlength %i, offset %i hdr data = %llu\n", __func__, bmip_ptl_ev_type(ev), ev->initiator.nid, ev->initiator.pid, ev->match_bits, ev->rlength, ev->mlength, ev->offset, ev->hdr_data);
switch(ev->type)
{
case PTL_EVENT_SEND_START:
break;
case PTL_EVENT_SEND_END:
break;
case PTL_EVENT_PUT_START:
break;
case PTL_EVENT_PUT_END:
break;
case PTL_EVENT_ACK:
break;
case PTL_EVENT_GET_START:
break;
case PTL_EVENT_GET_END:
break;
case PTL_EVENT_REPLY_START:
break;
case PTL_EVENT_REPLY_END:
break;
case PTL_EVENT_UNLINK:
break;
default:
ret = -1;
break;
};
out:
return ret;
}
int bmip_wait_event(int timeout, ptl_handle_eq_t * eq, ptl_event_t * ev)
{
int ret = -1;
int i = 0;
const int numhandles = 1;
ptl_event_t sev;
ptl_event_t * lev;
/* detect if we want a copy of the event data or not */
if(ev == NULL)
{
lev = &sev;
}
else
{
lev = ev;
}
/* wait for an unexpected message */
#ifndef BMIP_USE_TIMEOUT
ret = bmip_ptl_eq_wait(*eq, lev);
#else
ret = bmip_ptl_eq_poll(eq, numhandles, timeout, lev, &i);
#endif
if(ret != PTL_EQ_EMPTY)
{
if(ret != PTL_OK)
{
fprintf(stderr, "eq wait failure\n");
ret = -1;
goto out;
}
else
{
ret = bmip_unex_handler(lev);
if(ret == -1)
{
ret = -1;
fprintf(stderr, "ev handler failure\n");
goto out;
}
}
}
else
{
ret = -2;
}
out:
return ret;
}
unsigned int bmip_get_addr_seq(ptl_process_id_t pid)
{
int found = 0;
......
......@@ -83,6 +83,8 @@ typedef struct bmip_portals_conn_op
} bmip_portals_conn_op_t;
int bmip_wait_event(int timeout, ptl_handle_eq_t * eq, ptl_event_t * ev);
/* connection setup and shutdown */
int bmip_init(int pid);
int bmip_finalize(void);
......
#include "portals_fc.h"
#include <stdlib.h>
#define _GNU_SOURCE
#include <search.h>
static int * bmip_fc_credits = NULL;
static int bmip_fc_num_slots_used = 0; /* we only inc this... we assume we don't lose connections */
static const ptl_pt_index_t local_ptl_index = 37;
static void * bmip_fc_conn_tree = NULL;
bmip_fc_node_t * bmip_fc_alloc_node()
{
return (bmip_fc_node_t *)malloc(sizeof(bmip_fc_node_t));
}
void bmip_fc_free_node(void * node)
{
free(node);
}
int bmip_fc_node_comp(const void * a, const void * b)
{
bmip_fc_node_t * a_node = (bmip_fc_node_t *)a;
bmip_fc_node_t * b_node = (bmip_fc_node_t *)b;
if(a_node->key < b_node->key)
{
return -1;
}
else if(a_node->key > b_node->key)
{
return 1;
}
return 0;
}
int bmip_fc_node_ins(bmip_fc_node_t * node)
{
tsearch(node, &bmip_fc_conn_tree, bmip_fc_node_comp);
}
bmip_fc_node_t * bmip_fc_node_find(int64_t key)
{
bmip_fc_node_t node;
node.key = key;
return tfind(&node, &bmip_fc_conn_tree, bmip_fc_node_comp);
}
bmip_fc_node_t * bmip_fc_node_del(int64_t key)
{
bmip_fc_node_t node;
node.key = key;
return (bmip_fc_node_t *)tdelete(&node, &bmip_fc_conn_tree, bmip_fc_node_comp);
}
int64_t bmip_fc_hash(int32_t pid, int32_t nid)
{
int64_t key = 0;
key |= nid;
key = (key << 32) | pid;
key = (~key) + (key << 21);
key = key ^ (key >> 24);
key = (key + (key << 3)) + (key << 8);
key = key ^ (key >> 14);
key = (key + (key << 2)) + (key << 4);
key = key ^ (key >> 28);
key = key + (key << 31);
return key;
}
int bmip_fc_init()
{
int i = 0;
bmip_fc_credits = (int *)malloc(sizeof(int) * BMIP_MAX_NUM_CLIENTS);
/* setup the credit ds */
for(i = 0 ; i < BMIP_MAX_NUM_CLIENTS ; i++)
{
bmip_fc_credits[i] = 1;
}
return 0;
}
int bmip_fc_destroy()
{
/* cleanup the credit ds */
free(bmip_fc_credits);
bmip_fc_credits = NULL;
return 0;
}
int bmip_fc_resv(int id)
{
/* allocate space */
bmip_fc_credits[id] = 0;
}
int bmip_fc_release(int id)
{
/* release the space */
bmip_fc_credits[id] = 1;
}
int bmip_fc_check(int id)
{
return bmip_fc_credits[id];
}
int bmip_fc_resv_slot(int32_t nid, int32_t pid)
{
int64_t key = bmip_fc_hash(nid, pid);
bmip_fc_node_t * node = bmip_fc_alloc_node();
/* init the node */
node->nid = nid;
node->pid = pid;
node->key = key;
node->slot = (bmip_fc_num_slots_used++);
/* insert the node into the tree */
bmip_fc_node_ins(node);
}
bmip_fc_node_t * bmip_fc_find_slot(int32_t nid, int32_t pid)
{
int64_t key = bmip_fc_hash(nid, pid);
return bmip_fc_node_find(key);
}
int bmip_fc_tree_destroy()
{
int ret = 0;
tdestroy(&bmip_fc_conn_tree, bmip_fc_free_node);
return ret;
}
int bmip_fc_setup_pp_me(bmip_fc_node_t * node)
{
int ret = 0;
ret = bmip_ptl_me_attach(node->ni_handle, local_ptl_index, node->ptl_pid, node->mb, node->ib, PTL_RETAIN, PTL_INS_AFTER, &node->me_handle);
if(ret != PTL_OK)
{
goto out;
}
out:
return ret;
}
int bmip_fc_setup_pp_md(bmip_fc_node_t * node)
{
int ret = 0;
/* setup the md */
node->md.start = node->data;
node->md.length = node->length;
node->md.threshold = PTL_MD_THRESH_INF;
node->md.options = PTL_MD_OP_PUT | PTL_MD_OP_GET;
node->md.user_ptr = NULL;
node->md.eq_handle = node->eq_handle;
/* attach the md */
ret = bmip_ptl_md_attach(node->me_handle, node->md, PTL_RETAIN, &node->md_handle);
if(ret != PTL_OK)
{
goto out;
}
out:
return ret;
}
#ifndef PORTALS_FC_H
#define PORTALS_FC_H
#define BMIP_MAX_NUM_CLIENTS 768 /* 768 clients (192 XT4 nodes or 64 XT5 nodes) */
#define BMIP_SLOT_MAX_SIZE (2<<10)
#define BMIP_SLOT_MASK (BMIP_SLOT_MAX_SIZE - 1)
#include <stdint.h>
/* portals includes */
#include <portals/portals3.h>
#include <sys/utsname.h>
/* connection node */
typedef struct bmip_fc_node
{
/* id info */
int64_t key;
int32_t nid;
int64_t pid;
ptl_pid_t ptl_pid;
/* large data attrs */
int16_t slot;
void * data;
ptl_size_t length;
ptl_handle_eq_t * eq_handle;
ptl_md_t md;
/* portals handles */
int8_t valid;
ptl_handle_md_t md_handle;
ptl_handle_me_t me_handle;
ptl_handle_ni_t ni_handle;
/* match bits */
ptl_match_bits_t mb;
ptl_match_bits_t ib;
} bmip_fc_node_t;
/* fc mgmt funcs */
int bmip_fc_init();
int bmip_fc_destroy();
int bmip_fc_resv(int id);
int bmip_fc_release(int id);
int bmip_fc_check(int id);
int bmip_fc_resv_slot(int32_t nid, int32_t pid);
bmip_fc_node_t * bmip_fc_find_slot(int32_t nid, int32_t pid);
/* node mgmt funcs */
bmip_fc_node_t * bmip_fc_alloc_node();
void bmip_fc_free_node(void * node);
/* low level tree mgmt funcs */
int bmip_fc_node_comp(const void * a, const void * b);
int bmip_fc_node_ins(bmip_fc_node_t * node);
bmip_fc_node_t * bmip_fc_node_find(int64_t key);
bmip_fc_node_t * bmip_fc_node_del(int64_t key);
int64_t bmip_fc_hash(int32_t pid, int32_t nid);
int bmip_fc_tree_destroy();
int bmip_fc_setup_pp_me(bmip_fc_node_t * node);
int bmip_fc_setup_pp_md(bmip_fc_node_t * node);
#endif
#include "portals_conn.h"
#include "portals_comm.h"
#include "portals_helpers.h"
#include <stdio.h>
#include <pthread.h>
......
#include "portals_conn.h"
#include "portals_comm.h"
#include "portals_helpers.h"
#include "portals.h"
#include <stdio.h>
......
#include "portals_conn.h"
#include "portals_comm.h"
#include "portals_helpers.h"
#include <stdio.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment