ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
resources.cpp
Go to the documentation of this file.
1 #include <cstdint>
2 #include "etiss/jit/CPU.h"
3 
4 extern "C"
5 {
6  uint32_t handleResources(uint32_t *resource_time,
7  uint32_t (*resources)[ETISS_MAX_RESOURCES],
8  uint32_t num_stages,
9  uint32_t *num_resources, ETISS_CPU *cpu)
10  {
11  for (uint32_t i = 0; i < num_stages; i++)
12  {
13  etiss_uint64 max = 0;
14  for (uint32_t j = 0; j < num_resources[i]; j++)
15  { // set "in use" metric
16  cpu->resourceUsages[resources[i][j]] += resource_time[resources[i][j]];
17  }
18  for (uint32_t j = 0; j < num_resources[i]; j++)
19  { // find max in this stage
20  if (cpu->cycles[resources[i][j]] > max)
21  {
22  max = cpu->cycles[resources[i][j]];
23  }
24  }
25 
26  if (!(i == 0))
27  { // find max in stage before this stage
28  for (uint32_t j = 0; j < num_resources[i - 1]; j++)
29  {
30  if (cpu->cycles[resources[i - 1][j]] > max)
31  {
32  max = cpu->cycles[resources[i - 1][j]];
33  }
34  }
35  }
36  uint32_t max_stagetime = 0;
37  for (uint32_t j = 0; j < num_resources[i]; j++)
38  { // find max time in stage
39  if (resource_time[resources[i][j] > max_stagetime])
40  {
41  max_stagetime = resource_time[resources[i][j]];
42  }
43  }
44 
45  for (uint32_t j = 0; j < num_resources[i]; j++)
46  { // set new values
47  cpu->cycles[resources[i][j]] = max + max_stagetime;
48  }
49  }
50  return 0;
51  }
52 }
__DEVICE__ int max(int __a, int __b)
static __inline__ uint32_t
Definition: arm_cde.h:25
#define ETISS_MAX_RESOURCES
Definition: CPU.h:59
uint64_t etiss_uint64
Definition: types.h:96
uint32_t handleResources(uint32_t *resource_time, uint32_t(*resources)[ETISS_MAX_RESOURCES], uint32_t num_stages, uint32_t *num_resources, ETISS_CPU *cpu)
Definition: resources.cpp:6
basic cpu state structure needed for execution of any cpu architecture.
Definition: CPU.h:89
etiss_uint64 resourceUsages[ETISS_MAX_RESOURCES]
how many cycles each resource is used
Definition: CPU.h:99
etiss_uint64 cycles[ETISS_MAX_RESOURCES]
how many cycles in each resource (including waiting)
Definition: CPU.h:103