10 #ifndef ARAMID_ARAMID_H 11 #define ARAMID_ARAMID_H 22 #define ARMD_EXTERN_C extern "C" 64 typedef void *(*ARMD_MemoryAllocatorAllocateFunc)(
void *context,
246 void *callback_context,
int has_error);
257 void *callback_context,
311 ARMD_ContinuationResult_Error,
312 ARMD_ContinuationResult_Ended,
313 ARMD_ContinuationResult_Repeat,
323 ARMD_Job *job,
const void *constants,
void *args,
void *frame,
324 const void *continuation_constants,
void *continuation_frame);
330 ARMD_Job *job,
const void *constants,
void *args,
void *frame,
331 const void *continuation_constants,
void *continuation_frame);
345 typedef void *(*ARMD_ContinuationFrameCreator)(
363 void *args,
void *frame);
377 const void *constants,
378 void *args,
void *frame,
393 const void *constants,
394 void *args,
void *frame,
404 void *args,
void *frame,
405 int dependency_has_error);
414 void *args,
void *frame);
550 typedef enum TAG_ARMD_LogLevel {
559 typedef struct TAG_ARMD_Logger ARMD_Logger;
564 const char *filename;
569 typedef void (*ARMD_LoggerCallbackFunc)(
void *
context, ARMD_Logger *logger);
572 ARMD_LogLevel level);
573 ARMD_EXTERN_C
void armd_logger_increment_reference_count(ARMD_Logger *logger);
575 armd_logger_decrement_reference_count(ARMD_Logger *logger);
578 armd_logger_set_callback(ARMD_Logger *logger,
579 ARMD_LoggerCallbackFunc callback_func,
580 void *callback_context);
581 ARMD_EXTERN_C
void armd_logger_set_stdout_callback(ARMD_Logger *logger);
582 ARMD_EXTERN_C
void armd_logger_set_stderr_callback(ARMD_Logger *logger);
585 armd_logger_get_memory_region(ARMD_Logger *logger);
586 ARMD_EXTERN_C
int armd_logger_get_log_element(ARMD_Logger *logger,
589 armd_logger_destroy_log_element(ARMD_Logger *logger,
593 void armd_logger_log_string(ARMD_Logger *logger, ARMD_LogLevel level,
597 #if defined(__GNUC__) || defined(__clang__) 598 #define ARMD_LOGGER_LOG_FORMAT_ATTRIBUTE __attribute__((format(printf, 5, 6))) 600 #define ARMD_LOGGER_LOG_FORMAT_ATTRIBUTE 604 void armd_logger_log_format(ARMD_Logger *logger, ARMD_LogLevel level,
607 ...) ARMD_LOGGER_LOG_FORMAT_ATTRIBUTE;
609 #undef ARMD_LOGGER_LOG_FORMAT_ATTRIBUTE 611 #define armd_log_fatal(logger, format, ...) \ 612 armd_logger_log_format(logger, ARMD_LogLevel_Fatal, __FILE__, __LINE__, \ 615 #define armd_log_error(logger, format, ...) \ 616 armd_logger_log_format(logger, ARMD_LogLevel_Error, __FILE__, __LINE__, \ 619 #define armd_log_warn(logger, format, ...) \ 620 armd_logger_log_format(logger, ARMD_LogLevel_Warn, __FILE__, __LINE__, \ 623 #define armd_log_info(logger, format, ...) \ 624 armd_logger_log_format(logger, ARMD_LogLevel_Info, __FILE__, __LINE__, \ 627 #define armd_log_debug(logger, format, ...) \ 628 armd_logger_log_format(logger, ARMD_LogLevel_Debug, __FILE__, __LINE__, \ 631 #define armd_log_trace(logger, format, ...) \ 632 armd_logger_log_format(logger, ARMD_LogLevel_Trace, __FILE__, __LINE__, \ void(* ARMD_PromiseCallbackFunc)(ARMD_Handle handle, void *callback_context, int has_error)
Promise callback.
Definition: aramid.h:245
ARMD_MemoryAllocatorAllocateFunc allocate
Memory allocation function.
Definition: aramid.h:92
int(* ARMD_SequentialForContinuationFunc)(ARMD_Job *job, const void *constants, void *args, void *frame, ARMD_Size index)
Sequential-For Continuation Function.
Definition: aramid.h:376
struct TAG_ARMD_MemoryAllocator ARMD_MemoryAllocator
Abstract memory allocator.
ARMD_EXTERN_C void armd_memory_region_free(ARMD_MemoryRegion *memory_region, void *buf)
Free memory area allocated with ARMD_MemoryRegion.
ARMD_ContinuationResult(* ARMD_ErrorTrapFunc)(ARMD_Job *job, const void *constants, void *args, void *frame, const void *continuation_constants, void *continuation_frame)
Error Trap Function.
Definition: aramid.h:329
ARMD_EXTERN_C ARMD_Size armd_memory_region_destroy(ARMD_MemoryRegion *memory_region)
Destroy ARMD_MemoryRegion.
ARMD_EXTERN_C int armd_then_sequential_for(ARMD_ProcedureBuilder *procedure_builder, ARMD_SequentialForCountFunc sequential_for_count_func, ARMD_SequentialForContinuationFunc sequential_for_continuation_func)
Appends a sequential-for continuation to the procedure.
struct TAG_ARMD_ProcedureBuilder ARMD_ProcedureBuilder
Builder object for ARMD_Procedure.
Definition: aramid.h:419
ARMD_EXTERN_C int armd_detach(ARMD_Context *context, ARMD_Handle handle)
Detach promise.
ARMD_EXTERN_C void * armd_memory_region_allocate(ARMD_MemoryRegion *memory_region, ARMD_Size size)
Allocates memory area with ARMD_MemoryRegion.
ARMD_EXTERN_C ARMD_Procedure * armd_procedure_builder_build_and_destroy(ARMD_ProcedureBuilder *procedure_builder)
Build ARMD_Procedure and destroy ARMD_ProcedureBuilder.
enum TAG_ARMD_ContinuationResult ARMD_ContinuationResult
Continuation Status.
void *(* ARMD_ContinuationFrameCreator)(ARMD_MemoryRegion *memory_region)
Continuation Frame Creator.
Definition: aramid.h:345
ARMD_EXTERN_C void armd_memory_allocator_init_default(ARMD_MemoryAllocator *memory_allocator)
Initialize ARMD_MemoryAllocator with default value.
ARMD_EXTERN_C ARMD_MemoryAllocator armd_procedure_builder_get_memory_allocator(ARMD_ProcedureBuilder *procedure_builder)
Get the memory allocator used in ARMD_ProcedureBuilder.
int armd_setup(ARMD_ProcedureBuilder *builder, ARMD_SetupFunc setup_func)
Add unwind callback to the procedure.
ARMD_EXTERN_C ARMD_Size armd_job_get_num_executors(ARMD_Job *job)
Get the number of executors in the ARMD_Context via ARMD_Job.
ARMD_EXTERN_C int armd_then_parallel_for(ARMD_ProcedureBuilder *procedure_builder, ARMD_ParallelForCountFunc parallel_for_count_func, ARMD_ParallelForContinuationFunc parallel_for_continuation_func)
Appends a parallel-for continuation to the procedure.
ARMD_EXTERN_C void * armd_procedure_get_constants(ARMD_Procedure *procedure)
Get the pointer to constant table.
TAG_ARMD_ContinuationResult
Continuation Status.
Definition: aramid.h:310
ARMD_EXTERN_C int armd_await(ARMD_Context *context, ARMD_Handle handle)
Await promise.
ARMD_EXTERN_C ARMD_Size armd_job_get_executor_id(ARMD_Job *job)
Get the executor id via ARMD_Job.
size_t ARMD_Size
Size type.
Definition: aramid.h:30
ARMD_EXTERN_C int armd_add_promise_callback(ARMD_Context *context, ARMD_Handle handle, void *callback_context, ARMD_PromiseCallbackFunc callback_func)
Add callback to the promise.
ARMD_EXTERN_C int armd_then_single(ARMD_ProcedureBuilder *procedure_builder, ARMD_SingleContinuationFunc single_continuation_func)
Appends a single continuation to the procedure.
ARMD_EXTERN_C int armd_fork_with_id(ARMD_Size executor_id, ARMD_Job *parent_job, ARMD_Procedure *procedure, void *args)
Fork and invoke procedure specifying the executor.
ARMD_EXTERN_C void * armd_procedure_builder_get_constants(ARMD_ProcedureBuilder *procedure_builder)
Get the pointer to constant table.
ARMD_EXTERN_C void armd_memory_allocator_free(const ARMD_MemoryAllocator *allocator, void *buf)
Free memory area allocated with ARMD_MemoryAllocator.
void(* ARMD_UnwindFunc)(ARMD_Job *job, const void *constants, void *args, void *frame)
Unwind Function.
Definition: aramid.h:413
ARMD_EXTERN_C int armd_then(ARMD_ProcedureBuilder *procedure_builder, ARMD_ContinuationFunc continuation_func, void *continuation_constants, ARMD_ContinuationConstantsDestroyer continuation_constants_destroyer, ARMD_ErrorTrapFunc error_trap_func, ARMD_ContinuationFrameCreator continuation_frame_creator, ARMD_ContinuationFrameDestroyer continuation_frame_destroyer)
Appends a versatile continuation to the procedure.
struct TAG_ARMD_Procedure ARMD_Procedure
Aramid Procedure.
Definition: aramid.h:55
ARMD_EXTERN_C ARMD_Context * armd_context_create(const ARMD_MemoryAllocator *memory_allocator, ARMD_Size num_executors)
Create ARMD_Context.
ARMD_EXTERN_C int armd_fork(ARMD_Job *parent_job, ARMD_Procedure *procedure, void *args)
Fork and invoke procedure.
void(* ARMD_ContinuationFrameDestroyer)(ARMD_MemoryRegion *memory_region, void *continuation_frame)
Continuation Frame Destroyer.
Definition: aramid.h:353
struct TAG_ARMD_Job ARMD_Job
Aramid Job.
Definition: aramid.h:48
ARMD_EXTERN_C int armd_procedure_builder_destroy(ARMD_ProcedureBuilder *procedure_builder)
Destroy ARMD_ProcedureBuilder without building ARMD_Procedure.
void(* ARMD_MemoryAllocatorFreeFunc)(void *context, void *buf)
Memory free function interface.
Definition: aramid.h:73
struct TAG_ARMD_Context ARMD_Context
The execution engine.
Definition: aramid.h:183
uint64_t ARMD_Handle
Handle type.
Definition: aramid.h:42
int(* ARMD_ParallelForContinuationFunc)(ARMD_Job *job, const void *constants, void *args, void *frame, ARMD_Size index)
Parallel-For Continuation Function.
Definition: aramid.h:392
ARMD_EXTERN_C int armd_unwind(ARMD_ProcedureBuilder *procedure_builder, ARMD_UnwindFunc unwind_func)
Add unwind callback to the procedure.
ARMD_EXTERN_C ARMD_Handle armd_invoke(ARMD_Context *context, ARMD_Procedure *procedure, void *args, ARMD_Size num_dependencies, const ARMD_Handle *dependencies)
Invoke procedure.
void * context
Memory allocator context.
Definition: aramid.h:88
int ARMD_Bool
Boolean type.
Definition: aramid.h:34
struct TAG_ARMD_MemoryRegion ARMD_MemoryRegion
Memory region.
Definition: aramid.h:135
ARMD_MemoryAllocatorFreeFunc free
Memory free function.
Definition: aramid.h:96
double ARMD_Real
Floating point value type.
Definition: aramid.h:38
ARMD_Size(* ARMD_ParallelForCountFunc)(void *args, void *frame)
Parallel-For Count Function.
Definition: aramid.h:385
ARMD_EXTERN_C int armd_context_destroy(ARMD_Context *context)
Destroy ARMD_Context.
Abstract memory allocator.
Definition: aramid.h:82
ARMD_EXTERN_C int armd_await_all(ARMD_Context *context)
Await all promise.
ARMD_Bool(* ARMD_SetupFunc)(ARMD_Job *job, const void *constants, void *args, void *frame, int dependency_has_error)
Setup Function.
Definition: aramid.h:403
ARMD_EXTERN_C char * armd_memory_region_strdup(ARMD_MemoryRegion *memory_region, const char *str)
strdup for memory_region
ARMD_Size(* ARMD_SequentialForCountFunc)(void *args, void *frame)
Sequential-For Count Function.
Definition: aramid.h:369
ARMD_ContinuationResult(* ARMD_ContinuationFunc)(ARMD_Job *job, const void *constants, void *args, void *frame, const void *continuation_constants, void *continuation_frame)
Continuation Function.
Definition: aramid.h:322
int(* ARMD_SingleContinuationFunc)(ARMD_Job *job, const void *constants, void *args, void *frame)
Single Continuation Function.
Definition: aramid.h:362
void(* ARMD_ContinuationConstantsDestroyer)(ARMD_MemoryAllocator *memory_region, void *continuation_constants)
Continuation Constant Destroyer.
Definition: aramid.h:336
void *(* ARMD_MemoryAllocatorAllocateFunc)(void *context, ARMD_Size size)
Memory allocation function interface.
Definition: aramid.h:64
ARMD_EXTERN_C void * armd_memory_allocator_allocate(const ARMD_MemoryAllocator *allocator, ARMD_Size size)
Allocates memory area with ARMD_MemoryAllocator.
ARMD_EXTERN_C ARMD_ProcedureBuilder * armd_procedure_builder_create(const ARMD_MemoryAllocator *memory_allocator, ARMD_Size constant_size, ARMD_Size frame_size)
Create ARMD_ProcedureBuilder.
ARMD_EXTERN_C int armd_procedure_destroy(ARMD_Procedure *procedure)
Destroy ARMD_Procedure.
ARMD_EXTERN_C ARMD_MemoryRegion * armd_memory_region_create(const ARMD_MemoryAllocator *memory_allocator)
Create ARMD_MemoryRegion.