Exemplo n.º 1
0
int gptlstop (char *name, int nc1)
{
  char cname[MAX_CHARS+1];
  int numchars;

  numchars = MIN (nc1, MAX_CHARS);
  strncpy (cname, name, numchars);
  cname[numchars] = '\0';
  return GPTLstop (cname);
}
Exemplo n.º 2
0
double sub (int iter)
{
  unsigned long usec;
  unsigned long looplen = iam*iter*100000;
  unsigned long i;
  double sum;
  int ret;

  ret = GPTLstart ("sub");
  /* Sleep msec is mpi rank + thread number */
  usec = 1000 * (iam * iter);

  ret = GPTLstart ("sleep");
  usleep (usec);
  ret = GPTLstop ("sleep");

  ret = GPTLstart ("work");
  sum = 0.;
  ret = GPTLstart ("add");
  for (i = 0; i < looplen; ++i) {
    sum += i;
  }
  ret = GPTLstop ("add");

  ret = GPTLstart ("madd");
  for (i = 0; i < looplen; ++i) {
    sum += i*1.1;
  }
  ret = GPTLstop ("madd");

  ret = GPTLstart ("div");
  for (i = 0; i < looplen; ++i) {
    sum /= 1.1;
  }
  ret = GPTLstop ("div");
  ret = GPTLstop ("work");
  ret = GPTLstop ("sub");
  return sum;
}
Exemplo n.º 3
0
int main (int argc, char **argv)
{
  char pname[MPI_MAX_PROCESSOR_NAME];

  int iter;
  int counter;
  int c;
  int tnum = 0;
  int resultlen;
  int ret;
  double value;
  extern char *optarg;

  while ((c = getopt (argc, argv, "p:")) != -1) {
    switch (c) {
    case 'p':
      if ((ret = GPTLevent_name_to_code (optarg, &counter)) != 0) {
	printf ("Failure from GPTLevent_name_to_code\n");
	return 1;
      }
      if (GPTLsetoption (counter, 1) < 0) {
	printf ("Failure from GPTLsetoption (%s,1)\n", optarg);
	return 1;
      }
      break;
    default:
      printf ("unknown option %c\n", c);
      printf ("Usage: %s [-p option_name]\n", argv[0]);
      return 2;
    }
  }
  
  ret = GPTLsetoption (GPTLabort_on_error, 1);
  ret = GPTLsetoption (GPTLoverhead, 1);
  ret = GPTLsetoption (GPTLnarrowprint, 1);

  if (MPI_Init (&argc, &argv) != MPI_SUCCESS) {
    printf ("Failure from MPI_Init\n");
    return 1;
  }

  ret = GPTLinitialize ();
  ret = GPTLstart ("total");
	 
  ret = MPI_Comm_rank (MPI_COMM_WORLD, &iam);
  ret = MPI_Comm_size (MPI_COMM_WORLD, &nproc);

  ret = MPI_Get_processor_name (pname, &resultlen);
  printf ("Rank %d is running on processor %s\n", iam, pname);

#ifdef THREADED_OMP
  nthreads = omp_get_max_threads ();
#pragma omp parallel for private (iter, ret, tnum)
#endif

  for (iter = 1; iter <= nthreads; iter++) {
#ifdef THREADED_OMP
    tnum = omp_get_thread_num ();
#endif
    printf ("Thread %d of rank %d on processor %s\n", tnum, iam, pname);
    value = sub (iter);
  }

  ret = GPTLstop ("total");
  ret = GPTLpr (iam);

  if (iam == 0) {
    printf ("summary: testing GPTLpr_summary...\n");
    printf ("Number of threads was %d\n", nthreads);
    printf ("Number of tasks was %d\n", nproc);
  }

  // NOTE: if ENABLE_PMPI is set, 2nd pr call below will show some extra send/recv calls
  // due to MPI calls from within GPTLpr_summary_file
  if (GPTLpr_summary (MPI_COMM_WORLD) != 0)
    return 1;

  if (GPTLpr_summary_file (MPI_COMM_WORLD, "timing.summary.duplicate") != 0)
    return 1;

  ret = MPI_Finalize ();

  if (GPTLfinalize () != 0)
    return 1;

  return 0;
}
Exemplo n.º 4
0
int main (int argc, char **argv)
{
  int ret;
  int i, code;
  long long pc[1]; /* papi counters */
  double sum;

  printf ("testpapi: Testing PAPI interface...\n");

  printf ("%s: testing getting event code for PAPI_TOT_CYC...\n", argv[0]);
  if ((ret = GPTLevent_name_to_code ("PAPI_TOT_CYC", &code)) != 0) {
    printf ("Failure\n");
    return 2;
  }
  printf ("Success\n");

  printf ("%s: testing GPTLsetoption(PAPI_TOT_CYC,1)...\n", argv[0]);
  if (GPTLsetoption (code, 1) != 0) {
    printf ("Failure\n");
    return 3;
  }
  printf ("Success\n");

  printf ("%s: testing GPTLinitialize\n", argv[0]);
  if ((ret = GPTLinitialize ()) != 0) {
    printf ("Failure\n");
    return 3;
  }
  printf ("Success\n");

  printf ("%s: testing GPTLstart\n", argv[0]);
  if ((ret = GPTLstart ("sum")) != 0) {
    printf ("Unexpected failure from GPTLstart(\"sum\")\n");
    return 3;
  }
  printf ("Success\n");

  sum = 0.;
  for (i = 0; i < 1000000; ++i) 
    sum += (double) i;
  printf ("%s: testing GPTLstop\n", argv[0]);
  if ((ret = GPTLstop ("sum")) != 0) {
    printf ("Unexpected failure from GPTLstop(\"sum\")\n");
    return 3;
  }
  printf ("Success\n");

  printf ("%s: testing GPTLquerycounters...\n", argv[0]);
  if (GPTLquerycounters ("sum", 0, pc) != 0) {
    printf ("Failure\n");
    return 4;
  }
  printf ("sum=%g\n",sum);
  printf ("%s: testing reasonableness of PAPI counters...\n", argv[0]);
  if (pc[0] < 1 || pc[0] > 1.e8) {
    printf ("Suspicious PAPI_TOT_CYC value=%lld for 1e6 additions\n", pc[0]);
    return 5;
  } else {
    printf ("Success\n");
  }
  printf ("%s: all tests successful\n", argv[0]);
  return 0;
}
Exemplo n.º 5
0
/*
 * If define GPUALL=1, then vector x and y are in GPU
 * Otherwise, x and y are in CPU
 * */
void aprod(int version, int procRank, int numProc, int mode, int m /*row*/,
		int n /*column*/, MY_FLOAT_TYPE x[]/*v len=n*/,
		MY_FLOAT_TYPE y[] /*u=perPorcVectorB len=m, assign NULL if PLSQRV3*/, void *UsrWork,
		int isFinalIteration, int iteration)
{
#ifdef BARRIER
	MPI_Barrier(MPI_COMM_WORLD);
#endif
#ifdef GPTL
	GPTLstart("aprod");
#endif
	int i;

///////////////////////////////////////PLSQRv3///////////////////////////////////////////////////////////////////////////////////////////////

		PPDataV3_TRI * p = (PPDataV3_TRI *)  UsrWork;

		if (mode == 1) {//y <- y+Ax
#ifdef BARRIER 
	MPI_Barrier(MPI_COMM_WORLD);
#endif
#ifdef GPTL
			GPTLstart("aprod1_spmv");
#endif

			aprod_mode_1_tridiagonal(procRank, numProc, iteration, isFinalIteration, p);

#ifdef BARRIER
	MPI_Barrier(MPI_COMM_WORLD);
#endif
#ifdef GPTL
			GPTLstop("aprod1_spmv");
#endif
		}//end of PLSQR3 mode=1


		/*PLSQR3 Aprod mode = 2*/

		else if (mode == 2){//x<-x+AT*y
#ifdef BARRIER 
	MPI_Barrier(MPI_COMM_WORLD);
#endif
#ifdef GPTL
			GPTLstart("aprod2_spmvT");
#endif

			aprod_mode_2_tridiagonal(procRank, numProc, iteration, isFinalIteration, p);

#ifdef BARRIER
	MPI_Barrier(MPI_COMM_WORLD);
#endif
#ifdef GPTL
			GPTLstop("aprod2_spmvT");
#endif
		}//end of mode =2


#ifdef GPTL
	GPTLstop("aprod");
#endif
}