当前位置: 首页>>代码示例>>C++>>正文


C++ PAPIERROR函数代码示例

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


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

示例1: add_ib_counter

static ib_counter_t*
add_ib_counter(const char* name, const char* file_name, int extended, ib_device_t *device)
{
   ib_counter_t *new_cnt = (ib_counter_t*) papi_calloc(sizeof(ib_counter_t), 1);
   if (new_cnt == 0) {
      PAPIERROR("cannot allocate memory for new IB counter structure");
      return (0);
   }
   
   new_cnt->ev_name = strdup(name);
   new_cnt->ev_file_name = strdup(file_name);
   new_cnt->extended = extended;
   new_cnt->ev_device = device;
   if (new_cnt->ev_name==0 || new_cnt->ev_file_name==0)
   {
      PAPIERROR("cannot allocate memory for counter internal fields");
      papi_free(new_cnt);
      return (0);
   }

   // prepend the new counter to the counter list
   new_cnt->next = root_counter;
   root_counter = new_cnt;
   
   return (new_cnt);
}
开发者ID:Hope1993,项目名称:pbdPAPI,代码行数:26,代码来源:linux-infiniband.c

示例2: attach

static int
attach( hwd_control_state_t * ctl, unsigned long tid )
{
	struct vperfctr_control tmp;

#ifdef VPERFCTR_CONTROL_CLOEXEC
	tmp.flags = VPERFCTR_CONTROL_CLOEXEC;
#endif

	ctl->rvperfctr = rvperfctr_open( ( int ) tid );
	if ( ctl->rvperfctr == NULL ) {
		PAPIERROR( VOPEN_ERROR );
		return ( PAPI_ESYS );
	}
	SUBDBG( "_papi_hwd_ctl rvperfctr_open() = %p\n", ctl->rvperfctr );

	/* Initialize the per thread/process virtualized TSC */
	memset( &tmp, 0x0, sizeof ( tmp ) );
	tmp.cpu_control.tsc_on = 1;

	/* Start the per thread/process virtualized TSC */
	if ( rvperfctr_control( ctl->rvperfctr, &tmp ) < 0 ) {
		PAPIERROR( RCNTRL_ERROR );
		return ( PAPI_ESYS );
	}

	return ( PAPI_OK );
}							 /* end attach() */
开发者ID:drahoslavzan,项目名称:MKP-PSO,代码行数:28,代码来源:perfctr.c

示例3: _xml_papi_hwi_setup_all_presets

int
_xml_papi_hwi_setup_all_presets( char *arch, hwi_dev_notes_t * notes )
{
	int done = 0;
	FILE *fp = fopen( "./papi_events.xml", "r" );
	XML_Parser p = XML_ParserCreate( NULL );

	if ( !p ) {
		PAPIERROR( "Couldn't allocate memory for XML parser." );
		fclose(fp);
		return ( PAPI_ESYS );
	}
	XML_SetElementHandler( p, _xml_start, _xml_end );
	XML_SetCharacterDataHandler( p, _xml_content );
	if ( fp == NULL ) {
		PAPIERROR( "Error opening Preset XML file." );
		fclose(fp);
		return ( PAPI_ESYS );
	}

	xml_arch = arch;

	do {
		int len;
		void *buffer = XML_GetBuffer( p, BUFFSIZE );

		if ( buffer == NULL ) {
			PAPIERROR( "Couldn't allocate memory for XML buffer." );
			fclose(fp);
			return ( PAPI_ESYS );
		}
		len = fread( buffer, 1, BUFFSIZE, fp );
		if ( ferror( fp ) ) {
			PAPIERROR( "XML read error." );
			fclose(fp);
			return ( PAPI_ESYS );
		}
		done = feof( fp );
		if ( !XML_ParseBuffer( p, len, len == 0 ) ) {
			PAPIERROR( "Parse error at line %d:\n%s",
					   XML_GetCurrentLineNumber( p ),
					   XML_ErrorString( XML_GetErrorCode( p ) ) );
			fclose(fp);
			return ( PAPI_ESYS );
		}
		if ( error ) {
			fclose(fp);
			return ( PAPI_ESYS );
		}
	} while ( !done );
	XML_ParserFree( p );
	fclose( fp );
	return ( PAPI_OK );
}
开发者ID:QuantScientist3,项目名称:pbdPAPI,代码行数:54,代码来源:papi_preset.c

示例4: _perfctr_init

int
_perfctr_init( hwd_context_t * ctx )
{
	struct vperfctr_control tmp;
	int error;

	/* Initialize our thread/process pointer. */
	if ( ( ctx->perfctr = vperfctr_open(  ) ) == NULL ) {
#ifdef VPERFCTR_OPEN_CREAT_EXCL
		/* New versions of perfctr have this, which allows us to
		   get a previously created context, i.e. one created after
		   a fork and now we're inside a new process that has been exec'd */
		if ( errno ) {
			if ( ( ctx->perfctr = vperfctr_open_mode( 0 ) ) == NULL ) {
				PAPIERROR( VOPEN_ERROR );
				return ( PAPI_ESYS );
			}
		} else {
			PAPIERROR( VOPEN_ERROR );
			return ( PAPI_ESYS );
		}
#else
		PAPIERROR( VOPEN_ERROR );
		return ( PAPI_ESYS );
#endif
	}
	SUBDBG( "_papi_hwd_init vperfctr_open() = %p\n", ctx->perfctr );

	/* Initialize the per thread/process virtualized TSC */
	memset( &tmp, 0x0, sizeof ( tmp ) );
	tmp.cpu_control.tsc_on = 1;

#ifdef VPERFCTR_CONTROL_CLOEXEC
	tmp.flags = VPERFCTR_CONTROL_CLOEXEC;
	SUBDBG( "close on exec\t\t\t%u\n", tmp.flags );
#endif

	/* Start the per thread/process virtualized TSC */
	error = vperfctr_control( ctx->perfctr, &tmp );
	if ( error < 0 ) {
		SUBDBG( "starting virtualized TSC; vperfctr_control returns %d\n",
				error );
		PAPIERROR( VCNTRL_ERROR );
		return ( PAPI_ESYS );
	}

	return ( PAPI_OK );
}
开发者ID:pyrovski,项目名称:papi-rapl,代码行数:48,代码来源:perfctr.c

示例5: _perfctr_dispatch_timer

void
_perfctr_dispatch_timer( int signal, siginfo_t * si, void *context )
{
   ( void ) signal;		 /*unused */
   _papi_hwi_context_t ctx;
   ThreadInfo_t *master = NULL;
   int isHardware = 0;
   caddr_t address;
   int cidx = _perfctr_vector.cmp_info.CmpIdx;
   hwd_context_t *our_context;
   
   ctx.si = si;
   ctx.ucontext = ( ucontext_t * ) context;

#define OVERFLOW_MASK si->si_pmc_ovf_mask
#define GEN_OVERFLOW 0

   address = ( caddr_t ) GET_OVERFLOW_ADDRESS( ( ctx ) );
   _papi_hwi_dispatch_overflow_signal( ( void * ) &ctx, address, &isHardware,
       	      	      			OVERFLOW_MASK, GEN_OVERFLOW, &master,
	   	      			_perfctr_vector.cmp_info.CmpIdx );

   /* We are done, resume interrupting counters */
   if ( isHardware ) {
     our_context=(hwd_context_t *) master->context[cidx];
      errno = vperfctr_iresume( our_context->perfctr );
      if ( errno < 0 ) {
	 PAPIERROR( "vperfctr_iresume errno %d", errno );
      }
   }
}
开发者ID:drahoslavzan,项目名称:MKP-PSO,代码行数:31,代码来源:perfctr.c

示例6: _papi_hwd_stop

int
_papi_hwd_stop( hwd_context_t * ctx, hwd_control_state_t * state )
{
	if ( state->rvperfctr != NULL ) {
		if ( rvperfctr_stop( ( struct rvperfctr * ) ctx->perfctr ) < 0 ) {
			PAPIERROR( RCNTRL_ERROR );
			return ( PAPI_ESYS );
		}
		return ( PAPI_OK );
	}
	if ( vperfctr_stop( ctx->perfctr ) < 0 ) {
		PAPIERROR( VCNTRL_ERROR );
		return ( PAPI_ESYS );
	}
	return ( PAPI_OK );
}
开发者ID:jtombiamba,项目名称:MABTools,代码行数:16,代码来源:perfctr-ppc64.c

示例7: mpx_check

int
mpx_check( int EventSet )
{
	/* Currently, there is only the need for one mpx check: if
	 * running on POWER6/perfctr platform, the domain must
	 * include user, kernel, and supervisor, since the scale
	 * event uses the dedicated counter #6, PM_RUN_CYC, which
	 * cannot be controlled on a domain level.
	 */
	EventSetInfo_t *ESI = _papi_hwi_lookup_EventSet( EventSet );

	if (ESI==NULL) return PAPI_EBUG;

	if ( strstr( _papi_hwd[ESI->CmpIdx]->cmp_info.name, "perfctr.c" ) == NULL )
		return PAPI_OK;

	if ( strcmp( _papi_hwi_system_info.hw_info.model_string, "POWER6" ) == 0 ) {
		unsigned int chk_domain =
			PAPI_DOM_USER + PAPI_DOM_KERNEL + PAPI_DOM_SUPERVISOR;

		if ( ( ESI->domain.domain & chk_domain ) != chk_domain ) {
			PAPIERROR
				( "This platform requires PAPI_DOM_USER+PAPI_DOM_KERNEL+PAPI_DOM_SUPERVISOR\n"
				  "to be set in the domain when using multiplexing.  Instead, found %#x\n",
				  ESI->domain.domain );
			return ( PAPI_EINVAL_DOM );
		}
	}
	return PAPI_OK;
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:30,代码来源:sw_multiplex.c

示例8: make_ib_event_description

static char*
make_ib_event_description(const char* input_str, int extended)
{
   int i, len;
   char *desc = 0;
   if (! input_str)
      return (0);
   
   desc = (char*) papi_calloc(PAPI_MAX_STR_LEN, 1);
   if (desc == 0) {
      PAPIERROR("cannot allocate memory for event description");
      return (0);
   }
   len = strlen(input_str);
   
   snprintf(desc, PAPI_MAX_STR_LEN, "%s (%s).",
           input_str, (extended ? "free-running 64bit counter" :
            "overflowing, auto-resetting counter"));
   desc[0] = toupper(desc[0]);
   for (i=0 ; i<len ; ++i)
      if (desc[i] == '_')
         desc[i] = ' ';
   
   return (desc);
}
开发者ID:Hope1993,项目名称:pbdPAPI,代码行数:25,代码来源:linux-infiniband.c

示例9: mpx_remove_unused

/** Remove events that are not used any longer from the run 
 * list of events to multiplex by the handler
 * MUST BE CALLED WITH THE SIGNAL HANDLER DISABLED
 */
static void
mpx_remove_unused( MasterEvent ** head )
{
	MasterEvent *mev, *lastmev = NULL, *nextmev;
	Threadlist *thr = ( *head == NULL ) ? NULL : ( *head )->mythr;
	int retval;

	/* Clean up and remove unused master events. */
	for ( mev = *head; mev != NULL; mev = nextmev ) {
		nextmev = mev->next; /* get link before mev is freed */
		if ( !mev->uses ) {
			if ( lastmev == NULL ) {	/* this was the head event */
				*head = nextmev;
			} else {
				lastmev->next = nextmev;
			}
			retval=PAPI_cleanup_eventset( mev->papi_event );
			retval=PAPI_destroy_eventset( &( mev->papi_event ) );
			if (retval!=PAPI_OK) PAPIERROR("Error destroying event\n");
			papi_free( mev );
		} else {
			lastmev = mev;
		}
	}

	/* Always be sure the head master event points to the thread */
	if ( *head != NULL ) {
		( *head )->mythr = thr;
	}
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:34,代码来源:sw_multiplex.c

示例10: setup_preset_term

static int setup_preset_term(int *native, pfmlib_event_t *event)
{
    /* It seems this could be greatly simplified. If impl_cnt is non-zero,
	the event lives on a counter. Therefore the entire routine could be:
	if (impl_cnt!= 0) encode_native_event.
	Am I wrong?
    */
  pfmlib_regmask_t impl_cnt, evnt_cnt;
  unsigned int n;
  int j, ret;

  /* find out which counters it lives on */
  if ((ret = pfm_get_event_counters(event->event,&evnt_cnt)) != PFMLIB_SUCCESS)
    {
      PAPIERROR("pfm_get_event_counters(%d,%p): %s",event->event,&evnt_cnt,pfm_strerror(ret));
      return(PAPI_EBUG);
    }
  if ((ret = pfm_get_impl_counters(&impl_cnt)) != PFMLIB_SUCCESS)
    {
      PAPIERROR("pfm_get_impl_counters(%p): %s", &impl_cnt, pfm_strerror(ret));
      return(PAPI_EBUG);
    }

  /* Make sure this event lives on some counter, if so, put in the description. If not, BUG */
  if ((ret = pfm_get_num_counters(&n)) != PFMLIB_SUCCESS)
    {
      PAPIERROR("pfm_get_num_counters(%d): %s", n, pfm_strerror(ret));
      return(PAPI_EBUG);
    }

  for (j=0;n;j++)
    {
      if (pfm_regmask_isset(&impl_cnt, j))
	{
	  n--;
	  if (pfm_regmask_isset(&evnt_cnt,j))
	    {
	      *native = encode_native_event(event->event,event->num_masks,event->unit_masks);
	      return(PAPI_OK);
	    }
	}
    }

  PAPIERROR("PAPI preset 0x%08x PFM event %d did not have any available counters", event->event, j);
  return(PAPI_ENOEVNT);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:46,代码来源:pmapi-ppc64_events.c

示例11: get_temperature_value

int
get_temperature_value(  )
{
    char txt[256];
    char *p;
    int v, fd;
    static FILE *f = NULL;
    static int old_acpi = 0;

    if ( !f ) {
        if ( !( f = fopen_first( "/proc/acpi/thermal_zone", "temperature", "r" ) ) ) {
            if ( !( f = fopen_first( "/proc/acpi/thermal", "status", "r" ) ) ) {
                SUBDBG( "Unable to open ACPI temperature file." );
                goto fail;
            }
            old_acpi = 1;
        }
    }

    if ( !( p = fgets( txt, sizeof ( txt ), f ) ) ) {
        SUBDBG( "Unable to read data from ACPI temperature file." );
        goto fail;
    }

    fd = dup( fileno( f ) );
    if (fd<0) goto fail;

    fclose( f );
    f = fdopen( fd, "r" );
    assert( f );
    fseek( f, 0, SEEK_SET );

    if ( !old_acpi ) {
        if ( strlen( p ) > 20 )
            v = atoi( p + 20 );
        else
            v = 0;
    } else {
        if ( strlen( p ) > 15 )
            v = atoi( p + 15 );
        else
            v = 0;
        v = ( ( v - 2732 ) / 10 );	/* convert from deciKelvin to degrees Celcius */
    }

    if (( v > 100 ) || ( v < 0 )) PAPIERROR("Unexpected temperature value.\n");

    return v;

fail:
    if ( f ) {
        fclose( f );
        f = NULL;
    }

    return INVALID_VALUE;
}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:57,代码来源:linux-acpi.c

示例12: mpx_restore_signal

static void
mpx_restore_signal( void )
{
	MPXDBG( "restore signal\n" );
	if ( _papi_os_info.itimer_sig != PAPI_NULL ) {
		if ( signal( _papi_os_info.itimer_sig, SIG_IGN ) == SIG_ERR )
			PAPIERROR( "sigaction stop errno %d", errno );
	}
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:9,代码来源:sw_multiplex.c

示例13: mpx_shutdown_itimer

static void
mpx_shutdown_itimer( void )
{
	MPXDBG( "setitimer off\n" );
	if ( _papi_os_info.itimer_num != PAPI_NULL ) {
		if ( setitimer( _papi_os_info.itimer_num,
			   ( struct itimerval * ) &itimestop, NULL ) == -1 )
			PAPIERROR( "setitimer stop errno %d", errno );
	}
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:10,代码来源:sw_multiplex.c

示例14: _papi_libpfm_ntv_enum_events

int
_papi_libpfm_ntv_enum_events( unsigned int *EventCode, int modifier )
{
	unsigned int event, umask, num_masks;
	int ret;

	if ( modifier == PAPI_ENUM_FIRST ) {
		*EventCode = PAPI_NATIVE_MASK;	/* assumes first native event is always 0x4000000 */
		return ( PAPI_OK );
	}

	if ( _pfm_decode_native_event( *EventCode, &event, &umask ) != PAPI_OK )
		return ( PAPI_ENOEVNT );

	ret = pfm_get_num_event_masks( event, &num_masks );
	if ( ret != PFMLIB_SUCCESS ) {
		PAPIERROR( "pfm_get_num_event_masks(%d,%p): %s", event, &num_masks,
				   pfm_strerror( ret ) );
		return ( PAPI_ENOEVNT );
	}
	if ( num_masks > PAPI_NATIVE_UMASK_MAX )
		num_masks = PAPI_NATIVE_UMASK_MAX;
	SUBDBG( "This is umask %d of %d\n", umask, num_masks );

	if ( modifier == PAPI_ENUM_EVENTS ) {
		if ( event < ( unsigned int ) num_native_events - 1 ) {
			*EventCode =
				( unsigned int ) encode_native_event_raw( event + 1, 0 );
			return ( PAPI_OK );
		}
		return ( PAPI_ENOEVNT );
	} else if ( modifier == PAPI_NTV_ENUM_UMASK_COMBOS ) {
		if ( umask + 1 < ( unsigned int ) ( 1 << num_masks ) ) {
			*EventCode =
				( unsigned int ) encode_native_event_raw( event, umask + 1 );
			return ( PAPI_OK );
		}
		return ( PAPI_ENOEVNT );
	} else if ( modifier == PAPI_NTV_ENUM_UMASKS ) {
		int thisbit = ffs( ( int ) umask );

		SUBDBG( "First bit is %d in %08x\b\n", thisbit - 1, umask );
		thisbit = 1 << thisbit;

		if ( thisbit & ( ( 1 << num_masks ) - 1 ) ) {
			*EventCode =
				( unsigned int ) encode_native_event_raw( event,
														  ( unsigned int )
														  thisbit );
			return ( PAPI_OK );
		}
		return ( PAPI_ENOEVNT );
	} else
		return ( PAPI_EINVAL );
}
开发者ID:FMCalisto,项目名称:SMP,代码行数:55,代码来源:papi_libpfm3_events.c

示例15: _papi_hwd_init

int
_papi_hwd_init( hwd_context_t * ctx )
{
	/* Initialize our thread/process pointer. */
	if ( ( ctx->self = pmc_dev = pmc_open(  ) ) == NULL ) {
		PAPIERROR( "pmc_open() returned NULL" );
		return ( PAPI_ESYS );
	}
	SUBDBG( "_papi_hwd_init pmc_open() = %p\n", ctx->self );

	/* Linux makes sure that each thread has a virtualized TSC here.
	   This makes no sense on Windows, since the counters aren't
	   saved at context switch. */
	return ( PAPI_OK );
}
开发者ID:pyrovski,项目名称:papi-rapl,代码行数:15,代码来源:windows.c


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