Skip to content

Commit

Permalink
Merge Pull Request sstsimulator#2406 from bliu1013/sst-elements/seria…
Browse files Browse the repository at this point in the history
…lization

Automatically Merged using SST Pull Request AutoTester
PR Title: b'Add basic test for simpleElementExample checkpointing'
PR Author: bliu1013
  • Loading branch information
sst-autotester authored Oct 10, 2024
2 parents 91707b4 + 5dd7aa1 commit 37c64f6
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/sst/elements/memHierarchy/memTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static const std::string NONE = "None";
enum class MemEventStatus { OK, Stall, Reject };

/* Define an address region by start/end & interleaving */
class MemRegion : public SST::Core::Serialization::serializable, SST::Core::Serialization::serializable_type<MemRegion> {
class MemRegion : public SST::Core::Serialization::serializable {
public:
SST::MemHierarchy::Addr start; // First address that is part of the region
SST::MemHierarchy::Addr end; // Last address that is part of the region
Expand Down
1 change: 1 addition & 0 deletions src/sst/elements/simpleElementExample/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ endif
EXTRA_DIST = \
README \
tests/testsuite_default_simpleComponents.py \
tests/basicCheckpoint.py \
tests/basicClocks.py \
tests/basicParams.py \
tests/basicStatistics1.py \
Expand Down
4 changes: 4 additions & 0 deletions src/sst/elements/simpleElementExample/basicSimLifeCycle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ void basicSimLifeCycle::serialize_order(SST::Core::Serialization::serializer& se
switch ( ser.mode() ) {
case SST::Core::Serialization::serializer::SIZER:
case SST::Core::Serialization::serializer::PACK:
break;
case SST::Core::Serialization::serializer::UNPACK:
{
//Reinitialize iter from neighbors
Expand All @@ -336,5 +337,8 @@ void basicSimLifeCycle::serialize_order(SST::Core::Serialization::serializer& se

break;
}
case SST::Core::Serialization::serializer::MAP:
// Mapping mode not supported
break;
}
}
31 changes: 31 additions & 0 deletions src/sst/elements/simpleElementExample/tests/basicCheckpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sst

# Test a basic param
basicParam = sst.Component("basicParam", "simpleElementExample.basicParams")
params = {
"int_param" : 20,
"bool_param" : "false",
"uint32_param" : "678",
"array_param" : "[0, 1, 5, 20, -1 ]",
"example_param" : "a:92",
}
basicParam.addParams(params)

component0 = sst.Component("c0", "simpleElementExample.example0")
component1 = sst.Component("c1", "simpleElementExample.example1")

params = {
"eventsToSend" : 50, # Required parameter, error if not provided
"eventSize" : 32 # Optional parameter, defaults to 16 if not provided
}
component0.addParams(params)
component1.addParams(params)

link = sst.Link("component_link0")
link.connect( (component0, "port", "1ns"), (component1, "port", "1ns") )


sst.setStatisticLoadLevel(7)
sst.setStatisticOutput("sst.statOutputConsole")
sst.enableAllStatisticsForComponentType("simpleElementExample.example0")
sst.enableAllStatisticsForComponentType("simpleElementExample.example1")
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ def test_basic_simlifecycle(self):
def test_basic_subcomponent(self):
self.simple_components_template("basicSubComponent")

def test_basic_checkpoint(self):
self.simple_components_template("basicCheckpoint", checkpoint=True)

#def test_simple_rng_component_marsaglia(self):
# self.simple_components_template("simpleRNGComponent_marsaglia", striptotail=1)

#####

def simple_components_template(self, testcase, striptotail=0):
def simple_components_template(self, testcase, striptotail=0, checkpoint=False):
# Get the path to the test files
test_path = self.get_testsuite_dir()
outdir = self.get_test_output_run_dir()
Expand All @@ -75,29 +78,51 @@ def simple_components_template(self, testcase, striptotail=0):
errfile = "{0}/{1}.err".format(outdir, testDataFileName)
mpioutfiles = "{0}/{1}.testfile".format(outdir, testDataFileName)

self.run_sst(sdlfile, outfile, errfile, mpi_out_files=mpioutfiles)

testing_remove_component_warning_from_file(outfile)

# Copy the outfile to the cmpfile
os.system("cp {0} {1}".format(outfile, cmpfile))

if striptotail == 1:
# Post processing of the output data to scrub it into a format to compare
os.system("grep Random {0} > {1}".format(outfile, tmpfile))
os.system("tail -5 {0} > {1}".format(tmpfile, cmpfile))

# NOTE: THE PASS / FAIL EVALUATIONS ARE PORTED FROM THE SQE BAMBOO
# BASED testSuite_XXX.sh THESE SHOULD BE RE-EVALUATED BY THE
# DEVELOPER AGAINST THE LATEST VERSION OF SST TO SEE IF THE
# TESTS & RESULT FILES ARE STILL VALID

# Perform the tests
if os_test_file(errfile, "-s"):
log_testing_note("simpleComponents test {0} has a Non-Empty Error File {1}".format(testDataFileName, errfile))

cmp_result = testing_compare_sorted_diff(testcase, cmpfile, reffile)
if (cmp_result == False):
diffdata = testing_get_diff_data(testcase)
log_failure(diffdata)
self.assertTrue(cmp_result, "Sorted Output file {0} does not match sorted Reference File {1}".format(cmpfile, reffile))
if not checkpoint:
self.run_sst(sdlfile, outfile, errfile, mpi_out_files=mpioutfiles)

testing_remove_component_warning_from_file(outfile)

# Copy the outfile to the cmpfile
os.system("cp {0} {1}".format(outfile, cmpfile))

if striptotail == 1:
# Post processing of the output data to scrub it into a format to compare
os.system("grep Random {0} > {1}".format(outfile, tmpfile))
os.system("tail -5 {0} > {1}".format(tmpfile, cmpfile))

# NOTE: THE PASS / FAIL EVALUATIONS ARE PORTED FROM THE SQE BAMBOO
# BASED testSuite_XXX.sh THESE SHOULD BE RE-EVALUATED BY THE
# DEVELOPER AGAINST THE LATEST VERSION OF SST TO SEE IF THE
# TESTS & RESULT FILES ARE STILL VALID

# Perform the tests
if os_test_file(errfile, "-s"):
log_testing_note("simpleComponents test {0} has a Non-Empty Error File {1}".format(testDataFileName, errfile))

cmp_result = testing_compare_sorted_diff(testcase, cmpfile, reffile)
if (cmp_result == False):
diffdata = testing_get_diff_data(testcase)
log_failure(diffdata)
self.assertTrue(cmp_result, "Sorted Output file {0} does not match sorted Reference File {1}".format(cmpfile, reffile))

# Checkpoint test
else:
cptfreq = "15us"
cptrestart = "0_15000000"

# Generate checkpoint
sdlfile_generate = "{0}/{1}.py".format(test_path,testcase)
outfile_generate = "{0}/{1}_generate.out".format(outdir,testcase)
options_checkpoint="--checkpoint-sim-period={0} --checkpoint-prefix={1}".format(cptfreq,testcase)
self.run_sst(sdlfile_generate, outfile_generate, other_args=options_checkpoint)

# Run from restart
sdlfile_restart = "{0}/{1}/{1}_{2}/{1}_{2}.sstcpt".format(outdir,testcase,cptrestart)
outfile_restart = "{0}/{1}_restart.out".format(outdir, testcase)
options_restart = "--load-checkpoint"
self.run_sst(sdlfile_restart, outfile_restart, other_args=options_restart)

# Check that restart output is a subset of checkpoint output
cmp_result = testing_compare_filtered_subset(outfile_restart, outfile_generate)
self.assertTrue(cmp_result, "Output/Compare file {0} does not match Reference File {1}".format(outfile_restart, outfile_generate))

0 comments on commit 37c64f6

Please sign in to comment.