drake  1.0.0
include/drake/platform.h File Reference
#include <stddef.h>
#include <drake/task.h>
#include <drake/schedule.h>
Include dependency graph for platform.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define drake_platform_stream_create(stream, application)

Typedefs

typedef struct drake_time * drake_time_t
typedef struct drake_platform * drake_platform_t
typedef struct drake_power * drake_power_t

Enumerations

enum  drake_power_monitor { DRAKE_POWER_CHIP, DRAKE_POWER_MEMORY_CONTROLLER, DRAKE_POWER_CORE }

Functions

size_t drake_platform_shared_size ()
size_t drake_platform_shared_align ()
size_t drake_platform_private_size ()
drake_platform_t drake_platform_init (void *)
int drake_platform_destroy (drake_platform_t)
volatile void * drake_platform_shared_malloc (size_t size, size_t core)
volatile void * drake_platform_shared_malloc_mailbox (size_t size, size_t core)
void drake_platform_shared_free (volatile void *addr, size_t core)
void * drake_platform_store_malloc (size_t size)
void drake_platform_store_free (void *)
void * drake_platform_private_malloc (size_t size)
void drake_platform_private_free (void *)
void * drake_remote_addr (void *addr, size_t core)
int drake_platform_pull (volatile void *addr)
int drake_platform_commit (volatile void *addr)
size_t drake_platform_core_id ()
size_t drake_platform_core_size ()
size_t drake_platform_core_max ()
void drake_platform_barrier (void *)
void drake_platform_exclusive_begin ()
void drake_platform_exclusive_end ()
int drake_platform_set_frequency (int frequency)
int drake_platform_set_frequency_autoscale (int frequency)
int drake_platform_set_voltage (float voltage)
int drake_platform_set_voltage_frequency (drake_platform_t, size_t frequency)
size_t drake_platform_get_frequency (drake_platform_t)
float drake_platform_get_voltage ()
int drake_platform_time_get (drake_time_t)
int drake_platform_time_subtract (drake_time_t res, drake_time_t t1, drake_time_t t2)
int drake_platform_time_add (drake_time_t res, drake_time_t t1, drake_time_t t2)
int drake_platform_time_greater (drake_time_t t1, drake_time_t t2)
int drake_platform_time_equals (drake_time_t t1, drake_time_t t2)
int drake_platform_time_init (drake_time_t t, double ms)
FILE * drake_platform_time_printf (FILE *stream, drake_time_t)
void drake_platform_time_destroy (drake_time_t time)
drake_time_t drake_platform_time_alloc ()
int drake_platform_sleep (drake_time_t period)
drake_power_t drake_platform_power_init (drake_platform_t pt, size_t samples, int measurement)
void drake_platform_power_begin (drake_power_t pwr)
size_t drake_platform_power_end (drake_power_t)
FILE * drake_platform_power_printf (FILE *stream, drake_power_t, char *separator)
FILE * drake_platform_power_printf_line (FILE *stream, drake_power_t, size_t line, char *separator)
FILE * drake_platform_power_printf_cumulate (FILE *stream, drake_power_t, int metrics, char *separator)
FILE * drake_platform_power_printf_line_cumulate (FILE *stream, drake_power_t, size_t line, int metrics, char *separator)
void drake_platform_power_destroy (drake_power_t)
int drake_platform_stream_create_explicit (drake_platform_t stream, void(*schedule_init)(drake_schedule_t *), void(*schedule_destroy)(drake_schedule_t *), void *(*task_function)(size_t id, task_status_t status))
int drake_platform_stream_init (drake_platform_t stream, void *arg)
int drake_platform_stream_run (drake_platform_t)
int drake_platform_stream_destroy (drake_platform_t)
void drake_platform_core_disable (drake_platform_t pt, size_t core)
void drake_platform_core_enable (drake_platform_t pt, size_t core)
void drake_platform_sleep_disable (drake_platform_t pt, size_t core)
void drake_platform_sleep_enable (drake_platform_t pt, size_t core)

Define Documentation

#define drake_platform_stream_create (   stream,
  application 
)
Value:
void* (drake_function(application))(size_t id, task_status_t state); \
void (drake_schedule_init(application))(drake_schedule_t*); \
void (drake_schedule_destroy(application))(drake_schedule_t*); \
int (drake_task_number(application))(); \
char* (drake_task_name(application))(size_t); \
drake_platform_stream_create_explicit(stream, PELIB_##CONCAT_2(drake_schedule_init_, application), PELIB_##CONCAT_2(drake_schedule_destroy_, application), PELIB_CONCAT_2(drake_function_, application))

Provides a frontend to create a stream for an application. Generates a call to drake_stream_create_explicit with a pointer to the function to schedule initialization function that corresponds to the application

Definition at line 31 of file platform.h.


Typedef Documentation

typedef struct drake_platform* drake_platform_t

Abstract type for time measurement

Definition at line 42 of file platform.h.

typedef struct drake_power* drake_power_t

Abstract type for power measurement and recording

Definition at line 44 of file platform.h.

typedef struct drake_time* drake_time_t

Abstract type for time measurement

Definition at line 40 of file platform.h.


Enumeration Type Documentation

Descriptor of power quantities to manipulate. DRAKE_POWER_CHIP denotes the pwoer consumption of the whoe chip the caller core is part of. DRAKE_POWER_MEMORY_CONTROLLER is the power consumption of all memory controllers. DRAKE_POWER_CORE is the power of the caller core alone

Enumerator:
DRAKE_POWER_CHIP 
DRAKE_POWER_MEMORY_CONTROLLER 
DRAKE_POWER_CORE 

Definition at line 155 of file platform.h.


Function Documentation

void drake_platform_barrier ( void *  )

Barrier accross all cores involved in the streaming application running

int drake_platform_commit ( volatile void *  addr)

Triggers the sending of data written at addr, to the corresponding core. The data may have been sent before the call, but it is guaranteed to have been sent after this function call. It is not guaranteed however, that the recicpient core has received it when the function returns.

void drake_platform_core_disable ( drake_platform_t  pt,
size_t  core 
)
void drake_platform_core_enable ( drake_platform_t  pt,
size_t  core 
)

Returns the id of the core calling this function

Maximum number of cores the execution platform can offer

Returns the number of cores available at the time the streaming program is run. This must match the number of cores in the schedule of the streaming task begin run

Cleans up a drake stream execution platform. Runs after a streaming application is destroyed

Begins a critical section

Ends a critical section

Returns the current frequency in KHz

Returns the current voltage in Volts

Initializes a drake stream execution platform. Runs before a streaming application is created

Begins power consumption measurement

Parameters:
pwrPower data structure that holds power data measured and well as all pwoer measurement settings

Clean up and deallocate the memory associated to a power measurement and recording structure

Stops power consumption measurement

drake_power_t drake_platform_power_init ( drake_platform_t  pt,
size_t  samples,
int  measurement 
)

Initializes a power structure

Parameters:
sampleMaximal number of sample the power structure can hold
measurementbinary combination of power quantities to measure. For instance, 1 << DRAKE_POWER_CHIP | 1 << DRAKE_POWER_CORE
Returns:
0 if the power structure could not be allocated
FILE* drake_platform_power_printf ( FILE *  stream,
drake_power_t  ,
char *  separator 
)

Writes all power quantities measured associated to a time step, in output stream in human-readable manner, one line per time step, all power quantities of a time step in the same line, with a separator

Parameters:
streamOutput stream
separatorString to write between two power quantities shown in each output line
Returns:
Output stream after writing pwoer information
FILE* drake_platform_power_printf_cumulate ( FILE *  stream,
drake_power_t  ,
int  metrics,
char *  separator 
)

Writes the sum of all power quantities measured associated to a time step, in output stream in human-readable manner, one line per time step, all power quantities of a time step in the same line, with a separator.

Parameters:
streamOutput stream
metricsPower quantities to be combined together, for instance 1 << DRAKE_POWER_CHIP | 1 << DRAKE_POWER_CORE
separatorString to write between two power quantities shown in each output line
Returns:
Output stream after writing pwoer information
FILE* drake_platform_power_printf_line ( FILE *  stream,
drake_power_t  ,
size_t  line,
char *  separator 
)

Writes a unique line of all power quantities measured associated to a time step, in output stream in human-readable manner, one line per time step, all power quantities of a time step in the same line, with a separator

Parameters:
streamOutput stream
lineline index, starting at 0, of the line to be written
separatorString to write between two power quantities shown in each output line
Returns:
Output stream after writing pwoer information
FILE* drake_platform_power_printf_line_cumulate ( FILE *  stream,
drake_power_t  ,
size_t  line,
int  metrics,
char *  separator 
)

Writes the sum of all power quantities measured associated to a time step, in output stream in human-readable manner, one line per time step, all power quantities of a time step in the same line, with a separator.

Parameters:
streamOutput stream
lineline index, starting at 0, of the line to be written
metricsPower quantities to be combined together, for instance 1 << DRAKE_POWER_CHIP | 1 << DRAKE_POWER_CORE
separatorString to write between two power quantities shown in each output line
Returns:
Output stream after writing pwoer information
void drake_platform_private_free ( void *  )

Free memory in off-chip private memory of the caller core

void* drake_platform_private_malloc ( size_t  size)

Allocate memory in off-chip private memory of the caller core

Returns the size in byte of the calling core's allocatable private on-chip memory

int drake_platform_pull ( volatile void *  addr)

Fetch data from the core corresponding to the memory address

int drake_platform_set_frequency ( int  frequency)

Set the frequency of the caller core

Parameters:
frequencyFrequency in KHz
Returns:
0 if frequency switching could not be performed

Sets the frequency of the caller core and scales voltage if necessary

Parameters:
frequencyFrequency in KHz
Returns:
0 if frequency switching could not be performed
int drake_platform_set_voltage ( float  voltage)

Sets the voltage of the caller core

Parameters:
voltageVoltage in Volts
Returns:
0 if voltage scaling could not be performed
int drake_platform_set_voltage_frequency ( drake_platform_t  ,
size_t  frequency 
)

Sets the frequency of the caller core and scales voltage if necessary

Parameters:
frequencyFrequency in KHz
Returns:
0 if frequency switching could not be performed

Returns the size of a memory line in shared memory

void drake_platform_shared_free ( volatile void *  addr,
size_t  core 
)

Deallocates the on-chip communication memory corresponding to the address given. Only the calling cores can see that the memory has been freed. Every core should run this function in the same order using the same parameter. Any implementation must be deterministic.

volatile void* drake_platform_shared_malloc ( size_t  size,
size_t  core 
)

Allocates on-chip communication memory for a given core. Memory allocated is only visible to the calling core. Every core should run this function in the same order using the same parameters. Any implementation must be deterministic.

Parameters:
sizeSice in byte of the memory to be allocated
coreid of the core for which to allocate memory
Returns:
A pointer to memory whose content is sent to corresponding core upon call to drake_platform_commit()
volatile void* drake_platform_shared_malloc_mailbox ( size_t  size,
size_t  core 
)

Returns the size in byte of the calling core's allocatable communication on-chip memory

Makes the caller core to sleep

Parameters:
periodsleep time in milliseconds
Returns:
0 if the core could not be put to sleep
void drake_platform_sleep_disable ( drake_platform_t  pt,
size_t  core 
)
void drake_platform_sleep_enable ( drake_platform_t  pt,
size_t  core 
)
void drake_platform_store_free ( void *  )

Frees on-chip private memory of the core that call this function

void* drake_platform_store_malloc ( size_t  size)

Allocates memory on on-chip private memory of the core that calls this function

int drake_platform_stream_create_explicit ( drake_platform_t  stream,
void(*)(drake_schedule_t *)  schedule_init,
void(*)(drake_schedule_t *)  schedule_destroy,
void *(*)(size_t id, task_status_t status)  task_function 
)
int drake_platform_stream_init ( drake_platform_t  stream,
void *  arg 
)

Adds two time quantities and stores the resutl in a time structure

Parameters:
resTime struction containing the result of t1 + t2
t1First operand of the time addition
t2Second operand of the time addition
Returns:
0 if addition could not be performed

Allocates a time structure

Cleans up and deallocates a time structure

Returns 0 if t1 != t2

Gives the current time in millisecond

Parameters:
timeAbstract type that receives the current time
Returns:
0 if the time could not be measured

Returns 0 if t1 <= t2

int drake_platform_time_init ( drake_time_t  t,
double  ms 
)

Inittializes a time structure

Parameters:
msTime in millisecond to initialize time structure with
FILE* drake_platform_time_printf ( FILE *  stream,
drake_time_t   
)

Writes time on output stream from time structure

Substract two time quantities and stores the result in a time structure

Parameters:
resTime structure containing the result of t1 - t2
t1First operand of time subtraction
t2Second operation of time subtraction
Returns:
0 if subtraction could not be performed
void* drake_remote_addr ( void *  addr,
size_t  core 
)

Returns the memory address in a distant core, that corresponds to an address of the caller core's local communication memory and that can be used to send messages

Parameters:
addrAddress of the caller core's local communication memory
coreCore id that can directly read of write in the memory address returned