Blame src/aix-memory.c

Packit 577717
/*
Packit 577717
* File:    aix-memory.c
Packit 577717
* Author:  Kevin London
Packit 577717
*          london@cs.utk.edu
Packit 577717
*
Packit 577717
* Mods:    <your name here>
Packit 577717
*          <your email address>
Packit 577717
*/
Packit 577717
Packit 577717
#include "papi.h"
Packit 577717
#include "papi_internal.h"
Packit 577717
Packit 577717
#include "aix.h"
Packit 577717
Packit 577717
int
Packit 577717
_aix_get_memory_info( PAPI_hw_info_t * mem_info, int type )
Packit 577717
{
Packit 577717
	PAPI_mh_level_t *L = mem_info->mem_hierarchy.level;
Packit 577717
Packit 577717
	/* Not quite sure what bit 30 indicates.
Packit 577717
	   I'm assuming it flags a unified tlb */
Packit 577717
	if ( _system_configuration.tlb_attrib & ( 1 << 30 ) ) {
Packit 577717
		L[0].tlb[0].type = PAPI_MH_TYPE_UNIFIED;
Packit 577717
		L[0].tlb[0].num_entries = _system_configuration.itlb_size;
Packit 577717
		L[0].tlb[0].type = PAPI_MH_TYPE_UNIFIED;
Packit 577717
	} else {
Packit 577717
		L[0].tlb[0].type = PAPI_MH_TYPE_INST;
Packit 577717
		L[0].tlb[0].num_entries = _system_configuration.itlb_size;
Packit 577717
		L[0].tlb[0].associativity = _system_configuration.itlb_asc;
Packit 577717
		L[0].tlb[1].type = PAPI_MH_TYPE_DATA;
Packit 577717
		L[0].tlb[1].num_entries = _system_configuration.dtlb_size;
Packit 577717
		L[0].tlb[1].associativity = _system_configuration.dtlb_asc;
Packit 577717
	}
Packit 577717
	/* Not quite sure what bit 30 indicates.
Packit 577717
	   I'm assuming it flags a unified cache */
Packit 577717
	if ( _system_configuration.cache_attrib & ( 1 << 30 ) ) {
Packit 577717
		L[0].cache[0].type = PAPI_MH_TYPE_UNIFIED;
Packit 577717
		L[0].cache[0].size = _system_configuration.icache_size;
Packit 577717
		L[0].cache[0].associativity = _system_configuration.icache_asc;
Packit 577717
		L[0].cache[0].line_size = _system_configuration.icache_line;
Packit 577717
	} else {
Packit 577717
		L[0].cache[0].type = PAPI_MH_TYPE_INST;
Packit 577717
		L[0].cache[0].size = _system_configuration.icache_size;
Packit 577717
		L[0].cache[0].associativity = _system_configuration.icache_asc;
Packit 577717
		L[0].cache[0].line_size = _system_configuration.icache_line;
Packit 577717
		L[0].cache[1].type = PAPI_MH_TYPE_DATA;
Packit 577717
		L[0].cache[1].size = _system_configuration.dcache_size;
Packit 577717
		L[0].cache[1].associativity = _system_configuration.dcache_asc;
Packit 577717
		L[0].cache[1].line_size = _system_configuration.dcache_line;
Packit 577717
	}
Packit 577717
	L[1].cache[0].type = PAPI_MH_TYPE_UNIFIED;
Packit 577717
	L[1].cache[0].size = _system_configuration.L2_cache_size;
Packit 577717
	L[1].cache[0].associativity = _system_configuration.L2_cache_asc;
Packit 577717
	/* is there a line size for Level 2 cache? */
Packit 577717
Packit 577717
	/* it looks like we've always got at least 2 levels of info */
Packit 577717
	/* what about level 3 cache? */
Packit 577717
	mem_info->mem_hierarchy.levels = 2;
Packit 577717
Packit 577717
	return PAPI_OK;
Packit 577717
}
Packit 577717
Packit 577717
int
Packit 577717
_aix_get_dmem_info( PAPI_dmem_info_t * d )
Packit 577717
{
Packit 577717
	/* This function has been reimplemented 
Packit 577717
	   to conform to current interface.
Packit 577717
	   It has not been tested.
Packit 577717
	   Nor has it been confirmed for completeness.
Packit 577717
	   dkt 05-10-06
Packit 577717
	 */
Packit 577717
Packit 577717
	struct procsinfo pi;
Packit 577717
	pid_t mypid = getpid(  );
Packit 577717
	pid_t pid;
Packit 577717
	int found = 0;
Packit 577717
Packit 577717
	pid = 0;
Packit 577717
	while ( 1 ) {
Packit 577717
		if ( getprocs( &pi, sizeof ( pi ), 0, 0, &pid, 1 ) != 1 )
Packit 577717
			break;
Packit 577717
		if ( mypid == pi.pi_pid ) {
Packit 577717
			found = 1;
Packit 577717
			break;
Packit 577717
		}
Packit 577717
	}
Packit 577717
	if ( !found )
Packit 577717
		return ( PAPI_ESYS );
Packit 577717
Packit 577717
	d->size = pi.pi_size;
Packit 577717
	d->resident = pi.pi_drss + pi.pi_trss;
Packit 577717
	d->high_water_mark = PAPI_EINVAL;
Packit 577717
	d->shared = PAPI_EINVAL;
Packit 577717
	d->text = pi.pi_trss;	 /* this is a guess */
Packit 577717
	d->library = PAPI_EINVAL;
Packit 577717
	d->heap = PAPI_EINVAL;
Packit 577717
	d->locked = PAPI_EINVAL;
Packit 577717
	d->stack = PAPI_EINVAL;
Packit 577717
	d->pagesize = getpagesize(  );
Packit 577717
Packit 577717
	return ( PAPI_OK );
Packit 577717
}