CIRCT 22.0.0git
Loading...
Searching...
No Matches
ArcRuntime.h
Go to the documentation of this file.
1//===- ArcRuntime.h - ArcRuntime public API -------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the ArcRuntime's public API.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CIRCT_DIALECT_ARC_RUNTIME_ARCRUNTIME_H
14#define CIRCT_DIALECT_ARC_RUNTIME_ARCRUNTIME_H
15
17
18// `ARC_RUNTIME_ENABLE_EXPORT` must be set when compiling the runtime.
19// Do not set when using (i.e., linking against) it.
20
21#ifndef ARC_RUNTIME_EXPORT
22#ifdef ARC_RUNTIME_ENABLE_EXPORT
23
24#ifdef _WIN32
25#define ARC_RUNTIME_EXPORT extern "C" __declspec(dllexport)
26#else
27#define ARC_RUNTIME_EXPORT extern "C" __attribute__((visibility("default")))
28#endif
29
30#else // #ifndef ARC_RUNTIME_EXPORT
31
32#ifdef _WIN32
33#define ARC_RUNTIME_EXPORT extern "C" __declspec(dllimport)
34#else
35#define ARC_RUNTIME_EXPORT extern "C"
36#endif
37
38#endif // #ifdef ARC_RUNTIME_ENABLE_EXPORT
39#endif // #ifndef ARC_RUNTIME_EXPORT
40
41// Host architecture checks
42#ifndef __cplusplus
43#include <assert.h>
44#endif
45
46static_assert(sizeof(void *) == 8, "Unsupported architecture");
47static_assert(sizeof(struct ArcState) == 16, "Unexpected ArcState size");
48static_assert(sizeof(struct ArcRuntimeModelInfo) == 24,
49 "Unexpected ArcRuntimeModelInfo size");
50
51/// Allocate and initialize the state for a new instance of the given
52/// hardware model.
53///
54/// After the end of simulation, the state must be deallocated by calling
55/// `arcRuntimeDeleteInstance`.
56///
57/// `args` is a zero terminated string containing implementation specific
58/// runtime options or `null`.
61 const char *args);
62
63/// Destroy and deallocate the state of a model instance.
65
66/// Pre-Eval hook. Must be called by the driver once before every `eval` step.
67ARC_RUNTIME_EXPORT void arcRuntimeOnEval(struct ArcState *instance);
68
69/// Return the API version of the runtime library.
71
72/// Project a pointer to the model state to its ArcState container.
73/// `offset` is the byte offset of the given pointer within the model state.
75arcRuntimeGetStateFromModelState(uint8_t *modelState, uint64_t offset);
76
77#endif // CIRCT_DIALECT_ARC_RUNTIME_ARCRUNTIME_H
ARC_RUNTIME_EXPORT uint64_t arcRuntimeGetAPIVersion()
Return the API version of the runtime library.
ARC_RUNTIME_EXPORT struct ArcState * arcRuntimeGetStateFromModelState(uint8_t *modelState, uint64_t offset)
Project a pointer to the model state to its ArcState container.
ARC_RUNTIME_EXPORT void arcRuntimeDeleteInstance(struct ArcState *instance)
Destroy and deallocate the state of a model instance.
#define ARC_RUNTIME_EXPORT
Definition ArcRuntime.h:35
ARC_RUNTIME_EXPORT struct ArcState * arcRuntimeAllocateInstance(const struct ArcRuntimeModelInfo *model, const char *args)
Allocate and initialize the state for a new instance of the given hardware model.
ARC_RUNTIME_EXPORT void arcRuntimeOnEval(struct ArcState *instance)
Pre-Eval hook. Must be called by the driver once before every eval step.
Static information for a compiled hardware model, generated by the MLIR lowering.
Definition Common.h:57
Combined runtime and model state for a hardware model instance.
Definition Common.h:40
uint8_t modelState[]
Definition Common.h:48