PULSAR  1.0.0
Parallel Ultra Light Systolic Array Runtime
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
prt_request.c
Go to the documentation of this file.
1 
11 #include "prt_request.h"
12 
14 
26  prt_packet_t *packet, int count,
27  MPI_Datatype datatype, int peer, int tag)
28 {
29  prt_request_t *request = (prt_request_t*)malloc(sizeof(prt_request_t));
30  prt_assert(request != NULL, "malloc failed");
31  request->packet = packet;
32  request->count = count;
33  request->datatype = datatype;
34  request->peer = peer;
35  request->tag = tag;
36  return request;
37 }
38 
40 
49 {
50  // Free the request.
51  free(request);
52 }
53 
55 
62 {
63  int retval;
64  int type_size;
65  long request_size;
66 
67  // Compute type size. Check for overflow.
68  MPI_Type_size(request->datatype, &type_size);
69  request_size = (long)request->count*type_size;
70  prt_assert(request_size <= INT_MAX, "request size overflow");
71 
72  // Post and trace the request. Check the status.
73  svg_trace_start(0);
74  retval = MPI_Isend(
75  request->packet->data,
76  request->count*type_size,
77  MPI_BYTE,
78  request->peer,
79  request->tag,
80  MPI_COMM_WORLD,
81  &request->request);
83  prt_assert(retval == MPI_SUCCESS, "error in MPI_Isend");
84 }
85 
87 
94 {
95  int retval;
96  int type_size;
97  long request_size;
98 
99  // Compute type size. Check for overflow.
100  MPI_Type_size(request->datatype, &type_size);
101  request_size = (long)request->count*type_size;
102  prt_assert(request_size <= INT_MAX, "request size overflow");
103 
104  // Post and trace the request. Check the status.
105  svg_trace_start(0);
106  retval = MPI_Irecv(
107  request->packet->data,
108  request->count*type_size,
109  MPI_BYTE,
110  request->peer,
111  request->tag,
112  MPI_COMM_WORLD,
113  &request->request);
115  prt_assert(retval == MPI_SUCCESS, "error in MPI_Isend");
116 }
117 
119 
129 {
130  int flag;
131  int retval;
132 
133  // Test the request.
134  // Check the status.
135  // Trace if completed.
136  svg_trace_start(0);
137  retval = MPI_Test(&request->request, &flag, &request->status);
138  if (flag == 1)
140  prt_assert(retval == MPI_SUCCESS, "error in MPI_Test");
141  return flag;
142 }
143 
145 
152 {
153  int retval;
154  // Cancel the request.
155  retval = MPI_Cancel(&request->request);
156  prt_assert(retval == MPI_SUCCESS, "error in MPI_Cancel");
157 
158  // Release the packet.
159  prt_packet_release(request->packet);
160 
161  // Free the request.
162  free(request);
163 }
void prt_packet_release(prt_packet_t *packet)
Release a packet. Decrements the number of active references. Destroys the packet when the last refer...
Definition: prt_packet.c:44
MPI_Datatype datatype
Definition: prt_request.h:30
MPI_Status status
Definition: prt_request.h:34
void prt_request_send(prt_request_t *request)
Post a send request. Detects a possible overflow of the request size.
Definition: prt_request.c:61
MPI_Request request
Definition: prt_request.h:33
void prt_request_cancel(prt_request_t *request)
Cancel a request. Cancel the request, release the packet, free the request object.
Definition: prt_request.c:151
VDP&#39;s data packet A packet of data transferred through VDP&#39;s channels.
Definition: prt_packet.h:24
prt_request_t * prt_request_new(prt_packet_t *packet, int count, MPI_Datatype datatype, int peer, int tag)
request constructor
Definition: prt_request.c:25
void * data
Definition: prt_packet.h:25
void svg_trace_start(int thread_rank)
Start tracing an event.
Definition: svg_trace.c:50
int prt_request_test(prt_request_t *request)
Test a request. Trace only completed requests.
Definition: prt_request.c:128
PRT communication request.
struct prt_packet_s * packet
Definition: prt_request.h:28
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
void prt_request_destroy(prt_request_t *request)
request destructor Request is only an envelope for a packet. Request destruction does not affect the ...
Definition: prt_request.c:48
void svg_trace_stop(int thread_rank, int color)
Stop tracing an event.
Definition: svg_trace.c:63
void prt_request_recv(prt_request_t *request)
Post a receive request. Detects a possible overflow of the request size.
Definition: prt_request.c:93
VSA proxy&#39;s communication request Contains basic information about the communication request...
Definition: prt_request.h:27