PULSAR  0.1
Parallel Unified Linear Algebra with Systolic Arrays
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
prt_channel.c File Reference

PRT data channel implementation. More...

#include "prt_channel.h"
Include dependency graph for prt_channel.c:

Go to the source code of this file.

Functions

prt_channel_tprt_channel_new (int count, MPI_Datatype datatype, int *src_tuple, int src_slot, int *dst_tuple, int dst_slot)
 channel constructor More...
 
void prt_channel_delete (prt_channel_t *channel)
 channel destructor More...
 
void prt_channel_push (prt_channel_t *channel, prt_packet_t *packet)
 Sends a packed down a channel. Increments the packet's number of active references. More...
 
prt_packet_tprt_channel_pop (prt_channel_t *channel)
 Fetches a packef from a channel. Does not decrement the number of active references. The packet leaves the channel, but enters the VDP. More...
 
int prt_channel_empty (prt_channel_t *channel)
 Checks if a channel is empty. More...
 
int prt_channel_compare (void *channel1, void *channel2)
 Compare two channels. Channels are equal if they have the same source and destination tuples and slots. More...
 

Detailed Description

PRT data channel implementation.

Author
Jakub Kurzak

PULSAR Runtime /pulsar/ Copyright (C) 2012-2013 University of Tennessee.

Definition in file prt_channel.c.

Function Documentation

int prt_channel_compare ( void *  channel1,
void *  channel2 
)

Compare two channels. Channels are equal if they have the same source and destination tuples and slots.

Parameters
channel1
channel2
Return values
0Channels are equal. @
1Channels are not equal.

Definition at line 171 of file prt_channel.c.

References prt_channel_s::dst_slot, prt_channel_s::dst_tuple, prt_tuple_compare(), prt_channel_s::src_slot, and prt_channel_s::src_tuple.

172 {
173  prt_channel_t *c1 = (prt_channel_t*)channel1;
174  prt_channel_t *c2 = (prt_channel_t*)channel2;
175  if (prt_tuple_compare(c1->src_tuple, c2->src_tuple) != 0) return 1;
176  if (prt_tuple_compare(c1->dst_tuple, c2->dst_tuple) != 0) return 1;
177  if (c1->src_slot != c2->src_slot) return 1;
178  if (c1->dst_slot != c2->dst_slot) return 1;
179  return 0;
180 }
int prt_tuple_compare(void *tuple_a, void *tuple_b)
tuple comparison
Definition: prt_tuple.c:135
int * dst_tuple
Definition: prt_channel.h:35
int * src_tuple
Definition: prt_channel.h:33
VDP's data channel Implements a data link between a pair of VDPs. Identifies the source and destinati...
Definition: prt_channel.h:29

Here is the call graph for this function:

Here is the caller graph for this function:

void prt_channel_delete ( prt_channel_t channel)

channel destructor

Parameters
channel

Definition at line 63 of file prt_channel.c.

References prt_channel_s::dst_tuple, icl_deque_destroy(), icl_deque_size(), prt_channel_s::packets, prt_assert, and prt_channel_s::src_tuple.

64 {
65  // Check for a NULL channel.
66  prt_assert(channel != NULL, "NULL channel");
67 
68  // Free the source tuple.
69  prt_assert(channel->src_tuple != NULL, "NULL tuple");
70  free(channel->src_tuple);
71 
72  // Free the destination tuple.
73  prt_assert(channel->dst_tuple != NULL, "NULL tuple");
74  free(channel->dst_tuple);
75 
76  // Destroy the list of packets.
77  // Only an empty list can be destroyed.
78  // Therefore NULL given as the packet destructor.
79  prt_assert(channel->packets != NULL, "NULL packets list");
80  int size = icl_deque_size(channel->packets);
81  prt_assert(size == 0, "non-epty packet list");
82  icl_deque_destroy(channel->packets, NULL);
83 //printf("delete\n"); fflush(stdout);
84  // Free the channel.
85  free(channel);
86 }
icl_deque_t * packets
Definition: prt_channel.h:38
int icl_deque_size(icl_deque_t *deque)
Return the deque size.
Definition: icl_deque.c:189
int * dst_tuple
Definition: prt_channel.h:35
int * src_tuple
Definition: prt_channel.h:33
int icl_deque_destroy(icl_deque_t *deque, void(*free_func)(void *))
deque destructor
Definition: icl_deque.c:53
#define prt_assert(cond, msg)
Definition: prt_assert.h:30

Here is the call graph for this function:

Here is the caller graph for this function:

int prt_channel_empty ( prt_channel_t channel)

Checks if a channel is empty.

Parameters
channel
Return values
0Channel is not empty. @
1Channel is empty.

Definition at line 150 of file prt_channel.c.

References icl_deque_first(), prt_channel_s::packets, and prt_assert.

151 {
152  // Check for a NULL input params.
153  prt_assert(channel != NULL, "NULL channel");
154  prt_assert(channel->packets != NULL, "NULL packet list");
155 
156  // Return the status.
157  return (icl_deque_first(channel->packets) == NULL);
158 }
icl_deque_t * packets
Definition: prt_channel.h:38
icl_node_t * icl_deque_first(icl_deque_t *deque)
Get the first node in the deque.
Definition: icl_deque.c:76
#define prt_assert(cond, msg)
Definition: prt_assert.h:30

Here is the call graph for this function:

Here is the caller graph for this function:

prt_channel_t* prt_channel_new ( int  count,
MPI_Datatype  datatype,
int *  src_tuple,
int  src_slot,
int *  dst_tuple,
int  dst_slot 
)

channel constructor

Parameters
countnumber of data elements in a packet
datatypeMPI data type of elements in a packet
src_tupletuple of the source VDP
src_slotslot number in the source VDP
dst_tupletuple of the destination VDP
dst_slotslot number in the destination VDP
Returns
new channel

Definition at line 26 of file prt_channel.c.

References prt_channel_s::count, prt_channel_s::datatype, prt_channel_s::dst_slot, prt_channel_s::dst_tuple, icl_deque_new(), prt_channel_s::packets, prt_assert, prt_channel_s::src_slot, prt_channel_s::src_tuple, and prt_channel_s::vdp.

30 {
31  // Allocate the channel.
32  prt_channel_t *channel = (prt_channel_t*)malloc(sizeof(prt_channel_t));
33  prt_assert(channel != NULL, "malloc failed");
34 
35  // Check parameters.
36  prt_assert(count > 0, "count less or equal zero");
37  prt_assert(src_tuple != NULL, "NULL source tuple");
38  prt_assert(src_tuple != NULL, "NULL destination tuple");
39 
40  // Initialize the channel.
41  channel->vdp = NULL;
42  channel->count = count;
43  channel->datatype = datatype;
44  channel->src_tuple = src_tuple;
45  channel->dst_tuple = dst_tuple;
46  channel->src_slot = src_slot;
47  channel->dst_slot = dst_slot;
48 
49  // Create the list of packets.
50  channel->packets = icl_deque_new();
51  prt_assert(channel->packets != NULL, "icl_deque_new() failed");
52 //printf("new\n"); fflush(stdout);
53  // Return the channel.
54  return channel;
55 }
icl_deque_t * packets
Definition: prt_channel.h:38
icl_deque_t * icl_deque_new()
deque constructor
Definition: icl_deque.c:23
MPI_Datatype datatype
Definition: prt_channel.h:32
int * dst_tuple
Definition: prt_channel.h:35
int * src_tuple
Definition: prt_channel.h:33
VDP's data channel Implements a data link between a pair of VDPs. Identifies the source and destinati...
Definition: prt_channel.h:29
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
struct prt_vdp_s * vdp
Definition: prt_channel.h:30

Here is the call graph for this function:

prt_packet_t* prt_channel_pop ( prt_channel_t channel)

Fetches a packef from a channel. Does not decrement the number of active references. The packet leaves the channel, but enters the VDP.

Parameters
channel
Returns
data packet

Definition at line 125 of file prt_channel.c.

References icl_list_s::data, icl_deque_delete(), icl_deque_first(), prt_channel_s::packets, and prt_assert.

126 {
127  // Check for a NULL input params.
128  prt_assert(channel != NULL, "popping from a NULL channel");
129  prt_assert(channel->packets != NULL, "popping from a NULL packet list");
130 
131  icl_node_t *node = icl_deque_first(channel->packets);
132  prt_assert(node != NULL, "empty packet list");
133 
134  prt_packet_t *packet = (prt_packet_t*)node->data;
135  prt_assert(packet != NULL, "NULL packet");
136 
137  icl_deque_delete(channel->packets, node, NULL);
138  return packet;
139 }
icl_deque_t * packets
Definition: prt_channel.h:38
void * data
Definition: icl_list.h:20
icl_node_t * icl_deque_first(icl_deque_t *deque)
Get the first node in the deque.
Definition: icl_deque.c:76
VDP's data packet A packet of data transferred through VDP's channels.
Definition: prt_packet.h:24
int icl_deque_delete(icl_deque_t *deque, icl_node_t *node, void(*free_func)(void *))
Delete the node from the deque.
Definition: icl_deque.c:164
#define prt_assert(cond, msg)
Definition: prt_assert.h:30

Here is the call graph for this function:

Here is the caller graph for this function:

void prt_channel_push ( prt_channel_t channel,
prt_packet_t packet 
)

Sends a packed down a channel. Increments the packet's number of active references.

Parameters
channel
packet

Definition at line 96 of file prt_channel.c.

References prt_channel_s::dst_node, icl_deque_append(), prt_vsa_s::node_rank, prt_packet_s::num_refs, prt_channel_s::packets, prt_vsa_s::proxy, prt_assert, prt_proxy_send(), prt_thread_s::rank, prt_vdp_s::thread, prt_channel_s::vdp, and prt_thread_s::vsa.

97 {
98  // Check for a NULL input params.
99  prt_assert(packet != NULL, "NULL packet");
100  prt_assert(channel != NULL, "NULL channel");
101  prt_assert(channel->packets != NULL, "NULL packet list");
102 
103  __sync_fetch_and_add(&packet->num_refs, 1);
104  icl_deque_append(channel->packets, (void*)packet);
105 
106  // IF a dangling channel.
107  if (channel->dst_node != channel->vdp->thread->vsa->node_rank)
108  // Notify the proxy.
110  channel->vdp->thread->vsa->proxy,
111  channel->vdp->thread->rank,
112  channel);
113 }
icl_node_t * icl_deque_append(icl_deque_t *deque, void *data)
Insert the node at the end of the deque.
Definition: icl_deque.c:118
icl_deque_t * packets
Definition: prt_channel.h:38
struct prt_vsa_s * vsa
Definition: prt_thread.h:28
int node_rank
Definition: prt_vsa.h:46
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
struct prt_thread_s * thread
Definition: prt_vdp.h:38
struct prt_proxy_s * proxy
Definition: prt_vsa.h:56
struct prt_vdp_s * vdp
Definition: prt_channel.h:30
void prt_proxy_send(prt_proxy_t *proxy, int thread_rank, prt_channel_t *channel)
send from a channel
Definition: prt_proxy.c:122

Here is the call graph for this function:

Here is the caller graph for this function: