예제 #1
0
PowerMonitor::PowerMonitor() {
	powerA7 = NULL;
	powerA15 = NULL;
	powerGPU = NULL;
	powerDRAM = NULL;
	sensingMethod = ODROID;
	if (enableSensor(SENSOR_A7) == 0) {
		enableSensor(SENSOR_A15);
		enableSensor(SENSOR_GPU);
		enableSensor(SENSOR_DRAM);
		sensingMethod = ODROID;
		std::cerr << "Power sensors: ODROID" << std::endl;
#ifdef PAPI_MONITORING
	} else {
		/*************************************************
			Insert code to attempt to initialise for PAPI
			here please
		*****************************************************/
		if(papi_init() == 0) {
			/*
			Dependent on what is required for initialisation of CUDA? and when it becomes
			available OpenCL for GPU PAPI then we can either insert the initialisation
			code into papi_init OR to create different initialisation functions ...
			*/
			sensingMethod = PAPI_CPU;
			std::cerr << "Power sensors: PAPI CPU" << std::endl;
		}

	}
#else
	} else {
예제 #2
0
파일: mm8.c 프로젝트: gronostajo/oora_lab5
int main(int argc, const char *argv[]) {
    int i, j, iret;
    double first[SIZE][SIZE];
    double second[SIZE][SIZE];
    double multiply[SIZE][SIZE];
    double dtime;
    for (i = 0; i < SIZE; i++) {     // rows in first
        for (j = 0; j < SIZE; j++) { // columns in first
            first[i][j] = i + j;
            second[j][i] = i - j;
            multiply[i][j] = 0.0;
        }
    }
    papi_init(atoi(argv[1]));
    papi_start();
    iret = mm(first, second, multiply);
    papi_stop();

    double check = 0.0;
    for (i = 0; i < SIZE; i++) {
        for (j = 0; j < SIZE; j++) {
            check += multiply[i][j];
        }
    }
    fprintf(stderr, "check %le \n", check);

    return iret;
}
예제 #3
0
파일: chol_3.c 프로젝트: jwegrzy/OORA
int
main(int argc, char** argv)
{
	double *A;
	int n, ret, event;
	double startTime;
	double endTime;
	long long value;

	n = atoi(argv[2]);
	A = load_matrix(argv[1], n);
	event = atoi(argv[3]);
	if (event != 5) {
  		papi_init(event);
	  	papi_start();
	} else {
		startTime = dclock();
	}
	ret = chol(A, n);
	if (event != 5) {
		value = papi_stop();
		printf("%lld\n", value);
	} else {
		endTime = dclock();
		printf("%lf\n", endTime - startTime);
	}
	fprintf(stderr, "RET:%d\n", ret);
	check(A,n);
	free(A);
	return 0;
}
예제 #4
0
파일: papi.c 프로젝트: DundalkIT/pcp
/*
 * Set up agent if running as daemon.
 */
int
main(int argc, char **argv)
{
    int sep = __pmPathSeparator();
    pmdaInterface dispatch;

    isDSO = 0;
    __pmSetProgname(argv[0]);

    snprintf(helppath, sizeof(helppath), "%s%c" "papi" "%c" "help",
	     pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&dispatch, PMDA_INTERFACE_6, pmProgname, PAPI, "papi.log", helppath);	
    pmdaGetOptions(argc, argv, &opts, &dispatch);
    if (opts.errors) {
	pmdaUsageMessage(&opts);
	exit(1);
    }
 
    pmdaOpenLog(&dispatch);
    papi_init(&dispatch);
    pmdaConnect(&dispatch);
    pmdaMain(&dispatch);

    free(ctxtab);
    free(papi_info);
    free(values);

    exit(0);
}
예제 #5
0
파일: mm1.c 프로젝트: ZawilecxD/OORA5
int main( int argc, const char* argv[] )
{

	papi_init();
	int i,j,iret,w;
	for(w = 320;w<640;w+=64){
		SIZE = w;
		double first[SIZE][SIZE];
		double second[SIZE][SIZE];
		double multiply[SIZE][SIZE];
		double dtime;
		for (i = 0; i < SIZE; i++) { //rows in first
			for (j = 0; j < SIZE; j++) { //columns in first
				first[i][j]=i+j;
				second[i][j]=i-j;
				multiply[i][j]=0.0;
			}
		}
		papi_start();
		iret=mm(first,second,multiply); 
		papi_stop((w-320)/64);
	}
	print_papi_results();
	return iret;
}
예제 #6
0
int main(int argc, char *argv[]) {
  double results[NUM_TRIALS];
  int i, papi_setnum;
  
  // initialize papi
  int desired_events[] = {PAPI_TOT_CYC, PAPI_FP_INS, PAPI_L2_DCA, PAPI_L2_DCM, PAPI_L3_DCA, PAPI_L3_DCM, PAPI_TLB_DM, PAPI_LD_INS, PAPI_SR_INS};
  int num_desired = 9;
  PAPI_event_set_wrapper_t* event_sets;
  int num_sets;
  papi_init(desired_events, num_desired, &event_sets, &num_sets);

  // input parameters
  int log2_stanzaLength = atoi(argv[1]);
  int log2_numIterations = atoi(argv[2]);

  // compute actual values from base 2 logs
  stanzaLength = 1;
  for (i=0; i<log2_stanzaLength; i++) {
    stanzaLength *= 2;
  }

  numIterations = 1;
  for (i=0; i<log2_numIterations; i++) {
    numIterations *= 2;
  }
  
  int arrayLength = stanzaLength;

  printf("\nstanzaLength = %d\n", stanzaLength);
  printf("arrayLength = %d\n", arrayLength);
  printf("numIterations = %d\n", numIterations);
  printf("num_sets = %d\n\n", num_sets);
  
  // allocate working arrays
  A = (double *) malloc(arrayLength * sizeof(double));
  B = (double *) malloc(arrayLength * sizeof(double));

  if (A==NULL) {
    printf("Error on array A malloc.\n");
    exit(EXIT_FAILURE);
  }
  if (B==NULL) {
    printf("Error on array B malloc.\n");
    exit(EXIT_FAILURE);
  }

  // initialize arrays
  init_flush_cache_array();
  initArrays();

  for (papi_setnum=0; papi_setnum < num_sets; papi_setnum++) {
    PAPI_MAKE_MEASUREMENTS(event_sets[papi_setnum].set, cacheBenchmark(), NUM_TRIALS, results);
    print_measurements(&(event_sets[papi_setnum]), results, NUM_TRIALS);
  }

  papi_cleanup(event_sets, num_sets);

  return 0;
}
예제 #7
0
int main(int argc, char *argv[]) {
  unsigned n;
  int evt;
  double *A;
  int i, j;
  double checksum = 0;
  double startTime, endTime;
  long long counter;

  if (argc < 2) {
    return -1;
  }

  n = atoi(argv[1]);
  evt = (argc > 2) ? atoi(argv[2]) : -1;

  A = randomMatrix(n);
  assert(A != NULL);

  if (evt == -1) {
    startTime = dclock();
  } else {
    papi_init(evt);
    papi_start();
  }

  if (chol(A, n)) {
    fprintf(stderr, "Error: matrix is either not symmetric or not positive definite.\n");
  } else {
    for (i = 0; i < n; i++) {
        for (j = i; j < n; j++) {
            checksum += A[IDX(i, j, n)];
        }
    }
    printf("Checksum: %f \n", checksum);
  }

  if (evt == -1) {
    endTime = dclock();
    fprintf(stderr, "%f\n", endTime - startTime);

  } else {
    counter = papi_stop();
    fprintf(stderr, "%lld\n", counter);
  }

  free(A);
  return 0;
}
예제 #8
0
파일: mm8.c 프로젝트: piotrMocz/oora
int main( int argc, const char* argv[] )
{

  FILE *fp = init_file(argv[0] + 2);
  int iret;
  for (SIZE = 8; SIZE <= 512; SIZE += 8) {
    int i,j;
    double first[SIZE][SIZE];
    double second[SIZE][SIZE];
    double multiply[SIZE][SIZE];
    double dtime;
    double gflops;

    for (i = 0; i < SIZE; i++) { //rows in first
      for (j = 0; j < SIZE; j++) { //columns in first
        first[i][j]=i+j;
        second[i][j]=i-j;
        multiply[i][j]=0.0;
      }
    }

    papi_init();
    dtime = dclock();
    iret = mm(first,second,multiply);
    dtime = dclock()-dtime;
    fprintf(fp, "%d, ", SIZE);
    papi_results(fp);   
 
    gflops = 2.0 * SIZE * SIZE * SIZE * 1e-9 / dtime;

    printf( "%d, %le, %f\n", SIZE, dtime, gflops);

    //double check=0.0;
    //for(i=0;i<SIZE;i++){
    //  for(j=0;j<SIZE;j++){
    //    check+=multiply[i][j];
    //  }
    //}
    //printf("check %le \n",check);
    fflush( stdout );
  }

  return iret;
}
예제 #9
0
int main(int argc, char *argv[]) {
  pthread_t *threads;
  pthread_attr_t attr;
  uint32_t **ranks;
  void *status;

#if defined(PAPI_ENABLED) && !defined(DEBUG)
  int num_sets;
  PAPI_event_set_wrapper_t* event_sets;
#endif
  int rc;
  uint32_t t;

  printf("Optimized Stream benchmark (using SSE intrinsics)\n");

  init_flush_cache_array();
  malloc_arrays(argv);
  print_array_parameters();
  select_code_variant(argv);
  print_code_variant_parameters();

  threads = (pthread_t *) malloc(numThreads * sizeof(pthread_t));
  ranks = (uint32_t **) malloc(numThreads * sizeof(uint32_t *));

#if !defined(DEBUG)
#if defined(PAPI_ENABLED)
  papi_init(desired_events, num_desired, &event_sets, &num_sets);

  // initialize threaded PAPI
  if (PAPI_thread_init((unsigned long (*)(void)) (pthread_self)) != PAPI_OK) {
    printf("Error with PAPI_thread_init().\n");
    exit(EXIT_FAILURE);
  }

  results = (double *) malloc(num_sets * numThreads * NUM_TRIALS * sizeof(double));
  if (results==NULL) {
    printf("Error on array results malloc.\n");
    exit(EXIT_FAILURE);
  }
#else
  results = (double *) malloc(numThreads * NUM_TRIALS * sizeof(double));
  if (results==NULL) {
    printf("Error on array results malloc.\n");
    exit(EXIT_FAILURE);
  }
#if defined(CYCLE_TIME)
  // calculate clock rate
  GET_CLOCK_RATE(results, NUM_TRIALS);
  median_counts_per_sec = find_median(results, NUM_TRIALS);
  //printf("Median ticks per second = %e\n", median_counts_per_sec);

#else
  timer_init();
  median_counts_per_sec = 1.0;
#endif
#endif
#endif

  pthread_attr_init(&attr);
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
  barrier_init(&my_barrier, numThreads);
#if defined(AFFINITY_ENABLED)
  Affinity_Init();
#endif

  // run stream tests
  for (t=0; t < numThreads; t++) {
    ranks[t] = (uint32_t *) malloc(sizeof(uint32_t));
    *ranks[t] = t;
  }

  for (t=1; t < numThreads; t++) {
#if defined(DEBUG)
    printf("Creating thread %u\n", t);
#endif
    rc = pthread_create(&threads[t], &attr, pthreads_each, (void *) ranks[t]);
    if (rc) {
      printf("ERROR; return code from pthread_create() is %d\n", rc);
      exit(EXIT_FAILURE);
    }
  }
  pthreads_each((void *) ranks[0]);

  // join the other threads
  for (t=1; t < numThreads; t++) {
    pthread_join(threads[t], &status);
  }

#if defined(PAPI_ENABLED) && !defined(DEBUG)
  papi_cleanup(event_sets, num_sets);
#endif
  pthread_attr_destroy(&attr);
  pthread_exit(NULL);
  barrier_destroy(&my_barrier);
  free_arrays();

  return EXIT_SUCCESS;
}
예제 #10
0
int main(int argc, char *argv[]) {
  double results[NUM_TRIALS];
#if !defined(DEBUG)
#if defined(PAPI_ENABLED)
  int papi_setnum, num_desired, num_sets;
#else
  double median_counts_per_sec;
#endif
#endif
  int i;

  printf("7-point stencil, no add, naive C code with non-periodic boundary conditions\n");

#if !defined(DEBUG)
#if defined(PAPI_ENABLED)
  // initialize papi
  int desired_events[] = {PAPI_TOT_CYC, PAPI_FP_INS, PAPI_L2_DCA, PAPI_L2_DCM, PAPI_L3_DCM, PAPI_TLB_DM, PAPI_LD_INS, PAPI_SR_INS};
  num_desired = 9;
  PAPI_event_set_wrapper_t* event_sets;
  papi_init(desired_events, num_desired, &event_sets, &num_sets);
#else
  // calculate clock rate
  GET_CLOCK_RATE(results, NUM_TRIALS);
  median_counts_per_sec = find_median(results, NUM_TRIALS);
#endif
#endif

  // initialize arrays
  init_flush_cache_array();
  malloc_grids(argv);
  printf("\n");

#if defined(DEBUG)
  init_grids();
  printf("SINGLY NESTED LOOP:\n");
  printf("\nGRID A BEFORE:");
  print_grid(A);
  printf("\nGRID B BEFORE:");
  print_grid(B);

  naive_singly_nested_loop();

  printf("\nGRID A AFTER:");
  print_grid(A);
  printf("\nGRID B AFTER:");
  print_grid(B);

  init_grids();
  printf("TRIPLY NESTED LOOPS:\n");
  printf("\nGRID A BEFORE:");
  print_grid(A);
  printf("\nGRID B BEFORE:");
  print_grid(B);

  naive_triply_nested_loops();

  printf("\nGRID A AFTER:");
  print_grid(A);
  printf("\nGRID B AFTER:");
  print_grid(B);
#else
#if defined(PAPI_ENABLED)
  printf("SINGLY NESTED LOOP:\n");
  for (papi_setnum=0; papi_setnum < num_sets; papi_setnum++) {
    PAPI_MAKE_MEASUREMENTS(event_sets[papi_setnum].set, naive_singly_nested_loop(), NUM_TRIALS, results);
    print_papi_measurements(&(event_sets[papi_setnum]), results, NUM_TRIALS);
  }
  printf("\n");
  printf("TRIPLY NESTED LOOPS:\n");
  for (papi_setnum=0; papi_setnum < num_sets; papi_setnum++) {
    PAPI_MAKE_MEASUREMENTS(event_sets[papi_setnum].set, naive_triply_nested_loops(), NUM_TRIALS, results);
    print_papi_measurements(&(event_sets[papi_setnum]), results, NUM_TRIALS);
  }
  printf("\n");
  papi_cleanup(event_sets, num_sets);
#else
  printf("SINGLY NESTED LOOP:\n");
  TIMER_MAKE_MEASUREMENTS(naive_singly_nested_loop(), results, NUM_TRIALS);
  print_timer_measurements(results, NUM_TRIALS, median_counts_per_sec);
  printf("\n");
  printf("TRIPLY NESTED LOOPS:\n");
  TIMER_MAKE_MEASUREMENTS(naive_triply_nested_loops(), results, NUM_TRIALS);
  print_timer_measurements(results, NUM_TRIALS, median_counts_per_sec);
  printf("\n");
  printf("\n");
#endif
#endif

  printf("\nFinal interior values: A[%lu, %lu, %lu] = %4.2e, B[%lu, %lu, %lu] = %4.2e\n", nx/2, ny/2, nz/2, A[Index3D(nx/2, ny/2, nz/2)], nx/2, ny/2, nz/2, B[Index3D(nx/2, ny/2, nz/2)]);
  fc_checksum();
  free(A);
  free(B);

  return EXIT_SUCCESS;
}