SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
common.cpp
1 #include "smaug/core/globals.h"
3 
4 namespace smaug {
5 
6 std::string getTraceName(int accelIdx) {
7  std::string traceName =
8  "dynamic_trace_acc" + std::to_string(accelIdx) + ".gz";
9  return traceName;
10 }
11 
12 void mapArrayToAccel(unsigned reqCode,
13  const char* arrayName,
14  void* baseAddr,
15  size_t size) {
16  if (runningInSimulation) {
17  mapArrayToAccelerator(reqCode, arrayName, baseAddr, size);
18  }
19 }
20 
21 void setArrayMemTypeIfSimulating(unsigned reqCode,
22  const char* arrayName,
23  MemoryType memType) {
24  if (runningInSimulation) {
25  setArrayMemoryType(reqCode, arrayName, memType);
26  }
27 }
28 
29 } // namespace smaug
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
36 size_t next_multiple(size_t request, size_t align) {
37  size_t n = request / align;
38  if (n == 0)
39  return align; // Return at least this many bytes.
40  size_t remainder = request % align;
41  if (remainder)
42  return (n + 1) * align;
43  return request;
44 }
45 
46 #ifdef __cplusplus
47 }
48 #endif
smaug::setArrayMemTypeIfSimulating
void setArrayMemTypeIfSimulating(unsigned reqCode, const char *arrayName, MemoryType memType)
Sets what memory access mechanism the accelerator will use when accessing this array.
Definition: common.cpp:21
smaug::runningInSimulation
bool runningInSimulation
This is true if the user chooses to run the network in gem5 simulation.
Definition: globals.cpp:4
globals.h
SMAUG Global variables.
smaug::getTraceName
std::string getTraceName(int accelIdx)
Return the name of the dynamic trace for this accelerator.
Definition: common.cpp:6
smaug
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Definition: backend.cpp:38
common.h
Utilities for writing and invoking Aladdin kernels from Operators.
ALWAYS_INLINE
#define ALWAYS_INLINE
We have to disable all function inlining at the global level for Aladdin + LLVM-Tracer to work,...
Definition: common.h:521
next_multiple
size_t next_multiple(size_t request, size_t align)
Returns the smallest multiple of align that is >= request.
Definition: common.cpp:36
smaug::mapArrayToAccel
void mapArrayToAccel(unsigned reqCode, const char *arrayName, void *baseAddr, size_t size)
Maps an array of data to the accelerator.
Definition: common.cpp:12