PAPI  5.7.0.0
cache_helper.c File Reference
Include dependency graph for cache_helper.c:

Go to the source code of this file.

Data Structures

struct  cache_info_t
 

Functions

static int check_if_cache_info_available (void)
 
long long get_cachesize (int type)
 
long long get_entries (int type)
 
long long get_linesize (int type)
 

Variables

const PAPI_hw_info_thw_info =NULL
 
static struct cache_info_t cache_info [MAX_CACHE]
 

Function Documentation

◆ check_if_cache_info_available()

static int check_if_cache_info_available ( void  )
static

Definition at line 21 of file cache_helper.c.

21  {
22 
23  int cache_type,level,j;
24 
25  /* Get PAPI Hardware Info */
27  if (hw_info==NULL) {
28  return -1;
29  }
30 
31  /* Iterate down the levels (L1, L2, L3) */
32  for(level=0;level<hw_info->mem_hierarchy.levels;level++) {
33  for(j=0;j<2;j++) {
34  cache_type=PAPI_MH_CACHE_TYPE(
35  hw_info->mem_hierarchy.level[level].cache[j].type);
36  if (cache_type==PAPI_MH_TYPE_EMPTY) continue;
37 
38  if (level==0) {
39  if (cache_type==PAPI_MH_TYPE_DATA) {
46  }
47  else if (cache_type==PAPI_MH_TYPE_INST) {
54  }
55  }
56  else if (level==1) {
63  }
64  else if (level==2) {
71  }
72 
73  }
74  }
75  return 0;
76 }
int levels
Definition: papi.h:775
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]
Definition: papi.h:776
#define PAPI_MH_TYPE_INST
Definition: papi.h:731
PAPI_mh_info_t mem_hierarchy
Definition: papi.h:800
#define L3_CACHE
Definition: cache_helper.h:4
#define PAPI_MH_TYPE_DATA
Definition: papi.h:732
#define L2_CACHE
Definition: cache_helper.h:3
#define PAPI_MH_CACHE_WRITE_POLICY(a)
Definition: papi.h:739
#define PAPI_MH_CACHE_REPLACEMENT_POLICY(a)
Definition: papi.h:743
#define L1D_CACHE
Definition: cache_helper.h:2
PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS]
Definition: papi.h:769
static struct cache_info_t cache_info[MAX_CACHE]
Definition: cache_helper.c:19
#define PAPI_MH_TYPE_EMPTY
Definition: papi.h:730
const PAPI_hw_info_t * hw_info
Definition: cache_helper.c:8
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6185
#define L1I_CACHE
Definition: cache_helper.h:1
#define PAPI_MH_CACHE_TYPE(a)
Definition: papi.h:736
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_cachesize()

long long get_cachesize ( int  type)

Definition at line 78 of file cache_helper.c.

78  {
79 
80  int result;
81 
83  if (result<0) return result;
84 
85  if (type>=MAX_CACHE) {
86  printf("Errror!\n");
87  return -1;
88  }
89 
90  return cache_info[type].size;
91 }
static int check_if_cache_info_available(void)
Definition: cache_helper.c:21
static struct cache_info_t cache_info[MAX_CACHE]
Definition: cache_helper.c:19
#define MAX_CACHE
Definition: cache_helper.h:5
Here is the call graph for this function:

◆ get_entries()

long long get_entries ( int  type)

Definition at line 94 of file cache_helper.c.

94  {
95 
96  int result;
97 
99  if (result<0) return result;
100 
101  if (type>=MAX_CACHE) {
102  printf("Errror!\n");
103  return -1;
104  }
105 
106  return cache_info[type].entries;
107 }
static int check_if_cache_info_available(void)
Definition: cache_helper.c:21
static struct cache_info_t cache_info[MAX_CACHE]
Definition: cache_helper.c:19
#define MAX_CACHE
Definition: cache_helper.h:5
Here is the call graph for this function:

◆ get_linesize()

long long get_linesize ( int  type)

Definition at line 110 of file cache_helper.c.

110  {
111 
112  int result;
113 
115  if (result<0) return result;
116 
117  if (type>=MAX_CACHE) {
118  printf("Errror!\n");
119  return -1;
120  }
121 
122  return cache_info[type].linesize;
123 }
static int check_if_cache_info_available(void)
Definition: cache_helper.c:21
static struct cache_info_t cache_info[MAX_CACHE]
Definition: cache_helper.c:19
#define MAX_CACHE
Definition: cache_helper.h:5
Here is the call graph for this function:

Variable Documentation

◆ cache_info

struct cache_info_t cache_info[MAX_CACHE]
static

Definition at line 19 of file cache_helper.c.

◆ hw_info

const PAPI_hw_info_t* hw_info =NULL

Definition at line 8 of file cache_helper.c.