summaryrefslogtreecommitdiff
path: root/src/cuda-sim/instructions.cc
diff options
context:
space:
mode:
authorDeval Shah <[email protected]>2018-11-09 21:29:18 -0800
committerDeval Shah <[email protected]>2018-11-09 21:29:18 -0800
commit642818ae5ff61c1544bcce9e7ba2dd0aea47ea6a (patch)
tree74e003ab7fca4acf74272399ff5e90a470bd79ca /src/cuda-sim/instructions.cc
parent7a9c450e6b905af9ca6cdd3c7b79ad5aec535a5a (diff)
Adding checkpoint support
Diffstat (limited to 'src/cuda-sim/instructions.cc')
-rw-r--r--src/cuda-sim/instructions.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index f57a3f7..31a33c6 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -183,7 +183,63 @@ void ptx_thread_info::set_reg( const symbol *reg, const ptx_reg_t &value )
m_last_set_operand_value = value;
}
+void ptx_thread_info::print_reg_thread(char * fname)
+{
+
+ FILE *fp= fopen(fname,"w");
+ assert(fp!=NULL);
+
+ int size = m_regs.size();
+
+ if(size>0)
+ {
+ reg_map_t reg = m_regs.back();
+
+ typename reg_map_t::const_iterator it;
+ for (it = reg.begin(); it != reg.end(); ++it)
+ {
+ const std::string &name = it->first->name();
+ const std::string &dec= it->first->decl_location();
+ unsigned size = it->first->get_size_in_bytes();
+ fprintf(fp,"%s %llu %s %d\n",name.c_str(),it->second, dec.c_str(),size );
+
+ }
+ //m_regs.pop_back();
+ }
+ fclose(fp);
+
+ }
+
+void ptx_thread_info::resume_reg_thread(char * fname, symbol_table * symtab)
+{
+
+ FILE * fp2 = fopen(fname, "r");
+ assert(fp2!=NULL);
+ //m_regs.push_back( reg_map_t() );
+ char line [ 200 ];
+ while ( fgets ( line, sizeof line, fp2 ) != NULL )
+ {
+ symbol *reg;
+ char * pch;
+ unsigned size;
+ pch = strtok (line," ");
+ char * name =pch;
+ reg= symtab->lookup(name);
+ ptx_reg_t data;
+ pch = strtok (NULL," ");
+ data = atoi(pch);
+ pch = strtok (NULL," ");
+ char * decl= pch;
+ pch = strtok (NULL," ");
+ size = atoi(pch);
+
+
+ m_regs.back()[reg] = data;
+ }
+ fclose ( fp2 );
+}
+
ptx_reg_t ptx_thread_info::get_reg( const symbol *reg )
{