Commit bc11da33 authored by William Gropp's avatar William Gropp
Browse files

[svn-r3032] More fixes for the debugger interface

parent dca33f8b
......@@ -48,11 +48,20 @@ enum { TYPE_UNKNOWN = 0,
TYPE_MPIR_SENDQ = 6,
} KnownTypes;
static int curType = TYPE_UNKNOWN;
/* The dll_mpich2.c has a few places where it doesn't always use the most
recent type, so a static current type will not work. Instead, we
have an example of each type, and return that value. */
static int knownTypesArray[] = { TYPE_UNKNOWN, TYPE_MPID_COMM,
TYPE_MPIR_COMM_LIST, TYPE_MPIDI_REQUEST,
TYPE_MPIDI_MESSAGE_MATCH, TYPE_MPID_REQUEST,
TYPE_MPIR_SENDQ };
mqs_type * dbgrI_find_type(mqs_image *image, char *name,
mqs_lang_code lang)
{
int curType = TYPE_UNKNOWN;
if (strcmp(name,"MPID_Comm") == 0) {
curType = TYPE_MPID_COMM;
}
......@@ -74,11 +83,17 @@ mqs_type * dbgrI_find_type(mqs_image *image, char *name,
else {
curType = TYPE_UNKNOWN;
}
return (mqs_type *)&curType;
return (mqs_type *)&knownTypesArray[curType];
}
int dbgrI_field_offset(mqs_type *type, char *name)
{
int off = -1;
int curType = *(int*)type;
/* printf ( "curtype is %d\n", curType ); */
switch (curType) {
case TYPE_MPID_COMM:
{
......@@ -98,6 +113,12 @@ int dbgrI_field_offset(mqs_type *type, char *name)
else if (strcmp( name, "context_id" ) == 0) {
off = ((char*)&c.context_id - (char*)&c.handle);
}
else if (strcmp( name, "recvcontext_id" ) == 0) {
off = ((char*)&c.recvcontext_id - (char*)&c.handle);
}
else {
printf( "Panic! Unrecognized COMM field %s\n", name );
}
}
break;
case TYPE_MPIR_COMM_LIST:
......@@ -109,6 +130,9 @@ int dbgrI_field_offset(mqs_type *type, char *name)
else if (strcmp( name, "head" ) == 0) {
off = ((char*)&c.head - (char*)&c);
}
else {
printf( "Panic! Unrecognized Comm List field %s\n", name );
}
}
break;
case TYPE_MPIDI_REQUEST:
......@@ -120,7 +144,11 @@ int dbgrI_field_offset(mqs_type *type, char *name)
else if (strcmp( name, "match" ) == 0) {
off = ((char *)&c.match - (char *)&c);
}
else {
printf( "Panic! Unrecognized mpidi request field %s\n", name );
}
}
break;
case TYPE_MPIDI_MESSAGE_MATCH:
{
MPIDI_Message_match c;
......@@ -133,6 +161,9 @@ int dbgrI_field_offset(mqs_type *type, char *name)
else if (strcmp( name, "context_id" ) == 0) {
off = ((char *)&c.context_id - (char *)&c);
}
else {
printf( "Panic! Unrecognized message match field %s\n", name );
}
}
break;
case TYPE_MPID_REQUEST:
......@@ -147,6 +178,12 @@ int dbgrI_field_offset(mqs_type *type, char *name)
else if (strcmp( name, "cc" ) == 0) {
off = ((char *)&c.cc - (char *)&c);
}
/* else if (strcmp( name, "next" ) == 0) {
off = ((char *)&c.next - (char *)&c);
} */
else {
printf( "Panic! Unrecognized request field %s\n", name );
}
}
break;
case TYPE_MPIR_SENDQ:
......@@ -164,6 +201,9 @@ int dbgrI_field_offset(mqs_type *type, char *name)
else if (strcmp( name, "context_id" ) == 0) {
off = ((char *)&c.context_id - (char *)&c);
}
else {
printf( "Panic! Unrecognized Sendq field %s\n", name );
}
}
break;
case TYPE_UNKNOWN:
......@@ -185,6 +225,8 @@ int dbgrI_find_symbol( mqs_image *image, char *name, mqs_taddr_t * loc )
}
else if (strcmp( name, "MPID_Recvq_posted_head_ptr" ) == 0) {
*loc = (mqs_taddr_t)&MPID_Recvq_posted_head_ptr;
printf( "Address of ptr to posted head ptr = %p\n", &MPID_Recvq_posted_head_ptr );
printf( "Address of posted head ptr = %p\n", MPID_Recvq_posted_head_ptr );
return mqs_ok;
}
else if (strcmp( name, "MPID_Recvq_unexpected_head_ptr" ) == 0) {
......@@ -195,5 +237,8 @@ int dbgrI_find_symbol( mqs_image *image, char *name, mqs_taddr_t * loc )
*loc = (mqs_taddr_t)&MPIR_Sendq_head;
return mqs_ok;
}
else {
printf( "Panic! Unrecognized symbol %s\n", name );
}
return 1;
}
......@@ -11,6 +11,11 @@
#include <string.h>
#include "mpi.h"
/* Define this to have the code print out details of its list traversal
action. This is primarily for use with dbgstub.c and the test programs
such as tvtest.c */
/* #define DEBUG_LIST_ITER */
/* MPIR_dll_name is defined in dbg_init.c; it must be part of the target image,
not the debugger interface */
......@@ -50,6 +55,18 @@ enum {
};
/* Internal structure we hold for each communicator */
typedef struct communicator_t
{
struct communicator_t * next;
group_t * group; /* Translations */
int context_id; /* To catch changes */
int recvcontext_id; /* May also be needed for
matchine */
int present;
mqs_communicator comm_info; /* Info needed at the higher level */
} communicator_t;
/* Internal functions used only by routines in this package */
static void mqs_free_communicator_list( struct communicator_t *comm );
......@@ -57,6 +74,14 @@ static int communicators_changed (mqs_process *proc);
static int rebuild_communicator_list (mqs_process *proc);
static int compare_comms (const void *a, const void *b);
static group_t * find_or_create_group (mqs_process *proc,
mqs_tword_t np,
mqs_taddr_t table);
static int translate (group_t *this, int idx);
static int reverse_translate (group_t * this, int idx);
static void group_decref (group_t * group);
static communicator_t * find_communicator (mpich_process_info *p_info,
mqs_taddr_t comm_base, int recv_ctx);
/* ------------------------------------------------------------------------ */
/*
......@@ -414,19 +439,6 @@ char * mqs_dll_error_string (int errcode)
* routines make an internal copy of the communicator list.
*
*/
/* Internal structure we hold for each communicator */
typedef struct communicator_t
{
struct communicator_t * next;
group_t * group; /* Translations */
int context_id; /* To catch changes */
int recvcontext_id; /* May also be needed for
matchine */
int present;
mqs_communicator comm_info; /* Info needed at the higher level */
} communicator_t;
/* update_communicator_list makes a copy of the list of currently active
* communicators and stores it in the mqs_process structure.
*/
......@@ -502,6 +514,8 @@ int mqs_setup_operation_iterator (mqs_process *proc, int op)
return mqs_ok;
}
/* The address on the receive queues is the address of a pointer to
the head of the list. */
case mqs_pending_receives:
p_info->next_msg = p_info->posted_base;
return mqs_ok;
......@@ -574,10 +588,17 @@ static int fetch_receive (mqs_process *proc, mpich_process_info *p_info,
int16_t wanted_context = comm->recvcontext_id;
mqs_taddr_t base = fetch_pointer (proc, p_info->next_msg, p_info);
#ifdef DEBUG_LIST_ITER
printf( "fetch receive base = %x, comm= %x, context = %d\n",
base, comm, wanted_context );
#endif
while (base != 0) {
/* Check this entry to see if the context matches */
int16_t actual_context = fetch_int16( proc, base + i_info->req_context_id_offs, p_info );
#ifdef DEBUG_LIST_ITER
printf( "fetch receive msg context = %d\n", actual_context );
#endif
if (actual_context == wanted_context) {
/* Found a request for this communicator */
int tag = fetch_int( proc, base + i_info->req_tag_offs, p_info );
......@@ -615,7 +636,7 @@ static int fetch_receive (mqs_process *proc, mpich_process_info *p_info,
#if 0
while (base != 0)
{ /* Well, there's a queue, at least ! */
mqs_tword_t actual_context = fetch_int (proc, base + i_info->context_id_offs, p_info);
mqs_tword_t actual_context = fetch_int16(proc, base + i_info->context_id_offs, p_info);
if (actual_context == wanted_context)
{ /* Found a good one */
......@@ -626,7 +647,7 @@ static int fetch_receive (mqs_process *proc, mpich_process_info *p_info,
mqs_taddr_t ptr = fetch_pointer (proc, base + i_info->ptr_offs, p_info);
/* Fetch the fields from the MPIR_RHANDLE */
int is_complete = fetch_int (proc, ptr + i_info->is_complete_offs, p_info);
int is_complete = fetch_int (proc, ptr + i_info->is_complete_offs, p_info);
mqs_taddr_t buf = fetch_pointer (proc, ptr + i_info->buf_offs, p_info);
mqs_tword_t len = fetch_int (proc, ptr + i_info->len_offs, p_info);
mqs_tword_t count = fetch_int (proc, ptr + i_info->count_offs, p_info);
......@@ -716,6 +737,11 @@ static int fetch_send (mqs_process *proc, mpich_process_info *p_info,
if (!p_info->has_sendq)
return mqs_no_information;
#ifdef DEBUG_LIST_ITER
if (base) {
printf( "comm ptr = %p, comm context = %d\n", comm, comm->context_id );
}
#endif
/* Say what operation it is. We can only see non blocking send operations
* in MPICH. Other MPI systems may be able to show more here.
*/
......@@ -725,10 +751,32 @@ static int fetch_send (mqs_process *proc, mpich_process_info *p_info,
while (base != 0) {
/* Check this entry to see if the context matches */
int actual_context = fetch_int( proc, base + i_info->sendq_context_id_offs, p_info );
int actual_context = fetch_int16( proc, base + i_info->sendq_context_id_offs, p_info );
if (actual_context == wanted_context) {
/* Fill in some of the fields */
mqs_tword_t target = fetch_int (proc, base+i_info->sendq_rank_offs, p_info);
mqs_tword_t tag = fetch_int (proc, base+i_info->sendq_tag_offs, p_info);
mqs_tword_t length = 0;
mqs_taddr_t data = 0;
mqs_taddr_t shandle= 0;
mqs_tword_t complete=0;
#ifdef DEBUG_LIST_ITER
printf( "sendq entry = %p, rank off = %d, tag off = %d, context = %d\n",
base, i_info->sendq_rank_offs, i_info->sendq_tag_offs, actual_context );
#endif
/* Ok, fill in the results */
res->status = -1; /* complete ? mqs_st_complete : mqs_st_pending; *//* We can't discern matched */
res->actual_local_rank = res->desired_local_rank = target;
res->actual_global_rank= res->desired_global_rank= translate (comm->group, target);
res->tag_wild = 0;
res->actual_tag = res->desired_tag = tag;
res->desired_length = res->actual_length = length;
res->system_buffer = 0;
res->buffer = data;
/* Don't forget to step the queue ! */
p_info->next_msg = base + i_info->sendq_next_offs;
......@@ -779,16 +827,6 @@ static int fetch_send (mqs_process *proc, mpich_process_info *p_info,
/* ------------------------------------------------------------------------ */
/* Communicator */
static communicator_t * find_communicator (mpich_process_info *p_info,
mqs_taddr_t comm_base, int recv_ctx);
static group_t * find_or_create_group (mqs_process *proc,
mqs_tword_t np,
mqs_taddr_t table);
static int translate (group_t *this, int idx);
static int reverse_translate (group_t * this, int idx);
static void group_decref (group_t * group);
static int communicators_changed (mqs_process *proc)
{
mpich_process_info *p_info =
......@@ -813,8 +851,8 @@ static int communicators_changed (mqs_process *proc)
* being re-allocated from a free list, in which case the same
* address will be re-used a lot, which could confuse us.
*/
static communicator_t * find_communicator (mpich_process_info *p_info,
mqs_taddr_t comm_base, int recv_ctx)
static communicator_t * find_communicator ( mpich_process_info *p_info,
mqs_taddr_t comm_base, int recv_ctx)
{
communicator_t * comm = p_info->communicator_list;
......@@ -858,7 +896,8 @@ static int rebuild_communicator_list (mqs_process *proc)
*/
while (comm_base) {
/* We do have one to look at, so extract the info */
int recv_ctx = fetch_int (proc, comm_base+i_info->comm_recvcontext_id_offs, p_info);
int recv_ctx = fetch_int16 (proc, comm_base+i_info->comm_recvcontext_id_offs, p_info);
int send_ctx = fetch_int16 (proc, comm_base+i_info->comm_context_id_offs, p_info);
communicator_t *old = find_communicator (p_info, comm_base, recv_ctx);
char *name = "--unnamed--";
......@@ -871,7 +910,7 @@ static int rebuild_communicator_list (mqs_process *proc)
if (old) {
old->present = 1; /* We do want this communicator */
strncpy (old->comm_info.name, name, 64); /* Make sure the name is up to date,
strncpy (old->comm_info.name, name, sizeof(old->comm_info.name) ); /* Make sure the name is up to date,
* it might have changed and we can't tell.
*/
}
......@@ -892,14 +931,19 @@ static int rebuild_communicator_list (mqs_process *proc)
/* Save the results */
nc->next = p_info->communicator_list;
p_info->communicator_list = nc;
nc->present = 1;
nc->group = g;
nc->context_id = recv_ctx;
nc->present = 1;
nc->group = g;
nc->context_id = send_ctx;
nc->recvcontext_id = recv_ctx;
strncpy (nc->comm_info.name, name, 64);
strncpy (nc->comm_info.name, name, sizeof( nc->comm_info.name ) );
nc->comm_info.unique_id = comm_base;
nc->comm_info.size = np;
nc->comm_info.local_rank = fetch_int (proc, comm_base+i_info->comm_rank_offs,p_info);
#ifdef DEBUG_LIST_ITER
printf( "Adding communicator %p, send context=%d, recv context=%d, size=%d, name=%s\n",
comm_base, send_ctx, recv_ctx, np, name );
#endif
#if 0
nc->comm_info.local_rank= reverse_translate (g, dbgr_get_global_rank (proc));
#endif
......
......@@ -100,7 +100,7 @@
#ifndef _MPI_INTERFACE_INCLUDED
#define _MPI_INTERFACE_INCLUDED
#include <stdio.h> /* For FILENAME_MAX */
#include <stdio.h> /* For FILENAME_MAX */
#ifdef __cplusplus
extern "C" {
......@@ -112,7 +112,7 @@ extern "C" {
enum
{
#if defined(FOR_MPI2)
MQS_INTERFACE_COMPATIBILITY = 3 /* Has MPI-2 functions */
MQS_INTERFACE_COMPATIBILITY = 3 /* Has MPI-2 functions */
#else
MQS_INTERFACE_COMPATIBILITY = 2
#endif
......@@ -168,11 +168,11 @@ typedef struct mqs_type_ mqs_type;
*/
#if !defined (FORCE_32BIT_MPI) && (defined (__sgi) || defined (__hpux) || defined (_AIX))
typedef unsigned long long mqs_taddr_t; /* Something long enough for a target address */
typedef long long mqs_tword_t; /* Something long enough for a word */
typedef unsigned long long mqs_taddr_t; /* Something long enough for a target address */
typedef long long mqs_tword_t; /* Something long enough for a word */
#else
typedef unsigned long mqs_taddr_t; /* Something long enough for a target address */
typedef long mqs_tword_t; /* Something long enough for a word */
typedef unsigned long mqs_taddr_t; /* Something long enough for a target address */
typedef long mqs_tword_t; /* Something long enough for a word */
#endif
/***********************************************************************
......@@ -182,11 +182,11 @@ typedef long mqs_tword_t; /* Something long enough for a word */
/* A structure for (target) architectural information */
typedef struct
{
int short_size; /* sizeof (short) */
int int_size; /* sizeof (int) */
int long_size; /* sizeof (long) */
int long_long_size; /* sizeof (long long) */
int pointer_size; /* sizeof (void *) */
int short_size; /* sizeof (short) */
int int_size; /* sizeof (int) */
int long_size; /* sizeof (long) */
int long_long_size; /* sizeof (long long) */
int pointer_size; /* sizeof (void *) */
} mqs_target_type_sizes;
/* Result codes.
......@@ -207,7 +207,7 @@ enum {
mqs_ok = 0,
mqs_no_information,
mqs_end_of_list,
mqs_first_user_code = 100 /* Allow for more pre-defines */
mqs_first_user_code = 100 /* Allow for more pre-defines */
};
#if defined(FOR_MPI2)
......@@ -251,10 +251,10 @@ enum mqs_status
/* A structure to represent a communicator */
typedef struct
{
mqs_taddr_t unique_id; /* A unique tag for the communicator */
mqs_tword_t local_rank; /* The rank of this process Comm_rank */
mqs_tword_t size; /* Comm_size */
char name[64]; /* the name if it has one */
mqs_taddr_t unique_id; /* A unique tag for the communicator */
mqs_tword_t local_rank; /* The rank of this process Comm_rank */
mqs_tword_t size; /* Comm_size */
char name[64]; /* the name if it has one */
} mqs_communicator;
/*
......@@ -265,18 +265,18 @@ typedef struct
typedef struct
{
/* Fields for all messages */
int status; /* Status of the message (really enum mqs_status) */
mqs_tword_t desired_local_rank; /* Rank of target/source -1 for ANY */
mqs_tword_t desired_global_rank; /* As above but in COMM_WORLD */
int tag_wild; /* Flag for wildcard receive */
mqs_tword_t desired_tag; /* Only if !tag_wild */
mqs_tword_t desired_length; /* Length of the message buffer */
int system_buffer; /* Is it a system or user buffer ? */
mqs_taddr_t buffer; /* Where data is */
int status; /* Status of the message (really enum mqs_status) */
mqs_tword_t desired_local_rank; /* Rank of target/source -1 for ANY */
mqs_tword_t desired_global_rank; /* As above but in COMM_WORLD */
int tag_wild; /* Flag for wildcard receive */
mqs_tword_t desired_tag; /* Only if !tag_wild */
mqs_tword_t desired_length; /* Length of the message buffer */
int system_buffer; /* Is it a system or user buffer ? */
mqs_taddr_t buffer; /* Where data is */
/* Fields valid if status >= matched or it's a send */
mqs_tword_t actual_local_rank; /* Actual local rank */
mqs_tword_t actual_global_rank; /* As above but in COMM_WORLD */
mqs_tword_t actual_local_rank; /* Actual local rank */
mqs_tword_t actual_global_rank; /* As above but in COMM_WORLD */
mqs_tword_t actual_tag;
mqs_tword_t actual_length;
......
......@@ -15,8 +15,9 @@
int main( int argc, char *argv[] )
{
int wsize, wrank;
int source, dest;
int source, dest, i;
int buf1[10], buf2[10], buf3[10];
MPI_Request r[3];
volatile int hold = 1;
MPI_Comm dupcomm;
MPI_Status status;
......@@ -33,6 +34,11 @@ int main( int argc, char *argv[] )
MPI_Comm_dup( MPI_COMM_WORLD, &dupcomm );
MPI_Comm_set_name( dupcomm, "Dup of comm world" );
for (i=0; i<3; i++) {
MPI_Irecv( MPI_BOTTOM, 0, MPI_INT, source, i + 100, MPI_COMM_WORLD,
&r[i] );
}
MPI_Send( buf2, 8, MPI_INT, dest, 1, MPI_COMM_WORLD );
MPI_Send( buf3, 4, MPI_INT, dest, 2, dupcomm );
......@@ -41,6 +47,10 @@ int main( int argc, char *argv[] )
MPI_Recv( buf1, 10, MPI_INT, source, 1, MPI_COMM_WORLD, &status );
MPI_Recv( buf1, 10, MPI_INT, source, 1, dupcomm, &status );
for (i=0; i<3; i++) {
MPI_Cancel( &r[i] );
}
MPI_Comm_free( &dupcomm );
......
......@@ -42,6 +42,7 @@ int main( int argc, char *argv[] )
/* Create some pending receives and unexpected messages */
MPI_Comm_dup( MPI_COMM_WORLD, &dupworld );
MPI_Comm_set_name( dupworld, "Dup of comm world" );
MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
MPI_Comm_size( MPI_COMM_WORLD, &wsize );
MPI_Irecv( &buf, 1, MPI_INT, (wrank + 1) % wsize, 17, dupworld, &rreq );
......@@ -52,7 +53,11 @@ int main( int argc, char *argv[] )
/* MPI_Send( &ssbuf, 1, MPI_INT, (wrank + 2) %wsize, 18, dupworld );*/
/* Access the queues */
printf( "Should see pending recv with tag 17, 19 on dupworld and send with tag 18 on world\n" );
showQueues();
MPI_Barrier( MPI_COMM_WORLD );
/* Match up some of the messages */
MPI_Send( &sbuf, 1, MPI_INT, (wrank + wsize - 1) % wsize, 17, dupworld );
MPI_Recv( &rbuf, 1, MPI_INT, (wrank + 1) % wsize, 18, MPI_COMM_WORLD,
MPI_STATUS_IGNORE );
......@@ -61,8 +66,10 @@ int main( int argc, char *argv[] )
/* Access the queues again */
printf( "\nAfter a few send/receives\n" );
printf( "Should see recv with tag 19 on dupworld\n" );
showQueues();
MPI_Barrier( MPI_COMM_WORLD );
MPI_Send( &sbuf, 1, MPI_INT, (wrank + wsize - 1) % wsize, 19, dupworld );
/* Access the queues again */
......
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