PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
darwin-memory.c
Go to the documentation of this file.
1 #include <string.h>
2 #include <errno.h>
3 
4 #include "papi.h"
5 #include "papi_internal.h"
6 #include "papi_memory.h" /* papi_calloc() */
7 
8 #include "x86_cpuid_info.h"
9 
10 #include "darwin-lock.h"
11 
12 int
14 {
15 
16  int mib[4];
17  size_t len;
18  char buffer[BUFSIZ];
19  long long ll;
20 
21  /**********/
22  /* memory */
23  /**********/
24  len = 2;
25  sysctlnametomib("hw.memsize", mib, &len);
26 
27  len = 8;
28  if (sysctl(mib, 2, &ll, &len, NULL, 0) == -1) {
29  return PAPI_ESYS;
30  }
31 
32  d->size=ll;
33 
34  d->pagesize = getpagesize( );
35 
36  return PAPI_OK;
37 }
38 
39 /*
40  * Architecture-specific cache detection code
41  */
42 
43 
44 #if defined(__i386__)||defined(__x86_64__)
45 static int
46 x86_get_memory_info( PAPI_hw_info_t * hw_info )
47 {
48  int retval = PAPI_OK;
49 
50  switch ( hw_info->vendor ) {
51  case PAPI_VENDOR_AMD:
52  case PAPI_VENDOR_INTEL:
53  retval = _x86_cache_info( &hw_info->mem_hierarchy );
54  break;
55  default:
56  PAPIERROR( "Unknown vendor in memory information call for x86." );
57  return PAPI_ENOIMPL;
58  }
59  return retval;
60 }
61 #endif
62 
63 
64 int
65 _darwin_get_memory_info( PAPI_hw_info_t * hwinfo, int cpu_type )
66 {
67  ( void ) cpu_type; /*unused */
68  int retval = PAPI_OK;
69 
70  x86_get_memory_info( hwinfo );
71 
72  return retval;
73 }
74 
75 int
77 {
78 
79 
80  return PAPI_OK;
81 }
#define PAPI_ENOIMPL
Definition: fpapi.h:124
Hardware info structure.
Definition: papi.h:775
PAPI_mh_info_t mem_hierarchy
Definition: papi.h:794
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
Return codes and api definitions.
int _darwin_update_shlib_info(papi_mdi_t *mdi)
Definition: darwin-memory.c:76
int _x86_cache_info(PAPI_mh_info_t *mh_info)
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:866
long long pagesize
Definition: papi.h:877
void PAPIERROR(char *format,...)
#define PAPI_ESYS
Definition: fpapi.h:108
#define PAPI_VENDOR_INTEL
Definition: papi.h:346
char * buffer
Definition: iozone.c:1366
int vendor
Definition: papi.h:782
int _darwin_get_memory_info(PAPI_hw_info_t *hwinfo, int cpu_type)
Definition: darwin-memory.c:65
ssize_t retval
Definition: libasync.c:338
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23
long long size
Definition: papi.h:868
int _darwin_get_dmem_info(PAPI_dmem_info_t *d)
Definition: darwin-memory.c:13
#define PAPI_VENDOR_AMD
Definition: papi.h:347