Ejemplo n.º 1
0
inline_static int setup_all_presets(struct wininfo *hwinfo)
{
  int pnum, s;
  char note[100];

  if (IS_UNKNOWN(hwinfo))
    {
      fprintf(stderr,"PAPI doesn't support this chipset?\n");
      abort();
    }

  if (IS_AMDATHLON(hwinfo) || IS_AMDDURON(hwinfo))
    _papi_hwd_preset_map = k7_preset_map;
  else if (IS_P4(hwinfo))
  {
      fprintf(stderr,"PAPI doesn't support the P4 yet...\n");
      abort();
  }
  else 
    _papi_hwd_preset_map = p6_preset_map;

  for (pnum = 0; pnum < PAPI_MAX_PRESET_EVENTS; pnum++)
    {
      if ((s = _papi_hwd_preset_map[pnum].selector))
	{
	  if (_papi_hwi_system_info.num_cntrs == 2)
	    {
	      sprintf(note,"0x%x,0x%x",
		      _papi_hwd_preset_map[pnum].counter_cmd.evntsel[0],
		      _papi_hwd_preset_map[pnum].counter_cmd.evntsel[1]);
	      strcat(_papi_hwd_preset_map[pnum].note,note);
	    }
	  else if (_papi_hwi_system_info.num_cntrs == 4)
	    {
	      sprintf(note,"0x%x,0x%x,0x%x,0x%x",
		      _papi_hwd_preset_map[pnum].counter_cmd.evntsel[0],
		      _papi_hwd_preset_map[pnum].counter_cmd.evntsel[1],
		      _papi_hwd_preset_map[pnum].counter_cmd.evntsel[2],
		      _papi_hwd_preset_map[pnum].counter_cmd.evntsel[3]);
	      strcat(_papi_hwd_preset_map[pnum].note,note);
	    }
	  else
	    abort();
	}
    }
  return(PAPI_OK);
}
Ejemplo n.º 2
0
int
_papi_hwd_get_system_info( void )
{
	struct wininfo win_hwinfo;
	HMODULE hModule;
	DWORD len;
	long i = 0;

	/* Path and args */
	_papi_hwi_system_info.pid = getpid(  );

	hModule = GetModuleHandle( NULL );	// current process
	len =
		GetModuleFileName( hModule, _papi_hwi_system_info.exe_info.fullname,
						   PAPI_MAX_STR_LEN );
	if ( len )
		splitpath( _papi_hwi_system_info.exe_info.fullname,
				   _papi_hwi_system_info.exe_info.address_info.name );
	else
		return ( PAPI_ESYS );

	SUBDBG( "Executable is %s\n",
			_papi_hwi_system_info.exe_info.address_info.name );
	SUBDBG( "Full Executable is %s\n",
			_papi_hwi_system_info.exe_info.fullname );
	/* Hardware info */
	if ( !init_hwinfo( &win_hwinfo ) )
		return ( PAPI_ESYS );

	_papi_hwi_system_info.hw_info.ncpu = win_hwinfo.ncpus;
	_papi_hwi_system_info.hw_info.nnodes = win_hwinfo.nnodes;
	_papi_hwi_system_info.hw_info.totalcpus = win_hwinfo.total_cpus;

	_papi_hwi_system_info.hw_info.vendor = win_hwinfo.vendor;
	_papi_hwi_system_info.hw_info.revision = ( float ) win_hwinfo.revision;
	strcpy( _papi_hwi_system_info.hw_info.vendor_string,
			win_hwinfo.vendor_string );

	/* initialize the model to something */
	_papi_hwi_system_info.hw_info.model = PERFCTR_X86_GENERIC;

	if ( IS_P3( &win_hwinfo ) || IS_P3_XEON( &win_hwinfo ) ||
		 IS_CELERON( &win_hwinfo ) )
		_papi_hwi_system_info.hw_info.model = PERFCTR_X86_INTEL_PIII;

	if ( IS_MOBILE( &win_hwinfo ) )
		_papi_hwi_system_info.hw_info.model = PERFCTR_X86_INTEL_PENTM;

	if ( IS_P4( &win_hwinfo ) ) {
		if ( win_hwinfo.model >= 2 )
			/* this is a guess for Pentium 4 Model 2 */
			_papi_hwi_system_info.hw_info.model = PERFCTR_X86_INTEL_P4M2;
		else
			_papi_hwi_system_info.hw_info.model = PERFCTR_X86_INTEL_P4;
	}

	if ( IS_AMDDURON( &win_hwinfo ) || IS_AMDATHLON( &win_hwinfo ) )
		_papi_hwi_system_info.hw_info.model = PERFCTR_X86_AMD_K7;

	strcpy( _papi_hwi_system_info.hw_info.model_string,
			win_hwinfo.model_string );

	_papi_hwi_system_info.num_cntrs = win_hwinfo.nrctr;
	_papi_hwi_system_info.num_gp_cntrs = _papi_hwi_system_info.num_cntrs;

	_papi_hwi_system_info.hw_info.mhz = ( float ) win_hwinfo.mhz;
	_papi_hwi_system_info.hw_info.clock_mhz = mhz;

	return ( PAPI_OK );
}