Skip to content

Commit 211fb11

Browse files
committed
Lots of changes to enhance build perf, update Mavis, move to Boost::json
1 parent b862948 commit 211fb11

File tree

18 files changed

+22985
-156
lines changed

18 files changed

+22985
-156
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -U_FORTIFY_SOURCE")
6363
# Include directories
6464
include_directories (core mss sim)
6565
include_directories (SYSTEM fsl)
66-
include_directories (SYSTEM mavis)
66+
include_directories (SYSTEM mavis mavis/elfio)
6767
include_directories (SYSTEM stf_lib)
6868

69+
# Include dead header files that we can't remove just yet
70+
include_directories (deprecated)
71+
6972
# Mavis
7073
add_subdirectory (mavis)
7174

@@ -87,8 +90,9 @@ add_subdirectory (test EXCLUDE_FROM_ALL)
8790
add_executable(olympia
8891
sim/OlympiaSim.cpp
8992
sim/main.cpp
90-
)
93+
)
9194
target_link_libraries (olympia core mss SPARTA::sparta ${STF_LINK_LIBS})
95+
9296
if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease")
9397
target_compile_options (core PUBLIC -flto)
9498
target_compile_options (mss PUBLIC -flto)

core/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ add_library(instgen
1616
InstGenerator.cpp
1717
)
1818

19-
target_link_libraries(instgen stf zstd mavis)
19+
find_package(Boost REQUIRED COMPONENTS json)
20+
21+
target_link_libraries(instgen stf zstd mavis Boost::json)
2022

2123
get_property(SPARTA_INCLUDE_PROP TARGET SPARTA::sparta PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
2224
target_include_directories(core SYSTEM PRIVATE ${SPARTA_INCLUDE_PROP})

core/CPUFactory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <string>
66
#include <algorithm>
77

8+
#include "CoreExtensions.hpp"
9+
810
/**
911
* @brief Constructor for CPUFactory
1012
*/

core/CPUTopology.hpp

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "sparta/simulation/ResourceFactory.hpp"
1010
#include "sparta/simulation/RootTreeNode.hpp"
1111
#include "sparta/simulation/ResourceTreeNode.hpp"
12-
#include "sparta/simulation/TreeNodeExtensions.hpp"
1312

1413
namespace olympia
1514
{
@@ -128,79 +127,6 @@ namespace olympia
128127

129128
}; // class CPUTopology
130129

131-
//
132-
// \class CoreExtensions
133-
// \brief Common extensions for a specific core
134-
//
135-
// Similar to Parameters, Extensions allow the modeler to provide
136-
// common "preferences" to any node (and it's children). For
137-
// example, the topology of the execution units: the number of
138-
// ALUs. Both Dispatch and Execute (as well as testers) need to
139-
// know this information.
140-
//
141-
//
142-
class CoreExtensions : public sparta::ExtensionsParamsOnly
143-
{
144-
public:
145-
static constexpr char name[] = "core_extensions";
146-
147-
using ExecutionTopology = std::vector<std::vector<std::string>>;
148-
using ExecutionTopologyParam = sparta::Parameter<ExecutionTopology>;
149-
150-
using PipeTopology = std::vector<std::vector<std::string>>;
151-
using PipeTopologyParam = sparta::Parameter<PipeTopology>;
152-
153-
using IssueQueueTopology = std::vector<std::vector<std::string>>;
154-
using IssueQueueTopologyParam = sparta::Parameter<IssueQueueTopology>;
155-
156-
CoreExtensions() : sparta::ExtensionsParamsOnly() {}
157-
158-
virtual ~CoreExtensions() {}
159-
160-
void postCreate() override
161-
{
162-
sparta::ParameterSet* ps = getParameters();
163-
164-
//
165-
// Example of an execution topology:
166-
// [["alu", "1"], ["fpu", "1"], ["br", "1"]]
167-
//
168-
// LSU is its own entity at this time
169-
//
170-
execution_topology_.reset(
171-
new ExecutionTopologyParam("execution_topology", ExecutionTopology(),
172-
"Topology Post Dispatch -- the execution pipes. "
173-
"Expect: [[\"<unit_name>\", \"<count>\"]] ",
174-
ps));
175-
pipelines_.reset(new PipeTopologyParam("pipelines", PipeTopology(),
176-
"Topology Mapping"
177-
"Mapping of Pipe Targets to execution unit",
178-
ps));
179-
issue_queue_to_pipe_map_.reset(
180-
new IssueQueueTopologyParam("issue_queue_to_pipe_map", IssueQueueTopology(),
181-
"Issue Queue Topology"
182-
"Defines Issue Queue to Execution Unit Mapping",
183-
ps));
184-
exe_pipe_rename_.reset(new IssueQueueTopologyParam("exe_pipe_rename",
185-
IssueQueueTopology(),
186-
"Rename for ExecutionPipes"
187-
"Defines alias for ExecutionPipe",
188-
ps));
189-
issue_queue_rename_.reset(new IssueQueueTopologyParam("issue_queue_rename",
190-
IssueQueueTopology(),
191-
"Rename for IssueQueues"
192-
"Defines alias for IssueQueue",
193-
ps));
194-
}
195-
196-
private:
197-
std::unique_ptr<ExecutionTopologyParam> execution_topology_;
198-
std::unique_ptr<PipeTopologyParam> pipelines_;
199-
std::unique_ptr<IssueQueueTopologyParam> issue_queue_to_pipe_map_;
200-
std::unique_ptr<PipeTopologyParam> exe_pipe_rename_;
201-
std::unique_ptr<PipeTopologyParam> issue_queue_rename_;
202-
};
203-
204130
/**
205131
* @brief CoreTopologySimple topology class
206132
*/

core/CoreExtensions.hpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// <CoreExtension.h> -*- C++ -*-
2+
3+
#pragma once
4+
5+
#include <vector>
6+
#include <string>
7+
#include <memory>
8+
9+
#include "sparta/simulation/TreeNodeExtensions.hpp"
10+
#include "sparta/simulation/ParameterSet.hpp"
11+
12+
namespace olympia
13+
{
14+
15+
//
16+
// \class CoreExtensions
17+
// \brief Common extensions for a specific core
18+
//
19+
// Similar to Parameters, Extensions allow the modeler to provide
20+
// common "preferences" to any node (and it's children). For
21+
// example, the topology of the execution units: the number of
22+
// ALUs. Both Dispatch and Execute (as well as testers) need to
23+
// know this information.
24+
//
25+
//
26+
class CoreExtensions : public sparta::ExtensionsParamsOnly
27+
{
28+
public:
29+
static constexpr char name[] = "core_extensions";
30+
31+
using ExecutionTopology = std::vector<std::vector<std::string>>;
32+
using ExecutionTopologyParam = sparta::Parameter<ExecutionTopology>;
33+
34+
using PipeTopology = std::vector<std::vector<std::string>>;
35+
using PipeTopologyParam = sparta::Parameter<PipeTopology>;
36+
37+
using IssueQueueTopology = std::vector<std::vector<std::string>>;
38+
using IssueQueueTopologyParam = sparta::Parameter<IssueQueueTopology>;
39+
40+
CoreExtensions() : sparta::ExtensionsParamsOnly() {}
41+
42+
virtual ~CoreExtensions() {}
43+
44+
void postCreate() override
45+
{
46+
sparta::ParameterSet* ps = getParameters();
47+
48+
//
49+
// Example of an execution topology:
50+
// [["alu", "1"], ["fpu", "1"], ["br", "1"]]
51+
//
52+
// LSU is its own entity at this time
53+
//
54+
execution_topology_.reset(
55+
new ExecutionTopologyParam("execution_topology", ExecutionTopology(),
56+
"Topology Post Dispatch -- the execution pipes. "
57+
"Expect: [[\"<unit_name>\", \"<count>\"]] ",
58+
ps));
59+
pipelines_.reset(new PipeTopologyParam("pipelines", PipeTopology(),
60+
"Topology Mapping"
61+
"Mapping of Pipe Targets to execution unit",
62+
ps));
63+
issue_queue_to_pipe_map_.reset(
64+
new IssueQueueTopologyParam("issue_queue_to_pipe_map", IssueQueueTopology(),
65+
"Issue Queue Topology"
66+
"Defines Issue Queue to Execution Unit Mapping",
67+
ps));
68+
exe_pipe_rename_.reset(new IssueQueueTopologyParam("exe_pipe_rename",
69+
IssueQueueTopology(),
70+
"Rename for ExecutionPipes"
71+
"Defines alias for ExecutionPipe",
72+
ps));
73+
issue_queue_rename_.reset(new IssueQueueTopologyParam("issue_queue_rename",
74+
IssueQueueTopology(),
75+
"Rename for IssueQueues"
76+
"Defines alias for IssueQueue",
77+
ps));
78+
}
79+
80+
private:
81+
std::unique_ptr<ExecutionTopologyParam> execution_topology_;
82+
std::unique_ptr<PipeTopologyParam> pipelines_;
83+
std::unique_ptr<IssueQueueTopologyParam> issue_queue_to_pipe_map_;
84+
std::unique_ptr<PipeTopologyParam> exe_pipe_rename_;
85+
std::unique_ptr<PipeTopologyParam> issue_queue_rename_;
86+
};
87+
}

core/CoreUtils.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
#include "sparta/simulation/TreeNode.hpp"
77
#include "sparta/utils/Utils.hpp"
88

9-
#include "CPUTopology.hpp"
9+
#include "mavis/InstMetaData.h"
10+
#include "mavis/OperandInfo.hpp"
11+
12+
#include "CoreExtensions.hpp"
13+
#include "CoreTypes.hpp"
1014

1115
namespace olympia::coreutils
1216
{

core/InstArchInfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,30 @@ namespace olympia
8282
{"PERMUTE", InstArchInfo::UopGenType::PERMUTE},
8383
{"NONE", InstArchInfo::UopGenType::NONE}};
8484

85-
void InstArchInfo::update(const nlohmann::json & jobj)
85+
void InstArchInfo::update(const boost::json::object & jobj)
8686
{
87-
if (jobj.find("pipe") != jobj.end())
87+
if (const auto it = jobj.find("pipe"); it != jobj.end())
8888
{
89-
auto pipe_name = jobj["pipe"].get<std::string>();
89+
auto pipe_name = it->value().as_string();
9090
const auto itr = execution_pipe_map.find(pipe_name);
9191
sparta_assert(itr != execution_pipe_map.end(),
9292
"Unknown pipe target: " << pipe_name << " for inst: "
93-
<< jobj["mnemonic"].get<std::string>());
93+
<< jobj.at("mnemonic").as_string());
9494
tgt_pipe_ = itr->second;
9595
}
9696

97-
if (jobj.find("latency") != jobj.end())
97+
if (const auto it = jobj.find("latency"); it != jobj.end())
9898
{
99-
execute_time_ = jobj["latency"].get<uint32_t>();
99+
execute_time_ = boost::json::value_to<uint32_t>(it->value());
100100
}
101101

102-
if (jobj.find("uop_gen") != jobj.end())
102+
if (const auto it = jobj.find("uop_gen"); it != jobj.end())
103103
{
104-
auto uop_gen_name = jobj["uop_gen"].get<std::string>();
104+
auto uop_gen_name = it->value().as_string();
105105
const auto itr = uop_gen_type_map.find(uop_gen_name);
106106
sparta_assert(itr != uop_gen_type_map.end(),
107107
"Unknown uop gen: " << uop_gen_name << " for inst: "
108-
<< jobj["mnemonic"].get<std::string>());
108+
<< jobj.at("mnemonic").as_string());
109109
uop_gen_ = itr->second;
110110
}
111111

core/InstArchInfo.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#include <cinttypes>
1515
#include <map>
1616

17-
#include "sparta/utils/SpartaSharedPointer.hpp"
17+
#include "mavis/JSONUtils.hpp"
1818

19-
#include "json.hpp"
19+
#include "sparta/utils/SpartaSharedPointer.hpp"
2020

2121
namespace olympia
2222
{
@@ -69,7 +69,7 @@ namespace olympia
6969

7070
static constexpr uint32_t N_TARGET_PIPES = static_cast<uint32_t>(TargetPipe::UNKNOWN);
7171

72-
using TargetPipeMap = std::map<std::string, TargetPipe>;
72+
using TargetPipeMap = std::map<std::string, TargetPipe, mavis::JSONStringMapCompare>;
7373
static const TargetPipeMap execution_pipe_map;
7474

7575
using TargetPipeStringMap = std::map<TargetPipe, std::string>;
@@ -100,15 +100,15 @@ namespace olympia
100100

101101
static constexpr uint32_t N_UOP_GEN_TYPES = static_cast<uint32_t>(UopGenType::NONE);
102102

103-
using UopGenMap = std::map<std::string, UopGenType>;
103+
using UopGenMap = std::map<std::string, UopGenType, mavis::JSONStringMapCompare>;
104104
static const UopGenMap uop_gen_type_map;
105105

106106
// Called by Mavis during its initialization
107-
explicit InstArchInfo(const nlohmann::json & jobj) { update(jobj); }
107+
explicit InstArchInfo(const boost::json::object & jobj) { update(jobj); }
108108

109109
// Called by Mavis if, during initialization, changes are
110110
// dynamically made to an instruction.
111-
void update(const nlohmann::json & jobj);
111+
void update(const boost::json::object & jobj);
112112

113113
//! Return the target unit for this instruction type
114114
TargetPipe getTargetPipe() const { return tgt_pipe_; }

0 commit comments

Comments
 (0)