Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
arax_object.c File Reference
#include "arax_object.h"
#include "arax_pipe.h"
#include "arax_accel.h"
#include "arax_proc.h"
#include "arax_task.h"
#include "arax_data.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
+ Include dependency graph for arax_object.c:

Go to the source code of this file.

Data Structures

union  arax_object_union
 

Macros

#define PRINT_REFS(OBJ, DELTA)
 

Typedefs

typedef void(* arax_object_dtor) (arax_pipe_s *pipe, arax_object_s *obj)
 

Functions

 ARAX_OBJ_DTOR_DECL (arax_accel_s)
 
 ARAX_OBJ_DTOR_DECL (arax_vaccel_s)
 
 ARAX_OBJ_DTOR_DECL (arax_proc_s)
 
 ARAX_OBJ_DTOR_DECL (arax_task_msg_s)
 
 ARAX_OBJ_DTOR_DECL (arax_data_s)
 
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)
 

Variables

static const char * type2str [ARAX_TYPE_COUNT]
 
static const arax_object_dtor dtor_table [ARAX_TYPE_COUNT]
 

Macro Definition Documentation

◆ PRINT_REFS

#define PRINT_REFS ( OBJ,
DELTA )

Definition at line 38 of file arax_object.c.

Referenced by arax_object_ref_dec(), and arax_object_ref_inc().

Typedef Documentation

◆ arax_object_dtor

typedef void(* arax_object_dtor) (arax_pipe_s *pipe, arax_object_s *obj)

Definition at line 43 of file arax_object.c.

Function Documentation

◆ ARAX_OBJ_DTOR_DECL() [1/5]

ARAX_OBJ_DTOR_DECL ( arax_accel_s )
extern

Definition at line 180 of file arax_accel.c.

References arax_accel_release(), arax_assert, arax_assert_obj, ARAX_TYPE_PHYS_ACCEL, async_condition_lock(), async_condition_unlock(), arax_accel_s::free_vaq, utils_list_s::length, arax_accel_s::lock, arax_object_s::name, arax_accel_s::obj, and arax_accel_s::vaccels.

+ Here is the call graph for this function:

◆ ARAX_OBJ_DTOR_DECL() [2/5]

ARAX_OBJ_DTOR_DECL ( arax_data_s )
extern

Definition at line 373 of file arax_data.c.

References arax_data_s::accel, arax_assert, arax_assert_obj, arax_data_size(), arax_object_ref_dec(), arax_proc_get(), arax_task_issue(), ARAX_THROTTLE_DEBUG_PRINT, ARAX_TYPE_COUNT, ARAX_TYPE_DATA, ARAX_TYPE_VIRT_ACCEL, arax_data_s::flags, arax_accel_s::free_vaq, OTHR_REMT, arax_data_s::phys, arax_data_s::remote, and arax_data_s::size.

+ Here is the call graph for this function:

◆ ARAX_OBJ_DTOR_DECL() [3/5]

ARAX_OBJ_DTOR_DECL ( arax_proc_s )
extern

Definition at line 41 of file arax_proc.c.

◆ ARAX_OBJ_DTOR_DECL() [4/5]

ARAX_OBJ_DTOR_DECL ( arax_task_msg_s )
extern

Definition at line 89 of file arax_task.c.

References arax_task_msg::accel, arax_object_ref_dec(), arax_task_msg::in_count, arax_task_msg::io, and arax_task_msg::out_count.

+ Here is the call graph for this function:

◆ ARAX_OBJ_DTOR_DECL() [5/5]

ARAX_OBJ_DTOR_DECL ( arax_vaccel_s )
extern

Definition at line 113 of file arax_vaccel.c.

References arax_accel_del_vaccel(), arax_assert_obj, arax_pipe_remove_orphan_vaccel(), ARAX_TYPE_VIRT_ACCEL, and arax_vaccel_s::phys.

+ Here is the call graph for this function:

◆ 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:

Variable Documentation

◆ dtor_table

◆ type2str

const char* type2str[ARAX_TYPE_COUNT]
static
Initial value:
= {
"Phys.Accel",
"Virt.Accel",
"Procedures",
"Arax--Data",
"Arax-Tasks",
}

Definition at line 11 of file arax_object.c.

Referenced by arax_object_repo_exit(), and arax_object_type_to_str().