Commit 66d15160 authored by phlo's avatar phlo

updated Simulator class visibility

parent 7d21ef24
......@@ -5,6 +5,7 @@
#include "smtlib.hh"
#include "mmap.hh"
#include "trace.hh"
#include "parser.hh"
#include "encoder.hh"
......
......@@ -7,15 +7,10 @@
#include <vector>
#include "common.hh"
#include "instruction.hh"
namespace ConcuBinE {
//==============================================================================
// forward declarations
//==============================================================================
class Instruction;
//==============================================================================
// Program class
//==============================================================================
......
This diff is collapsed.
......@@ -2,13 +2,10 @@
#define MACHINE_HH_
#include <functional>
#include <unordered_set>
#include "common.hh"
#include "instruction.hh"
// TODO: forward-declare
#include "program.hh"
#include "trace.hh"
namespace ConcuBinE {
......@@ -17,15 +14,18 @@ namespace ConcuBinE {
//==============================================================================
class MMap;
class Trace;
//==============================================================================
// Simulator class
// Simulator
//==============================================================================
struct Simulator
class Simulator
{
public: //======================================================================
//----------------------------------------------------------------------------
// member types
// public member types
//----------------------------------------------------------------------------
// thread state
......@@ -41,63 +41,34 @@ struct Simulator
};
//----------------------------------------------------------------------------
// members
// public constructors
//----------------------------------------------------------------------------
// Mersenne Twister pseudo-random number generator
//
std::mt19937_64 random;
// list of programs
//
const Program::List * programs;
// generated trace
//
std::unique_ptr<Trace> trace;
// bound
//
size_t bound;
// current step
//
size_t step;
Simulator ();
// current thread
//
word_t thread;
//----------------------------------------------------------------------------
// public member functions
//----------------------------------------------------------------------------
// list of thread states
// simulate given programs using a random scheduler
//
std::vector<State> state;
std::unique_ptr<Trace> simulate (const std::shared_ptr<Program::List> & programs,
const std::shared_ptr<MMap> & mmap = {},
size_t bound = 0);
// list of active threads
//
// NOTE: much more lookup than insert/remove operations
// replay given trace
//
std::vector<word_t> active;
std::unique_ptr<Trace> replay (const Trace & trace, size_t bound = 0);
// threads containing calls to a specific checkpoint
//
// checkpoint id -> list of threads
// double-dispatched execute functions
//
std::unordered_map<word_t, std::unordered_set<word_t>> threads_per_checkpoint;
template <class Instruction>
void execute (const Instruction & op);
// threads waiting for a specific checkpoint
//
// checkpoint id -> number of threads
//
std::unordered_map<word_t, word_t> waiting_for_checkpoint;
private: //=====================================================================
//----------------------------------------------------------------------------
// constructors
//----------------------------------------------------------------------------
Simulator ();
//----------------------------------------------------------------------------
// private functions
// private member functions
//----------------------------------------------------------------------------
// (re)initialize
......@@ -106,33 +77,33 @@ struct Simulator
const std::shared_ptr<MMap> & mmap,
size_t bound);
// program counter
// get or set program counter
//
word_t pc () const;
void pc (word_t value);
void pc_increment ();
// accumulator register
// get or set accumulator register
//
word_t accu () const;
void accu (word_t value);
// special CAS register
// get or set special CAS register
//
word_t mem () const;
void mem (word_t value);
// store buffer address
// get or set store buffer address
//
word_t sb_adr () const;
void sb_adr (word_t value);
// store buffer value
// get or set store buffer value
//
word_t sb_val () const;
void sb_val (word_t value);
// store buffer full flag
// get or set store buffer full flag
//
bool sb_full () const;
void sb_full (bool value);
......@@ -157,53 +128,59 @@ struct Simulator
//
void execute ();
// double-dispatched execute functions
// run simulator with given scheduler
//
void execute (const Instruction::Load &);
void execute (const Instruction::Store &);
std::unique_ptr<Trace> run (std::function<void()> scheduler);
void execute (const Instruction::Fence &);
//----------------------------------------------------------------------------
// private data members
//----------------------------------------------------------------------------
void execute (const Instruction::Add &);
void execute (const Instruction::Addi &);
void execute (const Instruction::Sub &);
void execute (const Instruction::Subi &);
void execute (const Instruction::Mul &);
void execute (const Instruction::Muli &);
// Mersenne Twister pseudo-random number generator
//
std::mt19937_64 random;
void execute (const Instruction::Cmp &);
void execute (const Instruction::Jmp &);
void execute (const Instruction::Jz &);
void execute (const Instruction::Jnz &);
void execute (const Instruction::Js &);
void execute (const Instruction::Jns &);
void execute (const Instruction::Jnzns &);
// list of programs
//
const Program::List * programs;
void execute (const Instruction::Mem &);
void execute (const Instruction::Cas &);
// generated trace
//
std::unique_ptr<Trace> trace;
void execute (const Instruction::Check &);
// bound
//
size_t bound;
void execute (const Instruction::Halt &);
void execute (const Instruction::Exit &);
// current step
//
size_t step;
// run the simulator, using the specified scheduler
// current thread
//
std::unique_ptr<Trace> run (std::function<void()> scheduler);
word_t thread;
//----------------------------------------------------------------------------
// public functions
//----------------------------------------------------------------------------
// list of thread states
//
std::vector<State> state;
// simulate given programs using a random scheduler
// list of active threads
//
std::unique_ptr<Trace> simulate (const std::shared_ptr<Program::List> & programs,
const std::shared_ptr<MMap> & mmap = {},
size_t bound = 0);
// NOTE: much more lookup than insert/remove operations
//
std::vector<word_t> active;
// replay given trace
// threads containing calls to a specific checkpoint
//
std::unique_ptr<Trace> replay (const Trace & trace, size_t bound = 0);
// checkpoint id -> list of threads
//
std::unordered_map<word_t, std::unordered_set<word_t>> threads_per_checkpoint;
// threads waiting for a specific checkpoint
//
// checkpoint id -> number of threads
//
std::unordered_map<word_t, word_t> waiting_for_checkpoint;
};
//==============================================================================
......
......@@ -5,6 +5,7 @@
#include "simulator.hh"
#include "mmap.hh"
#include "trace.hh"
#include "parser.hh"
namespace ConcuBinE::test {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment