Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
arax_pipe.h File Reference
#include <arax.h>
#include <utils/Kv.h>
#include "utils/queue.h"
#include "core/arax_accel.h"
#include "core/arax_task.h"
+ Include dependency graph for arax_pipe.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arax_process_tracker_s
 
struct  arax_pipe
 

Macros

#define ARAX_PIPE_SHA_SIZE   48
 
#define ARAX_PIPE_THOTTLE_DEBUG_PARAMS
 
#define ARAX_PIPE_THOTTLE_DEBUG_FUNC(FUNC)
 
#define pointer_to_offset(TYPE, BASE, VD)
 
#define offset_to_pointer(TYPE, BASE, VD)
 

Typedefs

typedef struct arax_pipe arax_pipe_s
 

Functions

arax_pipe_sarax_controller_init_start ()
 
void arax_controller_init_done ()
 
const char * arax_pipe_get_revision (arax_pipe_s *pipe)
 
void arax_pipe_add_orphan_vaccel (arax_pipe_s *pipe, arax_vaccel_s *vac)
 
int arax_pipe_have_orphan_vaccels (arax_pipe_s *pipe)
 
arax_vaccel_sarax_pipe_get_orphan_vaccel (arax_pipe_s *pipe)
 
void arax_pipe_remove_orphan_vaccel (arax_pipe_s *pipe, arax_vaccel_s *vac)
 
void arax_pipe_orphan_stop (arax_pipe_s *pipe)
 
uint64_t arax_pipe_add_process (arax_pipe_s *pipe)
 
uint64_t arax_pipe_del_process (arax_pipe_s *pipe)
 
int arax_pipe_have_to_mmap (arax_pipe_s *pipe, int pid)
 
void arax_pipe_mark_unmap (arax_pipe_s *pipe, int pid)
 
void * arax_pipe_mmap_address (arax_pipe_s *pipe)
 
arax_pipe_sarax_pipe_init (void *mem, size_t size, int enforce_version)
 
int arax_pipe_delete_accel (arax_pipe_s *pipe, arax_accel_s *accel)
 
arax_accel_sarax_pipe_find_accel (arax_pipe_s *pipe, const char *name, arax_accel_type_e type)
 
arax_proc_sarax_pipe_find_proc (arax_pipe_s *pipe, const char *name)
 
int arax_pipe_exit (arax_pipe_s *pipe)
 
void ARAX_PIPE_THOTTLE_DEBUG_FUNC arax_pipe_size_inc (arax_pipe_s *pipe, size_t sz ARAX_PIPE_THOTTLE_DEBUG_PARAMS)
 
void ARAX_PIPE_THOTTLE_DEBUG_FUNC arax_pipe_size_dec (arax_pipe_s *pipe, size_t sz ARAX_PIPE_THOTTLE_DEBUG_PARAMS)
 
size_t arax_pipe_get_available_size (arax_pipe_s *pipe)
 
size_t arax_pipe_get_total_size (arax_pipe_s *pipe)
 

Macro Definition Documentation

◆ ARAX_PIPE_SHA_SIZE

#define ARAX_PIPE_SHA_SIZE   48

Definition at line 19 of file arax_pipe.h.

Referenced by arax_pipe_init().

◆ ARAX_PIPE_THOTTLE_DEBUG_FUNC

#define ARAX_PIPE_THOTTLE_DEBUG_FUNC ( FUNC)
Value:
FUNC

Definition at line 218 of file arax_pipe.h.

◆ ARAX_PIPE_THOTTLE_DEBUG_PARAMS

#define ARAX_PIPE_THOTTLE_DEBUG_PARAMS

Definition at line 217 of file arax_pipe.h.

Referenced by arax_pipe_size_dec(), and arax_pipe_size_inc().

◆ offset_to_pointer

#define offset_to_pointer ( TYPE,
BASE,
VD )
Value:
( (TYPE) VD )

Definition at line 262 of file arax_pipe.h.

◆ pointer_to_offset

#define pointer_to_offset ( TYPE,
BASE,
VD )
Value:
( (TYPE) VD )

Definition at line 261 of file arax_pipe.h.

Typedef Documentation

◆ arax_pipe_s

typedef struct arax_pipe arax_pipe_s

