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

PRT data packet implementation. More...

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

Go to the source code of this file.

Functions

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

Detailed Description

PRT data packet implementation.

Author
Jakub Kurzak

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

Definition in file prt_packet.c.

Function Documentation

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 22 of file prt_packet.c.

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

23 {
24  prt_packet_t *packet = (prt_packet_t*)malloc(sizeof(prt_packet_t));
25  prt_assert(packet != NULL, "malloc failed");
26 
27  packet->data = malloc(data_size);
28  prt_assert(packet->data != NULL, "malloc failed");
29 
30  packet->num_refs = 1;
31  return packet;
32 }
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 42 of file prt_packet.c.

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

43 {
44  int num_refs = __sync_sub_and_fetch(&packet->num_refs, 1);
45  prt_assert(num_refs >= 0, "negative number of data references");
46  if (num_refs == 0) {
47  free(packet->data);
48  free(packet);
49  }
50 }
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: