main.cc (10152:52c552138ba1) | main.cc (10234:5cb711fa6176) |
---|---|
1/***************************************************************************** 2 * McPAT 3 * SOFTWARE LICENSE AGREEMENT 4 * Copyright 2012 Hewlett-Packard Development Company, L.P. | 1/***************************************************************************** 2 * McPAT 3 * SOFTWARE LICENSE AGREEMENT 4 * Copyright 2012 Hewlett-Packard Development Company, L.P. |
5 * Copyright (c) 2010-2013 Advanced Micro Devices, Inc. |
|
5 * All Rights Reserved 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer; 11 * redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the --- 7 unchanged lines hidden (view full) --- 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 6 * All Rights Reserved 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer; 12 * redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the --- 7 unchanged lines hidden (view full) --- 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 * 30 ***************************************************************************/ | 30 * 31 ***************************************************************************/ |
32#include <sys/stat.h> 33 34#include <cassert> |
|
31#include <iostream> 32 | 35#include <iostream> 36 |
33#include "XML_Parse.h" 34#include "globalvar.h" | 37#include "basic_components.h" |
35#include "io.h" | 38#include "io.h" |
36#include "processor.h" | 39#include "system.h" |
37#include "version.h" 38#include "xmlParser.h" 39 40using namespace std; 41 42void print_usage(char * argv0); 43 | 40#include "version.h" 41#include "xmlParser.h" 42 43using namespace std; 44 45void print_usage(char * argv0); 46 |
44int main(int argc,char *argv[]) 45{ 46 char * fb ; 47 bool infile_specified = false; 48 int plevel = 2; 49 opt_for_clk =true; 50 //cout.precision(10); 51 if (argc <= 1 || argv[1] == string("-h") || argv[1] == string("--help")) 52 { 53 print_usage(argv[0]); 54 } | 47int main(int argc, char *argv[]) { 48 char* xml_file = NULL; 49 int plevel = 2; |
55 | 50 |
56 for (int32_t i = 0; i < argc; i++) 57 { 58 if (argv[i] == string("-infile")) 59 { 60 infile_specified = true; 61 i++; 62 fb = argv[ i]; 63 } | 51 for (int32_t i = 0; i < argc; i++) { 52 if (argv[i] == string("-infile")) { 53 xml_file = argv[++i]; |
64 | 54 |
65 if (argv[i] == string("-print_level")) 66 { 67 i++; 68 plevel = atoi(argv[i]); 69 } | 55 } else if (argv[i] == string("-print_level")) { 56 plevel = atoi(argv[++i]); |
70 | 57 |
71 if (argv[i] == string("-opt_for_clk")) 72 { 73 i++; 74 opt_for_clk = (bool)atoi(argv[i]); 75 } | 58 } else if (argv[i] == string("-opt_for_clk")) { 59 McPATComponent::opt_for_clk = (bool)atoi(argv[++i]); |
76 } | 60 } |
77 if (infile_specified == false) 78 { 79 print_usage(argv[0]); 80 } | 61 } |
81 | 62 |
63 // Ensure that the XML file was specified 64 if (xml_file == NULL) { 65 cerr << "ERROR: Please specify infile\n\n"; 66 print_usage(argv[0]); 67 } |
|
82 | 68 |
83 cout<<"McPAT (version "<< VER_MAJOR <<"."<< VER_MINOR 84 << " of " << VER_UPDATE << ") is computing the target processor...\n "<<endl; | 69 // Ensure that the XML file exists 70 struct stat file_info; 71 if (stat(xml_file, &file_info)) { 72 cerr << "ERROR: File not found: " << xml_file << endl << endl; 73 print_usage(argv[0]); 74 } |
85 | 75 |
86 //parse XML-based interface 87 ParseXML *p1= new ParseXML(); 88 p1->parse(fb); 89 Processor proc(p1); 90 proc.displayEnergy(2, plevel); 91 delete p1; 92 return 0; | 76 cout << "McPAT (version " << VER_MAJOR << "." << VER_MINOR 77 << " of " << VER_UPDATE << ") is computing the target processor...\n " 78 << endl; 79 80 // Parse the XML input file 81 XMLNode xml_data = XMLNode::openFileHelper(xml_file, "component"); 82 unsigned int num_children = xml_data.nChildNode("component"); 83 assert(num_children == 1); 84 XMLNode system_xml = xml_data.getChildNode("component"); 85 assert(strcmp(system_xml.getAttribute("type"), "System") == 0); 86 87 // Recursively instantiate the system hierarchy 88 System* system = new System(&system_xml); 89 90 // Recursively compute chip area 91 system->computeArea(); 92 93 // Recursively compute the power consumed 94 system->computeEnergy(); 95 96 // Recursively output the computed values 97 system->displayData(2, plevel); 98 99 // Clean up 100 delete system; 101 return 0; 102 |
93} 94 | 103} 104 |
95void print_usage(char * argv0) 96{ | 105void print_usage(char * argv0) { |
97 cerr << "How to use McPAT:" << endl; | 106 cerr << "How to use McPAT:" << endl; |
98 cerr << " mcpat -infile <input file name> -print_level < level of details 0~5 > -opt_for_clk < 0 (optimize for ED^2P only)/1 (optimzed for target clock rate)>"<< endl; 99 //cerr << " Note:default print level is at processor level, please increase it to see the details" << endl; | 107 cerr << " mcpat -infile <input file name> -print_level < " 108 << "level of details 0~5 > -opt_for_clk < 0 (optimize for ED^2P " 109 << "only)/1 (optimzed for target clock rate)>" << endl; |
100 exit(1); 101} | 110 exit(1); 111} |