• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PAPI_library_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PAPI_library_init函数的典型用法代码示例。如果您正苦于以下问题:C++ PAPI_library_init函数的具体用法?C++ PAPI_library_init怎么用?C++ PAPI_library_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PAPI_library_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int
main( int argc, char **argv )
{
	int retval;

	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */

	if ( ( argc > 1 ) && ( strcmp( argv[1], "xxx" ) == 0 ) ) {
		retval = PAPI_library_init( PAPI_VER_CURRENT );
		if ( retval != PAPI_VER_CURRENT )
			test_fail( __FILE__, __LINE__, "execed PAPI_library_init", retval );
	} else {
		retval = PAPI_library_init( PAPI_VER_CURRENT );
		if ( retval != PAPI_VER_CURRENT )
			test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );

		PAPI_shutdown(  );

		if ( execlp( argv[0], argv[0], "xxx", NULL ) == -1 )
			test_fail( __FILE__, __LINE__, "execlp", PAPI_ESYS );
	}

	test_pass( __FILE__, NULL, 0 );
	exit( 1 );
}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:25,代码来源:exec.c


示例2: main

int
main( int argc, char **argv )
{
	int retval;
	int status;

	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */

	retval = PAPI_library_init( PAPI_VER_CURRENT );
	if ( retval != PAPI_VER_CURRENT )
		test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );

	if ( fork(  ) == 0 ) {
		retval = PAPI_library_init( PAPI_VER_CURRENT );
		if ( retval != PAPI_VER_CURRENT )
			test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval );
		exit( 0 );
	} else {
		wait( &status );
		if ( WEXITSTATUS( status ) != 0 )
			test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
	}

	test_pass( __FILE__, NULL, 0 );
	exit( 1 );
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:26,代码来源:fork.c


示例3: startPapiCounters

//
// This method should be placed at the start of instrumented code
//
void startPapiCounters(){
    initializeCounters(0);
#ifdef DBG
    printGEvents();
    printf("********* STARTING COUNTERS *************\n");
    //assert(NUM_EVENTS == _G_EVENT_COUNT);
#endif
    // initialize papi library and assert that it's successful
    _CALL_PAPI(PAPI_library_init( PAPI_VER_CURRENT ));    
    
    // check that all the events can be counted at once.
    int numCounters = PAPI_num_counters() ;
    assert( NUM_EVENTS <= numCounters );

    
#ifdef DBG
    printf("Number of hardware counters available on this machine: %d", numCounters);
#endif

    for ( int i = 0; i < NUM_EVENTS; i++ ) {
        char name[PAPI_MAX_STR_LEN];
        (void) _CALL_PAPI(PAPI_event_code_to_name( _G_EVENTS[i], name ));
        if(PAPI_query_event( _G_EVENTS[i] ) < PAPI_OK) {
            fprintf(stderr, "Event %s could not be counted on this machine.\n", name);
            abort();
        }
    }

    //*******  Start Counters ******
    (void) _CALL_PAPI(PAPI_start_counters(_G_EVENTS, NUM_EVENTS));
}
开发者ID:goyalankit,项目名称:benchmark-tools,代码行数:34,代码来源:papi_helper.c


示例4: my_papi_start

void my_papi_start( int myrank )
{
#ifdef PAPI_MONITOR
  int retval, index ;
  char EventCodeStr[PAPI_MAX_STR_LEN];
  
  if(myrank == 0)
    DO_TEST = 1;
  
  retval = PAPI_library_init(PAPI_VER_CURRENT);
  if (retval != PAPI_VER_CURRENT)
    {
      fprintf(stderr, "PAPI library init error! %d\n", retval);
      exit(1);
    }
  fprintf(stderr,"PAPI Library start ...\n");

  if (PAPI_create_eventset(&PAPI_EventSet) != PAPI_OK)
    exit(1);

  for (index = 0 ; index < NEVENTS ; index ++)
    {
      PAPI_event_code_to_name(PAPI_events[index], EventCodeStr);
      /*fprintf(stderr,"Adding event %s ... ",EventCodeStr); */
      if (PAPI_add_event(PAPI_EventSet,PAPI_events[index]) != PAPI_OK)
	exit(1);
      /*fprintf(stderr," DONE !\n"); */
    }
  /*fprintf(stderr,"\n"); */

  if (PAPI_start(PAPI_EventSet) != PAPI_OK)
    exit(1);
#endif /*PAPI_MONITOR */
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:34,代码来源:papi_defs.c


示例5: initTimers

void initTimers() {
#if USING_PERFCTR == 0
	int retval;
	fprintf(stderr, "1\n");

	if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
		printf("PAPI Library initialization error! \n");
		exit(1);
	}

	fprintf(stderr, "2\n");
	if ((retval = PAPI_set_debug(PAPI_VERB_ESTOP)) != PAPI_OK) {
		printf("PAPI set debug error! \n");
		exit(1);
	}
	fprintf(stderr, "3\n");
	if (PAPI_thread_init(pthread_self) != PAPI_OK) {
		printf("PAPI thread Library initialisation error! \n");
		exit(1);
	}
	fprintf(stderr, "4\n");
	PAPI_thread_init(gettid);
	PAPI_register_thread();
#else
	PERFCTR_initialize();
	PERFCTR_register_thread();
#endif

	gettimeofday(&program_start, NULL);
}
开发者ID:giovannic,项目名称:vexjine,代码行数:30,代码来源:JVMTIAgent_vtonly.cpp


示例6: main

 main(){

	long_long start_cycles, end_cycles, start_usec, end_usec;
	int EventSet = PAPI_NULL;

	int tabla[100];

	        
	if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT)
	  exit(1);

	/* Gets the starting time in clock cycles */
	start_cycles = PAPI_get_real_cyc();

	/* Gets the starting time in microseconds */
	start_usec = PAPI_get_real_usec();

	/*Create an EventSet */
	//if (PAPI_create_eventset(&EventSet) != PAPI_OK)
	//  exit(1);
	tabla[0]=1;
	tabla[100]=1;
	/* Gets the ending time in clock cycles */
	end_cycles = PAPI_get_real_cyc();

	/* Gets the ending time in microseconds */
	end_usec = PAPI_get_real_usec();

	printf("Wall clock cycles: %lld\n", end_cycles - start_cycles);
	printf("Wall clock time in microseconds: %lld\n", end_usec - start_usec); 
}
开发者ID:jvalle3,项目名称:imdea,代码行数:31,代码来源:papi1.c


示例7: main

int main(int argc, char *argv[]) {

     double a[MAXVSIZE], b[MAXVSIZE], c[MAXVSIZE];
     int i,n;
     long long before, after;
     float rtime, ptime, mflops;
     long long flpops; 

     if (PAPI_VER_CURRENT != 
		PAPI_library_init(PAPI_VER_CURRENT))
	ehandler("PAPI_library_init error.");


     printf("Enter vector size:  ");
     scanf("%d",&n);

     for (i=0;i<n;i++) {
       a[i] = i;
       b[i] = n-i;
     }

     PAPI_flops(&rtime, &ptime, &flpops, &mflops);
     loop(c,a,b,n);
     PAPI_flops(&rtime, &ptime, &flpops, &mflops);


     printf("Number of floatinig point operations = %lld\n",flpops);
     printf("mflops = %f\n",mflops);
     return 0;

}
开发者ID:di,项目名称:school,代码行数:31,代码来源:floops1.c


示例8: PAPI_HW_COUNTER_init

void PAPI_HW_COUNTER_init(int _numcpus, int _numiters){
  int retval;
  int i,j;

  numcpus = _numcpus;
  numiters= _numiters;

  retval = PAPI_library_init(PAPI_VER_CURRENT);
  if (retval <0){
    printf("ERROR: PAPI failed to initialize.(%d)\n",retval);
    exit(1);
  }else if (retval != PAPI_VER_CURRENT) {
    printf("ERROR: PAPI library version mismatch.(%d!=%d)\n", PAPI_VER_CURRENT,retval);
    exit(1);
  }
  printf("PAPI is initialized.\n");

  // malloc thr_vars
  if (posix_memalign((void**)&thr_vars, CACHELINE_SIZE, sizeof(struct PAPI_VARS)*numcpus)){
    printf("ERROR: failed to allocate memory to thr_vars\n");
    exit(1);
  }

  // Open file to overall result
  summary_f=fopen("summary.txt", "w");
  if (summary_f == NULL){
    printf("ERROR: failed to open file summary.txt.\n");
    exit(1);
  }
}
开发者ID:LaminarIR,项目名称:framework,代码行数:30,代码来源:papi_hw_counter.c


示例9: main

int main(int argc, char **argv)
{
   int retval;
   int preset;

   tests_quiet(argc, argv);     /* Set TESTS_QUIET variable */

   if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT)
      test_fail(__FILE__, __LINE__, "PAPI_library_init", retval);

   retval = PAPI_event_name_to_code("PAPI_FP_INS", &preset);
   if (retval != PAPI_OK)
      test_fail(__FILE__, __LINE__, "PAPI_event_name_to_code", retval);
   if (preset != PAPI_FP_INS)
      test_fail(__FILE__, __LINE__, "Wrong preset returned", retval);

   retval = PAPI_event_name_to_code("PAPI_TOT_CYC", &preset);
   if (retval != PAPI_OK)
      test_fail(__FILE__, __LINE__, "PAPI_event_name_to_code", retval);
   if (preset != PAPI_TOT_CYC)
      test_fail(__FILE__, __LINE__, "*preset returned did not equal PAPI_TOT_CYC",
                retval);

   test_pass(__FILE__, NULL, 0);
   exit(1);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:26,代码来源:eventname.c


示例10: main

int main(int argc, char **argv)
{
   int retval;
   long long elapsed_us, elapsed_cyc;
   const PAPI_hw_info_t *hw_info;

   tests_quiet(argc, argv);     /* Set TESTS_QUIET variable */

   retval = PAPI_library_init(PAPI_VER_CURRENT);
   if (retval != PAPI_VER_CURRENT)
      test_fail(__FILE__, __LINE__, "PAPI_library_init", retval);

   hw_info = PAPI_get_hardware_info();
   if (hw_info == NULL)
     test_fail(__FILE__, __LINE__, "PAPI_get_hardware_info", 2);

   elapsed_us = PAPI_get_real_usec();

   elapsed_cyc = PAPI_get_real_cyc();

   printf("Testing real time clock. (CLOCK %d MHz, CPU %f MHz)\n",hw_info->clock_mhz,hw_info->mhz);
   printf("Sleeping for 10 seconds.\n");

   sleep(10);

   elapsed_us = PAPI_get_real_usec() - elapsed_us;

   elapsed_cyc = PAPI_get_real_cyc() - elapsed_cyc;

   printf("%lld us. %lld cyc.\n",elapsed_us,elapsed_cyc);
   printf("%f Computed MHz.\n",(float)elapsed_cyc/(float)elapsed_us);

/* Elapsed microseconds and elapsed cycles are not as unambiguous as they appear.
   On Pentium III and 4, for example, cycles is a measured value, while useconds 
   is computed from cycles and mhz. MHz is read from /proc/cpuinfo (on linux).
   Thus, any error in MHz is propagated to useconds.
   Conversely, on ultrasparc useconds are extracted from a system call (gethrtime())
   and cycles are computed from useconds. Also, MHz comes from a scan of system info,
   Thus any error in gethrtime() propagates to both cycles and useconds, and cycles
   can be further impacted by errors in reported MHz.
   Without knowing the error bars on these system values, we can't really specify
   error ranges for our reported values, but we *DO* know that errors for at least
   one instance of Pentium 4 ([email protected]) are on the order of one part per thousand.
   Newer multicore Intel processors seem to have broken the relationship between the
   clock rate reported in /proc/cpuinfo and the actual computed clock. To accomodate
   this artifact, the test no longer fails, but merely reports results out of range.
*/

   if (elapsed_us < 9000000)
	   printf("NOTE: Elapsed real time less than 9 seconds!\n");
   if (elapsed_us > 11000000)
     printf("NOTE: Elapsed real time greater than 11 seconds!\n");
   if ((float)elapsed_cyc < 9.0 * hw_info->mhz * 1000000.0) 
     printf("NOTE: Elapsed real cycles less than 9*MHz*1000000.0!\n");
   if ((float)elapsed_cyc > 11.0 * hw_info->mhz * 1000000.0) 
     printf("NOTE: Elapsed real cycles greater than 11*MHz*1000000.0!\n");
   
   test_pass(__FILE__, NULL, 0);
   exit(1);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:60,代码来源:realtime.c


示例11: papi_global_init

void papi_global_init() {
  int retval;
  if ( (retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
    fprintf(stderr, "PAPI library init error!\n%s\n", PAPI_strerror(retval));
  }
  //papi_init_counters_name_non_thread_safe();
}
开发者ID:jreybert,项目名称:power,代码行数:7,代码来源:papi.c


示例12: initialize_papi

void initialize_papi (int eventCode) {
  /* Initialize the PAPI library */
  retval = PAPI_library_init(PAPI_VER_CURRENT);
  if (retval != PAPI_VER_CURRENT) {
    fprintf(stderr, "PAPI library init error! %d\n",PAPI_EINVAL);
    handle_error(1);
  }
  
  if (EventSet==PAPI_NULL) {
  	if (PAPI_create_eventset(&EventSet) != PAPI_OK) {
	  	printf("PAPI create eventset error\n");
  	  handle_error(1);
  	}
  } else {
  	if (PAPI_cleanup_eventset(EventSet) != PAPI_OK) {
  		printf("PAPI cleanup error\n");
			handle_error(1);
		}
	}
	
  if (PAPI_add_event(EventSet, eventCode) != PAPI_OK) {
		printf("PAPI add event error: %x\n", eventCode);
    handle_error(1);
  }  
}
开发者ID:Ruekov,项目名称:hwquery,代码行数:25,代码来源:papif.c


示例13: init_known_metrics

/* Initialize htable with the metrics known by the system */
int init_known_metrics()
{
  /* Initialize PAPI library */
  int retval;

  retval = PAPI_library_init(PAPI_VER_CURRENT);
  if (retval != PAPI_VER_CURRENT) {
    fprintf(stderr, "Error! PAPI_library_init %d\n",retval);

    PAPI_shutdown();
  }

  /* Initialize custom metrics storage */
  HASH_CLEAR(hh, callbacks_storage);

  for(int i = 0; i < available_metrics_no; ++i) {
    htable *new_pair = NULL;
    new_pair = malloc(sizeof(htable));

    if (!new_pair) {
        fprintf(stderr, "can't alloc memory for the new pair\n");
        exit(-1);
    }

    strcpy(new_pair->key, callbacks[i].alias);
    new_pair->value = callbacks[i].func;

    /* insert the new pair in callbacks_storage */
    HASH_ADD_STR(callbacks_storage, key, new_pair);
  }

  return 0;
}
开发者ID:GeorgianaElena,项目名称:Monitoring_clarisse,代码行数:34,代码来源:storage.c


示例14: papi_init

void papi_init(int eventNumber){
	if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) {
		fprintf(stderr, "PAPI is unsupported.\n");
		papi_supported = false;
	}

	if (PAPI_num_counters() < 5) {
		fprintf(stderr, "PAPI is unsupported.\n");
		papi_supported = false;
	}

	if ((papi_err = PAPI_create_eventset(&eventSet)) != PAPI_OK) {
		fprintf(stderr, "Could not create event set: %s\n", PAPI_strerror(papi_err));
	}

    /* force program to run on a single CPU */
    cpu_set_t my_set;        /* Define your cpu_set bit mask. */
    CPU_ZERO(&my_set);       /* Initialize it all to 0, i.e. no CPUs selected. */
	CPU_SET(0, &my_set);
	if (sched_setaffinity(0, sizeof(cpu_set_t), &my_set) != 0) {
		perror("sched_setaffinity error");
	}

	if ((papi_err = PAPI_add_event(eventSet, events[eventNumber])) != PAPI_OK ) {
		fprintf(stderr, "Could not add event: %s\n", PAPI_strerror(papi_err));
	}
}
开发者ID:gronostajo,项目名称:oora_lab6,代码行数:27,代码来源:papi.c


示例15: start_papi

void start_papi() {
    values = calloc(en, sizeof(long long));

    if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) {
        fprintf(stderr, "PAPI is unsupported.\n");
        papi_supported = 0;
    }

    if (PAPI_num_counters() < en) {
        fprintf(stderr, "PAPI is unsupported.\n");
        papi_supported = 0;
    }
    
    if ((papi_err = PAPI_create_eventset(&eventSet)) != PAPI_OK) {
        fprintf(stderr, "Could not create event set: %s\n", PAPI_strerror(papi_err));
    }

    for (int i=0; i<en; ++i) {
        if ((papi_err = PAPI_add_event(eventSet, events[i])) != PAPI_OK ) {
            fprintf(stderr, "Could not add event: %s %s\n", event_names[i], PAPI_strerror(papi_err));
        }
    }

    /* start counters */

    if (papi_supported) {
        if ((papi_err = PAPI_start(eventSet)) != PAPI_OK) {
            fprintf(stderr, "Could not start counters: %s\n", PAPI_strerror(papi_err));
        }
    }
}
开发者ID:kuba13,项目名称:optymalizacje,代码行数:31,代码来源:compressed_mat_register.c


示例16: main

int main(int argc, char **argv)
{
   int retval;

   const PAPI_component_info_t *cmpinfo;

   tests_quiet(argc, argv);     /* Set TESTS_QUIET variable */

   if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT)
      test_fail(__FILE__, __LINE__, "PAPI_library_init", retval);

   if ((cmpinfo = PAPI_get_component_info(0)) == NULL) 
     test_fail(__FILE__, __LINE__, "PAPI_get_component_info", retval);

   printf("name: %s\n",cmpinfo->name);
   printf("substrate_version: %s\n",cmpinfo->version);
   printf("support_version: %s\n",cmpinfo->support_version);
   printf("kernel_version: %s\n",cmpinfo->kernel_version);
   printf("num_cntrs: %d\n",cmpinfo->num_cntrs);
   printf("num_mpx_cntrs: %d\n",cmpinfo->num_mpx_cntrs);
   printf("num_preset_events: %d\n",cmpinfo->num_preset_events);           /* Number of counters the substrate supports */
   printf("num_native_events: %d\n",cmpinfo->num_native_events);           /* Number of counters the substrate supports */
   printf("default_domain: 0x%x (%s)\n",cmpinfo->default_domain,stringify_all_domains(cmpinfo->default_domain));
   printf("available_domains: 0x%x (%s)\n",cmpinfo->available_domains,stringify_all_domains(cmpinfo->available_domains));       /* Available domains */ 
   printf("default_granularity: 0x%x (%s)\n",cmpinfo->default_granularity,stringify_granularity(cmpinfo->default_granularity));
   /* The default granularity when this substrate is used */
   printf("available_granularities: 0x%x (%s)\n",cmpinfo->available_granularities,stringify_all_granularities(cmpinfo->available_granularities)); /* Available granularities */
   printf("itimer_sig: %d\n",cmpinfo->itimer_sig);     
   printf("itimer_num: %d\n",cmpinfo->itimer_num);     
   printf("itimer_ns: %d\n",cmpinfo->itimer_ns);      
   printf("itimer_res_ns: %d\n",cmpinfo->itimer_res_ns); 
   printf("hardware_intr_sig: %d\n",cmpinfo->hardware_intr_sig);      /* Width of opcode matcher if exists, 0 if not */
   printf("clock_ticks: %d\n",cmpinfo->clock_ticks);      
   printf("opcode_match_width: %d\n",cmpinfo->opcode_match_width);      /* Width of opcode matcher if exists, 0 if not */
/*   printf("reserved_ints[4]: %d\n",cmpinfo->reserved_ints[4]); */
   printf("hardware_intr: %d\n",cmpinfo->hardware_intr);         /* Needs hw overflow intr to be emulated in software*/
   printf("precise_intr: %d\n",cmpinfo->precise_intr);          /* Performance interrupts happen precisely */
   printf("posix1b_timers: %d\n",cmpinfo->posix1b_timers);          /* Performance interrupts happen precisely */
   printf("kernel_profile: %d\n",cmpinfo->kernel_profile);        /* Needs kernel profile support (buffered interrupts) to be emulated */
   printf("kernel_multiplex: %d\n",cmpinfo->kernel_multiplex);      /* In kernel multiplexing */
   printf("data_address_range: %d\n",cmpinfo->data_address_range);    /* Supports data address range limiting */
   printf("instr_address_range: %d\n",cmpinfo->instr_address_range);   /* Supports instruction address range limiting */
   printf("fast_counter_read: %d\n",cmpinfo->fast_counter_read);       /* Has a fast counter read */
   printf("fast_real_timer: %d\n",cmpinfo->fast_real_timer);       /* Has a fast real timer */
   printf("fast_virtual_timer: %d\n",cmpinfo->fast_virtual_timer);    /* Has a fast virtual timer */
   printf("attach: %d\n",cmpinfo->attach);    /* Has a fast virtual timer */
   printf("attach_must_ptrace: %d\n",cmpinfo->attach_must_ptrace);    /* Has a fast virtual timer */
   printf("edge_detect: %d\n",cmpinfo->edge_detect);    /* Has a fast virtual timer */
   printf("invert: %d\n",cmpinfo->invert);    /* Has a fast virtual timer */
   printf("profile_ear: %d\n",cmpinfo->profile_ear);     /* Supports data/instr/tlb miss address sampling */
   printf("cntr_groups: %d\n",cmpinfo->cntr_groups);           /* Underlying hardware uses counter groups */
   printf("cntr_umasks: %d\n",cmpinfo->cntr_umasks);           /* counters have unit masks */
   printf("cntr_IEAR_events: %d\n",cmpinfo->cntr_IEAR_events);      /* counters support instr event addr register */
   printf("cntr_DEAR_events: %d\n",cmpinfo->cntr_DEAR_events);      /* counters support data event addr register */
   printf("cntr_OPCM_events: %d\n",cmpinfo->cntr_OPCM_events);      /* counter events support opcode matching */

   test_pass(__FILE__, NULL, 0);
   exit(0);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:59,代码来源:subinfo.c


示例17: namdInitPapiCounters

static void namdInitPapiCounters(){
	if(CkMyRank()==0){
		//only initialize per OS process (i.e. a charm node)
		int retval = PAPI_library_init(PAPI_VER_CURRENT);
		if(retval != PAPI_VER_CURRENT) {
			if(CkMyPe()==0){
				CkPrintf("ERROR: PAPI library is not compatitible!");
				CkExit();
			}
		}
	#if CMK_SMP
		//now only consider systems that are compatible with POSIX
		if(PAPI_thread_init(pthread_self)!=PAPI_OK) {
			if(CkMyPe()==0){
				CkPrintf("ERROR: multi-thread mode in PAPI could not be initialized!");
				CkExit();
			}
		}
	#endif
	}
	CkpvInitialize(int *, papiEvents);
	CkpvAccess(papiEvents) = new int[NUM_PAPI_EVENTS];

#if MEASURE_PAPI_CACHE
	if(PAPI_query_event(PAPI_L1_DCM)==PAPI_OK) {
		CkpvAccess(papiEvents)[0] = PAPI_L1_DCM;
	}else{
		if(CkMyPe()==0){
			CkPrintf("WARNING: PAPI_L1_DCM doesn't exsit on this platform!\n");			
		}
		//if not default to PAPI_TOT_INS
		CkpvAccess(papiEvents)[0] = PAPI_TOT_INS;
	}

	if(PAPI_query_event(PAPI_L2_DCM)==PAPI_OK) {
		CkpvAccess(papiEvents)[1] = PAPI_L2_DCM;
	}else{
		//if not default to PAPI_TOT_CYC
		CkpvAccess(papiEvents)[1] = PAPI_TOT_CYC;
	}	
#elif MEASURE_PAPI_FLOPS
	if(PAPI_query_event(PAPI_FP_INS)==PAPI_OK) {
		CkpvAccess(papiEvents)[0] = PAPI_FP_INS;
	}else{
		if(CkMyPe()==0){
			CkPrintf("WARNING: PAPI_FP_INS doesn't exsit on this platform!\n");
		}
		//if not default to PAPI_TOT_INS
		CkpvAccess(papiEvents)[0] = PAPI_TOT_INS;
	}

	if(PAPI_query_event(PAPI_FMA_INS)==PAPI_OK) {
		CkpvAccess(papiEvents)[1] = PAPI_FMA_INS;
	}else{
		//if not default to PAPI_TOT_CYC
		CkpvAccess(papiEvents)[1] = PAPI_TOT_CYC;
	}
#endif
}
开发者ID:wware,项目名称:namd-povray-cloud,代码行数:59,代码来源:Node.C


示例18: main

int main(int argc, char **argv)
{
   int i, retval;
   long long elapsed_us, elapsed_cyc;

   tests_quiet(argc, argv);     /* Set TESTS_QUIET variable */

   retval = PAPI_library_init(PAPI_VER_CURRENT);
   if (retval != PAPI_VER_CURRENT)
      test_fail(__FILE__, __LINE__, "PAPI_library_init", retval);

   hw_info = PAPI_get_hardware_info();
   if (hw_info == NULL)
     test_fail(__FILE__, __LINE__, "PAPI_get_hardware_info", 2);

   elapsed_us = PAPI_get_real_usec();

   elapsed_cyc = PAPI_get_real_cyc();

#if defined(_AIX)
   retval = PAPI_thread_init((unsigned long (*)(void)) (pthread_self));
   if (retval != PAPI_OK) {
      if (retval == PAPI_ESBSTR)
         test_skip(__FILE__, __LINE__, "PAPI_thread_init", retval);
      else
         test_fail(__FILE__, __LINE__, "PAPI_thread_init", retval);
   }
#pragma ibm parallel_loop
#elif defined(sgi) && defined(mips)
   retval = PAPI_thread_init((unsigned long (*)(void)) (mp_my_threadnum));
   if (retval != PAPI_OK) {
      test_fail(__FILE__, __LINE__, "PAPI_thread_init", retval);
   }
#pragma parallel
#pragma local(i)
#pragma pfor
#elif defined(sun) && defined(sparc)
   retval = PAPI_thread_init((unsigned long (*)(void)) (thr_self));
   if (retval != PAPI_OK) {
      test_fail(__FILE__, __LINE__, "PAPI_thread_init", retval);
   }
#pragma MP taskloop private(i)
#else
#error "Architecture not included in this test file yet."
#endif
   for (i = 1; i < 3; i++)
      Thread(i, 10000000 * i);

   elapsed_cyc = PAPI_get_real_cyc() - elapsed_cyc;

   elapsed_us = PAPI_get_real_usec() - elapsed_us;

   if (!TESTS_QUIET) {
      printf("Master real usec   : \t%lld\n", elapsed_us);
      printf("Master real cycles : \t%lld\n", elapsed_cyc);
   }
   test_pass(__FILE__, NULL, 0);
   exit(1);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:59,代码来源:zero_smp.c


示例19: main

int main(int argc, char** argv) {
  int Events[NUM_EVENTS]; 
  const char* names[NUM_EVENTS] = {"OPEN_CALLS", "OPEN_FDS", "READ_CALLS", "READ_BYTES", "READ_USEC", "READ_ERR", "READ_INTERRUPTED", "READ_WOULD_BLOCK", "WRITE_CALLS","WRITE_BYTES","WRITE_USEC", "WRITE_WOULD_BLOCK"};
  long long values[NUM_EVENTS];

  /* Set TESTS_QUIET variable */
  tests_quiet( argc, argv );

  int version = PAPI_library_init (PAPI_VER_CURRENT);
  if (version != PAPI_VER_CURRENT) {
    fprintf(stderr, "PAPI_library_init version mismatch\n");
    exit(1);
  }

  if (!TESTS_QUIET) fprintf(stderr, "This program will read from stdin and echo it to stdout\n");
  int retval;
  int e;
  for (e=0; e<NUM_EVENTS; e++) {
    retval = PAPI_event_name_to_code((char*)names[e], &Events[e]);
    if (retval != PAPI_OK) {
      fprintf(stderr, "Error getting code for %s\n", names[e]);
      exit(2);
    } 
  }

  /* Start counting events */
  if (PAPI_start_counters(Events, NUM_EVENTS) != PAPI_OK) {
    fprintf(stderr, "Error in PAPI_start_counters\n");
    exit(1);
  }

  int bytes = 0;
  char buf[1024];

 
//if (PAPI_read_counters(values, NUM_EVENTS) != PAPI_OK)
//   handle_error(1);
//printf("After reading the counters: %lld\n",values[0]);

  while ((bytes = read(0, buf, 1024)) > 0) {
    write(1, buf, bytes);
  }


  /* Stop counting events */
  if (PAPI_stop_counters(values, NUM_EVENTS) != PAPI_OK) {
    fprintf(stderr, "Error in PAPI_stop_counters\n");
  }
 
  if (!TESTS_QUIET) { 
    printf("----\n");
    for (e=0; e<NUM_EVENTS; e++)  
      printf("%s: %lld\n", names[e], values[e]);
  }
  test_pass( __FILE__, NULL, 0 );
  return 0;
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:57,代码来源:appio_test_blocking.c


示例20: compute

void compute() {
#if PAPI
    int EventCode, retval;
    int EventSet = PAPI_NULL;
    long long PAPI_Counters[MAX_COUNTERS];

    /* Initialize the library */
    retval = PAPI_library_init(PAPI_VER_CURRENT);

    if  (retval != PAPI_VER_CURRENT) {
        fprintf(stderr, "PAPI library init error!\n");
        exit(1); 
    }

    /* PAPI create event */
    if (PAPI_create_eventset(&EventSet) != PAPI_OK) {
        fprintf(stderr, "create event set: %s", PAPI_strerror(retval));
    }

    for (int i = 0; i < NUMCOUNTERS; i++) {
        if ( (retval = PAPI_add_named_event(EventSet, events[i])) != PAPI_OK) {
            fprintf(stderr, "add named event: %s", PAPI_strerror(retval));
        }
    }

    retval = PAPI_start(EventSet);
#endif
    
    float matice1[rozmer][rozmer];
    float matice2[rozmer][rozmer];
    float matice3[rozmer][rozmer];
    //Main multiply code
    int j,k,m;
    for(j = 0; j < rozmer; j++)
    {
        for (k = 0; k < rozmer; k++)
        {
            float temp = 0;
            for (m = 0; m < rozmer; m++)
            {
                temp = temp + matice1[j][m] * matice2[m][k];
            }
            matice3[j][k] = temp;
        }
    }

#if PAPI
    retval = PAPI_stop(EventSet, PAPI_Counters);
    if (retval != PAPI_OK) exit(1);

    for (int j = 0; j < NUMCOUNTERS; j++) {
        printf("%20lld %s\n", PAPI_Counters[j], events[j]);
    //    fprintf(stderr, "%lld\n ", PAPI_Counters[j]);
    }
#endif
}
开发者ID:goyalankit,项目名称:benchmark-tools,代码行数:56,代码来源:test2.c



注:本文中的PAPI_library_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PAPI_start函数代码示例发布时间:2022-05-30
下一篇:
C++ PAPI_create_eventset函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap