Example #1
0
int
mpiPi_query_pc (void *pc, char **filename, char **functname, int *lineno)
{
  int rc = 0;
  callsite_pc_cache_entry_t key;
  callsite_pc_cache_entry_t *csp;
  char addr_buf[24];

  key.pc = pc;
  /* do we have a cache entry for this pc? If so, use entry */
  if (h_search (callsite_pc_cache, &key, (void **) &csp) == NULL)
    {
      /* no cache entry: create, lookup, and insert */
      csp =
	(callsite_pc_cache_entry_t *)
	malloc (sizeof (callsite_pc_cache_entry_t));
      csp->pc = pc;
#if defined(ENABLE_BFD) || defined(USE_LIBDWARF)
      if (mpiP_find_src_loc (pc, filename, lineno, functname) == 0)
	{
	  if (*filename == NULL || strcmp (*filename, "??") == 0)
	    *filename = "[unknown]";

	  if (*functname == NULL)
	    *functname = "[unknown]";

	  mpiPi_msg_debug
	    ("Successful Source lookup for [%s]: %s, %d, %s\n",
	     mpiP_format_address (pc, addr_buf), *filename, *lineno,
	     *functname);

	  csp->filename = strdup (*filename);
	  csp->functname = strdup (*functname);
	  csp->line = *lineno;
	}
      else
	{
	  mpiPi_msg_debug ("Unsuccessful Source lookup for [%s]\n",
			   mpiP_format_address (pc, addr_buf));
	  csp->filename = strdup ("[unknown]");
	  csp->functname = strdup ("[unknown]");
	  csp->line = 0;
	}
#else /* ! ENABLE_BFD || USE_LIBDWARF */
      csp->filename = strdup ("[unknown]");
      csp->functname = strdup ("[unknown]");
      csp->line = 0;
#endif
      h_insert (callsite_pc_cache, csp);
    }

  *filename = csp->filename;
  *functname = csp->functname;
  *lineno = csp->line;

  if (*lineno == 0)
    rc = 1;			/* use this value to indicate a failed lookup */

  return rc;
}
Example #2
0
/* take a callstats record (the pc) and determine src file, line, if
   possible and assign a callsite id.
 */
int
mpiPi_query_src (callsite_stats_t * p)
{
  int i;
  callsite_src_id_cache_entry_t key;
  callsite_src_id_cache_entry_t *csp;
  assert (p);

  /* Because multiple pcs can map to the same source line, we must
     check that mapping here. If we got unknown, then we assign
     different ids */
  bzero (&key, sizeof (callsite_src_id_cache_entry_t));

  for (i = 0; (i < MPIP_CALLSITE_STACK_DEPTH) && (p->pc[i] != NULL); i++)
    {
      if (mpiPi.do_lookup == 1)
	mpiPi_query_pc (p->pc[i], &(p->filename[i]), &(p->functname[i]),
			&(p->lineno[i]));
      else
	{
	  p->filename[i] = strdup ("[unknown]");
	  p->functname[i] = strdup ("[unknown]");
	  p->lineno[i] = 0;
	}

      key.filename[i] = p->filename[i];
      key.functname[i] = p->functname[i];
      key.line[i] = p->lineno[i];
      key.pc[i] = p->pc[i];
    }

  /* lookup/generate an ID based on the callstack, not just the callsite pc */
  if (h_search (callsite_src_id_cache, &key, (void **) &csp) == NULL)
    {
      /* create a new entry, and assign an id based on callstack */
      csp =
	(callsite_src_id_cache_entry_t *)
	malloc (sizeof (callsite_src_id_cache_entry_t));
      bzero (csp, sizeof (callsite_src_id_cache_entry_t));

      for (i = 0; (i < MPIP_CALLSITE_STACK_DEPTH) && (p->pc[i] != NULL); i++)
	{
	  csp->filename[i] = strdup (key.filename[i]);
	  csp->functname[i] = strdup (key.functname[i]);
	  csp->line[i] = key.line[i];
	  csp->pc[i] = p->pc[i];
	}
      csp->id = callsite_src_id_counter++;
      csp->op = p->op;
      h_insert (callsite_src_id_cache, csp);
    }

  /* assign ID to this record */
  p->csid = csp->id;
  return p->csid;
}
Example #3
0
void
rn_hash_insert(void *h, rn_link * event)
{
	rn_hash        *hash_t;

	hash_t = (rn_hash *) h;

	h_insert(hash_t->storage, event, hash_t->capacity);
	hash_t->nstored++;

	if(hash_t->nstored > floor(hash_t->capacity * RN_MAX_FRACTION))
		tw_error(TW_LOC, "Inserted beyond RN_MAX_FRACTION!");
}
Example #4
0
File: mpiPi.c Project: saxena/mpip
/*  Aggregate individual MPI call data by iterating through call sites.  */
static int
mpiPi_insert_MPI_records ()
{
  callsite_stats_t *csp = NULL;
  int i, ac;
  callsite_stats_t **av;
  callsite_stats_t *p;

  if (mpiPi.rank == mpiPi.collectorRank)
    {
      /*  Open hash table for MPI call data.  */
      mpiPi.global_MPI_stats_agg = h_open (mpiPi.tableSize,
					   mpiPi_callsite_stats_MPI_id_hashkey,
					   mpiPi_callsite_stats_op_comparator);

      /*  Get individual call data.  */
      h_gather_data (mpiPi.global_callsite_stats_agg, &ac, (void ***) &av);

      /*  Sort by MPI op.  */
      qsort (av, ac, sizeof (void *), callsite_sort_by_MPI_op);

      /*  For each call site, add call site info to hash table entry for MPI op, independent of rank.  */
      for (i = 0; i < ac; i++)
	{
	  p = av[i];

	  /* Check if there is already an entry for the MPI op. */
	  if (NULL ==
	      h_search (mpiPi.global_MPI_stats_agg, p, (void **) &csp))
	    {
	      callsite_stats_t *newp = NULL;
	      newp = (callsite_stats_t *) malloc (sizeof (callsite_stats_t));
	      memcpy (newp, p, sizeof (callsite_stats_t));
	      newp->rank = -1;
	      newp->csid = p->op - mpiPi_BASE;

	      /* insert new record into global */
	      h_insert (mpiPi.global_MPI_stats_agg, newp);
	    }
	  else
	    {
	      mpiPi_merge_individual_callsite_records (csp, p);
	    }
	}
    }

  return 1;
}
static void push(struct smq_policy *mq, struct entry *e)
{
	struct entry *sentinel;

	h_insert(&mq->table, e);

	/*
	 * Punch this into the queue just in front of the sentinel, to
	 * ensure it's cleaned straight away.
	 */
	if (e->dirty) {
		sentinel = writeback_sentinel(mq, e->level);
		q_push_before(&mq->dirty, sentinel, e);
	} else {
		sentinel = demote_sentinel(mq, e->level);
		q_push_before(&mq->clean, sentinel, e);
	}
}
static struct entry *update_hotspot_queue(struct smq_policy *mq, dm_oblock_t b, struct bio *bio)
{
	unsigned hi;
	dm_oblock_t hb = to_hblock(mq, b);
	struct entry *e = h_lookup(&mq->hotspot_table, hb);

	if (e) {
		stats_level_accessed(&mq->hotspot_stats, e->level);

		hi = get_index(&mq->hotspot_alloc, e);
		q_requeue(&mq->hotspot, e,
			  test_and_set_bit(hi, mq->hotspot_hit_bits) ?
			  0u : mq->hotspot_level_jump);

	} else {
		stats_miss(&mq->hotspot_stats);

		e = alloc_entry(&mq->hotspot_alloc);
		if (!e) {
			e = q_pop(&mq->hotspot);
			if (e) {
				h_remove(&mq->hotspot_table, e);
				hi = get_index(&mq->hotspot_alloc, e);
				clear_bit(hi, mq->hotspot_hit_bits);
			}

		}

		if (e) {
			e->oblock = hb;
			q_push(&mq->hotspot, e);
			h_insert(&mq->hotspot_table, e);
		}
	}

	return e;
}
/*
 * These methods tie together the dirty queue, clean queue and hash table.
 */
static void push_new(struct smq_policy *mq, struct entry *e)
{
	struct queue *q = e->dirty ? &mq->dirty : &mq->clean;
	h_insert(&mq->table, e);
	q_push(q, e);
}
/*Inserts table_name/db url into the list of heads*/
static int dp_head_insert(int dp_insert_type, str content,
				 str partition)
{
#define h_insert(type, url_addr, table_addr, ins_addr ) \
	do{  \
		if( type == DP_TYPE_URL ) { \
			dp_str_copy(url_addr, ins_addr); \
		} else { \
			dp_str_copy(table_addr, ins_addr); \
		} \
	}while(0);

	dp_head_p start = dp_hlist;
	dp_head_p tmp = NULL;

	/*First Insertion*/
	if (!dp_hlist) {
		dp_hlist = pkg_malloc(sizeof *dp_hlist + partition.len);
		if (!dp_hlist) {
			LM_ERR("No more pkg mem\n");
			return -1;
		}
		memset(dp_hlist, 0, sizeof *dp_hlist);

		dp_hlist->partition.s = (char *) (dp_hlist + 1);
		dp_str_copy(&dp_hlist->partition, &partition);

		h_insert( dp_insert_type, &dp_hlist->dp_db_url,
				 &dp_hlist->dp_table_name, &content);
		dp_hlist->next = NULL;
		return 0;
	}

	while (start != NULL) {
		if (!str_strcmp(&partition, &start->partition)) {
			h_insert( dp_insert_type, &start->dp_db_url,
					 &start->dp_table_name, &content);
			start->next = NULL;
			return 0;
		}
		if (!start->next) {
			break;
		}
		start = (dp_head_p)start->next;
	}

	tmp = pkg_malloc(sizeof(dp_head_t));

	if (!tmp) {
		LM_ERR("No more pkg mem\n");
		return -1;

	}
	dp_str_copy(&tmp->partition, &partition);

	h_insert( dp_insert_type, &tmp->dp_db_url,
			 &tmp->dp_table_name, &content);
	start->next = (dp_head_p)tmp;
	return 0;
#undef h_insert

}
Example #9
0
/*Inserts table_name/db url into the list of heads*/
static int dp_head_insert(int dp_insert_type, str *content,
				 str *partition)
{
#define h_insert(type, url_str, table_str, ins_str )    \
	do{                                                 \
		if( type == DP_TYPE_URL ) {                     \
			url_str = ins_str;                          \
		} else {                                        \
			table_str = ins_str;                        \
		}                                               \
	}while(0);

	dp_head_p start = dp_hlist;
	dp_head_p tmp = NULL;

	if ((!content && (!content->s || !content->len)) ||
		(!partition && (!partition->s || !partition->len))) {
		LM_ERR("invalid insert in partition!\n");
		return -1;
	}

	/*First Insertion*/
	if (!dp_hlist) {
		dp_hlist = pkg_malloc(sizeof *dp_hlist);
		if (!dp_hlist) {
			LM_ERR("No more pkg mem\n");
			return -1;
		}
		memset(dp_hlist, 0, sizeof *dp_hlist);

		dp_hlist->partition = *partition;

		h_insert( dp_insert_type, dp_hlist->dp_db_url,
				 dp_hlist->dp_table_name, *content);
		return 0;
	}


	/* start can't be null here, should exit on first IF instruction
	 * if null*/
	do {
		if (!str_strcmp(partition, &start->partition)) {
			h_insert( dp_insert_type, start->dp_db_url,
					 start->dp_table_name, *content);
			return 0;
		}
	/* always want second condition to be true since only the
	 * first condition is valid; the second is just an assignment
	 * in case the first one succeeds */
	} while (start->next != NULL && (start=start->next,1));

	tmp = pkg_malloc(sizeof(dp_head_t));

	if (!tmp) {
		LM_ERR("No more pkg mem\n");
		return -1;
	}
	memset(tmp, 0, sizeof(dp_head_t));

	tmp->partition = *partition;

	h_insert( dp_insert_type, tmp->dp_db_url,
			 tmp->dp_table_name, *content);
	start->next = tmp;
	return 0;
#undef h_insert

}
Example #10
0
void
mpiPi_update_callsite_stats (unsigned op, unsigned rank, void **pc,
			     double dur, double sendSize, double ioSize)
{
  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->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->maxDataSent = max (csp->maxDataSent, sendSize);
  csp->minDataSent = min (csp->minDataSent, sendSize);

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


  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;
}
Example #11
0
static int
mpiPi_insert_callsite_records (callsite_stats_t * p)
{
  callsite_stats_t *csp = NULL;

  mpiPi_query_src (p);		/* sets the file/line in p */

  /* If exists, accumulate, otherwise insert. This is
     specifically for optimizations that have multiple PCs for
     one src line. We aggregate across rank after this. 

     The collective_report reporting approach does not aggregate individual 
     process callsite information at the collector process.
   */
  if (mpiPi.collective_report == 0)
    {
      if (NULL == h_search (mpiPi.global_callsite_stats, p, (void **) &csp))
	{
	  int j;
	  callsite_stats_t *newp = NULL;
	  newp = (callsite_stats_t *) malloc (sizeof (callsite_stats_t));
	  bzero (newp, sizeof (callsite_stats_t));
	  newp->op = p->op;
	  newp->rank = p->rank;
	  for (j = 0; j < MPIP_CALLSITE_STACK_DEPTH; j++)
	    {
	      newp->pc[j] = p->pc[j];
	      newp->filename[j] = p->filename[j];
	      newp->functname[j] = p->functname[j];
	      newp->lineno[j] = p->lineno[j];
	    }
	  newp->csid = p->csid;
	  newp->count = p->count;
	  newp->cumulativeTime = p->cumulativeTime;
	  newp->cumulativeTimeSquared = p->cumulativeTimeSquared;
	  newp->maxDur = p->maxDur;
	  newp->minDur = p->minDur;
	  newp->maxDataSent = p->maxDataSent;
	  newp->minDataSent = p->minDataSent;
	  newp->cumulativeDataSent = p->cumulativeDataSent;
	  newp->maxIO = p->maxIO;
	  newp->minIO = p->minIO;
	  newp->cumulativeIO = p->cumulativeIO;
	  newp->arbitraryMessageCount = p->arbitraryMessageCount;
	  newp->cookie = MPIP_CALLSITE_STATS_COOKIE;

	  /* insert new record into global */
	  h_insert (mpiPi.global_callsite_stats, newp);
	}
      else
	{
	  csp->count += p->count;
	  csp->cumulativeTime += p->cumulativeTime;
	  assert (csp->cumulativeTime >= 0);
	  csp->cumulativeTimeSquared += p->cumulativeTimeSquared;
	  assert (csp->cumulativeTimeSquared >= 0);
	  csp->maxDur = max (csp->maxDur, p->maxDur);
	  csp->minDur = min (csp->minDur, p->minDur);
	  csp->maxDataSent = max (csp->maxDataSent, p->maxDataSent);
	  csp->minDataSent = min (csp->minDataSent, p->minDataSent);
	  csp->cumulativeDataSent += p->cumulativeDataSent;
	  csp->maxIO = max (csp->maxIO, p->maxIO);
	  csp->minIO = min (csp->minIO, p->minIO);
	  csp->cumulativeIO += p->cumulativeIO;
	  csp->arbitraryMessageCount += p->arbitraryMessageCount;
	}
    }

  /* Collect aggregate callsite summary information indpendent of rank. */
  if (NULL == h_search (mpiPi.global_callsite_stats_agg, p, (void **) &csp))
    {
      int j;
      callsite_stats_t *newp = NULL;
      newp = (callsite_stats_t *) malloc (sizeof (callsite_stats_t));
      bzero (newp, sizeof (callsite_stats_t));
      newp->op = p->op;
      newp->rank = -1;
      for (j = 0; j < MPIP_CALLSITE_STACK_DEPTH; j++)
	{
	  newp->pc[j] = p->pc[j];
	  newp->filename[j] = p->filename[j];
	  newp->functname[j] = p->functname[j];
	  newp->lineno[j] = p->lineno[j];
	}
      newp->csid = p->csid;
      newp->count = p->count;
      newp->cumulativeTime = p->cumulativeTime;
      newp->cumulativeTimeSquared = p->cumulativeTimeSquared;
      newp->maxDur = p->maxDur;
      newp->minDur = p->minDur;
      newp->maxDataSent = p->maxDataSent;
      newp->minDataSent = p->minDataSent;
      newp->cumulativeDataSent = p->cumulativeDataSent;
      newp->cumulativeIO = p->cumulativeIO;
      newp->maxIO = p->maxIO;
      newp->minIO = p->minIO;
      newp->cookie = MPIP_CALLSITE_STATS_COOKIE;

      if (mpiPi.calcCOV)
	{
	  newp->siteData = (double *) malloc (mpiPi.size * sizeof (double));
	  newp->siteData[0] = p->cumulativeTime;
	  newp->siteDataIdx = 1;
	}

      /* insert new record into global */
      h_insert (mpiPi.global_callsite_stats_agg, newp);
    }
  else
    {
      csp->count += p->count;
      csp->cumulativeTime += p->cumulativeTime;
      assert (csp->cumulativeTime >= 0);
      csp->cumulativeTimeSquared += p->cumulativeTimeSquared;
      assert (csp->cumulativeTimeSquared >= 0);
      csp->maxDur = max (csp->maxDur, p->maxDur);
      csp->minDur = min (csp->minDur, p->minDur);
      csp->maxDataSent = max (csp->maxDataSent, p->maxDataSent);
      csp->minDataSent = min (csp->minDataSent, p->minDataSent);
      csp->cumulativeDataSent += p->cumulativeDataSent;
      csp->maxIO = max (csp->maxIO, p->maxIO);
      csp->minIO = min (csp->minIO, p->minIO);
      csp->cumulativeIO += p->cumulativeIO;

      if (mpiPi.calcCOV)
	{
	  csp->siteData[csp->siteDataIdx] = p->cumulativeTime;
	  csp->siteDataIdx += 1;
	}
    }

  /* Do global accumulation while we are iterating through individual callsites */
  mpiPi.global_task_info[p->rank].mpi_time += p->cumulativeTime;

  mpiPi.global_mpi_time += p->cumulativeTime;
  assert (mpiPi.global_mpi_time >= 0);
  mpiPi.global_mpi_size += p->cumulativeDataSent;
  mpiPi.global_mpi_io += p->cumulativeIO;
  if (p->cumulativeTime > 0)
    mpiPi.global_time_callsite_count++;

  if (p->cumulativeDataSent > 0)
    {
      mpiPi.global_mpi_msize_threshold_count += p->arbitraryMessageCount;
      mpiPi.global_mpi_sent_count += p->count;
    }

  return 1;
}
Example #12
0
File: mpiPi.c Project: saxena/mpip
static int
mpiPi_insert_callsite_records (callsite_stats_t * p)
{
  callsite_stats_t *csp = NULL;

  mpiPi_query_src (p);		/* sets the file/line in p */

  /* If exists, accumulate, otherwise insert. This is
     specifically for optimizations that have multiple PCs for
     one src line. We aggregate across rank after this.

     The collective_report reporting approach does not aggregate individual
     process callsite information at the collector process.
   */
  if (mpiPi.collective_report == 0)
    {
      if (NULL == h_search (mpiPi.global_callsite_stats, p, (void **) &csp))
	{
	  callsite_stats_t *newp = NULL;
	  newp = (callsite_stats_t *) malloc (sizeof (callsite_stats_t));

	  memcpy (newp, p, sizeof (callsite_stats_t));
	  /* insert new record into global */
	  h_insert (mpiPi.global_callsite_stats, newp);
	}
      else
	mpiPi_merge_individual_callsite_records (csp, p);
    }

  /* Collect aggregate callsite summary information indpendent of rank. */
  if (NULL == h_search (mpiPi.global_callsite_stats_agg, p, (void **) &csp))
    {
      callsite_stats_t *newp = NULL;
      newp = (callsite_stats_t *) malloc (sizeof (callsite_stats_t));

      memcpy (newp, p, sizeof (callsite_stats_t));
      newp->rank = -1;

      if (mpiPi.calcCOV)
	{
	  newp->siteData = (double *) malloc (mpiPi.size * sizeof (double));
	  newp->siteData[0] = p->cumulativeTime;
	  newp->siteDataIdx = 1;
	}

      /* insert new record into global */
      h_insert (mpiPi.global_callsite_stats_agg, newp);
    }
  else
    {
      mpiPi_merge_individual_callsite_records (csp, p);

      if (mpiPi.calcCOV)
	{
	  csp->siteData[csp->siteDataIdx] = p->cumulativeTime;
	  csp->siteDataIdx += 1;
	}
    }

  /* Do global accumulation while we are iterating through individual callsites */
  mpiPi.global_task_mpi_time[p->rank] += p->cumulativeTime;

  mpiPi.global_mpi_time += p->cumulativeTime;
  assert (mpiPi.global_mpi_time >= 0);
  mpiPi.global_mpi_size += p->cumulativeDataSent;
  mpiPi.global_mpi_io += p->cumulativeIO;
  mpiPi.global_mpi_rma += p->cumulativeRMA;
  if (p->cumulativeTime > 0)
    mpiPi.global_time_callsite_count++;

  if (p->cumulativeDataSent > 0)
    {
      mpiPi.global_mpi_msize_threshold_count += p->arbitraryMessageCount;
      mpiPi.global_mpi_sent_count += p->count;
    }

  return 1;
}
Example #13
0
void insert_type(char *type) {
    mytype_t *t = malloc(sizeof(mytype_t));
    strcpy(t->name, type);
    h_insert(type, &t);
}