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

C++ PAPI_start函数代码示例

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

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



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

示例1: papi_start

void papi_start(){
	if (papi_supported) {
		if ((papi_err = PAPI_start(eventSet)) != PAPI_OK) {
			fprintf(stderr, "Could not start counters: %s\n", PAPI_strerror(papi_err));
		}
	}

}
开发者ID:gronostajo,项目名称:oora_lab6,代码行数:8,代码来源:papi.c


示例2: event_start

void event_start(int *eventSet, int threadID){

    int retval;

    retval = PAPI_start( *eventSet );
    if ( retval != PAPI_OK )
        test_fail( __FILE__, __LINE__, "PAPI_start",retval );

}
开发者ID:ManuelSelva,项目名称:orcc,代码行数:9,代码来源:eventLib.c


示例3: Thread

void
Thread( int t, int n )
{
	int retval, num_tests = 1;
	int EventSet1 = PAPI_NULL;
	int PAPI_event, mask1;
	int num_events1;
	long long **values;
	long long elapsed_us, elapsed_cyc;
	char event_name[PAPI_MAX_STR_LEN];

	/* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
	   PAPI_TOT_INS, depending on the availability of the event on the
	   platform */
	EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );

	retval = PAPI_event_code_to_name( PAPI_event, event_name );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );

	values = allocate_test_space( num_tests, num_events1 );

	retval = PAPI_start( EventSet1 );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_start", retval );

	elapsed_us = PAPI_get_real_usec(  );

	elapsed_cyc = PAPI_get_real_cyc(  );

	do_flops( n );

	elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;

	elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;

	retval = PAPI_stop( EventSet1, values[0] );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_stop", retval );

	remove_test_events( &EventSet1, mask1 );

	if ( !TESTS_QUIET ) {
		printf( "Thread %#x %-12s : \t%lld\n", t, event_name,
				values[0][1] );
		printf( "Thread %#x PAPI_TOT_CYC : \t%lld\n", t, 
			values[0][0] );
	}

	free_test_space( values, num_tests );
	if ( !TESTS_QUIET ) {
		printf( "Thread %#x Real usec    : \t%lld\n", t, elapsed_us );
		printf( "Thread %#x Real cycles  : \t%lld\n", t, elapsed_cyc );
	}
	PAPI_unregister_thread(  );
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:56,代码来源:zero_smp.c


示例4: 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


示例5: main

int
main( int argc, char **argv )
{
  double c, a = 0.999, b = 1.001;
	int n = 1000;
	int EventSet = PAPI_NULL;
	int retval;
	int i, j = 0;
	long long g1[2];

	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 ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );

	if ( PAPI_query_event( PAPI_L2_TCM ) == PAPI_OK )
		j++;

	if ( j == 1 &&
		 ( retval = PAPI_add_event( EventSet, PAPI_L2_TCM ) ) != PAPI_OK ) {
		if ( retval != PAPI_ECNFLCT )
			test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
		j--;				 /* The event was not added */
	}

	i = j;
	if ( PAPI_query_event( PAPI_L2_DCM ) == PAPI_OK )
		j++;

	if ( j == ( i + 1 ) &&
		 ( retval = PAPI_add_event( EventSet, PAPI_L2_DCM ) ) != PAPI_OK ) {
		if ( retval != PAPI_ECNFLCT )
			test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
		j--;				 /* The event was not added */
	}

	if ( j ) {
		if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
			test_fail( __FILE__, __LINE__, "PAPI_start", retval );
		for ( i = 0; i < n; i++ ) {
			c = a * b;
		}
		if (!TESTS_QUIET) fprintf(stdout,"c=%lf\n",c);

		if ( ( retval = PAPI_stop( EventSet, g1 ) ) != PAPI_OK )
			test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
	}
	test_pass( __FILE__, NULL, 0 );
	exit( 1 );
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:55,代码来源:case1.c


示例6: check_event

static int
check_event( int event_code, char *name )
{
	int retval;
	char errstring[PAPI_MAX_STR_LEN];
	long long values;
	int EventSet = PAPI_NULL;

   /* Is there an issue with older machines? */
   /* Disable for now, add back once we can reproduce */
//	if ( PENTIUM4 ) {
//		if ( strcmp( name, "REPLAY_EVENT:BR_MSP" ) == 0 ) {
//			return 1;
//		}
//	}

	retval = PAPI_create_eventset( &EventSet );
	if ( retval != PAPI_OK )
	   test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
   
	retval = PAPI_add_event( EventSet, event_code );
	if ( retval != PAPI_OK ) {
		printf( "Error adding %s\n", name );
		return 0;
	} else {
	  //		printf( "Added %s successfully ", name );
	}

	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
		PAPI_perror( retval, errstring, PAPI_MAX_STR_LEN );
		fprintf( stdout, "Error starting %s : %s\n", name, errstring );
	} else {
		retval = PAPI_stop( EventSet, &values );
		if ( retval != PAPI_OK ) {
			PAPI_perror( retval, errstring, PAPI_MAX_STR_LEN );
			fprintf( stdout, "Error stopping %s: %s\n", name, errstring );
			return 0;
		} else {
			printf( "Added and Stopped %s successfully.\n", name );
		}
	}


	retval=PAPI_cleanup_eventset( EventSet );
	if (retval != PAPI_OK ) {
	  test_warn( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval);
	}
	retval=PAPI_destroy_eventset( &EventSet );
	if (retval != PAPI_OK ) {
	  test_warn( __FILE__, __LINE__, "PAPI_destroy_eventset", retval);
	}
	return ( 1 );
}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:54,代码来源:all_native_events.c


示例7: my_thread

