Deleted Added
sdiff udiff text old ( 7454:3a3e8e8cce1b ) new ( 7542:49327b849c7f )
full compact
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 131 unchanged lines hidden (view full) ---

140 def writeCodeFiles(self, path):
141 self.printControllerPython(path)
142 self.printControllerHH(path)
143 self.printControllerCC(path)
144 self.printCSwitch(path)
145 self.printCWakeup(path)
146 self.printProfilerCC(path)
147 self.printProfilerHH(path)
148
149 for func in self.functions:
150 func.writeCodeFiles(path)
151
152 def printControllerPython(self, path):
153 code = self.symtab.codeFormatter()
154 ident = self.ident
155 py_ident = "%s_Controller" % ident

--- 47 unchanged lines hidden (view full) ---

203#include "params/$c_ident.hh"
204
205#include "mem/ruby/common/Global.hh"
206#include "mem/ruby/common/Consumer.hh"
207#include "mem/ruby/slicc_interface/AbstractController.hh"
208#include "mem/protocol/TransitionResult.hh"
209#include "mem/protocol/Types.hh"
210#include "mem/protocol/${ident}_Profiler.hh"
211''')
212
213 seen_types = set()
214 for var in self.objects:
215 if var.type.ident not in seen_types and not var.type.isPrimitive:
216 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
217 seen_types.add(var.type.ident)
218

--- 53 unchanged lines hidden (view full) ---

272int m_buffer_size;
273int m_recycle_latency;
274std::map<std::string, std::string> m_cfg;
275NodeID m_version;
276Network* m_net_ptr;
277MachineID m_machineID;
278bool m_is_blocking;
279std::map<Address, MessageBuffer*> m_block_map;
280${ident}_Profiler s_profiler;
281static int m_num_controllers;
282
283// Internal functions
284''')
285
286 for func in self.functions:
287 proto = func.prototype
288 if proto:

--- 63 unchanged lines hidden (view full) ---

352 code('''
353$c_ident *
354${c_ident}Params::create()
355{
356 return new $c_ident(this);
357}
358
359int $c_ident::m_num_controllers = 0;
360
361// for adding information to the protocol debug trace
362stringstream ${ident}_transitionComment;
363#define APPEND_TRANSITION_COMMENT(str) (${ident}_transitionComment << str)
364
365/** \\brief constructor */
366$c_ident::$c_ident(const Params *p)
367 : AbstractController(p)

--- 61 unchanged lines hidden (view full) ---

429{
430 MachineType machine_type;
431 int base;
432
433 m_machineID.type = MachineType_${ident};
434 m_machineID.num = m_version;
435
436 // initialize objects
437 s_profiler.setVersion(m_version);
438
439''')
440
441 code.indent()
442 for var in self.objects:
443 vtype = var.type
444 vid = "m_%s_ptr" % var.c_ident
445 if "network" not in var:

--- 103 unchanged lines hidden (view full) ---

549 for action in trans.actions:
550 if action.ident == "z_stall":
551 stall = True
552
553 # Only possible if it is not a 'z' case
554 if not stall:
555 state = "%s_State_%s" % (self.ident, trans.state.ident)
556 event = "%s_Event_%s" % (self.ident, trans.event.ident)
557 code('s_profiler.possibleTransition($state, $event);')
558
559 # added by SS to initialize recycle_latency of message buffers
560 for buf in self.message_buffer_names:
561 code("$buf->setRecycleLatency(m_recycle_latency);")
562
563 code.dedent()
564 code('}')
565

--- 87 unchanged lines hidden (view full) ---

653 for param in self.config_parameters:
654 if param.type_ast.type.ident == "CacheMemory" or \
655 param.type_ast.type.ident == "DirectoryMemory" or \
656 param.type_ast.type.ident == "MemoryControl":
657 assert(param.pointer)
658 code(' m_${{param.ident}}_ptr->printStats(out);')
659
660 code('''
661 s_profiler.dumpStats(out);
662}
663
664void $c_ident::clearStats() {
665''')
666 #
667 # Cache and Memory Controllers have specific profilers associated with
668 # them. These stats must be cleared too.
669 #
670 for param in self.config_parameters:
671 if param.type_ast.type.ident == "CacheMemory" or \
672 param.type_ast.type.ident == "MemoryControl":
673 assert(param.pointer)
674 code(' m_${{param.ident}}_ptr->clearStats();')
675
676 code('''
677 s_profiler.clearStats();
678}
679
680// Actions
681''')
682
683 for action in self.actions.itervalues():
684 if "c_code" not in action:
685 continue

--- 113 unchanged lines hidden (view full) ---

799 DEBUG_EXPR(GENERATED_COMP, MedPrio,addr);
800
801 TransitionResult result =
802 doTransitionWorker(event, state, next_state, addr);
803
804 if (result == TransitionResult_Valid) {
805 DEBUG_EXPR(GENERATED_COMP, MedPrio, next_state);
806 DEBUG_NEWLINE(GENERATED_COMP, MedPrio);
807 s_profiler.countTransition(state, event);
808 if (Debug::getProtocolTrace()) {
809 g_system_ptr->getProfiler()->profileTransition("${ident}",
810 m_version, addr,
811 ${ident}_State_to_string(state),
812 ${ident}_Event_to_string(event),
813 ${ident}_State_to_string(next_state),
814 GET_TRANSITION_COMMENT());
815 }

--- 107 unchanged lines hidden (view full) ---

923 WARN_EXPR(state);
924 ERROR_MSG(\"Invalid transition\");
925 }
926 return TransitionResult_Valid;
927}
928''')
929 code.write(path, "%s_Transitions.cc" % self.ident)
930
931 def printProfilerHH(self, path):
932 code = self.symtab.codeFormatter()
933 ident = self.ident
934
935 code('''
936// Auto generated C++ code started by $__file__:$__line__
937// ${ident}: ${{self.short}}
938
939#ifndef __${ident}_PROFILER_HH_
940#define __${ident}_PROFILER_HH_
941
942#include <iostream>
943
944#include "mem/ruby/common/Global.hh"
945#include "mem/protocol/${ident}_State.hh"
946#include "mem/protocol/${ident}_Event.hh"
947
948class ${ident}_Profiler
949{
950 public:
951 ${ident}_Profiler();
952 void setVersion(int version);
953 void countTransition(${ident}_State state, ${ident}_Event event);
954 void possibleTransition(${ident}_State state, ${ident}_Event event);
955 void dumpStats(std::ostream& out) const;
956 void clearStats();
957
958 private:
959 int m_counters[${ident}_State_NUM][${ident}_Event_NUM];
960 int m_event_counters[${ident}_Event_NUM];
961 bool m_possible[${ident}_State_NUM][${ident}_Event_NUM];
962 int m_version;
963};

--- 53 unchanged lines hidden (view full) ---

1017}
1018void
1019${ident}_Profiler::possibleTransition(${ident}_State state,
1020 ${ident}_Event event)
1021{
1022 m_possible[state][event] = true;
1023}
1024
1025void
1026${ident}_Profiler::dumpStats(std::ostream& out) const
1027{
1028 using namespace std;
1029
1030 out << " --- ${ident} " << m_version << " ---" << endl;
1031 out << " - Event Counts -" << endl;
1032 for (int event = 0; event < ${ident}_Event_NUM; event++) {
1033 int count = m_event_counters[event];
1034 out << (${ident}_Event) event << " " << count << endl;
1035 }
1036 out << endl;
1037 out << " - Transitions -" << endl;
1038 for (int state = 0; state < ${ident}_State_NUM; state++) {
1039 for (int event = 0; event < ${ident}_Event_NUM; event++) {
1040 if (m_possible[state][event]) {
1041 int count = m_counters[state][event];
1042 out << (${ident}_State) state << " "
1043 << (${ident}_Event) event << " " << count;
1044 if (count == 0) {
1045 out << " <-- ";
1046 }
1047 out << endl;
1048 }
1049 }
1050 out << endl;
1051 }
1052}
1053''')
1054 code.write(path, "%s_Profiler.cc" % self.ident)
1055
1056 # **************************
1057 # ******* HTML Files *******
1058 # **************************
1059 def frameRef(self, click_href, click_target, over_href, over_num, text):
1060 code = self.symtab.codeFormatter(fix_newlines=False)

--- 175 unchanged lines hidden ---