Exemplo n.º 1
0
void nv40_stop_monitoring(int cnum, int set, uint8_t *signals, uint32_t *real_signals, uint32_t *cycles)
{
	uint32_t cycles_cnt, s[4];
	uint8_t w_s[4];
	int i;

	/* readout */
	nva_mask(cnum, 0x400084, 0x0, 0x20);

	w_s[0] = nva_rd32(cnum, 0xa400 + set * 4);
	w_s[1] = nva_rd32(cnum, 0xa440 + set * 4);
	w_s[2] = nva_rd32(cnum, 0xa480 + set * 4);
	w_s[3] = nva_rd32(cnum, 0xa4c0 + set * 4);

	cycles_cnt = nva_rd32(cnum, 0xa600 + set * 4);
	s[0] = nva_rd32(cnum, 0xa700 + set * 4);
	s[1] = nva_rd32(cnum, 0xa6c0 + set * 4);
	s[2] = nva_rd32(cnum, 0xa680 + set * 4);
	s[3] = nva_rd32(cnum, 0xa740 + set * 4);

	for (i = 0; i < 4; i++) {
		if (signals)
			SIGNAL_VALUE(signals, set, w_s[i]) = s[i] * 100 / cycles_cnt;
		if (real_signals)
			SIGNAL_VALUE(real_signals, set, w_s[i]) = s[i];
		if (cycles)
			SIGNAL_VALUE(cycles, set, w_s[i]) = cycles_cnt;
	}
}
Exemplo n.º 2
0
signal_t * Spectral_AddSortedN (int num_signals, signal_t **signals)
{
  int cur_signal = 0;
  int maxAddedSize = 0;
  int count = 0;
  int i = 0;
  semantic_t *bursts = NULL;
  signal_t *addedSignal = NULL;

  for (cur_signal = 0; cur_signal < num_signals; cur_signal ++)
  {
    if (signals[cur_signal] != NULL)
    {
      maxAddedSize += signals[cur_signal]->cur_size;
    }
  }

  if (maxAddedSize > 0)
  {
    bursts = (semantic_t *)malloc(maxAddedSize * 2 * sizeof(semantic_t));
 
    for (cur_signal=0; cur_signal<num_signals; cur_signal++)
    {
      if (signals[cur_signal] != NULL)
      {
        for (i=0; i<signals[cur_signal]->cur_size; i++)
        {
          bursts[count].time  = SIGNAL_TIME(signals[cur_signal], i);
          bursts[count].value = SIGNAL_VALUE(signals[cur_signal], i);
          count ++;
  
          bursts[count].time  = SIGNAL_TIME(signals[cur_signal], i) + SIGNAL_DELTA(signals[cur_signal], i);
          bursts[count].value = -( SIGNAL_VALUE(signals[cur_signal], i) );
          count ++;
        }
      }
    }
  }
  
  if (count > 0)
  { 
    qsort(bursts, count, sizeof(semantic_t), qsort_cmp);
  }

  addedSignal = Spectral_AssembleSignal2 (count, bursts);
  if (bursts != NULL) free(bursts);
  return addedSignal;
}
Exemplo n.º 3
0
void Sampler_wavelet (signal_t *signal, spectral_value_t **waveletSignal, int number_of_points, char *dbg_file)
{
#ifdef TRACE_MODE
  Extrae_user_function (1);
#endif
  fprintf (stdout, "Executing Sampler Wavelet...");
  long long int period, last_signal_time;
  spectral_value_t last_value;
  int calculated_periods = 0, i;
  spectral_value_t * wavelet_values = NULL;
#ifdef DEBUG_MODE
  FILE *fp;
  if ((fp = fopen (dbg_file, "w")) == NULL)
    {
      fprintf (stderr, "\nDebug: Can't open file '%s'!\n\n");
      perror("fopen: ");
      exit (-1);
    }
#endif
  wavelet_values = (spectral_value_t *)malloc(sizeof(spectral_value_t) * number_of_points);

  /* Obtaning de last time of the wavelet */
  last_signal_time = SIGNAL_LAST_TIME(signal);

  /* Period = Total time / number of samples */
  period = last_signal_time / number_of_points;

  /* Calculating points */

  last_value = SIGNAL_FIRST_VALUE(signal);
  i = 1;

  while (calculated_periods < number_of_points)
    {
      while (i < SIGNAL_SIZE(signal) && calculated_periods * period > SIGNAL_TIME(signal, i))
	{
	  last_value = SIGNAL_VALUE(signal, i);
	  i++;
	}
      wavelet_values[calculated_periods] = last_value;
      calculated_periods++;
#ifdef DEBUG_MODE
      fprintf (fp, "%lf\n", last_value);
#endif
    }

#ifdef DEBUG_MODE
  fclose (fp);

#endif
  printf ("Done!\n");
  fflush (stdout);

  *waveletSignal = wavelet_values;
#ifdef TRACE_MODE
  Extrae_user_function (0);
#endif
}
Exemplo n.º 4
0
void find_host_mem_read_write(int cnum)
{
	uint32_t signals_real[0x100 * 8] = { 0 };
	uint32_t signals_real_cycles[0x100 * 8] = { 0 };
	struct pci_device *dev = nva_cards[cnum].pci;
	volatile uint8_t *bar1, val;
	int ret, i, e;

	ret = pci_device_map_range(dev, dev->regions[1].base_addr, dev->regions[1].size, PCI_DEV_MAP_FLAG_WRITABLE, (void**)&bar1);
	if (ret) {
		printf("HOST_MEM: Failed to mmap bar1. aborting.\n");
		return;
	}

	printf("<HOST_MEM (1000 rd, 200 wr @bar1[0])> /!\\ no drivers should be loaded!\n");

	/* let's create some activity  */
	for (i = 0; i < 0xff; i+=4) {
		nv40_start_monitoring(cnum, 0, i, i+1, i+2, i+3);
		for (e = 0; e < 1000; e++)
			val = bar1[0];
		for (e = 0; e < 200; e++)
			bar1[0] = val;
		nv40_stop_monitoring(cnum, 0, NULL, signals_real, signals_real_cycles);
	}

	for (i = 0; i < 0xff; i++) {
		uint32_t val = SIGNAL_VALUE(signals_real, 0, i);
		uint32_t cycles = SIGNAL_VALUE(signals_real_cycles, 0, i);
		if (val == 200)
			print_counter_value("HOST_MEM", "WR", 0, i, val, cycles);
		else if (val == 1000)
			print_counter_value("HOST_MEM", "RD", 0, i, val, cycles);
		else if (val == 1200)
			print_counter_value("HOST_MEM", "TRANS", 0, i, val, cycles);
		else if (val == 3000)
			print_counter_value("HOST_MEM", "3_RD", 0, i, val, cycles);
		else if (val >= 10 && val < 10000)
			print_counter_value("UNK", "", 0, i, val, cycles);
	}

	printf("</HOST_MEM>\n\n");
}
Exemplo n.º 5
0
void Spectral_AddPoint3(signal_t *signal, spectral_time_t time, spectral_time_t delta, spectral_value_t value)
{
  int idx = SIGNAL_SIZE(signal);

  if ((signal != NULL) && (idx == signal->max_size))
  {
    Spectral_ReallocateSignal(signal, signal->max_size + SIGNAL_CHUNK);
  }

  SIGNAL_TIME(signal, idx)  = time;
  SIGNAL_DELTA(signal, idx) = delta;
  SIGNAL_VALUE(signal, idx) = value;

  SIGNAL_SIZE(signal) ++;
}
Exemplo n.º 6
0
void find_mmio_read_write(int cnum, uint32_t reg, const char *engine)
{
	uint32_t signals_real[0x100 * 8] = { 0 };
	uint32_t signals_real_cycles[0x100 * 8] = { 0 };
	uint32_t reg_val;
	int i, e;

	printf("<%s (1000 rd, 200 wr @ 0x%x)> /!\\ no drivers should be loaded!\n", engine, reg);

	/* let's create some activity  */
	for (i = 0; i < 0xff; i+=4) {
		nv40_start_monitoring(cnum, 0, i, i+1, i+2, i+3);
		for (e = 0; e < 1000; e++)
			reg_val = nva_rd32(cnum, reg);
		for (e = 0; e < 200; e++)
			nva_wr32(cnum, reg, reg_val);
		nv40_stop_monitoring(cnum, 0, NULL, signals_real, signals_real_cycles);
	}

	for (i = 0; i < 0xff; i++) {
		uint32_t val = SIGNAL_VALUE(signals_real, 0, i);
		uint32_t cycles = SIGNAL_VALUE(signals_real_cycles, 0, i);
		if (val == 201)
			print_counter_value(engine, "WR", 0, i, val, cycles);
		else if (val == 1001)
			print_counter_value(engine, "RD", 0, i, val, cycles);
		else if (val == 1202)
			print_counter_value(engine, "TRANS", 0, i, val, cycles);
		else if (val == 3003)
			print_counter_value(engine, "3_RD", 0, i, val, cycles);
		else if (val >= 10 && val < 10000)
			print_counter_value("UNK", "", 0, i, val, cycles);
	}

	printf("</%s>\n\n", engine);
}
Exemplo n.º 7
0
void find_counter_noise(int cnum)
{
	uint32_t signals_real[0x100 * 8] = { 0 };
	uint32_t signals_real_cycles[0x100 * 8] = { 0 };
	int i;

	printf("<PCOUNTER_NOISE: 1ms wait> /!\\ no drivers should be loaded!\n");

	/* bare minimum activity  */
	for (i = 0; i < 0xff; i+=4) {
		nv40_start_monitoring(cnum, 0, i, i+1, i+2, i+3);
		usleep(1000);
		nv40_stop_monitoring(cnum, 0, NULL, signals_real, signals_real_cycles);
	}

	for (i = 0; i < 0xff; i++) {
		uint32_t val = SIGNAL_VALUE(signals_real, 0, i);
		uint32_t cycles = SIGNAL_VALUE(signals_real_cycles, 0, i);
		if (val > 0)
			print_counter_value("NOISE", "UNK", 0, i, val, cycles);
	}

	printf("</PCOUNTER_NOISE>\n\n");
}
Exemplo n.º 8
0
void print_poll_data(const char *name, uint8_t *signals)
{
	int i, s;

	printf("Print data poll '%s':\n", name);
	for (s = 0; s < 8; s++) {
		printf("Set %i:", s);
		for (i = 0; i < 0x20 * 8; i++) {
			if (i % 0x10 == 0)
				printf("\n0x%02x: ", i % (0x20 * 8));

			printf("%.3i ", SIGNAL_VALUE(signals, s, i));

			if (i != 0 && i % (SIGNALS_LENGTH) == 0)
				printf("\n\n");
		}

		if (s != 7)
			printf("\n");
		printf("\n");
	}
}
Exemplo n.º 9
0
signal_t * Cutter_signal (signal_t *signal, long long int t0, long long int t1, signal_data_t *maximum_point, char *dbg_file)
{
  int i = 0;
  signal_t *cut = NULL;
  spectral_time_t  max_time   = 0;
  spectral_time_t  max_delta  = 0;
  spectral_value_t max_value  = 0;

#ifdef TRACE_MODE
  Extrae_user_function (1);
#endif
  cut = Spectral_AllocateSignal( SIGNAL_SIZE(signal) );

  /* Skip times until t0 */
  i = 0;
  while ((i < SIGNAL_SIZE(signal)) && ((SIGNAL_TIME(signal, i) + SIGNAL_DELTA(signal, i)) < t0))
  {
    i++;
  }

  /* Reached t0, add the first point */
  if ((i < SIGNAL_SIZE(signal)) && ((SIGNAL_TIME(signal, i) + SIGNAL_DELTA(signal, i)) >= t0))
  {
    SIGNAL_ADD_POINT_3( cut,
      0,
      SIGNAL_TIME (signal, i) + SIGNAL_DELTA(signal, i) - t0,
      SIGNAL_VALUE(signal, i)
    );
    if (SIGNAL_LAST_VALUE(cut) > max_value)
    {
      max_time  = SIGNAL_LAST_TIME (cut);
      max_delta = SIGNAL_LAST_DELTA(cut);
      max_value = SIGNAL_LAST_VALUE(cut);
    }
    i++;
  }

  /* Between t0 and t1 */
  while ((i < SIGNAL_SIZE(signal)) && ((SIGNAL_TIME(signal, i) + SIGNAL_DELTA(signal, i)) <= t1))
  {
    SIGNAL_ADD_POINT_3( cut,
      SIGNAL_TIME(signal, i) - t0,
      SIGNAL_DELTA(signal, i),
      SIGNAL_VALUE(signal, i)
    );
    if (SIGNAL_LAST_VALUE(cut) > max_value)
    {
      max_time  = SIGNAL_LAST_TIME (cut);
      max_delta = SIGNAL_LAST_DELTA(cut);
      max_value = SIGNAL_LAST_VALUE(cut);
    }
    i++;
  }

  /* Reached t1, add a last point */
  if ((i < SIGNAL_SIZE(signal)) && ((SIGNAL_TIME(signal, i) + SIGNAL_DELTA(signal, i)) > t1))
  {
    SIGNAL_ADD_POINT_3( cut,
      SIGNAL_TIME(signal, i) - t0,
      t1 - SIGNAL_TIME(signal, i),
      SIGNAL_VALUE(signal, i)
    );
    if (SIGNAL_LAST_VALUE(cut) > max_value)
    {
      max_time  = SIGNAL_LAST_TIME (cut);
      max_delta = SIGNAL_LAST_DELTA(cut);
      max_value = SIGNAL_LAST_VALUE(cut);
    }
    i++;
  }

  if (maximum_point != NULL)
  {
    maximum_point->time  = max_time;
    maximum_point->delta = max_delta;
    maximum_point->value = max_value;
  }

  Spectral_ReallocateSignal( cut, SIGNAL_SIZE(cut) );

#ifdef DEBUG_MODE
  Spectral_DumpSignal( cut, dbg_file );
#endif

#ifdef TRACE_MODE
  Extrae_user_function (0);
#endif

  return cut;
}