void *
my_thread( void *v )
{
	long num = ( long ) v;
	int n;
	int EventSet = PAPI_NULL;
	long long value;

	int retval = PAPI_register_thread(  );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval );
	pthread_setspecific( key, v );

	count[num] = 0;
	iter[num] = 0;
	last[num] = start;
        
	if ( PAPI_create_eventset( &EventSet ) != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_create_eventset failed", 1 );

	if ( PAPI_add_event( EventSet, EVENT ) != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_add_event failed", 1 );

	if ( PAPI_overflow( EventSet, EVENT, threshold, 0, my_handler ) != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_overflow failed", 1 );

	if ( PAPI_start( EventSet ) != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_start failed", 1 );

	printf( "launched timer in thread %ld\n", num );

	for ( n = 1; n <= program_time; n++ ) {
		do_cycles( num, 1 );
		print_rate( num );
	}

	PAPI_stop( EventSet, &value );

        retval = PAPI_overflow( EventSet, EVENT, 0, 0, my_handler);
	if ( retval != PAPI_OK )
            test_fail( __FILE__, __LINE__, "PAPI_overflow failed to reset the overflow handler", retval );

	if ( PAPI_remove_event( EventSet, EVENT ) != PAPI_OK ) 
	    test_fail( __FILE__, __LINE__, "PAPI_remove_event", 1 );

	if ( PAPI_destroy_eventset( &EventSet ) != PAPI_OK ) 
	    test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", 1 );

	if ( PAPI_unregister_thread( ) != PAPI_OK != retval ) 
		test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", 1 );

	return ( NULL );
}
开发者ID:arm-hpc,项目名称:papi,代码行数:53,代码来源:krentel_pthreads.c


示例8: Thread

void Thread( int n ){

	int retval, num_tests = 1;
	int EventSet1 = PAPI_NULL;
	int PAPI_event, mask1;
	int num_events1;
	long long **values;
	long long elapsed_us, elapsed_cyc, L1_DCM;
	char event_name[PAPI_MAX_STR_LEN];

	printf( "Thread %#x started\n", omp_get_thread_num(  ) );
	num_events1 = 2;

	EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );

	retval = PAPI_event_code_to_name( PAPI_event, event_name );
	if ( retval != PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );

	values = allocate_test_space( num_tests, num_events1 );

	elapsed_us = PAPI_get_real_usec(  );
	
	elapsed_cyc = PAPI_get_real_cyc(  );

	retval = PAPI_start( EventSet1 );

	do_flops( n );

	retval = PAPI_stop( EventSet1, values[0] );

	elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;

	elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;

	remove_test_events( &EventSet1, mask1 );

	if ( !TESTS_QUIET ) {
		printf( "Thread %#x %-12s : \t%lld\n", omp_get_thread_num(  ),
			event_name, values[0][1] );
		printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", omp_get_thread_num(  ),
			values[0][0] );
		printf( "Thread %#x Real usec   : \t%lld\n", omp_get_thread_num(  ),
			elapsed_us );
		printf( "Thread %#x Real cycles : \t%lld\n", omp_get_thread_num(  ),
			elapsed_cyc );
	}

	free_test_space( values, num_tests );

	PAPI_unregister_thread(  );
	printf( "Thread %#x finished\n", omp_get_thread_num(  ) );
}
开发者ID:Cristofher,项目名称:Knn,代码行数:53,代码来源:Knn_multihilos_papic.c


示例9: reset_flops

static void
reset_flops( char *title, int EventSet )
{
	int retval;
	char err_str[PAPI_MAX_STR_LEN];

	retval = PAPI_start( EventSet );
	if ( retval != PAPI_OK ) {
		sprintf( err_str, "%s: PAPI_start", title );
		test_fail( __FILE__, __LINE__, err_str, retval );
	}
}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:12,代码来源:calibrate.c


示例10: compute

void compute(int *sequence) {
#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));
    }

    int i;
    for (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[SEQUENCE_CNT];
    float matice2[SEQUENCE_CNT];
    int j, idx;
    for(j = 0; j < SEQUENCE_CNT; j++)
    {
        idx = sequence[j];
        matice2[idx] = 13 % (idx + 1);
        matice1[idx] = matice2[idx] * 231;
      //  printf("%d\t", idx);
    }

    //printf("\n");
#if PAPI
    retval = PAPI_stop(EventSet, PAPI_Counters);

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


示例11: start_EVENTPAPI

void start_EVENTPAPI(int ind, int EventCode)
{
    /* Create the Event Set */
    if (PAPI_create_eventset(&oscrData_timerPAPIEventSet[ind]) != PAPI_OK)
        OSCR_error("PAPI create eventset error!\n", -1);

    /* Add Total Instructions Executed to our EventSet */
    if (PAPI_add_event(&oscrData_timerPAPIEventSet[ind], EventCode) != PAPI_OK)
        OSCR_error("PAPI add events error!\n", -1);

    if (PAPI_start(oscrData_timerPAPIEventSet[ind]) != PAPI_OK)
        OSCR_error("PAPI start init error!\n", -1);
}
开发者ID:shayany,项目名称:openmp,代码行数:13,代码来源:ompscrCommon.cpp


示例12: MBStartPAPI

int MBStartPAPI(void)
{
  system("rm -f *.mbo");
#ifdef EXETIME
  gettimeofday(&MB_Start, NULL);
#else
  MB_EventSet = PAPI_NULL;
  PAPI_library_init(PAPI_VER_CURRENT);
  PAPI_create_eventset(&MB_EventSet);
  PAPI_add_event(MB_EventSet, PAPI_TOT_CYC);
  PAPI_start(MB_EventSet);
#endif
  return 0;
}
开发者ID:Bootz,项目名称:multicore-opimization,代码行数:14,代码来源:Functions_IPB.c


示例13: PAPI_library_init

void Timing::setPapiEvents(std::vector<std::string> names){
#ifdef KRIPKE_USE_PAPI


  static bool papi_initialized = false;
  if(!papi_initialized){
    //printf("PAPI INIT\n");
    int retval = PAPI_library_init(PAPI_VER_CURRENT);
    papi_initialized = true;

    if(retval != PAPI_VER_CURRENT){
      fprintf(stderr, "ERROR INITIALIZING PAPI\n");
      exit(1);
    }
  }

  //printf("PAPI VERSION=%x\n",
  //    PAPI_VERSION);

  papi_set = PAPI_NULL;
  PAPI_create_eventset(&papi_set);


  for(int i = 0;i < names.size();++ i){
    // Convert text string to PAPI id
    int event_code;
    PAPI_event_name_to_code(
        const_cast<char*>(names[i].c_str()),
        &event_code);

    // TODO: error checking?

    // Add to our list of PAPI events
    papi_names.push_back(names[i]);
    papi_event.push_back(event_code);

    int retval = PAPI_add_event(papi_set, event_code);
    if(retval != PAPI_OK){
      fprintf(stderr, "ERROR ADDING %s, retval=%d, ID=0x%-10x\n", names[i].c_str(), retval, event_code);
    }

    //printf("EVT=%s, ID=0x%-10x\n", names[i].c_str(), event_code);
  }
  PAPI_start(papi_set);
#else
  if(names.size() > 0){
    fprintf(stderr, "WARNING: PAPI NOT ENABLED, IGNORING PAPI EVENTS\n");
  }
#endif
}
开发者ID:DavidPoliakoff,项目名称:performance-test-suite,代码行数:50,代码来源:Timing.cpp


示例14: esd_metric_create

struct esd_metv* esd_metric_create()
{
  struct esd_metv* metv;
  int retval, i, /* KF */ comp;
  
  if ( nmetrics == 0 )
    return NULL;
  
  metv = malloc(sizeof(struct esd_metv));
  if ( metv == NULL )
    elg_error();
  
  /* create event set */
  /* KF: create one per component */
  for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) {
    metv->EventSet[i]  = PAPI_NULL;
    metv->NumEvents[i] = 0;
      
    retval = PAPI_create_eventset(&metv->EventSet[i]);
    if ( retval != PAPI_OK)
      esd_metric_error(retval, "PAPI_create_eventset");
  }
  
  for ( i = 0; i < nmetrics; i++ ) {
    /* add event to event set */
      
    /* KF: figure out the right component and track mapping*/
    comp = PAPI_COMPONENT_INDEX( metricv[i]->papi_code );
    metv->Comp2Metr[comp][metv->NumEvents[comp]]=i;

    retval = PAPI_add_event(metv->EventSet[comp], metricv[i]->papi_code);
    if ( retval != PAPI_OK )
      esd_metric_error(retval, "PAPI_add_event");
    else /* KF: success */
      metv->NumEvents[comp]++;
  }

  /* KF: start only those event sets with events added */
  for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) {
    if( metv->NumEvents[i]>0 ) {
      retval = PAPI_start(metv->EventSet[i]);
      if ( retval != PAPI_OK )
        esd_metric_error(retval, "PAPI_start");
    }
  }

  elg_cntl_msg("Counters started");

  return metv;
}
开发者ID:linearregression,项目名称:scalasca,代码行数:50,代码来源:esd_metric_papi.c


示例15: start_record_cache_access

void start_record_cache_access()
{
  int retVal = PAPI_library_init(PAPI_VER_CURRENT);
  assert(retVal == PAPI_VER_CURRENT);
  EventSet = PAPI_NULL;
  retVal = PAPI_create_eventset(&g_event_set);
  assert(retVal == PAPI_OK);

  retVal = PAPI_add_event(g_event_set, PAPI_L1_TCM);
  assert(retVal == PAPI_OK);

  retVal = PAPI_start(g_event_set);
  assert(retVal == PAPI_OK);
  retVal = PAPI_read(g_event_set, startRecords);
  assert(retVal == PAPI_OK);
}
开发者ID:AthrunArthur,项目名称:functionflow,代码行数:16,代码来源:cache_eval.cpp


示例16: Thread

void
Thread( int n )
{
	int retval, num_tests = 1, tmp;
	int EventSet1 = PAPI_NULL;
	int mask1 = 0x5;
	int num_events1;
	long long **values;
	long long elapsed_us, elapsed_cyc;

	EventSet1 = add_test_events( &num_events1, &mask1 );

	/* num_events1 is greater than num_events2 so don't worry. */

	values = allocate_test_space( num_tests, num_events1 );

	elapsed_us = PAPI_get_real_usec(  );

	elapsed_cyc = PAPI_get_real_cyc(  );

	retval = PAPI_start( EventSet1 );
	if ( retval >= PAPI_OK )
		exit( 1 );

	do_flops( n );

	retval = PAPI_stop( EventSet1, values[0] );
	if ( retval >= PAPI_OK )
		exit( 1 );

	elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;

	elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;

	remove_test_events( &EventSet1, mask1 );

	printf( "Thread %#x PAPI_FP_INS : \t%lld\n", pthread_self(  ),
			( values[0] )[0] );
	printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", pthread_self(  ),
			( values[0] )[1] );
	printf( "Thread %#x Real usec   : \t%lld\n", pthread_self(  ),
			elapsed_us );
	printf( "Thread %#x Real cycles : \t%lld\n", pthread_self(  ),
			elapsed_cyc );

	free_test_space( values, num_tests );
}
开发者ID:FMCalisto,项目名称:SMP,代码行数:47,代码来源:zero_shmem.c


示例17: int

MeasureTimePAPI::MeasureTimePAPI(unsigned long int (*threadHandle)()) : MeasureTime(), threadHandle(threadHandle)
{
  _events = new int[NUM_PAPI_EVENTS];

#ifdef USE_PAPI
  _events[0] = PAPI_TOT_CYC;
  _events[1] = PAPI_L2_TCM;
  _events[2] = PAPI_TOT_INS;

  _eventSet = PAPI_NULL;
  int initRetVal = PAPI_library_init(PAPI_VER_CURRENT);

  if (initRetVal != PAPI_VER_CURRENT && initRetVal > 0)
  {
    std::cerr << "PAPI library init failed!" << std::endl;
    exit(1);
  }

  if (PAPI_thread_init(threadHandle) != PAPI_OK)
  {
    std::cerr << "PAPI thread init failed!" << std::endl;
    exit(1);
  }

  if (PAPI_create_eventset(&_eventSet) != PAPI_OK)
  {
    std::cerr << "PAPI create eventset failed!" << " Error: " << PAPI_create_eventset(&_eventSet) << std::endl;
    exit(1);
  }

  if (PAPI_add_events(_eventSet, _events, NUM_PAPI_EVENTS) != PAPI_OK)
  {
    std::cerr << "PAPI add events failed!" << std::endl;
    exit(1);
  }

  if (PAPI_start(_eventSet) != PAPI_OK)
  {
    std::cerr << "PAPI_start_counters - FAILED" << std::endl;
    throw ModelicaSimulationError(UTILITY,"PAPI_start_counters - FAILED");
  }
#else
  _eventSet = 0;
  throw ModelicaSimulationError(UTILITY,"Papi not supported!");
#endif
}
开发者ID:AntonDV235,项目名称:OMCompiler,代码行数:46,代码来源:measure_time_papi.cpp


示例18: flops_init

void flops_init()
{
    #ifdef HAVE_PAPI
    int err = PAPI_library_init( PAPI_VER_CURRENT );
    if ( err != PAPI_VER_CURRENT ) {
        fprintf( stderr, "Error: PAPI couldn't initialize: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    // read flops
    err = PAPI_create_eventset( &gPAPI_flops_set );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_create_eventset failed\n" );
    }
    
    err = PAPI_assign_eventset_component( gPAPI_flops_set, 0 );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_assign_eventset_component failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    PAPI_option_t opt;
    memset( &opt, 0, sizeof(PAPI_option_t) );
    opt.inherit.inherit  = PAPI_INHERIT_ALL;
    opt.inherit.eventset = gPAPI_flops_set;
    err = PAPI_set_opt( PAPI_INHERIT, &opt );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_set_opt failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    err = PAPI_add_event( gPAPI_flops_set, PAPI_FP_OPS );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_add_event failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    err = PAPI_start( gPAPI_flops_set );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_start failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    #endif  // HAVE_PAPI
}
开发者ID:XapaJIaMnu,项目名称:magma,代码行数:44,代码来源:magma_util.cpp


示例19: main

int main()  
{    
  /*@ prologue @*/  
 
  long long orio_total_cycles = 0;
  long long orio_avg_cycles;
  int orio_i;

  for (orio_i=0; orio_i<REPS; orio_i++) 
    {  
      int err, EventSet = PAPI_NULL;
      long long CtrValues[1];
      err = PAPI_library_init(PAPI_VER_CURRENT);
      if (err != PAPI_VER_CURRENT) {
	printf("PAPI library initialization error!\n");
	exit(1);
      }
      if (PAPI_create_eventset(&EventSet) != PAPI_OK) {
	printf("Failed to create PAPI Event Set\n");
	exit(1);
      }
      if (PAPI_query_event(PAPI_TOT_CYC) == PAPI_OK)
	err = PAPI_add_event(EventSet, PAPI_TOT_CYC);
      if (err != PAPI_OK) {
	printf("Failed to add PAPI event\n");
	exit(1);
      }
      PAPI_start(EventSet);
      
      /*@ tested code @*/ 
      
      PAPI_stop(EventSet, &CtrValues[0]);
      orio_total_cycles += CtrValues[0];
    }  
  
  orio_avg_cycles = orio_total_cycles / REPS;
  printf("%ld\n", orio_avg_cycles);

  printf("{'/*@ coordinate @*/' : %ld}", orio_avg_cycles);

  /*@ epilogue @*/  

  return y[0]; // to avoid the dead code elimination
}   
开发者ID:TharinduRusira,项目名称:Orio,代码行数:44,代码来源:skeleton_code.c


示例20: ref_measurements

void ref_measurements(int iters, int *eventset, int *events, int nevents, long long *refvalues)
{
   PAPI_event_info_t info;
   int i, retval;
   double x = 1.1, y;
   long long t1, t2;

   printf("PAPI reference measurements:\n");

   if ((retval = PAPI_create_eventset(eventset)))
      test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval);

   for (i = 0; i < nevents; i++) {
      if ((retval = PAPI_add_event(*eventset, events[i])))
         test_fail(__FILE__, __LINE__, "PAPI_add_event", retval);

      x = 1.0;

      t1 = PAPI_get_real_usec();
      if ((retval = PAPI_start(*eventset)))
         test_fail(__FILE__, __LINE__, "PAPI_start", retval);
      y = dummy3(x, iters);
      if ((retval = PAPI_stop(*eventset, &refvalues[i])))
         test_fail(__FILE__, __LINE__, "PAPI_stop", retval);
      t2 = PAPI_get_real_usec();

#if 0
      printf("\tOperations= %.1f Mflop", y * 1e-6);
      printf("\t(%g Mflop/s)\n\n", ((float) y / (t2 - t1)));
#endif
      
      PAPI_get_event_info(events[i], &info);
      printf("%20s = ", info.short_descr);
      printf(LLDFMT, refvalues[i]);
      printf("\n");
      
      if ((retval = PAPI_cleanup_eventset(*eventset)))
	test_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset", retval);
   }
   if ((retval = PAPI_destroy_eventset(eventset)))
      test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset", retval);
   *eventset = PAPI_NULL;
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:43,代码来源:sdsc.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PAPI_stop函数代码示例发布时间:2022-05-30
下一篇:
C++ PAPI_library_init函数代码示例发布时间: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