Shared Memory segment layout

Arax Pipe instance

Function Documentation

◆ arax_controller_init_done()

void arax_controller_init_done ( )

Should only be called by the controller process, after it is ready to recieve tasks. See arax_controller_init_start().

Definition at line 143 of file impl.c.

References arax_state, and async_condition_notify().

+ Here is the call graph for this function:

◆ arax_controller_init_start()

arax_pipe_s * arax_controller_init_start ( )

Similar to arax_init().

As this should be called only by the controller, prior to any other Arax function.

After the controller process is initialized and ready to recieve tasks arax_controller_init_done should be called.

Definition at line 138 of file impl.c.

References _arax_init().

+ Here is the call graph for this function:

◆ arax_pipe_add_orphan_vaccel()

void arax_pipe_add_orphan_vaccel ( arax_pipe_s * pipe,
arax_vaccel_s * vac )

Add vac to the list of orphan_vacs/ unassigned accels.

Parameters
pipearax_pipe instance.
vacUnassigned/Orphan Virtual Acceleator instance.

Definition at line 63 of file arax_pipe.c.

References arax_assert, arax_assert_obj, ARAX_TYPE_VIRT_ACCEL, async_condition_lock(), async_condition_notify(), async_condition_unlock(), arax_pipe::orphan_cond, arax_pipe::orphan_vacs, arax_vaccel_s::phys, utils_list_add(), and arax_vaccel_s::vaccels.

Referenced by arax_vaccel_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_add_process()

uint64_t arax_pipe_add_process ( arax_pipe_s * pipe)

Increase process counter for pipe.

Parameters
pipearax_pipe instance.
Returns
Number of active processes before adding issuer.

Definition at line 116 of file arax_pipe.c.

References arax_pipe::processes.

Referenced by arax_pipe_init().

+ Here is the caller graph for this function:

◆ arax_pipe_del_process()

uint64_t arax_pipe_del_process ( arax_pipe_s * pipe)

Decrease process counter for pipe.

Parameters
pipearax_pipe instance.
Returns
Number of active processes before removing issuer.

Definition at line 121 of file arax_pipe.c.

References arax_pipe::processes.

Referenced by arax_pipe_exit().

+ Here is the caller graph for this function:

◆ arax_pipe_delete_accel()

int arax_pipe_delete_accel ( arax_pipe_s * pipe,
arax_accel_s * accel )

Remove accel from the pipe accelerator list.

Parameters
pipeThe pipe instance where the accelerator belongs.
accelThe accelerator to be removed.
Returns
Returns 0 on success.

Definition at line 175 of file arax_pipe.c.

References arax_object_list_lock(), arax_object_list_unlock(), arax_object_ref_dec(), ARAX_TYPE_PHYS_ACCEL, arax_accel_s::obj, arax_pipe::objs, utils_list_node::owner, and utils_list_for_each.

+ Here is the call graph for this function:

◆ arax_pipe_exit()

int arax_pipe_exit ( arax_pipe_s * pipe)

Destroy arax_pipe.

Note
Ensure you perform any cleanup(e.g. delete shared segment) when return value becomes 0.
Parameters
pipearax_pipe instance to be destroyed.
Returns
Number of remaining users of this shared segment.

Destroy arax_pipe.

Definition at line 241 of file arax_pipe.c.

References arax_pipe::allocator, arax_object_repo_exit(), arax_pipe_del_process(), arch_alloc_exit(), arax_pipe::async, async_meta_exit(), and arax_pipe::objs.

Referenced by arax_exit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_find_accel()

arax_accel_s * arax_pipe_find_accel ( arax_pipe_s * pipe,
const char * name,
arax_accel_type_e type )

Find an accelerator matching the user specified criteria.

Parameters
pipearax_pipe instance.
nameThe cstring name of the accelerator, \ NULL if we dont care for the name.
typeType of the accelerator, see arax_accel_type_e.
Returns
An arax_accel_s instance, NULL on failure.

Definition at line 194 of file arax_pipe.c.

References arax_accel_get_name(), arax_object_list_lock(), arax_object_list_unlock(), ARAX_TYPE_PHYS_ACCEL, arax_pipe::objs, utils_list_node::owner, arax_accel_s::type, and utils_list_for_each.

+ Here is the call graph for this function:

◆ arax_pipe_find_proc()

arax_proc_s * arax_pipe_find_proc ( arax_pipe_s * pipe,
const char * name )

Find a procedure matching the user specified criteria.

Parameters
pipearax_pipe instance.
nameThe cstring name of the procedure.
Returns
An arax_proc_s instance, NULL on failure.

Definition at line 219 of file arax_pipe.c.

References arax_object_list_lock(), arax_object_list_unlock(), ARAX_TYPE_PROC, arax_object_s::name, arax_proc_s::obj, arax_pipe::objs, utils_list_node::owner, and utils_list_for_each.

Referenced by arax_proc_get(), and arax_proc_register().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_get_available_size()

size_t arax_pipe_get_available_size ( arax_pipe_s * pipe)

Gets available size of shm

Parameters
pipepipe for shm
Returns
Avaliable size of shm

Definition at line 265 of file arax_pipe.c.

References arax_assert, arax_throttle_get_available_size(), and arax_pipe::throttle.

Referenced by _arax_init(), and arax_exit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_get_orphan_vaccel()

arax_vaccel_s * arax_pipe_get_orphan_vaccel ( arax_pipe_s * pipe)

Return an orphan/unassigned virtual accelerator or null. Function will sleep if no orphans exist at the time of the call. Returned arax_vaccel_s should either be assigned to a arax_accel_s using arax_accel_add_vaccel(), or should be marked again as orphan using arax_pipe_add_orphan_vaccel().

Returns
Unassigned/Orphan Virtual Acceleator instance.

Definition at line 78 of file arax_pipe.c.

References arax_assert, arax_assert_obj, arax_pipe_have_orphan_vaccels(), ARAX_TYPE_VIRT_ACCEL, async_condition_lock(), async_condition_unlock(), async_condition_wait(), arax_pipe::orphan_cond, arax_pipe::orphan_vacs, utils_list_node::owner, arax_vaccel_s::phys, and utils_list_pop_head().

+ Here is the call graph for this function:

◆ arax_pipe_get_revision()

const char * arax_pipe_get_revision ( arax_pipe_s * pipe)

Get Arax revision

Parameters
pipearax_pipe instance.
Returns
const string with Arax revision.

Definition at line 58 of file arax_pipe.c.

References arax_pipe::sha.

◆ arax_pipe_get_total_size()

size_t arax_pipe_get_total_size ( arax_pipe_s * pipe)

Gets available total size of shm

Parameters
pipepipe for shm
Returns
Total size of shm

Definition at line 271 of file arax_pipe.c.

References arax_assert, arax_throttle_get_total_size(), and arax_pipe::throttle.

+ Here is the call graph for this function:

◆ arax_pipe_have_orphan_vaccels()

int arax_pipe_have_orphan_vaccels ( arax_pipe_s * pipe)

Will return != 0 if there are orphan vaccels.

@Note: This function may return old values.

Parameters
pipearax_pipe instance.
Returns
0 if no orphans, may return any non zero value if orphans exist

Definition at line 73 of file arax_pipe.c.

References utils_list_s::length, and arax_pipe::orphan_vacs.

Referenced by arax_pipe_get_orphan_vaccel().

+ Here is the caller graph for this function:

◆ arax_pipe_have_to_mmap()

int arax_pipe_have_to_mmap ( arax_pipe_s * pipe,
int pid )

Return if we have to mmap, for the given pid. This will return 1, only the first time it is callled with a specific pid.

Definition at line 126 of file arax_pipe.c.

References arax_assert, arax_pipe::proc_lock, arax_pipe::proc_map, utils_spinlock_lock, and utils_spinlock_unlock.

Referenced by _arax_init().

+ Here is the caller graph for this function:

◆ arax_pipe_init()

arax_pipe_s * arax_pipe_init ( void * mem,
size_t size,
int enforce_version )

Initialize a arax_pipe.

Note
This function must be called from all end points in order to initialize a arax_pipe instance.Concurrent issuers will be serialized and the returned arax_pipe instance will be initialized by the 'first' issuer. All subsequent issuers will receive the already initialized instance.
Parameters
memShared memory pointer.
sizeSize of the shared memory in bytes.
enforce_versionSet to 0 to make version mismatch non fatal.
Returns
An initialized arax_pipe_s instance.

Write sha sum except first byte

Definition at line 5 of file arax_pipe.c.

References arax_pipe::allocator, arax_object_repo_init(), arax_pipe_add_process(), ARAX_PIPE_SHA_SIZE, arax_throttle_init(), arch_alloc_init_always(), arch_alloc_init_once(), arax_pipe::ass_kv, arax_pipe::async, async_condition_init(), async_meta_init_once(), arax_pipe::cntrl_ready_cond, arax_pipe::metrics_kv, arax_pipe::objs, arax_pipe::orphan_cond, arax_pipe::orphan_vacs, arax_pipe::sha, arax_pipe::shm_size, arax_pipe::throttle, utils_kv_init(), and utils_list_init().

Referenced by _arax_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_mark_unmap()

void arax_pipe_mark_unmap ( arax_pipe_s * pipe,
int pid )

This should be called after munmap'ing pipe, in pid process.

Definition at line 148 of file arax_pipe.c.

References arax_assert, arax_pipe::proc_lock, arax_pipe::proc_map, utils_spinlock_lock, and utils_spinlock_unlock.

Referenced by arax_exit().

+ Here is the caller graph for this function:

◆ arax_pipe_mmap_address()

void * arax_pipe_mmap_address ( arax_pipe_s * pipe)

Return (and set if needed) the mmap location for pipe.

Parameters
pipearax_pipe instance.

Definition at line 165 of file arax_pipe.c.

References arax_pipe::self.

Referenced by _arax_init().

+ Here is the caller graph for this function:

◆ arax_pipe_orphan_stop()

void arax_pipe_orphan_stop ( arax_pipe_s * pipe)

This will return null to a blocked caller thread of arax_pipe_get_orphan_vaccel(). That should be used to signal thread termination.

This function should be called once for every thread using arax_pipe_get_orphan_vaccel().

Parameters
pipearax_pipe instance.

Definition at line 109 of file arax_pipe.c.

References async_condition_lock(), async_condition_notify(), async_condition_unlock(), and arax_pipe::orphan_cond.

+ Here is the call graph for this function:

◆ arax_pipe_remove_orphan_vaccel()

void arax_pipe_remove_orphan_vaccel ( arax_pipe_s * pipe,
arax_vaccel_s * vac )

Remove specific vac for list of orphan vacs.

Definition at line 100 of file arax_pipe.c.

References arax_assert_obj, ARAX_TYPE_VIRT_ACCEL, async_condition_lock(), async_condition_unlock(), arax_pipe::orphan_cond, arax_pipe::orphan_vacs, utils_list_del(), utils_list_node_linked(), and arax_vaccel_s::vaccels.

Referenced by arax_accel_add_vaccel(), and ARAX_OBJ_DTOR_DECL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_size_dec()

void ARAX_PIPE_THOTTLE_DEBUG_FUNC arax_pipe_size_dec ( arax_pipe_s * pipe,
size_t sz ARAX_PIPE_THOTTLE_DEBUG_PARAMS )

Decrements available size of gpu by sz

Parameters
pipepipe for shm
szsize of removed data
Returns
Nothing .

Definition at line 259 of file arax_pipe.c.

References arax_assert, arax_pipe_size_dec(), ARAX_PIPE_THOTTLE_DEBUG_PARAMS, and arax_throttle_size_dec().

Referenced by arax_object_register(), and arax_pipe_size_dec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arax_pipe_size_inc()

void ARAX_PIPE_THOTTLE_DEBUG_FUNC arax_pipe_size_inc ( arax_pipe_s * pipe,
size_t sz ARAX_PIPE_THOTTLE_DEBUG_PARAMS )

Increments available size of gpu by sz

Parameters
pipepipe for shm
szSize of added data
Returns
Nothing .

Definition at line 253 of file arax_pipe.c.

References arax_assert, arax_pipe_size_inc(), ARAX_PIPE_THOTTLE_DEBUG_PARAMS, and arax_throttle_size_inc().

Referenced by arax_object_ref_dec(), arax_object_ref_dec_pre_locked(), and arax_pipe_size_inc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: