Skip to content

Commit

Permalink
request: add MPICH_DEBUG_REQUEST
Browse files Browse the repository at this point in the history
When MPICH_DEBUG_REQUEST is defined (config option to be added), we add
an info string to the request objects that can be used to update
readable debug informations to the request.
  • Loading branch information
hzhou committed May 15, 2021
1 parent cda1359 commit 3fc146b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/include/mpir_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "mpir_process.h"

#define MPICH_DEBUG_REQUEST 1
/*
=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
Expand Down Expand Up @@ -227,7 +228,9 @@ struct MPIR_Request {
* Value is 0 or 1. */
} part; /* kind : MPIR_REQUEST_KIND__PART_SEND or MPIR_REQUEST_KIND__PART_RECV */
} u;

#ifdef MPICH_DEBUG_REQUEST
char info[100];
#endif
/* Other, device-specific information */
#ifdef MPID_DEV_REQUEST_DECL
MPID_DEV_REQUEST_DECL
Expand Down Expand Up @@ -297,6 +300,24 @@ extern MPIR_Request MPIR_Request_direct[MPIR_REQUEST_PREALLOC];
} \
} while (0)

#ifdef MPICH_DEBUG_REQUEST
#define MPIR_REQUEST_SET_INFO(req, ...) \
do { \
MPL_snprintf((req)->info, 100, __VA_ARGS__); \
} while (0)

#define MPIR_REQUEST_DEBUG(req) \
do { \
if (MPIR_cc_get((req)->cc) > 0) { \
printf(" %x: %s\n", (req)->handle, (req)->info); \
} \
} while (0)
#else

#define MPIR_REQUEST_SET_INFO(req, info) do { } while (0)
#define MPIR_REQUEST_DEBUG(req) do { } while (0)
#endif

void MPII_init_request(void);

/* To get the benefit of multiple request pool, device layer need register their per-vci lock
Expand Down Expand Up @@ -406,6 +427,9 @@ static inline MPIR_Request *MPIR_Request_create_from_pool(MPIR_Request_kind_t ki
req->kind = kind;
MPIR_cc_set(&req->cc, 1);
req->cc_ptr = &req->cc;
#ifdef MPICH_DEBUG_REQUEST
req->info[0] = '\0';
#endif

req->completion_notification = NULL;

Expand Down Expand Up @@ -540,6 +564,9 @@ static inline void MPIR_Request_free_with_safety(MPIR_Request * req, int need_sa
}

MPID_Request_destroy_hook(req);
#ifdef MPICH_DEBUG_REQUEST
MPIR_cc_set(&req->cc, 0);
#endif

if (need_safety) {
MPID_THREAD_CS_ENTER(POBJ, MPIR_THREAD_POBJ_HANDLE_MUTEX);
Expand Down Expand Up @@ -726,4 +753,6 @@ int MPIR_Waitsome(int incount, MPI_Request array_of_requests[], MPIR_Request * r
int *outcount, int array_of_indices[], MPI_Status array_of_statuses[]);
int MPIR_Parrived(MPI_Request * request, MPIR_Request * request_ptr, int partition, int *flag);

void MPIR_Request_debug(void);

#endif /* MPIR_REQUEST_H_INCLUDED */
22 changes: 22 additions & 0 deletions src/mpi/request/mpir_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,25 @@ int MPIR_Grequest_free(MPIR_Request * request_ptr)

return mpi_errno;
}

void MPIR_Request_debug(void)
{
for (int i = 0; i < MPIR_REQUEST_NUM_POOLS; i++) {
int n_pending = MPIR_Request_mem[i].num_allocated - MPIR_Request_mem[i].num_avail;
if (n_pending > 0) {
printf("%d pending requests in pool %d\n", n_pending, i);
if (i == 0) {
MPIR_Request *pool = MPIR_Request_direct;
for (int j = 0; j < MPIR_Request_mem[0].direct_size; j++) {
MPIR_REQUEST_DEBUG(&pool[j]);
}
}
for (int k = 0; k < MPIR_Request_mem[i].indirect_size; k++) {
MPIR_Request *pool = MPIR_Request_mem[i].indirect[k];
for (int j = 0; j < REQUEST_NUM_INDICES; j++) {
MPIR_REQUEST_DEBUG(&pool[j]);
}
}
}
}
}

0 comments on commit 3fc146b

Please sign in to comment.