コード例 #1
0
ファイル: mpiPi.c プロジェクト: HaoMengHIT/DwarfCode
int
mpiPi_mergeResults ()
{
  int ac;
  callsite_stats_t **av;
  int totalCount = 0;
  int maxCount = 0;
  int retval = 1, sendval;

  /* gather local task data */
  h_gather_data (mpiPi.task_callsite_stats, &ac, (void ***) &av);

  /* determine size of space necessary on collector */
  PMPI_Allreduce (&ac, &totalCount, 1, MPI_INT, MPI_SUM, mpiPi.comm);
  PMPI_Reduce (&ac, &maxCount, 1, MPI_INT, MPI_MAX, mpiPi.collectorRank,
	       mpiPi.comm);

  if (totalCount < 1)
    {
      mpiPi_msg_warn
	("Collector found no records to merge. Omitting report.\n");
      return 0;
    }

  /* gather global data at collector */
  if (mpiPi.rank == mpiPi.collectorRank)
    {
      int i;
      int ndx = 0;

#ifdef ENABLE_BFD
      if (mpiPi.appFullName != NULL)
	{
	  if (open_bfd_executable (mpiPi.appFullName) == 0)
	    mpiPi.do_lookup = 0;
	}
#elif defined(USE_LIBDWARF)
      if (mpiPi.appFullName != NULL)
	{
	  if (open_dwarf_executable (mpiPi.appFullName) == 0)
	    mpiPi.do_lookup = 0;
	}
#endif
#if defined(ENABLE_BFD) || defined(USE_LIBDWARF)
      else
	{
	  mpiPi_msg_warn ("Failed to open executable\n");
	  mpiPi.do_lookup = 0;
	}
#endif
      /* convert data to src line; merge, if nec */
      mpiPi.global_callsite_stats = h_open (mpiPi.tableSize,
					    mpiPi_callsite_stats_src_hashkey,
					    mpiPi_callsite_stats_src_comparator);
      mpiPi.global_callsite_stats_agg = h_open (mpiPi.tableSize,
						mpiPi_callsite_stats_src_id_hashkey,
						mpiPi_callsite_stats_src_id_comparator);
      if (callsite_pc_cache == NULL)
	{
	  callsite_pc_cache = h_open (mpiPi.tableSize,
				      callsite_pc_cache_hashkey,
				      callsite_pc_cache_comparator);
	}
      if (callsite_src_id_cache == NULL)
	{
	  callsite_src_id_cache = h_open (mpiPi.tableSize,
					  callsite_src_id_cache_hashkey,
					  callsite_src_id_cache_comparator);
	}
      /* Try to allocate space for max count of callsite info from all tasks  */
      mpiPi.rawCallsiteData =
	(callsite_stats_t *) calloc (maxCount, sizeof (callsite_stats_t));
      if (mpiPi.rawCallsiteData == NULL)
	{
	  mpiPi_msg_warn
	    ("Failed to allocate memory to collect callsite info");
	  retval = 0;
	}

      /* Clear global_mpi_time and global_mpi_size before accumulation in mpiPi_insert_callsite_records */
      mpiPi.global_mpi_time = 0.0;
      mpiPi.global_mpi_size = 0.0;

      if (retval == 1)
	{
	  /* Insert collector callsite data into global and task-specific hash tables */
	  for (ndx = 0; ndx < ac; ndx++)
	    {
	      mpiPi_insert_callsite_records (av[ndx]);
	    }
	  ndx = 0;
	  for (i = 1; i < mpiPi.size; i++)	/* n-1 */
	    {
	      MPI_Status status;
	      int count;
	      int j;

	      /* okay in any order */
	      PMPI_Probe (MPI_ANY_SOURCE, mpiPi.tag, mpiPi.comm, &status);
	      PMPI_Get_count (&status, MPI_CHAR, &count);
	      PMPI_Recv (&(mpiPi.rawCallsiteData[ndx]), count, MPI_CHAR,
			 status.MPI_SOURCE, mpiPi.tag, mpiPi.comm, &status);
	      count /= sizeof (callsite_stats_t);


	      for (j = 0; j < count; j++)
		{
		  mpiPi_insert_callsite_records (&(mpiPi.rawCallsiteData[j]));
		}
	    }
	  free (mpiPi.rawCallsiteData);
	}
    }
  else
    {
      int ndx;
      char *sbuf = (char *) malloc (ac * sizeof (callsite_stats_t));
      for (ndx = 0; ndx < ac; ndx++)
	{
	  bcopy (av[ndx],
		 &(sbuf[ndx * sizeof (callsite_stats_t)]),
		 sizeof (callsite_stats_t));
	}
      PMPI_Send (sbuf, ac * sizeof (callsite_stats_t),
		 MPI_CHAR, mpiPi.collectorRank, mpiPi.tag, mpiPi.comm);
      free (sbuf);
    }
  if (mpiPi.rank == mpiPi.collectorRank && retval == 1)
    {
      if (mpiPi.collective_report == 0)
	mpiPi_msg_debug
	  ("MEMORY : Allocated for global_callsite_stats     : %13ld\n",
	   h_count (mpiPi.global_callsite_stats) * sizeof (callsite_stats_t));
      mpiPi_msg_debug
	("MEMORY : Allocated for global_callsite_stats_agg : %13ld\n",
	 h_count (mpiPi.global_callsite_stats_agg) *
	 sizeof (callsite_stats_t));
    }

  /* TODO: need to free all these pointers as well. */
  free (av);

  if (mpiPi.rank == mpiPi.collectorRank)
    {
      if (mpiPi.do_lookup == 1)
	{
#ifdef ENABLE_BFD
	  /* clean up */
	  close_bfd_executable ();
#elif defined(USE_LIBDWARF)
	  close_dwarf_executable ();
#endif
	}
    }

  /*  Quadrics MPI does not appear to support MPI_IN_PLACE   */
  sendval = retval;
  PMPI_Allreduce (&sendval, &retval, 1, MPI_INT, MPI_MIN, mpiPi.comm);
  return retval;
}
コード例 #2
0
int
open_dwarf_executable (char *fileName)
{
  int dwStatus = -1;


  mpiPi_msg_debug ("enter open_dwarf_executable\n");
  if (fileName == NULL)
    {
      mpiPi_msg_warn ("Executable file name is NULL!\n");
      mpiPi_msg_warn
	("If this is a Fortran application, you may be using the incorrect mpiP library.\n");
    }

  /* open the executable */
  assert (dwFd == -1);
  mpiPi_msg_debug ("opening file %s\n", fileName);
  dwFd = open (fileName, O_RDONLY);
  if (dwFd == -1)
    {
      mpiPi_msg_warn ("could not open file %s\n", fileName);
      return 0;
    }

  /* initialize the DWARF library */
  assert (dwHandle == NULL);
  dwStatus = dwarf_init (dwFd,	/* exe file descriptor */
			 DW_DLC_READ,	/* desired access */
			 NULL,	/* error handler */
			 NULL,	/* error argument */
			 &dwHandle,	/* session handle */
			 NULL);	/* error object */
  if (dwStatus == DW_DLV_ERROR)
    {
      close (dwFd);
      dwFd = -1;
      mpiPi_abort ("could not initialize DWARF library\n");
    }

  if (dwStatus == DW_DLV_NO_ENTRY)
    {
      mpiPi_msg_warn ("No symbols in the executable\n");
      return 0;
    }

  /* initialize our function and addr-to-source mappings */
  AddrToSourceMap_Init ();
  FunctionMap_Init ();

  /* access symbol info */
  while (1)
    {
      Dwarf_Unsigned nextCompilationUnitHeaderOffset = 0;
      Dwarf_Die currCompileUnitDIE = NULL;
      Dwarf_Line *lineEntries = NULL;
      Dwarf_Signed nLineEntries = 0;
      Dwarf_Half currDIETag;
      Dwarf_Die currChildDIE = NULL;
      Dwarf_Die nextChildDIE = NULL;
      Dwarf_Die oldChildDIE = NULL;


      /* access next compilation unit header */
      dwStatus = dwarf_next_cu_header (dwHandle, NULL,	/* cu_header_length */
				       NULL,	/* version_stamp */
				       NULL,	/* abbrev_offset */
				       NULL,	/* address_size */
				       &nextCompilationUnitHeaderOffset, NULL);	/* error object */
      if (dwStatus != DW_DLV_OK)
	{
	  if (dwStatus != DW_DLV_NO_ENTRY)
	    {
	      mpiPi_abort ("failed to access next DWARF cu header\n");
	    }
	  break;
	}

      /* access the first debug info entry (DIE) for this computation unit */
      dwStatus = dwarf_siblingof (dwHandle, NULL,	/* current DIE */
				  &currCompileUnitDIE,	/* sibling DIE */
				  NULL);	/* error object */
      if (dwStatus != DW_DLV_OK)
	{
	  mpiPi_abort ("failed to access first DWARF DIE\n");
	}

      /* get line number information for this compilation 
       * unit, if available 
       */
      dwStatus = dwarf_srclines (currCompileUnitDIE,
				 &lineEntries, &nLineEntries, NULL);
      if (dwStatus == DW_DLV_OK)
	{
	  unsigned int i;


	  /*
	   * Extract and save address-to-source line mapping.
	   * 
	   * NOTE: At least on the Cray X1, we see line number 
	   * information with the same address mapping to different lines.
	   * It seems like when there are multiple entries for a given
	   * address, the last one is the correct one.  (Needs verification.)
	   * If we see multiple entries for a given address, we only 
	   * save the last one.
	   */
	  for (i = 0; i < nLineEntries; i++)
	    {
	      Dwarf_Unsigned lineNumber = 0;
	      Dwarf_Addr lineAddress = 0;
	      char *lineSourceFile = NULL;


	      int lineNoStatus = dwarf_lineno (lineEntries[i],
					       &lineNumber,
					       NULL);

	      int lineAddrStatus = dwarf_lineaddr (lineEntries[i],
						   &lineAddress,
						   NULL);

	      int lineSrcFileStatus = dwarf_linesrc (lineEntries[i],
						     &lineSourceFile,
						     NULL);

	      if ((lineNoStatus == DW_DLV_OK) &&
		  (lineAddrStatus == DW_DLV_OK)
		  && (lineSrcFileStatus == DW_DLV_OK))
		{
		  int saveCurrentEntry = 0;	/* bool */

		  if (i < (nLineEntries - 1))
		    {
		      /*
		       * We're not on the last line number entry -
		       * check the address associated with the next
		       * entry to see if it differs from this one.
		       * Only save the entry if it the next address
		       * differs.
		       */
		      Dwarf_Addr nextLineAddress = 0;
		      int nextLineAddrStatus =
			dwarf_lineaddr (lineEntries[i + 1],
					&nextLineAddress,
					NULL);
		      assert (nextLineAddrStatus == DW_DLV_OK);
		      if (nextLineAddress != lineAddress)
			{
			  saveCurrentEntry = 1;
			}
		    }
		  else
		    {
		      /* we're on the last line number entry */
		      saveCurrentEntry = 1;
		    }

		  if (saveCurrentEntry)
		    {
		      /* save the mapping entry */
		      AddrToSourceMap_Add (lineAddress, lineSourceFile,
					   lineNumber);
		    }
		}

	      if (lineSourceFile != NULL)
		{
		  dwarf_dealloc (dwHandle, lineSourceFile, DW_DLA_STRING);
		}
	    }

	  /* release the line number info */
	  for (i = 0; i < nLineEntries; i++)
	    {
	      dwarf_dealloc (dwHandle, lineEntries[i], DW_DLA_LINE);
	    }
	  dwarf_dealloc (dwHandle, lineEntries, DW_DLA_LIST);
	}
      else if (dwStatus != DW_DLV_ERROR)
	{
	  /*
	   * no line information for the current DIE - 
	   * not an error, just unfortunate
	   */
	}
      else
	{
	  mpiPi_abort ("failed to obtain line info for the current DIE\n");
	}

      /* discover function information for the current compilation unit */
      /* 
       * NOTE: DWARF debug information entries can be organized in 
       * a hierarchy.  However, we presume that the function entries are
       * all children of the compilation unit DIE.
       */
      dwStatus = dwarf_tag (currCompileUnitDIE, &currDIETag, NULL);
      assert ((dwStatus == DW_DLV_OK) && (currDIETag == DW_TAG_compile_unit));

      /* access the first child DIE of the compile unit DIE */
      dwStatus = dwarf_child (currCompileUnitDIE, &currChildDIE, NULL);
      if (dwStatus == DW_DLV_NO_ENTRY)
	{
	  mpiPi_abort ("no child DIEs of compile unit DIE\n");
	}
      else if (dwStatus != DW_DLV_OK)
	{
	  mpiPi_abort
	    ("failed to access first child DIE of compile unit DIE\n");
	}

      while (dwStatus == DW_DLV_OK)
	{
	  /* determine the type of the child DIE */
	  dwStatus = dwarf_tag (currChildDIE, &currDIETag, NULL);
	  if (dwStatus == DW_DLV_OK)
	    {
	      if ((currDIETag == DW_TAG_subprogram) ||
		  (currDIETag == DW_TAG_entry_point))
		{
		  HandleFunctionDIE (dwHandle, currChildDIE);
		}
	    }
	  else
	    {
	      mpiPi_abort ("unable to determine tag of current child DIE\n");
	    }

	  /* advance to the next child DIE */
	  oldChildDIE = currChildDIE;
	  dwStatus = dwarf_siblingof (dwHandle,
				      currChildDIE, &nextChildDIE, NULL);
	  if (dwStatus == DW_DLV_OK)
	    {
	      currChildDIE = nextChildDIE;
	      nextChildDIE = NULL;
	    }
	  else if (dwStatus != DW_DLV_NO_ENTRY)
	    {
	      mpiPi_abort
		("unable to access next child DIE of current compilation unit\n");
	    }

	  if (oldChildDIE != NULL)
	    {
	      dwarf_dealloc (dwHandle, oldChildDIE, NULL);
	    }
	}

      /* release the current compilation unit DIE */
      dwarf_dealloc (dwHandle, currCompileUnitDIE, DW_DLA_DIE);
    }

  /*
   * DWARF address-to-source line information does not give
   * address ranges, so we need to patch the address ranges
   * in our address-to-source map.
   */
  AddrToSourceMap_PatchRanges ();

  return 1;
}
コード例 #3
0
ファイル: mpiPi.c プロジェクト: HaoMengHIT/DwarfCode
/* task level init 
   - executed by each MPI task only once immediately after MPI_Init
*/
void
mpiPi_init (char *appName)
{
  if (time (&mpiPi.start_timeofday) == (time_t) - 1)
    {
      mpiPi_msg_warn ("Could not get time of day from time()\n");
    }

  mpiPi.toolname = "mpiP";
  mpiPi.comm = MPI_COMM_WORLD;
  mpiPi.tag = 9821;
  mpiPi.procID = getpid ();
  mpiPi.appName = strdup (appName);
  PMPI_Comm_rank (mpiPi.comm, &mpiPi.rank);
  PMPI_Comm_size (mpiPi.comm, &mpiPi.size);
  PMPI_Get_processor_name (mpiPi.hostname, &mpiPi.hostnamelen);
  mpiPi.stdout_ = stdout;
  mpiPi.stderr_ = stderr;
  mpiPi.lookup = mpiPi_lookup;

  mpiPi.enabled = 1;
  mpiPi.enabledCount = 1;
  mpiPi.cumulativeTime = 0.0;
  mpiPi.global_app_time = 0.0;
  mpiPi.global_mpi_time = 0.0;
  mpiPi.global_mpi_size = 0.0;
  mpiPi.global_mpi_io = 0.0;
  mpiPi.global_mpi_msize_threshold_count = 0;
  mpiPi.global_mpi_sent_count = 0;
  mpiPi.global_time_callsite_count = 0;
  mpiPi.global_task_info = NULL;
  
  char tmpfilename[64];
  sprintf(tmpfilename,"%d.trace\0",mpiPi.rank);
  mpiPi.recfile = fopen(tmpfilename,"wb"); 
  printf("Open Rec File %s !\n", tmpfilename);

  /* set some defaults values */
  mpiPi.collectorRank = 0;
  mpiPi.tableSize = 256;
  mpiPi.stackDepth = 1;		/* the value 2 includes parent wrapper function */
  mpiPi.reportPrintThreshold = 0.0;
  mpiPi.baseNames = 0;
  mpiPi.reportFormat = MPIP_REPORT_SCI_FORMAT;
  mpiPi.calcCOV = 1;
  mpiPi.inAPIrtb = 0;
  mpiPi.do_lookup = 1;
  mpiPi.messageCountThreshold = -1;
  mpiPi.report_style = mpiPi_style_verbose;
  mpiPi.print_callsite_detail = 1;
#ifdef COLLECTIVE_REPORT_DEFAULT
  mpiPi.collective_report = 1;
#else
  mpiPi.collective_report = 0;
#endif
  mpiPi_getenv ();

  mpiPi.task_callsite_stats =
    h_open (mpiPi.tableSize, mpiPi_callsite_stats_pc_hashkey,
	    mpiPi_callsite_stats_pc_comparator);

  /* -- welcome msg only collector  */
  if (mpiPi.collectorRank == mpiPi.rank)
    {
      mpiPi_msg ("\n");
      mpiPi_msg ("%s V%d.%d.%d (Build %s/%s)\n", mpiPi.toolname, mpiPi_vmajor,
		 mpiPi_vminor, mpiPi_vpatch, mpiPi_vdate, mpiPi_vtime);
      mpiPi_msg ("Direct questions and errors to %s\n", MPIP_HELP_LIST);
      mpiPi_msg ("\n");
    }

  mpiPi_msg_debug ("appName is %s\n", appName);
  mpiPi_msg_debug ("successful init on %d, %s\n", mpiPi.rank, mpiPi.hostname);

  if (mpiPi.enabled)
    {
      mpiPi_GETTIME (&mpiPi.startTime);
    }

  return;
}
コード例 #4
0
static void
AddrRangeMap_Add (struct AddrRangeMap *map,
		  Dwarf_Addr lowAddr, Dwarf_Addr highAddr, void *info)
{
  struct AddrRangeMapNode *currNode = NULL;
  struct AddrRangeMapNode *newEntry = NULL;


  mpiPi_msg_debug ("AddrRangeMap::Add: [0x%016llx,0x%016llx]\n",
		   lowAddr, highAddr);

  /* build a new entry for this mapping */
  newEntry =
    (struct AddrRangeMapNode *) malloc (sizeof (struct AddrRangeMapNode));

  if (newEntry == NULL)
    {
      mpiPi_abort ("malloc failed\n");
    }
  newEntry->color = AddrRangeMapNodeColor_Red;
  assert (lowAddr <= highAddr);
  newEntry->lowAddr = lowAddr;
  newEntry->highAddr = highAddr;
  newEntry->info = info;
  newEntry->parent = NULL;
  newEntry->leftChild = NULL;
  newEntry->rightChild = NULL;

  /* add the new node to our map */
  if (map->root == NULL)
    {
      /* new node is the first node to be added */
      map->root = newEntry;
    }
  else
    {
      /* new node is not the first node to be added */
      currNode = map->root;
      while (currNode != NULL)
	{
	  if (highAddr <= currNode->lowAddr)
	    {
	      /* target address is below range covered by current node */
	      if (currNode->leftChild != NULL)
		{
		  /* compare with ranges smaller than ours */
		  currNode = currNode->leftChild;
		}
	      else
		{
		  /* adopt new node as our left child */
		  currNode->leftChild = newEntry;
		  newEntry->parent = currNode;
		  break;
		}
	    }
	  else if (lowAddr >= currNode->highAddr)
	    {
	      /* target address is above range covered by current node */
	      if (currNode->rightChild != NULL)
		{
		  /* compare with ranges larger than ours */
		  currNode = currNode->rightChild;
		}
	      else
		{
		  /* adopt new node as our right child */
		  currNode->rightChild = newEntry;
		  newEntry->parent = currNode;
		  break;
		}
	    }
	  else
	    {
	      /* new range overlaps with our range! */
	      mpiPi_abort
		("new address node range [0x%016llx,0x%016llx] overlaps our range [0x%016llx,0x%016llx]\n",
		 lowAddr, highAddr, currNode->lowAddr, currNode->highAddr);
	    }
	}
    }


  /*
   * new node has been inserted, but its insertion
   * may have unbalanced the tree -
   * re-balance it.
   * Based on red-black insert algorithm given in 
   * Cormen, Lieserson, Rivest "Introduction to Algorithms"
   */
  currNode = newEntry;
  while ((currNode != map->root) &&
	 (currNode->parent->color == AddrRangeMapNodeColor_Red))
    {
      struct AddrRangeMapNode *uncleNode = NULL;

      if (currNode->parent == currNode->parent->parent->leftChild)
	{
	  /* currNode's parent is its parent's left child */
	  uncleNode = currNode->parent->parent->rightChild;
	  if ((uncleNode != NULL) &&
	      (uncleNode->color == AddrRangeMapNodeColor_Red))
	    {
	      currNode->parent->color = AddrRangeMapNodeColor_Black;
	      uncleNode->color = AddrRangeMapNodeColor_Black;
	      currNode->parent->parent->color = AddrRangeMapNodeColor_Red;
	      currNode = currNode->parent->parent;
	    }
	  else
	    {
	      /* uncleNode is NULL (NULL is assumed black) or is black */
	      if (currNode == currNode->parent->rightChild)
		{
		  currNode = currNode->parent;
		  AddrRangeMap_LeftRotate (map, currNode);
		}
	      currNode->parent->color = AddrRangeMapNodeColor_Black;
	      currNode->parent->parent->color = AddrRangeMapNodeColor_Red;
	      AddrRangeMap_RightRotate (map, currNode->parent->parent);
	    }
	}
      else
	{
	  /* currNode's parent is its parent's right child */
	  uncleNode = currNode->parent->parent->leftChild;
	  if ((uncleNode != NULL) &&
	      (uncleNode->color == AddrRangeMapNodeColor_Red))
	    {
	      currNode->parent->color = AddrRangeMapNodeColor_Black;
	      uncleNode->color = AddrRangeMapNodeColor_Black;
	      currNode->parent->parent->color = AddrRangeMapNodeColor_Red;
	      currNode = currNode->parent->parent;
	    }
	  else
	    {
	      /* uncleNode is NULL (NULL is assumed black) or is black */
	      if (currNode == currNode->parent->leftChild)
		{
		  currNode = currNode->parent;
		  AddrRangeMap_RightRotate (map, currNode);
		}
	      currNode->parent->color = AddrRangeMapNodeColor_Black;
	      currNode->parent->parent->color = AddrRangeMapNodeColor_Red;
	      AddrRangeMap_LeftRotate (map, currNode->parent->parent);
	    }
	}
    }
  assert (map->root != NULL);
  map->root->color = AddrRangeMapNodeColor_Black;
}
コード例 #5
0
ファイル: mpiPi.c プロジェクト: saxena/mpip
void
mpiPi_recv_pt2pt_stats(int ac, pt2pt_stats_t** av)
{
  int i;
  int pt2pt_size = sizeof(pt2pt_stats_t);
  int nsenders = 0;

  /* Count number of senders, receiver will wait for them */
  /* i = 0 is copied locally */
  for(i = 1; i < mpiPi.size; i++)
    {
      if (mpiPi.accumulatedPt2ptCounts[i])
	nsenders++;
    }

  mpiPi_msg_debug("(%d) Waiting for %d senders\n",mpiPi.rank,nsenders);

  /* Allocate a pointer for each rank */
  mpiPi.accumulatedPt2ptData = (pt2pt_stats_t **) calloc (mpiPi.size, sizeof(pt2pt_stats_t*));
  if (mpiPi.accumulatedPt2ptData == NULL)
    {
      mpiPi_msg_warn
	("Failed to allocate memory to collect point to point info");
      assert(0);
    }

  /* Copy Data for collector rank */
  if (ac)
    {
      mpiPi.accumulatedPt2ptData[mpiPi.rank] = *av;
    }

  i = 0;
  /* Insert pt2pt data into aggregate array indexed by rank */
  while(i < nsenders)
    {
      MPI_Status status;
      int count;
      pt2pt_stats_t* ptp;
      unsigned src_rank;

      /* okay in any order */
      PMPI_Probe (MPI_ANY_SOURCE, mpiPi.tag, mpiPi.comm, &status);
      PMPI_Get_count (&status, MPI_CHAR, &count);
      src_rank = status.MPI_SOURCE;

      /* Allocate space for count number of pt2pt_stat_t structs */
      ptp = (pt2pt_stats_t*) calloc(count, pt2pt_size);

      mpiPi_msg_debug("(%d): Receiving %d bytes in pt2pt records from %d...\n",
		      mpiPi.rank, count, src_rank);

      PMPI_Recv (ptp, count, MPI_CHAR, src_rank,
		 mpiPi.tag, mpiPi.comm, &status);

      mpiPi_msg_debug("(%d): Received\n",mpiPi.rank);

      count /= pt2pt_size;

      assert(src_rank < mpiPi.size);
      assert(mpiPi.accumulatedPt2ptCounts[src_rank] == count);

      mpiPi.accumulatedPt2ptData[src_rank] = ptp;

      i++;
    }

}
コード例 #6
0
ファイル: mpiPi.c プロジェクト: saxena/mpip
void
mpiPi_init (char *appName)
{
  if (time (&mpiPi.start_timeofday) == (time_t) - 1)
    {
      mpiPi_msg_warn ("Could not get time of day from time()\n");
    }

  mpiPi.toolname = "mpiP";
  mpiPi.comm = MPI_COMM_WORLD;
  mpiPi.tag = 9821;
  mpiPi.procID = getpid ();
  mpiPi.appName = strdup (appName);
  PMPI_Comm_rank (mpiPi.comm, &mpiPi.rank);
  PMPI_Comm_size (mpiPi.comm, &mpiPi.size);
  PMPI_Get_processor_name (mpiPi.hostname, &mpiPi.hostnamelen);
  mpiPi.stdout_ = stdout;
  mpiPi.stderr_ = stderr;
  mpiPi.lookup = mpiPi_lookup;

  mpiPi.enabled = 1;
  mpiPi.enabledCount = 1;
  mpiPi.cumulativeTime = 0.0;
  mpiPi.global_app_time = 0.0;
  mpiPi.global_mpi_time = 0.0;
  mpiPi.global_mpi_size = 0.0;
  mpiPi.global_mpi_io = 0.0;
  mpiPi.global_mpi_rma = 0.0;
  mpiPi.global_mpi_msize_threshold_count = 0;
  mpiPi.global_mpi_sent_count = 0;
  mpiPi.global_time_callsite_count = 0;
  mpiPi.global_task_hostnames = NULL;
  mpiPi.global_task_app_time = NULL;
  mpiPi.global_task_mpi_time = NULL;

  /* set some defaults values */
  mpiPi.collectorRank = 0;
  mpiPi.tableSize = 256;
  mpiPi.reportPrintThreshold = 0.0;
  mpiPi.baseNames = 0;
  mpiPi.reportFormat = MPIP_REPORT_SCI_FORMAT;
  mpiPi.calcCOV = 1;
  mpiPi.inAPIrtb = 0;
  mpiPi.do_lookup = 1;
  mpiPi.messageCountThreshold = -1;

  if (DEFAULT_REPORT_FORMAT == mpiPi_style_concise)
    {
      mpiPi.report_style = mpiPi_style_concise;
      mpiPi.stackDepth = 0;
      mpiPi.print_callsite_detail = 0;
    }
  else				// verbose default
    {
      mpiPi.report_style = mpiPi_style_verbose;
      mpiPi.stackDepth = 1;
      mpiPi.print_callsite_detail = 1;
    }

#ifdef COLLECTIVE_REPORT_DEFAULT
  mpiPi.collective_report = 1;
#else
  mpiPi.collective_report = 0;
#endif
  mpiPi.disable_finalize_report = 0;
  mpiPi.do_collective_stats_report = 0;
  mpiPi.do_pt2pt_stats_report = 0;
#ifdef SO_LOOKUP
  mpiPi.so_info = NULL;
#endif

  mpiPi.do_pt2pt_detail_report = 0;

  mpiPi_getenv ();

  mpiPi.task_callsite_stats =
    h_open (mpiPi.tableSize, mpiPi_callsite_stats_pc_hashkey,
	    mpiPi_callsite_stats_pc_comparator);

  mpiPi.accumulatedPt2ptCounts = NULL;
  mpiPi.accumulatedPt2ptData = NULL;

  if (mpiPi.do_collective_stats_report == 1)
    {
      init_histogram (&mpiPi.coll_comm_histogram, 7, 32, NULL);
      init_histogram (&mpiPi.coll_size_histogram, 7, 32, NULL);
    }

  if (mpiPi.do_pt2pt_stats_report == 1)
    {
      init_histogram (&mpiPi.pt2pt_comm_histogram, 7, 32, NULL);
      init_histogram (&mpiPi.pt2pt_size_histogram, 7, 32, NULL);

      if(mpiPi.do_pt2pt_detail_report == 1)
	{
	  mpiPi.task_pt2pt_stats =
	    h_open(mpiPi.tableSize, mpiPi_pt2pt_stats_rank_hashkey,
		   mpiPi_pt2pt_stats_rank_comparator);
	}
    }

  /* -- welcome msg only collector  */
  if (mpiPi.collectorRank == mpiPi.rank)
    {
      mpiPi_msg ("");
      mpiPi_msg ("%s V%d.%d.%d (Build %s/%s)\n", mpiPi.toolname, mpiPi_vmajor,
		 mpiPi_vminor, mpiPi_vpatch, mpiPi_vdate, mpiPi_vtime);
      mpiPi_msg ("Direct questions and errors to %s\n", MPIP_HELP_LIST);
      mpiPi_msg ("\n");
    }

  mpiPi_msg_debug ("appName is %s\n", appName);
  mpiPi_msg_debug ("sizeof(callsite_stats_t) is %d\n",
		   sizeof (callsite_stats_t));
  mpiPi_msg_debug ("successful init on %d, %s\n", mpiPi.rank, mpiPi.hostname);

  if (mpiPi.enabled)
    {
      mpiPi_GETTIME (&mpiPi.startTime);
    }

  return;
}
コード例 #7
0
ファイル: mpiPi.c プロジェクト: saxena/mpip
void
mpiPi_update_callsite_stats (unsigned op, unsigned rank, void **pc,
			     double dur, double sendSize, double ioSize,
			     double rmaSize)
{
  int i;
  callsite_stats_t *csp = NULL;
  callsite_stats_t key;

  if (!mpiPi.enabled)
    return;

  assert (mpiPi.task_callsite_stats != NULL);
  assert (dur >= 0);


  key.op = op;
  key.rank = rank;
  key.cookie = MPIP_CALLSITE_STATS_COOKIE;
  for (i = 0; i < MPIP_CALLSITE_STACK_DEPTH; i++)
    {
      key.pc[i] = pc[i];
    }

  if (NULL == h_search (mpiPi.task_callsite_stats, &key, (void **) &csp))
    {
      /* create and insert */
      csp = (callsite_stats_t *) malloc (sizeof (callsite_stats_t));
      bzero (csp, sizeof (callsite_stats_t));
      csp->op = op;
      csp->rank = rank;
      for (i = 0; i < MPIP_CALLSITE_STACK_DEPTH; i++)
	{
	  csp->pc[i] = pc[i];
	}
      csp->cookie = MPIP_CALLSITE_STATS_COOKIE;
      csp->cumulativeTime = 0;
      csp->minDur = DBL_MAX;
      csp->minDataSent = DBL_MAX;
      csp->minIO = DBL_MAX;
      csp->arbitraryMessageCount = 0;
      h_insert (mpiPi.task_callsite_stats, csp);
    }
  /* ASSUME: csp cannot be deleted from list */
  csp->count++;
  csp->cumulativeTime += dur;
  assert (csp->cumulativeTime >= 0);
  csp->cumulativeTimeSquared += (dur * dur);
  assert (csp->cumulativeTimeSquared >= 0);
  csp->maxDur = max (csp->maxDur, dur);
  csp->minDur = min (csp->minDur, dur);
  csp->cumulativeDataSent += sendSize;
  csp->cumulativeIO += ioSize;
  csp->cumulativeRMA += rmaSize;

  csp->maxDataSent = max (csp->maxDataSent, sendSize);
  csp->minDataSent = min (csp->minDataSent, sendSize);

  csp->maxIO = max (csp->maxIO, ioSize);
  csp->minIO = min (csp->minIO, ioSize);

  csp->maxRMA = max (csp->maxRMA, rmaSize);
  csp->minRMA = min (csp->minRMA, rmaSize);

  if (mpiPi.messageCountThreshold > -1
      && sendSize >= (double) mpiPi.messageCountThreshold)
    csp->arbitraryMessageCount++;

#if 0
  mpiPi_msg_debug ("mpiPi.messageCountThreshold is %d\n",
		   mpiPi.messageCountThreshold);
  mpiPi_msg_debug ("sendSize is %f\n", sendSize);
  mpiPi_msg_debug ("csp->arbitraryMessageCount is %lld\n",
		   csp->arbitraryMessageCount);
#endif

  return;
}
コード例 #8
0
ファイル: mpiPi.c プロジェクト: saxena/mpip
/*
 * mpiPi_collect_basics() - all tasks send their basic info to the
 * collectorRank.
 */
static void
mpiPi_collect_basics (int report_style)
{
  mpiPi_msg_debug ("Collect Basics\n");

  if (mpiPi.rank == mpiPi.collectorRank)
    {
      /* In the case where multiple reports are generated per run,
         only allocate memory for global_task_info once */
      if (mpiPi.global_task_app_time == NULL)
	{
	  mpiPi.global_task_app_time =
	    (double *) calloc (mpiPi.size, sizeof (double));

	  if (mpiPi.global_task_app_time == NULL)
	    mpiPi_abort
	      ("Failed to allocate memory for global_task_app_time");

	  mpiPi_msg_debug
	    ("MEMORY : Allocated for global_task_app_time :          %13ld\n",
	     mpiPi.size * sizeof (double));
	}

      bzero (mpiPi.global_task_app_time, mpiPi.size * sizeof (double));

      if (mpiPi.global_task_mpi_time == NULL)
	{
	  mpiPi.global_task_mpi_time =
	    (double *) calloc (mpiPi.size, sizeof (double));

	  if (mpiPi.global_task_mpi_time == NULL)
	    mpiPi_abort
	      ("Failed to allocate memory for global_task_mpi_time");

	  mpiPi_msg_debug
	    ("MEMORY : Allocated for global_task_mpi_time :          %13ld\n",
	     mpiPi.size * sizeof (double));
	}

      bzero (mpiPi.global_task_mpi_time, mpiPi.size * sizeof (double));

      //  Only allocate hostname storage if we are doing a verbose report
      if (mpiPi.global_task_hostnames == NULL
	  && (report_style == mpiPi_style_verbose
	      || report_style == mpiPi_style_both))
	{
	  mpiPi.global_task_hostnames =
	    (mpiPi_hostname_t *) calloc (mpiPi.size,
					 sizeof (char) *
					 MPIPI_HOSTNAME_LEN_MAX);

	  if (mpiPi.global_task_hostnames == NULL)
	    mpiPi_abort
	      ("Failed to allocate memory for global_task_hostnames");

	  mpiPi_msg_debug
	    ("MEMORY : Allocated for global_task_hostnames :          %13ld\n",
	     mpiPi.size * sizeof (char) * MPIPI_HOSTNAME_LEN_MAX);
	}

      if (mpiPi.global_task_hostnames != NULL)
	bzero (mpiPi.global_task_hostnames,
	       mpiPi.size * sizeof (char) * MPIPI_HOSTNAME_LEN_MAX);
    }

  PMPI_Gather (&mpiPi.cumulativeTime, 1, MPI_DOUBLE,
	       mpiPi.global_task_app_time, 1, MPI_DOUBLE,
	       mpiPi.collectorRank, mpiPi.comm);

  if (report_style == mpiPi_style_verbose || report_style == mpiPi_style_both)
    {
      PMPI_Gather (mpiPi.hostname, MPIPI_HOSTNAME_LEN_MAX, MPI_CHAR,
		   mpiPi.global_task_hostnames, MPIPI_HOSTNAME_LEN_MAX,
		   MPI_CHAR, mpiPi.collectorRank, mpiPi.comm);
    }

  return;
}