⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainsim.cc

📁 ml-rsim 多处理器模拟器 支持类bsd操作系统
💻 CC
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (c) 2002 The Board of Trustees of the University of Illinois and *                    William Marsh Rice University * Copyright (c) 2002 The University of Utah * Copyright (c) 2002 The University of Notre Dame du Lac * * All rights reserved. * * Based on RSIM 1.0, developed by: *   Professor Sarita Adve's RSIM research group *   University of Illinois at Urbana-Champaign and     William Marsh Rice University *   http://www.cs.uiuc.edu/rsim and http://www.ece.rice.edu/~rsim/dist.html * ML-RSIM/URSIM extensions by: *   The Impulse Research Group, University of Utah *   http://www.cs.utah.edu/impulse *   Lambert Schaelicke, University of Utah and University of Notre Dame du Lac *   http://www.cse.nd.edu/~lambert *   Mike Parker, University of Utah *   http://www.cs.utah.edu/~map * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal with the Software without restriction, including without * limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to * whom the Software is furnished to do so, subject to the following * conditions: * * 1. Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimers.  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimers in the *    documentation and/or other materials provided with the distribution. * 3. Neither the names of Professor Sarita Adve's RSIM research group, *    the University of Illinois at Urbana-Champaign, William Marsh Rice *    University, nor the names of its contributors may be used to endorse *    or promote products derived from this Software without specific prior *    written permission.  * 4. Neither the names of the ML-RSIM project, the URSIM project, the *    Impulse research group, the University of Utah, the University of *    Notre Dame du Lac, nor the names of its contributors may be used to *    endorse or promote products derived from this software without specific *    prior written permission.  * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS WITH THE SOFTWARE.  */#include <stdlib.h>#include <stdio.h>#include <string.h>#include <fcntl.h>#include <signal.h>#include <unistd.h>#include <time.h>#include <math.h>#include <errno.h>#include <sys/param.h>#include <sys/stat.h>#include <sys/time.h>#include <sys/resource.h>#include <sys/utsname.h>int getrusage(int who, struct rusage *rusage);extern "C"{#include "sim_main/util.h"#include "sim_main/simsys.h"#include "sim_main/evlst.h"#include "Caches/system.h"#include "Caches/cache.h"#include "Caches/ubuf.h"#include "Bus/bus.h"}#include "Processor/multiprocessor.h"#include "Processor/predecode.h"#include "Processor/procstate.h"#include "Processor/memunit.h"#include "Processor/mainsim.h"#include "Processor/simio.h"#include "Processor/exec.h"#include "Processor/branchpred.h"#include "Processor/fastnews.h"#include "Processor/procstate.hh"#include "Processor/tagcvt.hh"#include "Processor/memunit.hh"#include "Processor/exec.hh"#include "Processor/stallq.hh"#include "Processor/active.hh"#include "../../lamix/machine/intr.h"/***********************************************************************//********** system configuration variable declarations *****************//***********************************************************************/int MAX_ACTIVE_NUMBER        = 128; /* this means 64 instructions */int MAX_ACTIVE_INSTS         = 64;int MAX_SPEC                 = 8;int FETCH_QUEUE_SIZE         = 8;int FETCHES_PER_CYCLE        = 4;int DECODES_PER_CYCLE        = 4;int GRADUATES_PER_CYCLE      = 4;int EXCEPT_FLUSHES_PER_CYCLE = 4;int MAX_MEM_OPS              = DEFMAX_MEM_OPS; /* defined in state.h = 32 */int MAX_ALU_OPS              = DEFMAX_ALU_OPS;int MAX_FPU_OPS              = DEFMAX_FPU_OPS;int MAX_STORE_BUF            = DEFMAX_STORE_BUF;int ALU_UNITS                = 2;int FPU_UNITS                = 2;int ADDR_UNITS               = 1;int MEM_UNITS                = L1D_DEFAULT_NUM_PORTS;int partial_stats_time = 3600;int  DEBUG_TIME = 0;FILE *corefile;/* Redirection file names */char *mailto   = NULL;char *subject  = NULL;const char *configfile = "rsim_params";int  statfile[MAX_NODES];int  logfile[MAX_NODES];char trace_dir[MAXPATHLEN];char fnstdin[MAXPATHLEN], fnstdout[MAXPATHLEN], fnstderr[MAXPATHLEN];char fnsimmount[MAXPATHLEN];char fncwd[MAXPATHLEN];char fnstat[MAXPATHLEN], fnlog[MAXPATHLEN];char fnkernel[MAXPATHLEN];char realsimpath[MAXPATHLEN];long long reset_instruction = 0;     // when to reset statisticslong long stop_instruction  = 0;     // when to record stats. and abort sim.int  StartStopInit();int  WatchDogInit();void GetRusage(int);void PrintHelpInformation(char *);/***********************************************************************//* UserMain    : the main procedure (in YACSIM programs); mainly sets  *//*             : variables, parses the command line, and calls         *//*             : initialization functions                              *//***********************************************************************/extern "C" void UserMain(int argc, char **argv, char **env){  extern char    *optarg;  extern int      optind;  int             c1, done;  char            c, unit;  char            execname[MAXPATHLEN];  char            simpath[MAXPATHLEN];  char           *rsim_dirname = NULL;  char            name[64];  int             fd, i;  char           *startdir;  char          **sim_args, **sim_exec = NULL;  int             mp = 1;  int             k;  struct utsname  s_uname;  uname(&s_uname);    if (argc == 1)    {      PrintHelpInformation(argv[0]);      return;    }  fnstdin[0] = fnstdout[0] = fnstderr[0] = fnstat[0] = fnlog[0] = 0;    /* Parse command line and initialize variables */  done = 0;  while ((!done) &&	 ((c1 = getopt(argc,		       argv,		       "D:F:S:X"		       "de:hm:nr:s:t:z:")) != -1))    {      c = c1;      switch (c)	{	case 'D': // D and S are used to redirect all files	  rsim_dirname = optarg;	  break;	case 'S':	  subject = optarg;	  break;	case 'z': // redirect simin separately from stdin	  configfile = optarg;	  break;	case 'e':	  mailto = optarg;	  break;        case 'd': // debug/dump bus trace and/or waveform	  BUS_TRACE_ENABLE = 1;          break;	case 'm':	  mp = atoi(optarg);	  if (mp == 0)	    {	      fprintf(stderr, "Illegal value %s for '-m' flag - defaulting to 1\n", optarg);	      mp = 1;	    }	  break;	  	case 'n':	  errno = 0;	  if ((nice(19) == -1) && (errno != 0))	    fprintf(stderr, "Cannot 'nice' simulation: %s\n",		    YS__strerror(errno));	  break;	case 'r':	  unit = ' ';	  sscanf(optarg, "%lld%c", &reset_instruction, &unit);	  if ((unit == 'm') || (unit == 'M'))	    reset_instruction *= 1000000ll;	  if ((unit == 'b') || (unit == 'B'))	    reset_instruction *= 1000000000ll;	  break;	  	case 's':	  unit = ' ';	  sscanf(optarg, "%lld%c", &stop_instruction, &unit);	  if ((unit == 'm') || (unit == 'M'))	    stop_instruction *= 1000000ll;	  if ((unit == 'b') || (unit == 'B'))	    stop_instruction *= 1000000000ll;	  break;	  	case 't':	  DEBUG_TIME = atoi(optarg);	  break;	case 'F': // executable to interpret	  done = 1;	  break;	case 'X': // static scheduling -- supported only with RC,//	  STALL_ON_FULL = 1;     // set in proc_config.h	  MAX_ALU_OPS = 1;       // stall as soon as first one cann't issue */	  MAX_FPU_OPS = 1;       // stall as soon as first one cann't issue */#if 0	  stat_sched = 1; */     // static scheduling is like STALL_ON_FULL,	                         // except that address generation is also	                         // counted with the ALU/FPU counter#endif	  break;	case 'h':	default:	  PrintHelpInformation(argv[0]);	  return;	}    }    //-------------------------------------------------------------------------  // find pointers to simulated executable name and arguments  sim_args = argv + optind - 1;  i = 0;  while ((i < argc - optind + 1) && (sim_args[i][0] == '-'))    i++;  if (i < argc - optind + 1)    sim_exec = sim_args + i;  else    {      PrintHelpInformation(argv[0]);      return;          }  if ((*sim_exec)[0] == '/')    strcpy(execname, *sim_exec);  else    {      startdir = getcwd(NULL, MAXPATHLEN);      sprintf(execname, "%s/%s", startdir, *sim_exec);      free(startdir);    }  *sim_exec = execname;  if (!subject)    {      subject = strrchr(execname, '/');      subject++;    }  //-------------------------------------------------------------------------  // attempt to find simulator executable directory and use it to derive  // the kernel file path.  // first try to remove the last three components of the name  // (bin/$ARCH/rsim) and replace them with lamix/lamix  // next, scan the search path for a component that points to a simulator  // executable, and replace the last three components with usr/lib/lamix  if (argv[0][0] == '/')    strcpy(simpath, argv[0]);  else    {      getcwd(simpath, sizeof(simpath));      strcat(simpath, "/");      strcat(simpath, argv[0]);    }  realpath(simpath, fnkernel);  realpath(simpath, realsimpath);  char *p;  if (p = strrchr(fnkernel, '/'))    *p = 0;  else    fnkernel[0] = 0;  if (p = strrchr(fnkernel, '/'))    *p = 0;  else    fnkernel[0] = 0;  if (p = strrchr(fnkernel, '/'))    *p = 0;  else    fnkernel[0] = 0;  if (fnkernel[0] == 0)    {      char *exe;      if (p = strrchr(argv[0], '/'))	exe = p;      else	exe = argv[0];      p = getenv("PATH");      if (!p)	fprintf(stderr, "Unable to obtain environment variable PATH");      while (strtok(p, ":"))	{	  sprintf(fnkernel, "%s/%s", p, exe);	  if (access(fnkernel, X_OK) == 0)	    break;	}      if (p = strrchr(fnkernel, '/'))	*p = 0;      else	fnkernel[0] = 0;      if (p = strrchr(fnkernel, '/'))	*p = 0;      else	fnkernel[0] = 0;      if (p = strrchr(fnkernel, '/'))	*p = 0;      else	fnkernel[0] = 0;    }  if (fnkernel[0] != 0)    {      strcpy(fnsimmount, fnkernel);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -