PULSAR  1.0.0
Parallel Ultra Light Systolic Array Runtime
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
PRT Application Programming Interface

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_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...
 
prt_packet_tprt_packet_new (size_t data_size)
 packet constructor Sets the number of references to one. More...
 
void prt_packet_release (prt_packet_t *packet)
 Release a packet. Decrements the number of active references. Destroys the packet when the last reference is removed. More...
 
prt_vdp_tprt_vdp_new (int *tuple, int counter, prt_vdp_function_t function, size_t local_store_size, int num_inputs, int num_outputs, int color)
 VDP constructor. More...
 
void prt_vdp_channel_insert (prt_vdp_t *vdp, prt_channel_t *channel, prt_channel_direction_t direction, int slot)
 Insert a new channel into a VDP. More...
 
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, prt_vdp_t *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_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, prt_config_param_t param, prt_config_value_t value)
 Set VSA configuration parameter. More...
 

Detailed Description

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

Function Documentation

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 27 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.

31 {
32  // Allocate the channel.
33  prt_channel_t *channel = (prt_channel_t*)malloc(sizeof(prt_channel_t));
34  prt_assert(channel != NULL, "malloc failed");
35 
36  // Check parameters.
37  prt_assert(count > 0, "count less or equal zero");
38  prt_assert(src_tuple != NULL, "NULL source tuple");
39  prt_assert(src_tuple != NULL, "NULL destination tuple");
40 
41  // Initialize the channel.
42  channel->vdp = NULL;
43  channel->count = count;
44  channel->datatype = datatype;
45  channel->src_tuple = src_tuple;
46  channel->dst_tuple = dst_tuple;
47  channel->src_slot = src_slot;
48  channel->dst_slot = dst_slot;
49 
50  // Create the list of packets.
51  channel->packets = icl_deque_new();
52  prt_assert(channel->packets != NULL, "icl_deque_new() failed");
53 
54  // Return the channel.
55  return channel;
56 }
icl_deque_t * packets
Definition: prt_channel.h:40
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 128 of file prt_channel.c.

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

129 {
130  // Check for a NULL input params.
131  prt_assert(channel != NULL, "popping from a NULL channel");
132  prt_assert(channel->packets != NULL, "popping from a NULL packet list");
133 
134  icl_node_t *node = icl_deque_first(channel->packets);
135  prt_assert(node != NULL, "empty packet list");
136 
137  prt_packet_t *packet = (prt_packet_t*)node->data;
138  prt_assert(packet != NULL, "NULL packet");
139 
140  icl_deque_delete(channel->packets, node, NULL);
141  return packet;
142 }
icl_deque_t * packets
Definition: prt_channel.h:40
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 98 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.

99 {
100  // Check for a NULL input params.
101  prt_assert(packet != NULL, "NULL packet");
102  prt_assert(channel != NULL, "NULL channel");
103  prt_assert(channel->packets != NULL, "NULL packet list");
104 
105  __sync_fetch_and_add(&packet->num_refs, 1);
106  icl_deque_append(channel->packets, (void*)packet);
107 
108  // IF a dangling channel.
109  if (channel->dst_node != channel->vdp->thread->vsa->node_rank)
110  // Notify the proxy.
112  channel->vdp->thread->vsa->proxy,
113  channel->vdp->thread->rank,
114  channel);
115 }
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:40
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:

prt_packet_t* prt_packet_new ( size_t  data_size)

packet constructor Sets the number of references to one.

Parameters
data_sizesize of the packet in bytes
Returns
new packet

Definition at line 23 of file prt_packet.c.

References prt_packet_s::data, prt_packet_s::num_refs, and prt_assert.

24 {
25  prt_packet_t *packet = (prt_packet_t*)malloc(sizeof(prt_packet_t));
26  prt_assert(packet != NULL, "malloc failed");
27 
28  packet->data = malloc(data_size);
29  prt_assert(packet->data != NULL, "malloc failed");
30 
31  packet->num_refs = 1;
32  return packet;
33 }
VDP's data packet A packet of data transferred through VDP's channels.
Definition: prt_packet.h:24
void * data
Definition: prt_packet.h:25
#define prt_assert(cond, msg)
Definition: prt_assert.h:30

Here is the caller graph for this function:

void prt_packet_release ( prt_packet_t packet)

Release a packet. Decrements the number of active references. Destroys the packet when the last reference is removed.

Parameters
packet

Definition at line 44 of file prt_packet.c.

References prt_packet_s::data, prt_packet_s::num_refs, and prt_assert.

45 {
46  int num_refs = __sync_sub_and_fetch(&packet->num_refs, 1);
47  prt_assert(num_refs >= 0, "negative number of data references");
48  if (num_refs == 0) {
49  free(packet->data);
50  free(packet);
51  }
52 }
void * data
Definition: prt_packet.h:25
#define prt_assert(cond, msg)
Definition: prt_assert.h:30

Here is the caller graph for this function:

void prt_vdp_channel_insert ( prt_vdp_t vdp,
prt_channel_t channel,
prt_channel_direction_t  direction,
int  slot 
)

Insert a new channel into a VDP.

Parameters
vdp
channel
directiondirection of the channel
slotslot number

Definition at line 176 of file prt_vdp.c.

References prt_channel_s::dst_tuple, prt_vdp_s::input, prt_vdp_s::output, prt_assert, prt_tuple_equal(), PrtInputChannel, PrtOutputChannel, prt_channel_s::src_tuple, prt_vdp_s::tuple, and prt_channel_s::vdp.

179 {
180  // Check input parameters.
181  prt_assert(vdp != NULL, "inserting in a NULL VDP");
182  prt_assert(channel != NULL, "inserting a NULL channel");
183  prt_assert(direction == PrtInputChannel || direction == PrtOutputChannel,
184  "wrong channel direction");
185 
186  if (direction == PrtInputChannel) {
187  // Check if channel destination tuple equals VDP's tuple.
188  prt_assert(prt_tuple_equal(channel->dst_tuple, vdp->tuple),
189  "input channel destination tuple does not match VDP tuple");
190  // Check if channel slot empty.
191  prt_assert(vdp->input[slot] == NULL,
192  "inserting channel in occupied input slot");
193  // Check the slot.
194  // Link the channel.
195  prt_assert(slot >= 0 && slot < vdp->num_inputs, "slot out of range");
196  vdp->input[slot] = channel;
197  channel->vdp = vdp;
198  }
199  else {
200  // Check if channel source tuple equals VDP's tuple.
201  prt_assert(prt_tuple_equal(channel->src_tuple, vdp->tuple),
202  "output channel source tuple does not match VDP tuple");
203  // Check if channel slot empty.
204  prt_assert(vdp->output[slot] == NULL,
205  "inserting channel in occupied output slot");
206  // Check the slot.
207  // Link the channel.
208  prt_assert(slot >= 0 && slot < vdp->num_outputs, "slot out of range");
209  vdp->output[slot] = channel;
210  channel->vdp = vdp;
211  }
212 }
struct prt_channel_s ** input
Definition: prt_vdp.h:42
int * dst_tuple
Definition: prt_channel.h:35
int * src_tuple
Definition: prt_channel.h:33
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
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_channel_s ** output
Definition: prt_vdp.h:44
int * tuple
Definition: prt_vdp.h:39
struct prt_vdp_s * vdp
Definition: prt_channel.h:30

Here is the call graph for this function:

prt_vdp_t* prt_vdp_new ( int *  tuple,
int  counter,
prt_vdp_function_t  function,
size_t  local_store_size,
int  num_inputs,
int  num_outputs,
int  color 
)

VDP constructor.

Parameters
tupleVDP's unique identificator
counternumber of times to fire the VDP
functionfunction implementing VDP's actions
local_store_sizesize of VDP's persistent local store in bytes
num_inputsnumber of input channels
num_outputsnumber of output channels
Returns
new VDP

Definition at line 27 of file prt_vdp.c.

References prt_vdp_s::color, prt_vdp_s::counter, prt_vdp_s::function, prt_vdp_s::input, prt_vdp_s::local_store, prt_vdp_s::num_inputs, prt_vdp_s::num_outputs, prt_vdp_s::output, prt_assert, prt_vdp_s::thread, and prt_vdp_s::tuple.

32 {
33  // Allocate the VDP.
34  prt_vdp_t *vdp = (prt_vdp_t*)malloc(sizeof(prt_vdp_t));
35  prt_assert(vdp != NULL, "malloc failed");
36 
37  // Check parameters.
38  prt_assert(tuple != NULL, "NULL tuple");
39  prt_assert(function != NULL, "NULL function");
40  prt_assert(counter > 0, "counter less or equal zero");
41 
42  // Initialize the VDP.
43  vdp->thread = NULL;
44  vdp->tuple = tuple;
45  vdp->counter = counter;
46  vdp->function = function;
47  vdp->color = color;
48 
49  // Initialize input channels.
50  vdp->num_inputs = num_inputs;
51  if (vdp->num_inputs > 0) {
52  vdp->input = (prt_channel_t**)calloc(vdp->num_inputs, sizeof(prt_channel_t*));
53  prt_assert(vdp->input != NULL, "malloc failed");
54  }
55  // Initialize output channels.
56  vdp->num_outputs = num_outputs;
57  if (vdp->num_outputs > 0) {
58  vdp->output = (prt_channel_t**)calloc(vdp->num_outputs, sizeof(prt_channel_t*));
59  prt_assert(vdp->output != NULL, "malloc failed");
60  }
61  // Allocate local store.
62  if (local_store_size > 0) {
63  vdp->local_store = (void*)malloc(local_store_size);
64  prt_assert(vdp->local_store != NULL, "malloc failed");
65  }
66  // Return the VDP.
67  return vdp;
68 }
int color
Definition: prt_vdp.h:47
prt_vdp_function_t function
Definition: prt_vdp.h:45
struct prt_channel_s ** input
Definition: prt_vdp.h:42
void * local_store
Definition: prt_vdp.h:46
int counter
Definition: prt_vdp.h:40
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
struct prt_thread_s * thread
Definition: prt_vdp.h:38
struct prt_channel_s ** output
Definition: prt_vdp.h:44
int * tuple
Definition: prt_vdp.h:39
void prt_vsa_config_set ( prt_vsa_t vsa,
prt_config_param_t  param,
prt_config_value_t  value 
)

Set VSA configuration parameter.

Parameters
vsa
param
value

Definition at line 357 of file prt_vsa.c.

References prt_vsa_s::config, prt_error, PRT_SVG_TRACING, PRT_SVG_TRACING_OFF, PRT_SVG_TRACING_ON, PRT_VDP_SCHEDULING, PRT_VDP_SCHEDULING_AGGRESSIVE, PRT_VDP_SCHEDULING_LAZY, prt_config_s::svg_tracing, and prt_config_s::vdp_scheduling.

359 {
360  switch (param) {
361  case PRT_VDP_SCHEDULING:
362  switch (value) {
365  vsa->config->vdp_scheduling = value;
366  break;
367  default:
368  prt_error("invalid value");
369  break;
370  }
371  break;
372  case PRT_SVG_TRACING:
373  switch (value) {
374  case PRT_SVG_TRACING_ON:
375  case PRT_SVG_TRACING_OFF:
376  vsa->config->svg_tracing = value;
377  break;
378  default:
379  prt_error("invalid value");
380  break;
381  }
382  break;
383  default:
384  prt_error("invalid param");
385  break;
386  }
387 }
struct prt_config_s * config
Definition: prt_vsa.h:55
#define prt_error(msg)
Definition: prt_assert.h:24
int svg_tracing
Definition: prt_config.h:43
int vdp_scheduling
Definition: prt_config.h:42
void prt_vsa_delete ( prt_vsa_t vsa)

VSA destructor.

Parameters
VSA

Definition at line 81 of file prt_vsa.c.

References prt_vsa_s::config, icl_hash_destroy(), prt_vsa_s::num_threads, prt_vsa_s::proxy, prt_config_delete(), prt_proxy_delete(), prt_thread_delete(), prt_vdp_delete(), prt_vsa_s::thread, prt_vsa_s::thread_attr, and prt_vsa_s::vdps_hash.

82 {
83  // Destroy the VDPs hash.
84  icl_hash_destroy(vsa->vdps_hash, NULL, (void(*)(void*))prt_vdp_delete);
85 
86  // Delete config & proxy.
88  prt_proxy_delete(vsa->proxy);
89 
90  int i;
91  // Pthreads cleanup.
92  pthread_attr_destroy(&vsa->thread_attr);
93  for (i = 0; i < vsa->num_threads; i++)
94  prt_thread_delete(vsa->thread[i]);
95  free(vsa->thread);
96 
97  // Free the VSA.
98  free(vsa);
99 }
int icl_hash_destroy(icl_hash_t *ht, void(*free_key)(void *), void(*free_data)(void *))
Free hash table structures. Key and data are freed using functions.
Definition: icl_hash.c:279
struct prt_config_s * config
Definition: prt_vsa.h:55
struct prt_thread_s ** thread
Definition: prt_vsa.h:51
void prt_proxy_delete(prt_proxy_t *proxy)
communication proxy destructor Checking if all the lists are empty at the time of destruction...
Definition: prt_proxy.c:66
void prt_config_delete(prt_config_t *config)
config object destructor
Definition: prt_config.c:39
void prt_thread_delete(prt_thread_t *thread)
thread object destructor
Definition: prt_thread.c:48
void prt_vdp_delete(prt_vdp_t *vdp)
VDP destructor Used for destruction of local VDPs. Destroy all input channels. Destroy all dangling o...
Definition: prt_vdp.c:80
pthread_attr_t thread_attr
Definition: prt_vsa.h:50
icl_hash_t * vdps_hash
Definition: prt_vsa.h:54
struct prt_proxy_s * proxy
Definition: prt_vsa.h:56
int num_threads
Definition: prt_vsa.h:48

Here is the call graph for this function:

prt_vsa_t* prt_vsa_new ( int  num_threads,
void *  global_store,
int(*)(int *, void *, int)  vdp_to_core 
)

VSA constructor.

Parameters
num_threadsnumber of local worker threads
global_storeVSA's global store accessible to all VDPs
vdp_to_corefunction mapping VDP's tuple to a global core number
max_vdpsmaximum number of VDP's within a node
Returns
new VSA

Definition at line 28 of file prt_vsa.c.

References prt_vsa_s::channel_lists, prt_vsa_s::config, prt_vsa_s::global_store, icl_hash_create(), prt_vsa_s::node_rank, prt_vsa_s::num_cores, prt_vsa_s::num_nodes, prt_vsa_s::num_threads, prt_vsa_s::proxy, prt_assert, prt_config_new(), prt_proxy_new(), prt_thread_new(), prt_tuple_equal(), prt_tuple_hash(), PRT_VSA_MAX_VDPS_PER_NODE, prt_vsa_s::thread, prt_vsa_s::thread_attr, prt_vsa_s::vdp_to_core, prt_vsa_s::vdps_hash, prt_thread_s::vsa, and prt_proxy_s::vsa.

30 {
31  // Allocate the VSA.
32  prt_vsa_t *vsa = (prt_vsa_t*)malloc(sizeof(prt_vsa_t));
33  prt_assert(vsa != NULL, "malloc failed");
34 
35  // Init the VSA.
36  MPI_Comm_rank(MPI_COMM_WORLD, &vsa->node_rank);
37  MPI_Comm_size(MPI_COMM_WORLD, &vsa->num_nodes);
38  vsa->num_threads = num_threads;
39  vsa->num_cores = vsa->num_nodes*vsa->num_threads;
40  vsa->global_store = global_store;
41  vsa->vdp_to_core = vdp_to_core;
42 
43  // Init config & proxy.
44  vsa->config = prt_config_new();
45  vsa->proxy = prt_proxy_new(num_threads);
46  vsa->proxy->vsa = vsa;
47 
48  // Init pthreads.
49  pthread_attr_init(&vsa->thread_attr);
50  pthread_attr_setscope(&vsa->thread_attr, PTHREAD_SCOPE_SYSTEM);
51  pthread_setconcurrency(vsa->num_threads+1);
52 
53  int i;
54  // Initialize the threads.
55  vsa->thread = (prt_thread_t**)malloc(vsa->num_threads*sizeof(prt_thread_t*));
56  prt_assert(vsa->thread != NULL, "malloc failed");
57  for (i = 0; i < vsa->num_threads; i++) {
58  vsa->thread[i] = prt_thread_new(i, vsa->node_rank*vsa->num_threads+i);
59  vsa->thread[i]->vsa = vsa;
60  }
61 
62  // Initialize the VDPs hash.
63  int nbuckets = PRT_VSA_MAX_VDPS_PER_NODE;
65 
66  // Allocate the array of channel lists.
67  vsa->channel_lists = (icl_list_t**)calloc(vsa->num_nodes, sizeof(icl_list_t*));
68  prt_assert(vsa->channel_lists != NULL, "malloc failed");
69 
70  // Return the VSA.
71  return vsa;
72 }
prt_vdp_map_func_t vdp_to_core
Definition: prt_vsa.h:53
struct prt_config_s * config
Definition: prt_vsa.h:55
struct prt_thread_s ** thread
Definition: prt_vsa.h:51
struct prt_vsa_s * vsa
Definition: prt_thread.h:28
Virtual Systolic Array (VSA) VSA contains global informationa about the system, a local communication...
Definition: prt_vsa.h:45
int num_nodes
Definition: prt_vsa.h:47
unsigned int prt_tuple_hash(void *tuple)
tuple hash Required by the VSA&#39;s tuples hash table. Computes the lenght in characters and calls a str...
Definition: prt_tuple.c:188
prt_proxy_t * prt_proxy_new(int num_threads)
communication proxy constructor
Definition: prt_proxy.c:21
int num_cores
Definition: prt_vsa.h:49
pthread_attr_t thread_attr
Definition: prt_vsa.h:50
prt_thread_t * prt_thread_new(int rank, int core)
thread object constructor
Definition: prt_thread.c:22
void * global_store
Definition: prt_vsa.h:52
struct prt_vsa_s * vsa
Definition: prt_proxy.h:40
int node_rank
Definition: prt_vsa.h:46
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
VSA&#39;s worker thread Owns a number of VDPs. Knows the communication proxy.
Definition: prt_thread.h:27
icl_list_t ** channel_lists
Definition: prt_vsa.h:57
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
icl_hash_t * icl_hash_create(int nbuckets, unsigned int(*hash_function)(void *), int(*hash_key_compare)(void *, void *))
Create a new hash table.
Definition: icl_hash.c:70
#define PRT_VSA_MAX_VDPS_PER_NODE
maximum VDPs per node She size of the VSA&#39;s hash table of VDPs. Should be a prime number ...
Definition: prt_vsa.h:32
prt_config_t * prt_config_new()
config object constructor
Definition: prt_config.c:19
struct prt_proxy_s * proxy
Definition: prt_vsa.h:56
int num_threads
Definition: prt_vsa.h:48

Here is the call graph for this function:

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.

Parameters
vsa

Definition at line 314 of file prt_vsa.c.

References prt_vsa_s::config, prt_thread_s::id, Indigo, prt_vsa_s::num_threads, prt_vsa_s::proxy, prt_assert, prt_proxy_run(), PRT_SVG_TRACING_ON, prt_thread_run(), prt_vsa_channel_tags(), svg_trace_finish(), svg_trace_init(), svg_trace_start(), svg_trace_stop(), prt_config_s::svg_tracing, prt_vsa_s::thread, and prt_vsa_s::thread_attr.

315 {
316  // Assign channel tags.
318 
319  // Init tracing.
321 
322  int i;
323  // Launch threads.
324  for (i = 0; i < vsa->num_threads; i++) {
325  int status =
326  pthread_create(
327  &vsa->thread[i]->id, &vsa->thread_attr, prt_thread_run, vsa->thread[i]);
328  prt_assert(status == 0, "pthread_create failed");
329  }
330  // Barrier for trace alignment.
331  svg_trace_start(0);
332  MPI_Barrier(MPI_COMM_WORLD);
334 
335  // Service the communication proxy.
336  prt_proxy_run(vsa->proxy);
337 
338  // Join threads.
339  for (i = 0; i < vsa->num_threads; i++) {
340  int status = pthread_join(vsa->thread[i]->id, NULL);
341  prt_assert(status == 0, "pthread_join failed");
342  }
343  // Finish tracing.
346 }
struct prt_config_s * config
Definition: prt_vsa.h:55
struct prt_thread_s ** thread
Definition: prt_vsa.h:51
void svg_trace_init(int num_cores)
Initialize tracing.
Definition: svg_trace.c:38
int svg_tracing
Definition: prt_config.h:43
void * prt_thread_run(void *thrd)
thread&#39;s production cycle Cycle through VDPs. Fire the ones that are ready. Remove the ones which bur...
Definition: prt_thread.c:70
void svg_trace_start(int thread_rank)
Start tracing an event.
Definition: svg_trace.c:50
void prt_vsa_channel_tags(prt_vsa_t *vsa)
Assign channel tags. Build the node-tag lookup. Destroy channel lists.
Definition: prt_vsa.c:274
pthread_attr_t thread_attr
Definition: prt_vsa.h:50
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
void svg_trace_finish()
Finish tracing. Collect traces from all nodes. Write the combined trace to an SVG file...
Definition: svg_trace.c:78
void svg_trace_stop(int thread_rank, int color)
Stop tracing an event.
Definition: svg_trace.c:63
void prt_proxy_run(prt_proxy_t *proxy)
communication proxy production cycle Serves communication requests of local worker threads until shut...
Definition: prt_proxy.c:171
struct prt_proxy_s * proxy
Definition: prt_vsa.h:56
pthread_t id
Definition: prt_thread.h:31
int num_threads
Definition: prt_vsa.h:48

Here is the call graph for this function:

void prt_vsa_vdp_insert ( prt_vsa_t vsa,
prt_vdp_t 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.

Parameters
vsa
vdp

Definition at line 113 of file prt_vsa.c.

References prt_vsa_s::global_store, icl_hash_insert(), icl_list_append(), prt_vsa_s::node_rank, prt_vsa_s::num_cores, prt_vsa_s::num_threads, prt_assert, prt_vdp_annihilate(), prt_vsa_vdp_merge_channels(), prt_vsa_vdp_track_tags(), prt_vdp_s::thread, prt_vsa_s::thread, prt_vdp_s::tuple, prt_vsa_s::vdp_to_core, prt_thread_s::vdps, and prt_vsa_s::vdps_hash.

114 {
115  int i;
116  // Check arguments.
117  prt_assert(vsa != NULL, "NULL VSA");
118  prt_assert(vdp != NULL, "NULL VDP");
119 
120  // Compute global core number and process rank.
121  int core = vsa->vdp_to_core(vdp->tuple, vsa->global_store, vsa->num_cores);
122  int node_rank = core / vsa->num_threads;
123  int thread_rank = core % vsa->num_threads;
124 
125  // IF VDP not in this node.
126  if (node_rank != vsa->node_rank) {
127  // Destroy along with all channels and return.
128  prt_vdp_annihilate(vdp);
129  return;
130  }
131  // Insert in the VSA's VDP hash.
132  icl_entry_t *entry = icl_hash_insert(
133  vsa->vdps_hash, (void*)vdp->tuple, (void*)vdp);
134  prt_assert(entry != NULL, "icl_hash_insert failed");
135 
136  // Insert in the thread's VDPs list.
137  icl_list_t *node = icl_list_append(vsa->thread[thread_rank]->vdps, vdp);
138  prt_assert(node != NULL, "icl_list_append failed");
139  vdp->thread = vsa->thread[thread_rank];
140 
141  // Merge intra-node channels.
142  prt_vsa_vdp_merge_channels(vsa, vdp, node_rank);
143  // Track channel tags for inter-node communication.
144  prt_vsa_vdp_track_tags(vsa, vdp, core, node_rank);
145 }
prt_vdp_map_func_t vdp_to_core
Definition: prt_vsa.h:53
struct prt_thread_s ** thread
Definition: prt_vsa.h:51
icl_list_t * icl_list_append(icl_list_t *head, void *data)
Insert a node at the end of this list.
Definition: icl_list.c:326
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
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.
Definition: prt_vsa.c:154
int num_cores
Definition: prt_vsa.h:49
icl_list_t * vdps
Definition: prt_thread.h:32
void * global_store
Definition: prt_vsa.h:52
int node_rank
Definition: prt_vsa.h:46
#define prt_assert(cond, msg)
Definition: prt_assert.h:30
void prt_vdp_annihilate(prt_vdp_t *vdp)
VDP annihilator Used for complete annihilation of VDPs that don&#39;t belong. Destroy all input channels...
Definition: prt_vdp.c:128
icl_hash_t * vdps_hash
Definition: prt_vsa.h:54
struct prt_thread_s * thread
Definition: prt_vdp.h:38
Definition: icl_hash.h:19
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.
Definition: prt_vsa.c:212
int * tuple
Definition: prt_vdp.h:39
int num_threads
Definition: prt_vsa.h:48

Here is the call graph for this function: