PULSAR  1.0.0
Parallel Ultra Light Systolic Array Runtime
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
prt_vsa.h File Reference

Virtual Systolic Array (VSA) More...

#include "prt.h"
Include dependency graph for prt_vsa.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  prt_vsa_s
 Virtual Systolic Array (VSA) VSA contains global informationa about the system, a local communication proxy and an array of local worker threads. More...
 

Macros

#define PRT_VSA_MAX_VDPS_PER_NODE   10003
 maximum VDPs per node She size of the VSA's hash table of VDPs. Should be a prime number More...
 

Typedefs

typedef int(* prt_vdp_map_func_t )(int *, void *, int)
 VSA's VDPs mapping function pointer Defines the pointer to the function mapping VDPs to cores. More...
 
typedef struct prt_vsa_s prt_vsa_t
 Virtual Systolic Array (VSA) VSA contains global informationa about the system, a local communication proxy and an array of local worker threads. More...
 

Functions

prt_vsa_tprt_vsa_new (int num_threads, void *global_store, int(*vdp_to_core)(int *, void *, int))
 VSA constructor. More...
 
void prt_vsa_delete (prt_vsa_t *vsa)
 VSA destructor. More...
 
void prt_vsa_vdp_insert (prt_vsa_t *vsa, struct prt_vdp_s *vdp)
 Inserts a new VDP into a VSA. Destroys VDPs that do not belong to this node. Puts the VDP in the list of VDPs of the owner thread. Connects corresponding input and output channels of intra-node VDPs. Builds the list of channel connections to other nodes. More...
 
void prt_vsa_vdp_merge_channels (prt_vsa_t *vsa, struct prt_vdp_s *vdp, int node_rank)
 Connects corresponding input and output channels of intra-node VDPs. More...
 
void prt_vsa_vdp_track_tags (prt_vsa_t *vsa, struct prt_vdp_s *vdp, int core, int node_rank)
 Builds the list of channel connections to other nodes. More...
 
void prt_vsa_channel_tags (prt_vsa_t *vsa)
 Assign channel tags. Build the node-tag lookup. Destroy channel lists. More...
 
void prt_vsa_run (prt_vsa_t *vsa)
 VSA's production cycle Launches worker threads. Sends the master thread in the communication proxy production cycle. Joins the worker threads. More...
 
void prt_vsa_config_set (prt_vsa_t *vsa, enum prt_config_param_e param, enum prt_config_value_e value)
 

Detailed Description

Virtual Systolic Array (VSA)

Author
Jakub Kurzak

PULSAR Runtime http://icl.eecs.utk.edu/pulsar/ Copyright (C) 2012-2013 University of Tennessee.

Definition in file prt_vsa.h.

Macro Definition Documentation

#define PRT_VSA_MAX_VDPS_PER_NODE   10003

maximum VDPs per node She size of the VSA's hash table of VDPs. Should be a prime number

Definition at line 32 of file prt_vsa.h.

Typedef Documentation

typedef int(* prt_vdp_map_func_t)(int *, void *, int)

VSA's VDPs mapping function pointer Defines the pointer to the function mapping VDPs to cores.

Definition at line 38 of file prt_vsa.h.

typedef struct prt_vsa_s prt_vsa_t

Virtual Systolic Array (VSA) VSA contains global informationa about the system, a local communication proxy and an array of local worker threads.

Function Documentation

void prt_vsa_channel_tags ( prt_vsa_t vsa)

Assign channel tags. Build the node-tag lookup. Destroy channel lists.

Parameters
vsa

Definition at line 274 of file prt_vsa.c.

References prt_vsa_s::channel_lists, icl_list_s::data, prt_channel_s::dst_node, icl_hash_insert(), icl_list_destroy(), icl_list_foreach, prt_vsa_s::node_rank, prt_vsa_s::num_nodes, prt_vsa_s::proxy, prt_assert, prt_tuple_new2, prt_channel_s::src_node, prt_channel_s::tag, and prt_proxy_s::tags_hash.

275 {
276  int i;
277  for (i = 0; i < vsa->num_nodes; i++)
278  if (vsa->channel_lists[i] != NULL) {
279  int tag = 0;
280  icl_list_t *node;
281  // Assign consecutive tags to the elements.
282  icl_list_foreach(vsa->channel_lists[i], node) {
283  prt_channel_t *channel = (prt_channel_t*)node->data;
284  channel->tag = tag++;
285 
286  int *node_tag;
287  if (channel->dst_node == vsa->node_rank)
288  node_tag = prt_tuple_new2(channel->src_node, channel->tag);
289  else
290  node_tag = prt_tuple_new2(channel->dst_node, channel->tag);
291 
292  icl_entry_t *entry = icl_hash_insert(
293  vsa->proxy->tags_hash, (void*)node_tag, (void*)channel);
294  prt_assert(entry != NULL, "icl_hash_insert failed");
295  }
296  // Destroy the list.
297  int status = icl_list_destroy(vsa->channel_lists[i], NULL);
298  prt_assert(status == 0, "icl_list_destroy failed");
299  }
300  // Free the array of lists.
301  free(vsa->channel_lists);
302 }
void * data
Definition: icl_list.h:20
int icl_list_destroy(icl_list_t *head, void(*free_function)(void *))
Frees the resources associated with this linked list.
Definition: icl_list.c:173
icl_entry_t * icl_hash_insert(icl_hash_t *ht, void *key, void *data)
Insert an item into the hash table.
Definition: icl_hash.c:134
int num_nodes
Definition: prt_vsa.h:47
#define icl_list_foreach(list, ptr)
Definition: icl_list.h:41
#define prt_tuple_new2(a, b)
Definition: prt_tuple.h:35
VDP&#39;s data channel Implements a data link between a pair of VDPs. Identifies the source and destinati...
Definition: prt_channel.h:29
int node_rank
Definition: prt_vsa.h:46
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
icl_list_t ** channel_lists
Definition: prt_vsa.h:57
Definition: icl_hash.h:19
struct prt_proxy_s * proxy
Definition: prt_vsa.h:56
icl_hash_t * tags_hash
Definition: prt_proxy.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

void prt_vsa_config_set ( prt_vsa_t vsa,
enum prt_config_param_e  param,
enum prt_config_value_e  value 
)
void prt_vsa_vdp_merge_channels ( prt_vsa_t vsa,
prt_vdp_t vdp,
int  node_rank 
)

Connects corresponding input and output channels of intra-node VDPs.

Parameters
vsa
vdp

Definition at line 154 of file prt_vsa.c.

References prt_channel_s::dst_slot, prt_channel_s::dst_tuple, icl_hash_find(), prt_vdp_s::input, prt_vdp_s::num_inputs, prt_vdp_s::num_outputs, prt_vdp_s::output, prt_vsa_s::proxy, prt_assert, prt_channel_delete(), prt_proxy_max_packet_size(), prt_tuple_equal(), prt_channel_s::src_slot, prt_channel_s::src_tuple, prt_vdp_s::tuple, and prt_vsa_s::vdps_hash.

155 {
156  int i;
157  // FOR each input channel.
158  for (i = 0; i < vdp->num_inputs; i++) {
159  prt_channel_t *channel = vdp->input[i];
160  if (channel != NULL) {
161  // Look for maximum channel size.
162  prt_proxy_max_packet_size(vsa->proxy, channel);
163  // Look up the source VDP.
164  prt_vdp_t *src_vdp =
165  icl_hash_find(vsa->vdps_hash, (void*)channel->src_tuple);
166  // IF source VDP found.
167  if (src_vdp != NULL) {
168  // Check for channel tuple mismatch.
169  int *src_vdp_dst_tuple =
170  src_vdp->output[channel->src_slot]->dst_tuple;
171  prt_assert(prt_tuple_equal(src_vdp_dst_tuple, vdp->tuple),
172  "VDP channel tuple mismatch");
173  // Swap this channel to the existing channel.
174  vdp->input[i] = src_vdp->output[channel->src_slot];
175  prt_channel_delete(channel);
176  }
177  }
178  }
179  // FOR each output channel.
180  for (i = 0; i < vdp->num_outputs; i++) {
181  prt_channel_t *channel = vdp->output[i];
182  if (channel != NULL) {
183  // Look for maximum channel size.
184  prt_proxy_max_packet_size(vsa->proxy, channel);
185  // Look up the destination VDP.
186  prt_vdp_t *dst_vdp =
187  icl_hash_find(vsa->vdps_hash, (void*)channel->dst_tuple);
188  // IF destination VDP found.
189  if (dst_vdp != NULL) {
190  // Check for channel tuple mismatch.
191  int *dst_vdp_src_tuple =
192  dst_vdp->input[channel->dst_slot]->src_tuple;
193  prt_assert(prt_tuple_equal(dst_vdp_src_tuple, vdp->tuple),
194  "VDP channel tuple mismatch");
195  // Swap this channel for the existing channel.
196  vdp->output[i] = dst_vdp->input[channel->dst_slot];
197  prt_channel_delete(channel);
198  }
199  }
200  }
201 }
struct prt_channel_s ** input
Definition: prt_vdp.h:42
int * dst_tuple
Definition: prt_channel.h:35
void prt_proxy_max_packet_size(prt_proxy_t *proxy, prt_channel_t *channel)
Look for maximum channel/packet size.
Definition: prt_proxy.c:105
int * src_tuple
Definition: prt_channel.h:33
void prt_channel_delete(prt_channel_t *channel)
channel destructor
Definition: prt_channel.c:64
VDP&#39;s data channel Implements a data link between a pair of VDPs. Identifies the source and destinati...
Definition: prt_channel.h:29
int num_inputs
Definition: prt_vdp.h:41
int num_outputs
Definition: prt_vdp.h:43
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
Virtual Data Processor (VDP) Is uniquely identified by a tuple. Fires for a predefined number of cycl...
Definition: prt_vdp.h:37
void * icl_hash_find(icl_hash_t *ht, void *key)
Search for an entry in a hash table.
Definition: icl_hash.c:108
icl_hash_t * vdps_hash
Definition: prt_vsa.h:54
int prt_tuple_equal(void *tuple_a, void *tuple_b)
tuple equality check Check if tuples are identical in length and content.
Definition: prt_tuple.c:161
struct prt_proxy_s * proxy
Definition: prt_vsa.h:56
struct prt_channel_s ** output
Definition: prt_vdp.h:44
int * tuple
Definition: prt_vdp.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void prt_vsa_vdp_track_tags ( prt_vsa_t vsa,
prt_vdp_t vdp,
int  core,
int  node_rank 
)

Builds the list of channel connections to other nodes.

Parameters
vsa
vdp
coreVDP's core number
node_rankVDP's node rank

Definition at line 212 of file prt_vsa.c.

References prt_vsa_s::channel_lists, prt_channel_s::dst_node, prt_channel_s::dst_tuple, prt_vsa_s::global_store, icl_list_isort(), icl_list_new(), prt_vdp_s::input, prt_vsa_s::node_rank, prt_vsa_s::num_cores, prt_vdp_s::num_inputs, prt_vdp_s::num_outputs, prt_vsa_s::num_threads, prt_vdp_s::output, prt_assert, prt_channel_compare(), prt_channel_s::src_node, prt_channel_s::src_tuple, and prt_vsa_s::vdp_to_core.

214 {
215  int i;
216  // FOR each input channel.
217  for (i = 0; i < vdp->num_inputs; i++) {
218  prt_channel_t *channel = vdp->input[i];
219  if (channel != NULL) {
220  channel->dst_node = node_rank;
221  int src_core = vsa->vdp_to_core(
222  channel->src_tuple, vsa->global_store, vsa->num_cores);
223  int src_node = src_core / vsa->num_threads;
224  channel->src_node = src_node;
225  // IF another node is the source.
226  if (src_node != vsa->node_rank) {
227  // Create the list if empty.
228  if (vsa->channel_lists[src_node] == NULL) {
229  vsa->channel_lists[src_node] = icl_list_new();
230  prt_assert(vsa->channel_lists[src_node] != NULL,
231  "icl_list_new failed");
232  }
233  // Add the channel to the list.
234  icl_list_t *node = icl_list_isort(
235  vsa->channel_lists[src_node], channel, prt_channel_compare);
236  prt_assert(node != NULL, "icl_list_isort failed");
237  }
238  }
239  }
240  // FOR each output channel.
241  for (i = 0; i < vdp->num_outputs; i++) {
242  prt_channel_t *channel = vdp->output[i];
243  if (channel != NULL) {
244  channel->src_node = node_rank;
245  int dst_core = vsa->vdp_to_core(
246  channel->dst_tuple, vsa->global_store, vsa->num_cores);
247  int dst_node = dst_core / vsa->num_threads;
248  channel->dst_node = dst_node;
249  // IF another node is the destination.
250  if (dst_node != vsa->node_rank) {
251  // Create the list if empty.
252  if (vsa->channel_lists[dst_node] == NULL) {
253  vsa->channel_lists[dst_node] = icl_list_new();
254  prt_assert(vsa->channel_lists[dst_node] != NULL,
255  "icl_list_new failed");
256  }
257  // Add the channel to the list.
258  icl_list_t *node = icl_list_isort(
259  vsa->channel_lists[dst_node], channel, prt_channel_compare);
260  prt_assert(node != NULL, "icl_list_isort failed");
261  }
262  }
263  }
264 }
icl_list_t * icl_list_new()
Create new linked list.
Definition: icl_list.c:23
struct prt_channel_s ** input
Definition: prt_vdp.h:42
prt_vdp_map_func_t vdp_to_core
Definition: prt_vsa.h:53
int * dst_tuple
Definition: prt_channel.h:35
int num_cores
Definition: prt_vsa.h:49
int * src_tuple
Definition: prt_channel.h:33
VDP&#39;s data channel Implements a data link between a pair of VDPs. Identifies the source and destinati...
Definition: prt_channel.h:29
icl_list_t * icl_list_isort(icl_list_t *head, void *data, int(*compare)(void *, void *))
Insert data into a sorted list. Does not support direct comparison of pointers.
Definition: icl_list.c:145
void * global_store
Definition: prt_vsa.h:52
int prt_channel_compare(void *channel1, void *channel2)
Compare two channels.
Definition: prt_channel.c:174
int num_inputs
Definition: prt_vdp.h:41
int num_outputs
Definition: prt_vdp.h:43
int node_rank
Definition: prt_vsa.h:46
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
icl_list_t ** channel_lists
Definition: prt_vsa.h:57
struct prt_channel_s ** output
Definition: prt_vdp.h:44
int num_threads
Definition: prt_vsa.h:48

Here is the call graph for this function:

Here is the caller graph for this function: