Skip to content

Commit 1c9f355

Browse files
authored
Merge pull request #302 from leekillough/misc_fixes
Misc fixes
2 parents 17f4c6e + 501dc4f commit 1c9f355

19 files changed

+145
-206
lines changed

include/RevCPU.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class RevCPU : public SST::Component {
4848
RevCPU( SST::ComponentId_t id, const SST::Params& params );
4949

5050
/// RevCPU: top-level SST component destructor
51-
~RevCPU();
51+
~RevCPU() = default;
5252

5353
/// RevCPU: disallow copying and assignment
5454
RevCPU( const RevCPU& ) = delete;
@@ -212,17 +212,17 @@ class RevCPU : public SST::Component {
212212
}
213213

214214
private:
215-
unsigned numCores{}; ///< RevCPU: number of RISC-V cores
216-
unsigned numHarts{}; ///< RevCPU: number of RISC-V cores
215+
uint32_t numCores{}; ///< RevCPU: number of RISC-V cores
216+
uint32_t numHarts{}; ///< RevCPU: number of RISC-V cores
217217
unsigned msgPerCycle{}; ///< RevCPU: number of messages to send per cycle
218218
// unsigned RDMAPerCycle{}; ///< RevCPU: number of RDMA messages per cycle to inject into PAN network
219219
// unsigned testStage{}; ///< RevCPU: controls the PAN Test harness staging
220220
// unsigned testIters{}; ///< RevCPU: the number of message iters for each PAN Test
221-
RevOpts* Opts{}; ///< RevCPU: Simulation options object
222-
RevMem* Mem{}; ///< RevCPU: RISC-V main memory object
223-
RevLoader* Loader{}; ///< RevCPU: RISC-V loader
224-
std::vector<RevCore*> Procs{}; ///< RevCPU: RISC-V processor objects
225-
bool* Enabled{}; ///< RevCPU: Completion structure
221+
std::unique_ptr<RevOpts> Opts; ///< RevCPU: Simulation options object
222+
std::unique_ptr<RevMem> Mem; ///< RevCPU: RISC-V main memory object
223+
std::unique_ptr<RevLoader> Loader; ///< RevCPU: RISC-V loader
224+
std::vector<std::unique_ptr<RevCore>> Procs; ///< RevCPU: RISC-V processor objects
225+
std::vector<bool> Enabled; ///< RevCPU: Completion structure
226226

227227
// Initializes a RevThread object.
228228
// - Adds it's ThreadID to the ThreadQueue to be scheduled
@@ -266,7 +266,7 @@ class RevCPU : public SST::Component {
266266
uint8_t PrivTag{}; ///< RevCPU: private tag locator
267267
// uint32_t LToken{}; ///< RevCPU: token identifier for PAN Test
268268

269-
int address{}; ///< RevCPU: local network address
269+
int address{ -1 }; ///< RevCPU: local network address
270270

271271
unsigned fault_width{}; ///< RevCPU: the width (in bits) for target faults
272272
// int64_t fault_range{}; ///< RevCPU: the range of cycles to inject the fault
@@ -289,10 +289,10 @@ class RevCPU : public SST::Component {
289289
TimeConverter* timeConverter{}; ///< RevCPU: SST time conversion handler
290290
SST::Output output{}; ///< RevCPU: SST output handler
291291

292-
nicAPI* Nic{}; ///< RevCPU: Network interface controller
293-
RevMemCtrl* Ctrl{}; ///< RevCPU: Rev memory controller
292+
nicAPI* Nic{}; ///< RevCPU: Network interface controller
293+
std::unique_ptr<RevMemCtrl> Ctrl; ///< RevCPU: Rev memory controller
294294

295-
std::vector<RevCoProc*> CoProcs{}; ///< RevCPU: CoProcessor attached to Rev
295+
std::vector<std::unique_ptr<RevCoProc>> CoProcs; ///< RevCPU: CoProcessor attached to Rev
296296

297297
SST::Clock::Handler<RevCPU>* ClockHandler{}; ///< RevCPU: Clock Handler
298298

include/RevMem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class RevMem {
5555
RevMem( uint64_t MemSize, RevOpts* Opts, SST::Output* Output );
5656

5757
/// RevMem: standard memory controller constructor
58-
RevMem( uint64_t MemSize, RevOpts* Opts, RevMemCtrl* Ctrl, SST::Output* Output );
58+
RevMem( uint64_t memSize, RevOpts* opts, RevMemCtrl* ctrl, SST::Output* output );
5959

6060
/// RevMem: standard destructor
6161
~RevMem() { delete[] physMem; }

include/insns/CMakeLists.txt

-15
This file was deleted.

scripts/slurm/build-gcc11-sst13.1.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc11-sst14.0.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc11.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc13-sst13.1.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc13-sst14.0.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-gcc13.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-llvm12-sst13.1.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-llvm12-sst14.0.0.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

scripts/slurm/build-llvm12.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cd build
3535
rm -Rf ./*
3636

3737
#-- Stage 3: initiate the build
38-
cmake -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
38+
cmake -DBUILD_ASM_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DRVCC=${RVCC} ../ >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
3939
make clean >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4040
make uninstall >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1
4141
make -j >> ../rev.jenkins.${SLURM_JOB_ID}.out 2>&1

src/RevCPU.cc

+28-76
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,18 @@ namespace SST::RevCPU {
1919

2020
using MemSegment = RevMem::MemSegment;
2121

22-
const char splash_msg[] = "\
23-
\n\
24-
******* \n\
25-
/**////** \n\
26-
/** /** ***** ** **\n\
27-
/******* **///**/** /**\n\
28-
/**///** /*******//** /** \n\
29-
/** //** /**//// //**** \n\
30-
/** //**//****** //** \n\
31-
// // ////// // \n\
32-
\n\
33-
";
34-
35-
RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
36-
: SST::Component( id ), PrivTag( 0 ), address( -1 ), EnableMemH( false ), DisableCoprocClock( false ), Nic( nullptr ),
37-
Ctrl( nullptr ), ClockHandler( nullptr ) {
22+
const char splash_msg[] = R"(
23+
*******
24+
/**////**
25+
/** /** ***** ** **
26+
/******* **///**/** /**
27+
/**///** /*******//** /**
28+
/** //** /**//// //****
29+
/** //**//****** //**
30+
// // ////// //
31+
)";
32+
33+
RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params ) : SST::Component( id ) {
3834

3935
const int Verbosity = params.find<int>( "verbose", 0 );
4036

@@ -52,12 +48,12 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
5248

5349
// Derive the simulation parameters
5450
// We must always derive the number of cores before initializing the options
55-
numCores = params.find<unsigned>( "numCores", "1" );
56-
numHarts = params.find<uint16_t>( "numHarts", "1" );
51+
numCores = params.find<uint32_t>( "numCores", "1" );
52+
numHarts = params.find<uint32_t>( "numHarts", "1" );
5753

58-
// Make sure someone isn't trying to have more than 65536 harts per core
54+
// Make sure someone isn't trying to have more than _MAX_HARTS_ harts per core
5955
if( numHarts > _MAX_HARTS_ ) {
60-
output.fatal( CALL_INFO, -1, "Error: number of harts must be <= %" PRIu32 "\n", _MAX_HARTS_ );
56+
output.fatal( CALL_INFO, -1, "Error: number of harts must be <= %" PRIu32 "\n", uint32_t{ _MAX_HARTS_ } );
6157
}
6258
output.verbose(
6359
CALL_INFO, 1, 0, "Building Rev with %" PRIu32 " cores and %" PRIu32 " hart(s) on each core \n", numCores, numHarts
@@ -67,9 +63,7 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
6763
auto Exe = params.find<std::string>( "program", "a.out" );
6864

6965
// Create the options object
70-
Opts = new( std::nothrow ) RevOpts( numCores, numHarts, Verbosity );
71-
if( !Opts )
72-
output.fatal( CALL_INFO, -1, "Error: failed to initialize the RevOpts object\n" );
66+
Opts = std::make_unique<RevOpts>( numCores, numHarts, Verbosity );
7367

7468
// Program arguments
7569
Opts->SetArgs( params );
@@ -85,7 +79,7 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
8579
} ) {
8680
std::vector<std::string> optList;
8781
params.find_array( ParamName, optList );
88-
if( !( Opts->*InitFunc )( optList ) )
82+
if( !( Opts.get()->*InitFunc )( optList ) )
8983
output.fatal( CALL_INFO, -1, "Error: failed to initialize %s\n", ParamName );
9084
}
9185

@@ -125,28 +119,15 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
125119
const uint64_t memSize = params.find<unsigned long>( "memSize", 1073741824 );
126120
EnableMemH = params.find<bool>( "enable_memH", 0 );
127121
if( !EnableMemH ) {
128-
// TODO: Use std::nothrow to return null instead of throwing std::bad_alloc
129-
Mem = new RevMem( memSize, Opts, &output );
130-
if( !Mem )
131-
output.fatal( CALL_INFO, -1, "Error: failed to initialize the memory object\n" );
122+
Mem = std::make_unique<RevMem>( memSize, Opts.get(), &output );
132123
} else {
133-
Ctrl = loadUserSubComponent<RevMemCtrl>( "memory" );
124+
Ctrl = std::unique_ptr<RevMemCtrl>( loadUserSubComponent<RevMemCtrl>( "memory" ) );
134125
if( !Ctrl )
135126
output.fatal( CALL_INFO, -1, "Error : failed to inintialize the memory controller subcomponent\n" );
136-
137-
// TODO: Use std::nothrow to return null instead of throwing std::bad_alloc
138-
Mem = new RevMem( memSize, Opts, Ctrl, &output );
139-
if( !Mem )
140-
output.fatal( CALL_INFO, -1, "Error : failed to initialize the memory object\n" );
127+
Mem = std::make_unique<RevMem>( memSize, Opts.get(), Ctrl.get(), &output );
141128

142129
if( EnableFaults )
143-
output.verbose(
144-
CALL_INFO,
145-
1,
146-
0,
147-
"Warning: memory faults cannot be enabled with "
148-
"memHierarchy support\n"
149-
);
130+
output.verbose( CALL_INFO, 1, 0, "Warning: memory faults cannot be enabled with memHierarchy support\n" );
150131
}
151132

152133
// Set TLB Size
@@ -158,27 +139,24 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
158139
Mem->SetMaxHeapSize( maxHeapSize );
159140

160141
// Load the binary into memory
161-
Loader = new( std::nothrow ) RevLoader( Exe, Opts->GetArgv(), Mem, &output );
162-
if( !Loader ) {
163-
output.fatal( CALL_INFO, -1, "Error: failed to initialize the RISC-V loader\n" );
164-
}
142+
Loader = std::make_unique<RevLoader>( Exe, Opts->GetArgv(), Mem.get(), &output );
165143

166144
// Create the processor objects
167145
Procs.reserve( Procs.size() + numCores );
168146
for( unsigned i = 0; i < numCores; i++ ) {
169-
Procs.push_back( new RevCore( i, Opts, numHarts, Mem, Loader, this->GetNewTID(), &output ) );
147+
Procs.push_back( std::make_unique<RevCore>( i, Opts.get(), numHarts, Mem.get(), Loader.get(), this->GetNewTID(), &output ) );
170148
}
171149

172150
EnableCoProc = params.find<bool>( "enableCoProc", 0 );
173151
if( EnableCoProc ) {
174152
// Create the co-processor objects
175153
for( unsigned i = 0; i < numCores; i++ ) {
176-
RevCoProc* CoProc = loadUserSubComponent<RevCoProc>( "co_proc", SST::ComponentInfo::SHARE_NONE, Procs[i] );
154+
RevCoProc* CoProc = loadUserSubComponent<RevCoProc>( "co_proc", SST::ComponentInfo::SHARE_NONE, Procs[i].get() );
177155
if( !CoProc ) {
178156
output.fatal( CALL_INFO, -1, "Error : failed to inintialize the co-processor subcomponent\n" );
179157
}
180-
CoProcs.push_back( CoProc );
181158
Procs[i]->SetCoProc( CoProc );
159+
CoProcs.push_back( std::unique_ptr<RevCoProc>( CoProc ) );
182160
}
183161
}
184162

@@ -335,7 +313,7 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
335313
DisableCoprocClock = params.find<bool>( "independentCoprocClock", 0 );
336314

337315
// Create the completion array
338-
Enabled = new bool[numCores]{ false };
316+
Enabled = std::vector<bool>( numCores );
339317

340318
const unsigned Splash = params.find<bool>( "splash", 0 );
341319

@@ -352,32 +330,6 @@ RevCPU::RevCPU( SST::ComponentId_t id, const SST::Params& params )
352330
}
353331
}
354332

355-
RevCPU::~RevCPU() {
356-
// delete the competion array
357-
delete[] Enabled;
358-
359-
// delete the processors objects
360-
for( size_t i = 0; i < Procs.size(); i++ ) {
361-
delete Procs[i];
362-
}
363-
364-
for( size_t i = 0; i < CoProcs.size(); i++ ) {
365-
delete CoProcs[i];
366-
}
367-
368-
// delete the memory controller if present
369-
delete Ctrl;
370-
371-
// delete the memory object
372-
delete Mem;
373-
374-
// delete the loader object
375-
delete Loader;
376-
377-
// delete the options object
378-
delete Opts;
379-
}
380-
381333
void RevCPU::DecodeFaultWidth( const std::string& width ) {
382334
fault_width = 1; // default to single bit failures
383335

@@ -850,7 +802,7 @@ void RevCPU::HandleThreadStateChangesForProc( uint32_t ProcID ) {
850802
}
851803

852804
void RevCPU::InitMainThread( uint32_t MainThreadID, const uint64_t StartAddr ) {
853-
auto MainThreadRegState = std::make_unique<RevRegFile>( Procs[0] );
805+
auto MainThreadRegState = std::make_unique<RevRegFile>( Procs[0].get() );
854806

855807
// The Program Counter gets set to the start address
856808
MainThreadRegState->SetPC( StartAddr );

src/RevFeature.cc

+15-5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ bool RevFeature::ParseMachineModel() {
8181
// -- step 2: parse all the features
8282
// Note: Extension strings, if present, must appear in the order listed in the table above.
8383
if( *mac ) {
84+
char unsupported_version[128];
85+
*unsupported_version = 0;
86+
8487
for( auto [ext, majorVersion, minorVersion, minimumVersion, maximumVersion, flags] : table ) {
8588
// Look for an architecture string matching the current extension
8689
if( !strncasecmp( mac, ext.data(), ext.size() ) ) {
@@ -98,10 +101,12 @@ bool RevFeature::ParseMachineModel() {
98101
minorVersion = strtoul( mac, const_cast<char**>( &mac ), 10 );
99102
}
100103

101-
if( majorVersion < minimumVersion || majorVersion > maximumVersion ) {
102-
output->fatal(
103-
CALL_INFO,
104-
-1,
104+
// Record first unsupported extension version
105+
// Error is delayed so that parse errors in the architecture string take priority
106+
if( ( majorVersion < minimumVersion || majorVersion > maximumVersion ) && !*unsupported_version ) {
107+
snprintf(
108+
unsupported_version,
109+
sizeof( unsupported_version ),
105110
"Error: Version %" PRIu32 ".%" PRIu32 " of %s extension is not supported\n",
106111
majorVersion,
107112
minorVersion,
@@ -114,8 +119,13 @@ bool RevFeature::ParseMachineModel() {
114119
++mac;
115120

116121
// Success if end of string is reached
117-
if( !*mac )
122+
if( !*mac ) {
123+
// Report error on first unsupported extension version
124+
if( *unsupported_version ) {
125+
output->fatal( CALL_INFO, -1, "%s", unsupported_version );
126+
}
118127
return true;
128+
}
119129
}
120130
}
121131
}

0 commit comments

Comments
 (0)