Пример #1
0
static int
_MPI_Init (int *argc, char ***argv)
{
  int rc = 0;
  int enabledStatus;

  enabledStatus = mpiPi.enabled;
  mpiPi.enabled = 0;

  rc = PMPI_Init (argc, argv);

  mpiPi.enabled = enabledStatus;

#if defined(Linux) && ! defined(ppc64)
  mpiPi.appFullName = getProcExeLink ();
  mpiPi_msg_debug ("appFullName is %s\n", mpiPi.appFullName);
  mpiPi_init (GetBaseAppName (mpiPi.appFullName));
#else
  if (argv != NULL && *argv != NULL && **argv != NULL)
    {
      mpiPi_init (GetBaseAppName (**argv));
      mpiPi.appFullName = strdup (**argv);
    }
  else
    {
      mpiPi_init ("Unknown");
      mpiPi_msg_debug ("argv is NULL\n");
    }
#endif

  return rc;
}
Пример #2
0
void
mpiPi_getenv ()
{				/* NEED TO ADD SANITY CHECKS HERE */
  char *cp = NULL;
  char *ep = NULL;

  mpiPi.outputDir = ".";

  ep = getenv ("MPIP");
  mpiPi.envStr = (ep ? strdup (ep) : 0);
  optind = 1;			/* reset to avoid conflicts if getopt already called */
  if (ep != NULL)
    {
      int c;
      extern char *optarg;
      int ac = 0;
      char *av[64];
      char *sep = " \t,";

      if (mpiPi.rank == 0)
	mpiPi_msg ("Found MPIP environment variable [%s]\n", ep);
      av[0] = "JUNK";
      for (cp = strtok (ep, sep), ac = 1; (ac < 64) && (NULL != cp); ac++)
	{
	  av[ac] = cp;
	  /*mpiPi_msg("av[%d] = %s\n", ac, av[ac]); */
	  cp = strtok (NULL, sep);
	}

      av[ac] = NULL;

      for (; ((c = getopt (ac, av, "cdef:gk:lm:noprs:t:vx:yz")) != EOF);)
	{
	  switch (c)
	    {
	    case 'f':
	      mpiPi.outputDir = optarg;
	      if (mpiPi.rank == 0)
		mpiPi_msg ("Set the output directory to [%s].\n",
			   mpiPi.outputDir);
	      break;

	    case 'g':
	      mpiPi_debug = 1;
	      if (mpiPi.rank == 0)
		mpiPi_msg ("Enabled mpiPi debug mode.\n");
	      break;

	    case 's':
	      {
		int defaultSize = mpiPi.tableSize;
		mpiPi.tableSize = atoi (optarg);
		if (mpiPi.tableSize < 2)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("-s tablesize invalid %d. Using default.\n",
			 mpiPi.tableSize);
		    mpiPi.tableSize = defaultSize;
		  }
		if (mpiPi.tableSize < 128)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("tablesize small %d. Consider making it larger w/ -s.\n",
			 mpiPi.tableSize);
		  }
		if (mpiPi.rank == 0)
		  mpiPi_msg
		    ("Set the callsite table size to [%d].\n",
		     mpiPi.tableSize);
	      }
	      break;

	    case 'k':
	      {
		mpiPi.stackDepth = atoi (optarg);
		if (mpiPi.stackDepth < 0)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("-k stackdepth invalid %d. Using 0.\n",
			 mpiPi.stackDepth);
		    mpiPi.stackDepth = 0;
		    mpiPi.print_callsite_detail = 0;
		  }
		if (mpiPi.stackDepth > MPIP_CALLSITE_STACK_DEPTH_MAX)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("stackdepth of %d too large. Using %d.\n",
			 mpiPi.stackDepth, MPIP_CALLSITE_STACK_DEPTH_MAX);
		    mpiPi.stackDepth = MPIP_CALLSITE_STACK_DEPTH_MAX;
		  }
		else if (mpiPi.stackDepth > 4)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("stackdepth of %d is large. Consider making it smaller.\n",
			 mpiPi.stackDepth);
		  }

		//  If the stack depth is 0, we are accumulating data
		//  for each MPI op (i.e. potentially multiple callsites),
		//  resulting in data that would not be useful for calculating COV.
		if (mpiPi.stackDepth == 0)
		  mpiPi.calcCOV = 0;

		if (mpiPi.rank == 0)
		  mpiPi_msg
		    ("Set the callsite stack traceback depth to [%d].\n",
		     mpiPi.stackDepth);
	      }
	      break;

	    case 't':
	      {
		int defaultThreshold = mpiPi.reportPrintThreshold;
		mpiPi.reportPrintThreshold = atof (optarg);
		if (mpiPi.reportPrintThreshold < 0)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("-t report print threshold invalid %g. Using default.\n",
			 mpiPi.reportPrintThreshold);
		    mpiPi.reportPrintThreshold = defaultThreshold;
		  }
		if (mpiPi.reportPrintThreshold >= 100)
		  {
		    if (mpiPi.rank == 0)
		      mpiPi_msg_warn
			("report print threshold large %g. Making it default.\n",
			 mpiPi.reportPrintThreshold);
		    mpiPi.reportPrintThreshold = defaultThreshold;
		  }
		if (mpiPi.rank == 0)
		  mpiPi_msg
		    ("Set the report print threshold to [%3.2lf%%].\n",
		     mpiPi.reportPrintThreshold);
	      }
	      break;

	    case 'o':
	      {
		if (mpiPi.rank == 0)
		  mpiPi_msg_warn
		    ("Disabling MPIP at Init. Code must use Pcontrol to enable.\n");
		mpiPi.enabled = 0;
		mpiPi.enabledCount = 0;
	      }
	      break;

	    case 'n':
	      mpiPi.baseNames = 1;
	      break;

	    case 'e':
	      mpiPi.reportFormat = MPIP_REPORT_FLT_FORMAT;
	      break;

	    case 'c':
	      mpiPi.report_style = mpiPi_style_concise;
	      break;

	    case 'v':
	      mpiPi.report_style = mpiPi_style_both;
	      break;

	    case 'm':
	      mpiPi.messageCountThreshold = atoi (optarg);
	      mpiPi_msg_debug ("Set messageCountThreshold to %d\n",
			       mpiPi.messageCountThreshold);
	      break;
	    case 'x':
	      if (optarg != NULL)
		{
		  mpiPi.appFullName = strdup (optarg);
		  mpiPi.av[0] = strdup (optarg);
		  mpiPi.appName = strdup (GetBaseAppName (mpiPi.appFullName));
		  mpiPi_msg_debug ("Set mpiPi.appFullName to %s\n",
				   mpiPi.appFullName);
		}
	      break;
	    case 'd':
	      /*  Suppress/Activate printing of call site detail based on default.  */
	      mpiPi.print_callsite_detail ^= 1;
	      break;

	    case 'l':
	      /*  Use low-memory use approach using MPI collectives 
	         for report generation   */
	      mpiPi.collective_report = 1;
	      break;

	    case 'r':
	      /*  Use collector task to aggregate all task data and
	         generate report   */
	      mpiPi.collective_report = 0;
	      break;

	    case 'z':
	      mpiPi.disable_finalize_report = 1;
	      break;

	    case 'y':
	      mpiPi.do_collective_stats_report = 1;
	      break;

	    case 'p':
	      mpiPi.do_pt2pt_stats_report = 1;
	      break;

	    case 'a':
	    case 'b':
	    case 'h':
	    case 'i':
	    case 'j':
	    case 'q':
	    case 'u':
	    case 'w':
	    default:
	      if (mpiPi.rank == 0)
		mpiPi_msg_warn
		  ("Option flag (-%c) not recognized. Ignored.\n", c);
	      break;
	    }
	}
    }
  if (mpiPi.rank == 0)
    mpiPi_msg ("\n");
  optind = 1;			/* reset to avoid conflicts if getopt called again */
}