Skip to content

Commit

Permalink
Merge Pull Request sstsimulator#2335 from mjleven/sst-elements/checkp…
Browse files Browse the repository at this point in the history
…oint

Automatically Merged using SST Pull Request AutoTester
PR Title: b'Checkpoint'
PR Author: mjleven
  • Loading branch information
sst-autotester authored Mar 18, 2024
2 parents 3b7b862 + 3094b0c commit 8fd0854
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 27 deletions.
15 changes: 8 additions & 7 deletions src/sst/elements/memHierarchy/membackend/backing.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class BackingMMAP : public Backing {
size_t m_offset;
};

#define CHECKPOINT_DBG 0
class BackingMalloc : public Backing {
public:
BackingMalloc(size_t size, bool init = false ) : m_init(init) {
Expand Down Expand Up @@ -126,7 +127,7 @@ class BackingMalloc : public Backing {
auto length = ( sizeof(uint8_t) * m_allocUnit ) / sizeof(uint64_t);

for ( auto i = 0; i < length ; i++ ) {
#if 0
#if CHECKPOINT_DBG
if ( i % 8 == 0 ) {
printf("\n%#lx ",addr + i*8);
}
Expand All @@ -141,7 +142,7 @@ class BackingMalloc : public Backing {
}

void set( Addr addr, uint8_t value ) {
#if 0
#if CHECKPOINT_DBG
printf("%s addr=%#lx\n",__func__,addr);
#endif
Addr bAddr = addr >> m_shift;
Expand All @@ -158,12 +159,12 @@ class BackingMalloc : public Backing {

allocIfNeeded(bAddr);

#if 0
#if CHECKPOINT_DBG
printf("%s() addr=%#lx size=%zu ",__func__,addr,size);
#endif
while (dataOffset != size) {
m_buffer[bAddr][offset] = data[dataOffset];
#if 0
#if CHECKPOINT_DBG
printf("%#x ",data[dataOffset]);
#endif
offset++;
Expand All @@ -175,13 +176,13 @@ class BackingMalloc : public Backing {
allocIfNeeded(bAddr);
}
}
#if 0
#if CHECKPOINT_DBG
printf("\n");
#endif
}

void get (Addr addr, size_t size, std::vector<uint8_t> &data) {
#if 0
#if CHECKPOINT_DBG
printf("%s() addr=%#lx size=%zu ",__func__,addr,size);
#endif
Addr bAddr = addr >> m_shift;
Expand All @@ -204,7 +205,7 @@ class BackingMalloc : public Backing {
allocIfNeeded(bAddr);
}
}
#if 0
#if CHECKPOINT_DBG
for ( auto i = 0; i < size; i++ ) {
printf("%x ",data[i]);
}
Expand Down
46 changes: 28 additions & 18 deletions src/sst/elements/vanadis/os/vnodeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,11 @@ void VanadisNodeOSComponent::handleIncomingMemory(StandardMem::Request* ev) {
}
} else {
// output->fatal(CALL_INFO, -1, "Error - received StandardMem response that does not belong to a core\n");
--m_x;
if ( m_x == 0 ) {
primaryComponentOKToEndSim();
m_flushPages.pop_front();
if ( m_flushPages.empty() ) {
primaryComponentOKToEndSim();
}

}
} else if (lookup_result != m_memRespMap.end()) {
handleIncomingMemory( lookup_result->second, ev );
Expand Down Expand Up @@ -603,21 +604,30 @@ VanadisNodeOSComponent::handleIncomingSyscall(SST::Event* ev) {
output->verbose(CALL_INFO, 0, VANADIS_DBG_CHECKPOINT,"checkoint \n");
// primaryComponentOKToEndSim();

StandardMem::Request* req = new SST::Interfaces::StandardMem::FlushAddr( 0x2bc0, 64, true, 5, 0 );
mem_if->send(req);
req = new SST::Interfaces::StandardMem::FlushAddr( 0x163c0, 64, true, 5, 0 );
mem_if->send(req);
req = new SST::Interfaces::StandardMem::FlushAddr( 0x16400, 64, true, 5, 0 );
mem_if->send(req);
req = new SST::Interfaces::StandardMem::FlushAddr( 0x90c0, 64, true, 5, 0 );
mem_if->send(req);
req = new SST::Interfaces::StandardMem::FlushAddr( 0x2c80, 64, true, 5, 0 );
mem_if->send(req);
req = new SST::Interfaces::StandardMem::FlushAddr( 0x2c00, 64, true, 5, 0 );
mem_if->send(req);
req = new SST::Interfaces::StandardMem::FlushAddr( 0x1b00, 64, true, 5, 0 );
mem_if->send(req);
m_x=7;
m_flushPages.push_back( 0x2bc0 );
m_flushPages.push_back( 0x163c0 );
m_flushPages.push_back( 0x16400 );
m_flushPages.push_back( 0x90c0 );
m_flushPages.push_back( 0x2c80 );
m_flushPages.push_back( 0x2c00 );
m_flushPages.push_back( 0x1b00 );

m_flushPages.push_back( 0x1b000 );
m_flushPages.push_back( 0x2b80 );
m_flushPages.push_back( 0x2980 );
m_flushPages.push_back( 0x2a00 );
m_flushPages.push_back( 0x2940 );
m_flushPages.push_back( 0x2900 );
m_flushPages.push_back( 0x3f80 );
m_flushPages.push_back( 0x2800 );
m_flushPages.push_back( 0x29c0 );
m_flushPages.push_back( 0x28c0 );

for ( auto & x : m_flushPages ) {
printf("%#lx\n",x);
StandardMem::Request* req = new SST::Interfaces::StandardMem::FlushAddr( x, 64, true, 5, 0 );
mem_if->send(req);
}
} else {
output->fatal(CALL_INFO, -1,
"Error - received an event in the OS, but cannot cast it to "
Expand Down
2 changes: 1 addition & 1 deletion src/sst/elements/vanadis/os/vnodeos.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class VanadisNodeOSComponent : public SST::Component {

void checkpoint( std::string dir );
int checkpointLoad( std::string dir );
int m_x;
std::deque<uint64_t> m_flushPages;
};

} // namespace Vanadis
Expand Down
15 changes: 14 additions & 1 deletion src/sst/elements/vanadis/tests/basic_vanadis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
dbgAddr="0"
stopDbg="0"

checkpointDir = ""
checkpoint = ""

#checkpointDir = "checkpoint0"
#checkpoint = "load"
#checkpoint = "save"

pythonDebug=False

vanadis_isa = os.getenv("VANADIS_ISA", "MIPS")
Expand Down Expand Up @@ -47,6 +54,7 @@
#exe = "openmp2"
#exe = "uname"
#exe = "mem-test"
#exe = "checkpoint"

physMemSize = "4GiB"

Expand Down Expand Up @@ -133,6 +141,8 @@
"page_size" : 4096,
"physMemSize" : physMemSize,
"useMMU" : True,
"checkpointDir" : checkpointDir,
"checkpoint" : checkpoint
}


Expand Down Expand Up @@ -205,7 +215,8 @@
"addr_range_end": 0xffffffff,
"debug_level" : mh_debug_level,
"debug" : mh_debug,

"checkpointDir" : checkpointDir,
"checkpoint" : checkpoint
}

memParams = {
Expand Down Expand Up @@ -260,6 +271,8 @@
"start_verbose_when_issue_address": dbgAddr,
"stop_verbose_when_retire_address": stopDbg,
"print_rob" : False,
"checkpointDir" : checkpointDir,
"checkpoint" : checkpoint
}

lsqParams = {
Expand Down
58 changes: 58 additions & 0 deletions src/sst/elements/vanadis/tests/small/misc/checkpoint/checkpoint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2009-2023 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2023, NTESS
// All rights reserved.
//
// Portions are copyright of other developers:
// See the file CONTRIBUTORS.TXT in the top level directory
// of the distribution for more information.
//
// This file is part of the SST software package. For license
// information, see the LICENSE file in the top level directory of the
// distribution.

#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>

#include <omp.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {

setvbuf(stdout, NULL, _IONBF ,0);

omp_lock_t lock;
omp_init_lock(&lock);

int nthreads, tid;
char* tmp = getenv("OMP_NUM_THREADS");
printf("OMP_NUM_THREADS %s\n", tmp ? tmp: "not set");

/* Fork a team of threads giving them their own copies of variables */
#pragma omp parallel private(nthreads, tid)
{
/* Obtain thread number */
tid = omp_get_thread_num();

syscall(500);

/* Only master thread does this */
if (tid == 0)
{
nthreads = omp_get_num_threads();
omp_set_lock( &lock );
printf("Number of threads = %d\n", nthreads);
omp_unset_lock( &lock );
}

omp_set_lock( &lock );
printf("Hello World from thread = %d\n", tid);
omp_unset_lock( &lock );

} /* All threads join master thread and disband */

printf("exit\n");
}
Binary file not shown.

0 comments on commit 8fd0854

Please sign in to comment.