PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
solaris-common.c File Reference
Include dependency graph for solaris-common.c:

Go to the source code of this file.

Functions

int _papi_hwi_init_os (void)
 
int _solaris_update_shlib_info (papi_mdi_t *mdi)
 
int _solaris_get_system_info (papi_mdi_t *mdi)
 
long long _solaris_get_real_usec (void)
 
long long _solaris_get_real_cycles (void)
 
long long _solaris_get_virt_usec (void)
 

Function Documentation

int _papi_hwi_init_os ( void  )

Definition at line 114 of file solaris-common.c.

114  {
115 
116  struct utsname uname_buffer;
117 
118  uname(&uname_buffer);
119 
120  strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);
121 
122  strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);
123 
128 
129  return PAPI_OK;
130 }
#define PAPI_INT_MPX_DEF_US
Definition: papi_internal.h:65
return PAPI_OK
Definition: linux-nvml.c:458
char name[PAPI_MAX_STR_LEN]
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_INT_ITIMER
Definition: papi_internal.h:54
char version[PAPI_MAX_STR_LEN]
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:52
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
long long _solaris_get_real_cycles ( void  )

Definition at line 769 of file solaris-common.c.

770 {
771  return ( _ultra_hwd_get_real_usec( ) *
772  ( long long ) _papi_hwi_system_info.hw_info.cpu_max_mhz );
773 }
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
int cpu_max_mhz
Definition: papi.h:793
long long _solaris_get_real_usec ( void  )

Definition at line 763 of file solaris-common.c.

764 {
765  return ( ( long long ) gethrtime( ) / ( long long ) 1000 );
766 }
int _solaris_get_system_info ( papi_mdi_t mdi)

Definition at line 584 of file solaris-common.c.

585 {
586  int retval;
587  pid_t pid;
588  char maxargs[PAPI_MAX_STR_LEN] = "<none>";
589  psinfo_t psi;
590  int fd;
591  int hz, version;
592  char cpuname[PAPI_MAX_STR_LEN], pname[PAPI_HUGE_STR_LEN];
593 
594  /* Check counter access */
595 
596  if ( cpc_version( CPC_VER_CURRENT ) != CPC_VER_CURRENT )
597  return PAPI_ECMP;
598  SUBDBG( "CPC version %d successfully opened\n", CPC_VER_CURRENT );
599 
600  if ( cpc_access( ) == -1 )
601  return PAPI_ECMP;
602 
603  /* Global variable cpuver */
604 
605  cpuver = cpc_getcpuver( );
606  SUBDBG( "Got %d from cpc_getcpuver()\n", cpuver );
607  if ( cpuver == -1 )
608  return PAPI_ECMP;
609 
610 #ifdef DEBUG
611  {
612  if ( ISLEVEL( DEBUG_SUBSTRATE ) ) {
613  const char *name;
614  int i;
615 
616  name = cpc_getcpuref( cpuver );
617  if ( name ) {
618  SUBDBG( "CPC CPU reference: %s\n", name );
619  }
620  else {
621  SUBDBG( "Could not get a CPC CPU reference\n" );
622  }
623 
624  for ( i = 0; i < cpc_getnpic( cpuver ); i++ ) {
625  SUBDBG( "\n%6s %-40s %8s\n", "Reg", "Symbolic name", "Code" );
626  cpc_walk_names( cpuver, i, "%6d %-40s %02x\n",
628  }
629  SUBDBG( "\n" );
630  }
631  }
632 #endif
633 
634 
635  /* Initialize other globals */
636 
637  if ( ( retval = build_tables( ) ) != PAPI_OK )
638  return retval;
639 
641  if ( cpuver <= CPC_ULTRA2 ) {
642  SUBDBG( "cpuver (==%d) <= CPC_ULTRA2 (==%d)\n", cpuver, CPC_ULTRA2 );
643  pcr_shift[0] = CPC_ULTRA_PCR_PIC0_SHIFT;
644  pcr_shift[1] = CPC_ULTRA_PCR_PIC1_SHIFT;
645  } else if ( cpuver <= LASTULTRA3 ) {
646  SUBDBG( "cpuver (==%d) <= CPC_ULTRA3x (==%d)\n", cpuver, LASTULTRA3 );
647  pcr_shift[0] = CPC_ULTRA_PCR_PIC0_SHIFT;
648  pcr_shift[1] = CPC_ULTRA_PCR_PIC1_SHIFT;
651  } else
652  return PAPI_ECMP;
653 
654  /* Path and args */
655 
656  pid = getpid( );
657  if ( pid == -1 )
658  return ( PAPI_ESYS );
659 
660  /* Turn on microstate accounting for this process and any LWPs. */
661 
662  sprintf( maxargs, "/proc/%d/ctl", ( int ) pid );
663  if ( ( fd = open( maxargs, O_WRONLY ) ) == -1 )
664  return ( PAPI_ESYS );
665  {
666  int retval;
667  struct
668  {
669  long cmd;
670  long flags;
671  } cmd;
672  cmd.cmd = PCSET;
673  cmd.flags = PR_MSACCT | PR_MSFORK;
674  retval = write( fd, &cmd, sizeof ( cmd ) );
675  close( fd );
676  SUBDBG( "Write PCSET returned %d\n", retval );
677  if ( retval != sizeof ( cmd ) )
678  return ( PAPI_ESYS );
679  }
680 
681  /* Get executable info */
682 
683  sprintf( maxargs, "/proc/%d/psinfo", ( int ) pid );
684  if ( ( fd = open( maxargs, O_RDONLY ) ) == -1 )
685  return ( PAPI_ESYS );
686  read( fd, &psi, sizeof ( psi ) );
687  close( fd );
688 
689  /* Cut off any arguments to exe */
690  {
691  char *tmp;
692  tmp = strchr( psi.pr_psargs, ' ' );
693  if ( tmp != NULL )
694  *tmp = '\0';
695  }
696 
697  if ( realpath( psi.pr_psargs, pname ) )
698  strncpy( _papi_hwi_system_info.exe_info.fullname, pname,
700  else
701  strncpy( _papi_hwi_system_info.exe_info.fullname, psi.pr_psargs,
703 
704  /* please don't use pr_fname here, because it can only store less that
705  16 characters */
708 
709  SUBDBG( "Full Executable is %s\n",
711 
712  /* Executable regions, reading /proc/pid/maps file */
713  retval = _ultra_hwd_update_shlib_info( &_papi_hwi_system_info );
714 
715  /* Hardware info */
716 
717  _papi_hwi_system_info.hw_info.ncpu = sysconf( _SC_NPROCESSORS_ONLN );
719  _papi_hwi_system_info.hw_info.totalcpus = sysconf( _SC_NPROCESSORS_CONF );
720 
721  retval = scan_prtconf( cpuname, PAPI_MAX_STR_LEN, &hz, &version );
722  if ( retval == -1 )
723  return PAPI_ECMP;
724 
726  cpc_getcciname( cpuver ) );
731 
732  _papi_hwi_system_info.hw_info.mhz = ( ( float ) hz / 1.0e6 );
733  SUBDBG( "hw_info.mhz = %f\n", _papi_hwi_system_info.hw_info.mhz );
734 
737 
738 
739  /* Number of PMCs */
740 
741  retval = cpc_getnpic( cpuver );
742  if ( retval < 0 )
743  return PAPI_ECMP;
744 
751 
752  /* Setup presets */
753 
755  if ( retval )
756  return ( retval );
757 
758  return ( PAPI_OK );
759 }
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:693
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
int close(int fd)
Definition: appio.c:175
#define PAPI_VENDOR_SUN
Definition: papi.h:350
long long flags
Definition: iozone.c:12330
papi_vector_t _solaris_vector
hwi_search_t * preset_table
int cpu_min_mhz
Definition: papi.h:794
#define PAPI_DOM_KERNEL
Definition: papi.h:298
int fd
Definition: iozone.c:1291
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_exe_info_t exe_info
static int pcr_shift[2]
#define PAPI_DOM_USER
Definition: papi.h:296
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static int cpuver
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
void print_walk_names(void *arg, int regno, const char *name, uint8_t bits)
float mhz
Definition: papi.h:804
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
#define LASTULTRA3
Definition: solaris-ultra.c:33
float revision
Definition: papi.h:788
int _papi_hwi_setup_all_presets(hwi_search_t *findem, int cidx)
Definition: papi_preset.c:37
static int scan_prtconf(char *cpuname, int len_cpuname, int *hz, int *ver)
int i
Definition: fileop.c:140
unsigned int fast_real_timer
Definition: papi.h:657
unsigned int fast_virtual_timer
Definition: papi.h:658
ssize_t write(int fd, const void *buf, size_t count)
Definition: appio.c:298
static int pid
PAPI_address_map_t address_info
Definition: papi.h:706
#define PAPI_ESYS
Definition: papi.h:253
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int nnodes
Definition: papi.h:782
#define PAPI_ECMP
Definition: papi.h:254
char version[]
Definition: fileop.c:134
static int build_tables(void)
hwi_search_t * preset_search_map
unsigned int hardware_intr
Definition: papi.h:649
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
strcpy(filename, default_filename)
PAPI_hw_info_t hw_info
int vendor
Definition: papi.h:784
int model
Definition: papi.h:786
char * name
Definition: iozone.c:23648
int cpu_max_mhz
Definition: papi.h:793
#define ISLEVEL(a)
Definition: papi_debug.h:54
int totalcpus
Definition: papi.h:783
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:705
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
#define DEBUG_SUBSTRATE
Definition: papi_debug.h:27
int ncpu
Definition: papi.h:778

Here is the call graph for this function:

Here is the caller graph for this function:

long long _solaris_get_virt_usec ( void  )

Definition at line 776 of file solaris-common.c.

777 {
778  return ( ( long long ) gethrvtime( ) / ( long long ) 1000 );
779 }
int _solaris_update_shlib_info ( papi_mdi_t mdi)

Definition at line 277 of file solaris-common.c.

278 {
279  char *file = "/proc/self/map";
280  char *resolve_pattern = "/proc/self/path/%s";
281 
282  char lastobject[PRMAPSZ];
283  char link[PAPI_HUGE_STR_LEN];
284  char path[PAPI_HUGE_STR_LEN];
285 
286  prmap_t mapping;
287 
288  int fd, count = 0, total = 0, position = -1, first = 1;
289  caddr_t t_min, t_max, d_min, d_max;
290 
291  PAPI_address_map_t *pam, *cur;
292 
293 #ifdef DEBUG
294  SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
295  __LINE__ );
296 #endif
297 
298  fd = open( file, O_RDONLY );
299 
300  if ( fd == -1 ) {
301  return PAPI_ESYS;
302  }
303 
304  memset( lastobject, 0, PRMAPSZ );
305 
306 #ifdef DEBUG
307  SUBDBG( " -> %s: Preprocessing memory maps from procfs\n", __func__ );
308 #endif
309 
310  /* Search through the list of mappings in order to identify a) how many
311  mappings are available and b) how many unique mappings are available. */
312  while ( read( fd, &mapping, sizeof ( prmap_t ) ) > 0 ) {
313 #ifdef DEBUG
314  SUBDBG( " -> %s: Found a new memory map entry\n", __func__ );
315 #endif
316  /* Another entry found, just the total count of entries. */
317  total++;
318 
319  /* Is the mapping accessible and not anonymous? */
320  if ( mapping.pr_mflags & ( MA_READ | MA_WRITE | MA_EXEC ) &&
321  !( mapping.pr_mflags & MA_ANON ) ) {
322  /* Test if a new library has been found. If a new library has been
323  found a new entry needs to be counted. */
324  if ( strcmp( lastobject, mapping.pr_mapname ) != 0 ) {
325  strncpy( lastobject, mapping.pr_mapname, PRMAPSZ );
326  count++;
327 
328 #ifdef DEBUG
329  SUBDBG( " -> %s: Memory mapping entry valid for %s\n", __func__,
330  mapping.pr_mapname );
331 #endif
332  }
333  }
334  }
335 #ifdef DEBUG
336  SUBDBG( " -> %s: Preprocessing done, starting to analyze\n", __func__ );
337 #endif
338 
339 
340  /* Start from the beginning, now fill in the found mappings */
341  if ( lseek( fd, 0, SEEK_SET ) == -1 ) {
342  return PAPI_ESYS;
343  }
344 
345  memset( lastobject, 0, PRMAPSZ );
346 
347  /* Allocate memory */
348  pam =
349  ( PAPI_address_map_t * ) papi_calloc( count,
350  sizeof ( PAPI_address_map_t ) );
351 
352  while ( read( fd, &mapping, sizeof ( prmap_t ) ) > 0 ) {
353 
354  if ( mapping.pr_mflags & MA_ANON ) {
355 #ifdef DEBUG
356  SUBDBG
357  ( " -> %s: Anonymous mapping (MA_ANON) found for %s, skipping\n",
358  __func__, mapping.pr_mapname );
359 #endif
360  continue;
361  }
362 
363  /* Check for a new entry */
364  if ( strcmp( mapping.pr_mapname, lastobject ) != 0 ) {
365 #ifdef DEBUG
366  SUBDBG( " -> %s: Analyzing mapping for %s\n", __func__,
367  mapping.pr_mapname );
368 #endif
369  cur = &( pam[++position] );
370  strncpy( lastobject, mapping.pr_mapname, PRMAPSZ );
371  snprintf( link, PAPI_HUGE_STR_LEN, resolve_pattern, lastobject );
372  memset( path, 0, PAPI_HUGE_STR_LEN );
373  readlink( link, path, PAPI_HUGE_STR_LEN );
374  strncpy( cur->name, path, PAPI_HUGE_STR_LEN );
375 #ifdef DEBUG
376  SUBDBG( " -> %s: Resolved name for %s: %s\n", __func__,
377  mapping.pr_mapname, cur->name );
378 #endif
379  }
380 
381  if ( mapping.pr_mflags & MA_READ ) {
382  /* Data (MA_WRITE) or text (MA_READ) segment? */
383  if ( mapping.pr_mflags & MA_WRITE ) {
384  cur->data_start = ( caddr_t ) mapping.pr_vaddr;
385  cur->data_end =
386  ( caddr_t ) ( mapping.pr_vaddr + mapping.pr_size );
387 
388  if ( strcmp
389  ( cur->name,
392  cur->data_start;
394  cur->data_end;
395  }
396 
397  if ( first )
398  d_min = cur->data_start;
399  if ( first )
400  d_max = cur->data_end;
401 
402  if ( cur->data_start < d_min ) {
403  d_min = cur->data_start;
404  }
405 
406  if ( cur->data_end > d_max ) {
407  d_max = cur->data_end;
408  }
409  } else if ( mapping.pr_mflags & MA_EXEC ) {
410  cur->text_start = ( caddr_t ) mapping.pr_vaddr;
411  cur->text_end =
412  ( caddr_t ) ( mapping.pr_vaddr + mapping.pr_size );
413 
414  if ( strcmp
415  ( cur->name,
418  cur->text_start;
420  cur->text_end;
421  }
422 
423  if ( first )
424  t_min = cur->text_start;
425  if ( first )
426  t_max = cur->text_end;
427 
428  if ( cur->text_start < t_min ) {
429  t_min = cur->text_start;
430  }
431 
432  if ( cur->text_end > t_max ) {
433  t_max = cur->text_end;
434  }
435  }
436  }
437 
438  first = 0;
439  }
440 
441  close( fd );
442 
443  /* During the walk of shared objects the upper and lower bound of the
444  segments could be discovered. The bounds are stored in the PAPI info
445  structure. The information is important for the profiling functions of
446  PAPI. */
447 
448 /* This variant would pass the addresses of all text and data segments
449  _papi_hwi_system_info.exe_info.address_info.text_start = t_min;
450  _papi_hwi_system_info.exe_info.address_info.text_end = t_max;
451  _papi_hwi_system_info.exe_info.address_info.data_start = d_min;
452  _papi_hwi_system_info.exe_info.address_info.data_end = d_max;
453 */
454 
455 #ifdef DEBUG
456  SUBDBG( " -> %s: Analysis of memory maps done, results:\n", __func__ );
457  SUBDBG( " -> %s: text_start=%#x, text_end=%#x, text_size=%lld\n", __func__,
462  SUBDBG( " -> %s: data_start=%#x, data_end=%#x, data_size=%lld\n", __func__,
467 #endif
468 
469  /* Store the map read and the total count of shlibs found */
472 
473 #ifdef DEBUG
474  SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
475  __LINE__ );
476 #endif
477 
478  return PAPI_OK;
479 }
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:693
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:225
memset(eventId, 0, size)
int close(int fd)
Definition: appio.c:175
caddr_t text_end
Definition: papi.h:695
off_t lseek(int fd, off_t offset, int whence)
Definition: appio.c:210
int fd
Definition: iozone.c:1291
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
PAPI_exe_info_t exe_info
#define PAPI_HUGE_STR_LEN
Definition: papi.h:465
PAPI_shlib_info_t shlib_info
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
const char FILE * file
Definition: pscanf.h:13
caddr_t text_start
Definition: papi.h:694
PAPI_address_map_t address_info
Definition: papi.h:706
#define PAPI_ESYS
Definition: papi.h:253
get the executable&#39;s address space info
Definition: papi.h:692
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
caddr_t data_start
Definition: papi.h:696
static int total
Definition: rapl_overflow.c:5
PAPI_address_map_t * map
Definition: papi.h:711
caddr_t data_end
Definition: papi.h:697
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:705
#define papi_calloc(a, b)
Definition: papi_memory.h:37

Here is the call graph for this function: