![]() |
Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
|
#include "arax_data.h"
#include "arax_task.h"
#include "arax_data_private.h"
#include "arax_pipe.h"
#include "arax_ptr.h"
#include <string.h>
#include <stdlib.h>
#include "utils/system.h"
Go to the source code of this file.
Macros | |
#define | printd(...) |
#define | VDFLAG(DATA, FLAG) |
#define | VD_BUFF_OWNER(BUFF) |
#define | TYPE_MASK(A, B) |
#define printd | ( | ... | ) |
Definition at line 11 of file arax_data.c.
#define TYPE_MASK | ( | A, | |
B ) |
Definition at line 115 of file arax_data.c.
Referenced by arax_data_migrate_accel().
#define VD_BUFF_OWNER | ( | BUFF | ) |
Definition at line 14 of file arax_data.c.
Referenced by arax_data_ref().
#define VDFLAG | ( | DATA, | |
FLAG ) |
Definition at line 13 of file arax_data.c.
void arax_data_allocate_remote | ( | arax_data_s * | data, |
arax_accel * | accel ) |
Initialize data
remote (accelerator) buffer.
data | Arax data. |
Definition at line 162 of file arax_data.c.
References arax_data_s::accel, arax_accel_size_dec(), arax_assert, arax_assert_obj, arax_data_size(), arax_object_ref_inc(), arax_proc_get(), arax_task_free(), arax_task_issue(), arax_task_wait(), ARAX_THROTTLE_DEBUG_PRINT, ARAX_TYPE_DATA, ARAX_TYPE_VIRT_ACCEL, CPU, arax_data_s::remote, and task_completed.
void arax_data_arg_init | ( | arax_data_s * | data, |
arax_accel * | accel ) |
Definition at line 220 of file arax_data.c.
References arax_assert, arax_assert_obj, arax_data_migrate_accel(), and ARAX_TYPE_DATA.
void * arax_data_deref | ( | arax_data * | data | ) |
Get pointer to buffer for use from CPU.
data | Valid arax_data pointer. |
Definition at line 260 of file arax_data.c.
References arax_assert_obj, ARAX_THROTTLE_DEBUG_PRINT, ARAX_TYPE_DATA, and arax_data_s::buffer.
Referenced by arax_data_memcpy(), arax_data_ref_offset(), and arax_data_stat().
void arax_data_free | ( | arax_data * | data | ) |
Mark data
for deletion.
Definition at line 325 of file arax_data.c.
References arax_assert_obj, arax_object_ref_dec(), ARAX_TYPE_DATA, and arax_data_s::obj.
void arax_data_get | ( | arax_data * | data, |
void * | user ) |
Get the data of data
, and copy them to user
.
data | A valid arax_data_s instance. |
user | An allocated memory of at least arax_data_size() bytes. |
Definition at line 52 of file arax_data.c.
References arax_data_s::accel, arax_assert, arax_assert_obj, arax_data_size(), arax_proc_get(), arax_proc_put(), arax_task_free(), arax_task_host_data(), arax_task_issue(), arax_task_wait(), ARAX_TYPE_DATA, and task_completed.
Referenced by arax_data_memcpy().
int arax_data_has_remote | ( | arax_data * | data | ) |
Returns true if data
has been allocated on the remote accelerator.
data | Data to be queried. |
data
has a remote accelerator allocation, 0 otherwise. Definition at line 334 of file arax_data.c.
References arax_assert_obj, ARAX_TYPE_DATA, and arax_data_s::remote.
arax_data_s * arax_data_init | ( | arax_pipe_s * | vpipe, |
size_t | size ) |
Initialize a new arax_data_s object.
vpipe | Valid arax_pipe_s instance. |
size | Size of data in bytes. |
Definition at line 16 of file arax_data.c.
References arax_data_init_aligned(), and vpipe.
Referenced by ARAX_BUFFER().
arax_data_s * arax_data_init_aligned | ( | arax_pipe_s * | vpipe, |
size_t | size, | ||
size_t | align ) |
Initialize a new arax_data_s object, with an aligned buffer.
vpipe | Valid arax_pipe_s instance. |
size | Size of data in bytes. |
align | alignment of buffer in bytes, power of two. |
Definition at line 21 of file arax_data.c.
References arax_data_s::align, arax_assert, ARAX_BUFF_ALLOC_SIZE, arax_object_register(), ARAX_TYPE_DATA, arax_data_s::buffer, arax_data_s::flags, arax_data_s::phys, arax_data_s::size, and vpipe.
Referenced by arax_data_init().
void arax_data_input_init | ( | arax_data_s * | data, |
arax_accel * | accel ) |
Definition at line 229 of file arax_data.c.
References arax_assert, arax_assert_obj, arax_data_migrate_accel(), arax_object_ref_inc(), ARAX_TYPE_DATA, and arax_data_s::obj.
Referenced by arax_task_alloc().
void arax_data_memcpy | ( | arax_accel * | accel, |
arax_data_s * | dst, | ||
arax_data_s * | src, | ||
int | block ) |
Copy data of src
to dst
.
@Note src
and dst
must have the same size. @Note If src
and dst
are the same, function is no-op.
accel | Accelerator/fifo to use. |
dst | Destination buffer. |
src | Source buffer. |
block | If true function returns only when copy has completed. |
Definition at line 95 of file arax_data.c.
References arax_assert, arax_assert_obj, arax_data_deref(), arax_data_get(), arax_data_set(), arax_data_size(), ARAX_TYPE_DATA, and arax_data_s::flags.
void arax_data_migrate_accel | ( | arax_data_s * | data, |
arax_accel * | accel ) |
Migrate data
accelerator location to accel
.
\NOTE: Does not yet support migration across physical devices.
Definition at line 117 of file arax_data.c.
References arax_data_s::accel, arax_assert, arax_assert_obj, arax_object_ref_dec(), arax_object_ref_inc(), arax_object_type_to_str(), ARAX_TYPE_DATA, ARAX_TYPE_VIRT_ACCEL, arax_vaccel_s::phys, arax_data_s::remote, and TYPE_MASK.
Referenced by arax_data_arg_init(), arax_data_input_init(), and arax_data_output_init().
void arax_data_output_init | ( | arax_data_s * | data, |
arax_accel * | accel ) |
Definition at line 240 of file arax_data.c.
References arax_assert, arax_assert_obj, arax_data_migrate_accel(), arax_object_ref_inc(), ARAX_TYPE_DATA, and arax_data_s::obj.
Referenced by arax_task_alloc().
arax_data * arax_data_ref | ( | void * | data | ) |
Get pointer to arax_data object from related CPU buffer data
. Undefined behaviour if data
is not a value returned by arax_data_deref.
Definition at line 274 of file arax_data.c.
References arax_assert, arax_ptr_valid(), ARAX_TYPE_DATA, arax_data_s::obj, arax_object_s::type, and VD_BUFF_OWNER.
Referenced by arax_data_ref_offset().
arax_data * arax_data_ref_offset | ( | arax_pipe_s * | vpipe, |
void * | data ) |
Get pointer to arax_data object from data
that points 'inside' related CPU buffer .
Definition at line 295 of file arax_data.c.
References arax_assert, arax_data_deref(), arax_data_ref(), arax_data_size(), arax_object_list_lock(), arax_object_list_unlock(), arax_ptr_valid(), ARAX_TYPE_DATA, utils_list_node::owner, utils_list_for_each, and vpipe.
void arax_data_set | ( | arax_data * | data, |
arax_accel * | accel, | ||
const void * | user ) |
Copy data from user
to 'c data.
data | A valid arax_data_s instance. |
accel | Accelerator/fifo to use. |
user | An allocated memory of at least arax_data_size() bytes. |
Definition at line 75 of file arax_data.c.
References arax_data_s::accel, arax_assert, arax_assert_obj, arax_data_size(), arax_object_ref_inc(), arax_proc_get(), arax_proc_put(), arax_task_issue(), and ARAX_TYPE_DATA.
Referenced by arax_data_memcpy().
void arax_data_set_accel | ( | arax_data_s * | data, |
arax_accel * | accel ) |
Set accelerator to data and increment reference counters.
data | A valid arax_data_s instance. |
accel | Accelerator/fifo to use. |
Definition at line 195 of file arax_data.c.
References arax_data_s::accel, arax_assert_obj, arax_object_ref_inc(), ARAX_TYPE_DATA, and ARAX_TYPE_VIRT_ACCEL.
void arax_data_set_remote | ( | arax_data_s * | data, |
arax_accel * | accel, | ||
void * | remt ) |
Set data
remote (accelerator) buffer to point to remt
, owned by accel
.
data | Arax data. |
Definition at line 206 of file arax_data.c.
References arax_data_s::accel, arax_assert, arax_assert_obj, arax_object_ref_inc(), ARAX_TYPE_DATA, ARAX_TYPE_VIRT_ACCEL, CPU, arax_data_s::flags, OTHR_REMT, and arax_data_s::remote.
size_t arax_data_size | ( | arax_data * | data | ) |
Return size of provided arax_data object.
data | Valid arax_data pointer. |
Definition at line 251 of file arax_data.c.
References arax_assert_obj, ARAX_TYPE_DATA, and arax_data_s::size.
Referenced by arax_data_allocate_remote(), arax_data_get(), arax_data_memcpy(), arax_data_ref_offset(), arax_data_set(), arax_data_stat(), and ARAX_OBJ_DTOR_DECL().
void arax_data_stat | ( | arax_data * | data, |
const char * | file, | ||
size_t | line ) |
Print debug info for 'c data.
Definition at line 346 of file arax_data.c.
References arax_assert_obj, arax_data_deref(), arax_data_size(), ARAX_TYPE_DATA, arax_data_s::flags, and OTHR_REMT.
ARAX_OBJ_DTOR_DECL | ( | arax_data_s | ) |
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.