14#define ARC_RUNTIME_ENABLE_EXPORT
21#ifdef ARC_RUNTIME_JIT_BIND
22#define ARC_RUNTIME_JITBIND_FNDECL
33 std::cerr <<
"[ArcRuntime] Internal Error: " << message << std::endl;
34 assert(
false &&
"ArcRuntime Internal Error");
39 assert(instance->
impl !=
nullptr &&
"Instance is null");
46 internalError(
"API version mismatch.\nMake sure to use an ArcRuntime "
48 "the arcilator version used to build the hardware model.");
52 auto *statePtr =
reinterpret_cast<ArcState *
>(
54 assert(
reinterpret_cast<intptr_t
>(&statePtr->modelState[0]) % 16 == 0 &&
55 "Simulation state must be 16 byte aligned");
77 uint8_t *modPtr =
static_cast<uint8_t *
>(modelState) - offset;
100#ifdef ARC_RUNTIME_JIT_BIND
107const APICallbacks &getArcRuntimeAPICallbacks() {
return apiCallbacksGlobal; }
static void internalError(const char *message)
ArcState * arcRuntimeAllocateInstance(const ArcRuntimeModelInfo *model, const char *args)
uint64_t arcRuntimeGetAPIVersion()
Return the API version of the runtime library.
void arcRuntimeDeleteInstance(ArcState *instance)
Destroy and deallocate the state of a model instance.
void arcRuntimeOnEval(ArcState *instance)
Pre-Eval hook. Must be called by the driver once before every eval step.
uint8_t * arcRuntimeIR_allocInstance(const ArcRuntimeModelInfo *model, const char *args)
Allocate and initialize the state for a new instance of the given hardware model.
static ModelInstance * getModelInstance(ArcState *instance)
void arcRuntimeIR_deleteInstance(uint8_t *modelState)
Destroy and deallocate the state of a model instance.
ArcState * arcRuntimeGetStateFromModelState(uint8_t *modelState, uint64_t offset)
Project a pointer to the model state to its ArcState container.
void arcRuntimeIR_onEval(uint8_t *modelState)
Pre-Eval hook of the runtime library.
assert(baseType &&"element must be base type")
ARC_IR_EXPORT uint8_t * arcRuntimeIR_allocInstance(const ArcRuntimeModelInfo *model, const char *args)
Allocate and initialize the state for a new instance of the given hardware model.
ARC_IR_EXPORT void arcRuntimeIR_deleteInstance(uint8_t *modelState)
Destroy and deallocate the state of a model instance.
ARC_IR_EXPORT void arcRuntimeIR_onEval(uint8_t *modelState)
Pre-Eval hook of the runtime library.
#define ARC_RUNTIME_MAGIC
Magic number used to assert the presence of an ArcState struct.
#define ARC_RUNTIME_API_VERSION
Version of the combined public and internal API.
Static information for a compiled hardware model, generated by the MLIR lowering.
uint64_t apiVersion
Runtime API version used when compiling the model.
uint64_t numStateBytes
Number of bytes required for the model's state.
Combined runtime and model state for a hardware model instance.
void * impl
Runtime implementation specific data. Usually points to a custom struct.
uint32_t magic
Runtime magic number. Must be set to ARC_RUNTIME_MAGIC.