|
PAPI
5.0.1.0
|
00001 #include <string.h> 00002 #include <errno.h> 00003 00004 #include "papi.h" 00005 #include "papi_internal.h" 00006 #include "papi_memory.h" /* papi_calloc() */ 00007 00008 #include "x86_cpuid_info.h" 00009 00010 #include "darwin-lock.h" 00011 00012 int 00013 _darwin_get_dmem_info( PAPI_dmem_info_t * d ) 00014 { 00015 00016 int mib[4]; 00017 size_t len; 00018 char buffer[BUFSIZ]; 00019 long long ll; 00020 00021 /**********/ 00022 /* memory */ 00023 /**********/ 00024 len = 2; 00025 sysctlnametomib("hw.memsize", mib, &len); 00026 00027 len = 8; 00028 if (sysctl(mib, 2, &ll, &len, NULL, 0) == -1) { 00029 return PAPI_ESYS; 00030 } 00031 00032 d->size=ll; 00033 00034 d->pagesize = getpagesize( ); 00035 00036 return PAPI_OK; 00037 } 00038 00039 /* 00040 * Architecture-specific cache detection code 00041 */ 00042 00043 00044 #if defined(__i386__)||defined(__x86_64__) 00045 static int 00046 x86_get_memory_info( PAPI_hw_info_t * hw_info ) 00047 { 00048 int retval = PAPI_OK; 00049 00050 switch ( hw_info->vendor ) { 00051 case PAPI_VENDOR_AMD: 00052 case PAPI_VENDOR_INTEL: 00053 retval = _x86_cache_info( &hw_info->mem_hierarchy ); 00054 break; 00055 default: 00056 PAPIERROR( "Unknown vendor in memory information call for x86." ); 00057 return PAPI_ENOIMPL; 00058 } 00059 return retval; 00060 } 00061 #endif 00062 00063 00064 int 00065 _darwin_get_memory_info( PAPI_hw_info_t * hwinfo, int cpu_type ) 00066 { 00067 ( void ) cpu_type; /*unused */ 00068 int retval = PAPI_OK; 00069 00070 x86_get_memory_info( hwinfo ); 00071 00072 return retval; 00073 } 00074 00075 int 00076 _darwin_update_shlib_info( papi_mdi_t *mdi ) 00077 { 00078 00079 00080 return PAPI_OK; 00081 }