Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
arax_object.h File Reference
#include "utils/list.h"
#include "utils/spinlock.h"
#include "arch/alloc.h"
+ Include dependency graph for arax_object.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arax_object_repo_s
 
struct  arax_object_s
 

Macros

#define ARAX_OBJ_DTOR_DECL(TYPE)
 
#define ARAX_OBJ_DTOR_USE(TYPE)
 

Typedefs

typedef enum arax_object_type arax_object_type_e
 

Enumerations

enum  arax_object_type {
  ARAX_TYPE_PHYS_ACCEL , ARAX_TYPE_VIRT_ACCEL , ARAX_TYPE_PROC , ARAX_TYPE_DATA ,
  ARAX_TYPE_TASK , ARAX_TYPE_COUNT
}
 

Functions

void arax_object_repo_init (arax_object_repo_s *repo, arax_pipe_s *pipe)
 
int arax_object_repo_exit (arax_object_repo_s *repo)
 
const char * arax_object_type_to_str (arax_object_type_e type)
 
arax_object_sarax_object_register (arax_object_repo_s *repo, arax_object_type_e type, const char *name, size_t size, const int ref_count)
 
void arax_object_rename (arax_object_s *obj, const char *fmt,...)
 
void arax_object_ref_inc (arax_object_s *obj)
 
int arax_object_ref_dec (arax_object_s *obj)
 
int arax_object_ref_dec_pre_locked (arax_object_s *obj)
 
int arax_object_refs (arax_object_s *obj)
 
utils_list_sarax_object_list_lock (arax_object_repo_s *repo, arax_object_type_e type)
 
void arax_object_list_unlock (arax_object_repo_s *repo, arax_object_type_e type)
 

Macro Definition Documentation

◆ ARAX_OBJ_DTOR_DECL

#define ARAX_OBJ_DTOR_DECL ( TYPE)
Value:
void __dtor_ ## TYPE(arax_pipe_s * pipe, arax_object_s * obj)
struct arax_pipe arax_pipe_s

Definition at line 152 of file arax_object.h.

◆ ARAX_OBJ_DTOR_USE

#define ARAX_OBJ_DTOR_USE ( TYPE)
Value:
__dtor_ ## TYPE

Definition at line 153 of file arax_object.h.

Typedef Documentation

◆ arax_object_type_e

Enumeration with available Arax Object Types.

Enumeration Type Documentation

◆ arax_object_type

Enumeration with available Arax Object Types.

Enumerator
ARAX_TYPE_PHYS_ACCEL 
ARAX_TYPE_VIRT_ACCEL 
ARAX_TYPE_PROC 
ARAX_TYPE_DATA 
ARAX_TYPE_TASK 
ARAX_TYPE_COUNT 

Definition at line 14 of file arax_object.h.

Function Documentation

◆ arax_object_list_lock()

utils_list_s * arax_object_list_lock ( arax_object_repo_s * repo,
arax_object_type_e type )

Get a locked utils_list_s for traversing all objects of type.

Parameters
repoA valid arax_object_repo_s instance.
typeType of objects contained in list.

Definition at line 248 of file arax_object.c.

References arax_object_repo_s::list, arax_object_repo_s::lock, arax_object_repo_s::repo, and utils_spinlock_lock.

Referenced by arax_accel_list(), arax_data_ref_offset(), arax_pipe_delete_accel(), arax_pipe_find_accel(), and arax_pipe_find_proc().

+ Here is the caller graph for this function:

◆ arax_object_list_unlock()

void arax_object_list_unlock ( arax_object_repo_s * repo,
arax_object_type_e type )

Unlock previously locked list. Parameters should be the same with the previous arax_object_list_locked() invocation.

Parameters
repoA valid arax_object_repo_s instance.
typeType of objects contained in list.

Definition at line 255 of file arax_object.c.

References arax_object_repo_s::lock, arax_object_repo_s::repo, and utils_spinlock_unlock.

Referenced by arax_accel_list(), arax_data_ref_offset(), arax_pipe_delete_accel(), arax_pipe_find_accel(), and arax_pipe_find_proc().

+ Here is the caller graph for this function:

◆ arax_object_ref_dec()

int arax_object_ref_dec ( arax_object_s * obj)

Decrease reference count of obj.

Parameters
objA valid arax_object_s instance.
Returns
Reference count after decreasing, 0 means object was reclaimed

Definition at line 161 of file arax_object.c.

References arax_object_s::alloc_size, arax_pipe::allocator, arax_assert, arax_pipe_size_inc(), ARAX_TYPE_COUNT, arch_alloc_free, dtor_table, arax_object_repo_s::list, arax_object_s::list, arax_object_repo_s::lock, arax_object_s::name, arax_object_repo_s::pipe, PRINT_REFS, arax_object_s::ref_count, arax_object_repo_s::repo, arax_object_s::repo, arax_object_s::type, utils_list_del(), utils_spinlock_lock, and utils_spinlock_unlock.

Referenced by arax_accel_list_free(), arax_accel_release(), arax_data_free(), arax_data_migrate_accel(), ARAX_OBJ_DTOR_DECL(), ARAX_OBJ_DTOR_DECL(), arax_pipe_delete_accel(), arax_proc_put(), and arax_task_free().

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

◆ arax_object_ref_dec_pre_locked()

int arax_object_ref_dec_pre_locked ( arax_object_s * obj)

Decrease reference count of obj.

Note
Assumes object repo lock is held.
Parameters
objA valid arax_object_s instance.
Returns
Reference count after decreasing, 0 means object was reclaimed

Definition at line 211 of file arax_object.c.

References arax_object_s::alloc_size, arax_pipe::allocator, arax_assert, arax_pipe_size_inc(), arch_alloc_free, dtor_table, arax_object_repo_s::list, arax_object_s::list, arax_object_s::name, arax_object_repo_s::pipe, arax_object_s::ref_count, arax_object_repo_s::repo, arax_object_s::repo, arax_object_s::type, and utils_list_del().

Referenced by arax_accel_list_free_pre_locked().

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

◆ arax_object_ref_inc()

void arax_object_ref_inc ( arax_object_s * obj)

Increase reference count of obj.

Parameters
objA valid arax_object_s instance.

Definition at line 145 of file arax_object.c.

References arax_assert, ARAX_TYPE_COUNT, PRINT_REFS, arax_object_s::ref_count, and arax_object_s::type.

Referenced by arax_accel_list(), arax_data_allocate_remote(), arax_data_input_init(), arax_data_migrate_accel(), arax_data_output_init(), arax_data_set(), arax_data_set_accel(), arax_data_set_remote(), arax_proc_get(), and arax_task_submit().

+ Here is the caller graph for this function:

◆ arax_object_refs()

int arax_object_refs ( arax_object_s * obj)

Returns obj current reference count.

Parameters
objA valid arax_object_s instance.

Definition at line 237 of file arax_object.c.

References arax_object_s::ref_count.

◆ arax_object_register()

arax_object_s * arax_object_register ( arax_object_repo_s * repo,
arax_object_type_e type,
const char * name,
size_t size,
const int ref_count )

Arax Object 'Constructor'

Register obj at repo.

Note: Sets reference count to 1

Parameters
repoA valid arax_object_repo_s instance.
typeType of the new arax_object.
nameThe name on the new arax_object.
sizeThe size of the new object (sizeof(struct)).
ref_countInitialize ref count

Definition at line 98 of file arax_object.c.

References arax_object_s::alloc_size, arax_pipe::allocator, arax_pipe_size_dec(), arch_alloc_allocate(), arax_object_repo_s::list, arax_object_s::list, arax_object_repo_s::lock, arax_object_s::name, arax_object_repo_s::pipe, arax_object_s::ref_count, arax_object_repo_s::repo, arax_object_s::repo, arax_object_s::type, utils_list_add(), utils_list_node_init(), utils_spinlock_lock, and utils_spinlock_unlock.

Referenced by arax_accel_init(), arax_data_init_aligned(), arax_proc_init(), arax_task_alloc(), and arax_vaccel_init().

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

◆ arax_object_rename()

void arax_object_rename ( arax_object_s * obj,
const char * fmt,
... )

Change name of obj to printf like format fmt

Parameters
objA valid arax_object_s instance.
fmtprintf style format string
...Args matching fmt

Definition at line 128 of file arax_object.c.

References arax_pipe::allocator, arch_alloc_allocate(), arch_alloc_free, arax_object_s::name, arax_object_repo_s::pipe, and arax_object_s::repo.

+ Here is the call graph for this function:

◆ arax_object_repo_exit()

int arax_object_repo_exit ( arax_object_repo_s * repo)

Perform cleanup and exit time checks.

Prints on stderr, the Objects still registered and thus considered as leaks.

Parameters
repoA valid arax_object_repo_s instance.
Returns
Number of 'leaked' Arax Objects.

Definition at line 71 of file arax_object.c.

References ARAX_TYPE_COUNT, utils_list_s::length, arax_object_repo_s::list, arax_object_repo_s::repo, and type2str.

Referenced by arax_pipe_exit().

+ Here is the caller graph for this function:

◆ arax_object_repo_init()

void arax_object_repo_init ( arax_object_repo_s * repo,
arax_pipe_s * pipe )

Initialize an arax_object_repo_s instance on allocated pointer repo.

Parameters
repoAn at least sizeof(arax_object_repo_s) big buffer.
pipearax_pipe_s owning all objects.

Definition at line 60 of file arax_object.c.

References ARAX_TYPE_COUNT, arax_object_repo_s::list, arax_object_repo_s::lock, arax_object_repo_s::pipe, arax_object_repo_s::repo, utils_list_init(), and utils_spinlock_init.

Referenced by arax_pipe_init().

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

◆ arax_object_type_to_str()

const char * arax_object_type_to_str ( arax_object_type_e type)

Convert a arax_object_type_e value to a human readable string. If type is not a valid arax_object_type_e, then NULL is returned.

Returns
Returns the string representation of type

Definition at line 90 of file arax_object.c.

References ARAX_TYPE_COUNT, and type2str.

Referenced by arax_data_migrate_accel().

+ Here is the caller graph for this function: