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

Virtual Data Processor (VDP) More...

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

Go to the source code of this file.

Data Structures

struct  prt_vdp_s
 Virtual Data Processor (VDP) Is uniquely identified by a tuple. Fires for a predefined number of cycles. Has a fixed number of input and output channels. Has a persistent local store. More...
 

Typedefs

typedef void(* prt_vdp_function_t )(int *, int, struct prt_channel_s **, struct prt_channel_s **, void *, void *)
 VDP's function pointer Defines the type of the pointer to the VDP's function. More...
 
typedef struct prt_vdp_s prt_vdp_t
 Virtual Data Processor (VDP) Is uniquely identified by a tuple. Fires for a predefined number of cycles. Has a fixed number of input and output channels. Has a persistent local store. More...
 

Functions

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_delete (prt_vdp_t *vdp)
 VDP destructor Delete all local output channels. All local input channels are destroyed as output channels of other VDPs. More...
 
void prt_vdp_destroy (prt_vdp_t *vdp)
 
void prt_vdp_channel_insert (prt_vdp_t *vdp, struct prt_channel_s *channel, enum prt_channel_direction_e direction, int slot)
 
int prt_vdp_ready (prt_vdp_t *vdp)
 Check if a VDP is ready to fire. Only checks established channels. (NULL channels don't prevent firing.) More...
 

Detailed Description

Virtual Data Processor (VDP)

Author
Jakub Kurzak

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

Definition in file prt_vdp.h.

Typedef Documentation

typedef void(* prt_vdp_function_t)(int *, int, struct prt_channel_s **, struct prt_channel_s **, void *, void *)

VDP's function pointer Defines the type of the pointer to the VDP's function.

Definition at line 28 of file prt_vdp.h.

typedef struct prt_vdp_s prt_vdp_t

Virtual Data Processor (VDP) Is uniquely identified by a tuple. Fires for a predefined number of cycles. Has a fixed number of input and output channels. Has a persistent local store.

Function Documentation

void prt_vdp_channel_insert ( prt_vdp_t vdp,
struct prt_channel_s channel,
enum prt_channel_direction_e  direction,
int  slot 
)
void prt_vdp_delete ( prt_vdp_t vdp)

VDP destructor Delete all local output channels. All local input channels are destroyed as output channels of other VDPs.

Parameters
vdp

Definition at line 77 of file prt_vdp.c.

References prt_channel_s::dst_node, prt_vdp_s::input, prt_vdp_s::local_store, prt_vsa_s::node_rank, prt_vdp_s::num_inputs, prt_vdp_s::num_outputs, prt_vdp_s::output, prt_assert, prt_channel_delete(), prt_tuple_delete(), prt_vdp_s::thread, prt_vdp_s::tuple, prt_channel_s::vdp, and prt_thread_s::vsa.

78 {
79  // Check for a NULL VDP.
80  prt_assert(vdp != NULL, "NULL VDP");
81 
82  // Delete the tuple.
83  prt_assert(vdp->tuple != NULL, "NULL tuple");
84  prt_tuple_delete(vdp->tuple);
85 
86  int i;
87  // Delete local output channels.
88  for (i = 0; i < vdp->num_outputs; i++) {
89  prt_channel_t *channel = vdp->output[i];
90  if (channel != NULL)
91  if (channel->dst_node == channel->vdp->thread->vsa->node_rank)
92  prt_channel_delete(channel);
93  }
94  // Free array of inputs.
95  if (vdp->num_inputs > 0)
96  free(vdp->input);
97 
98  // Free array of outputs.
99  if (vdp->num_outputs > 0)
100  free(vdp->output);
101 
102  // Free local store.
103  if (vdp->local_store != NULL)
104  free(vdp->local_store);
105 
106  // Free the VDP.
107  free(vdp);
108 }
struct prt_channel_s ** input
Definition: prt_vdp.h:42
struct prt_vsa_s * vsa
Definition: prt_thread.h:28
void * local_store
Definition: prt_vdp.h:46
void prt_tuple_delete(int *tuple)
tuple destructor
Definition: prt_tuple.c:95
void prt_channel_delete(prt_channel_t *channel)
channel destructor
Definition: prt_channel.c:63
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
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_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:

void prt_vdp_destroy ( prt_vdp_t vdp)
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 26 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.

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

Check if a VDP is ready to fire. Only checks established channels. (NULL channels don't prevent firing.)

Parameters
vdp
Return values
0not ready
1ready

Definition at line 170 of file prt_vdp.c.

References prt_vdp_s::input, prt_vdp_s::num_inputs, prt_assert, and prt_channel_empty().

171 {
172  // Check for a NULL VDP.
173  prt_assert(vdp != NULL, "NULL VDP");
174 
175  int i;
176  // FOR each input channel.
177  for (i = 0; i < vdp->num_inputs; i++)
178  // IF the channel was established.
179  if (vdp->input[i] != NULL)
180  // IF the list of packets is empty.
181  if (prt_channel_empty(vdp->input[i]))
182  // Return "not ready".
183  return 0;
184 
185  // Return "ready".
186  return 1;
187 }
struct prt_channel_s ** input
Definition: prt_vdp.h:42
int prt_channel_empty(prt_channel_t *channel)
Checks if a channel is empty.
Definition: prt_channel.c:150
int num_inputs
Definition: prt_vdp.h:41
#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: