false_sharing.h
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*********************************************************************
* false_sharing.h
*
* Track the false sharing in the caches... enabled by a run-time
* option.
*
* $Author: blythe $
* $Date: 2002/05/29 01:09:09 $
*********************************************************************/
#ifndef _FALSE_SHARING_H
#define _FALSE_SHARING_H
#include "machine_params.h"
#ifdef TRACK_FALSE_SHARING
#define FALSE_SHARING_ACCESS(_cpu, _fshE, _pA) {\
if (falseSharing) { \
(_fshE->accessedWords |= falseSharingMaskEntries[M_FROM_CPU(_cpu)]\
[_pA&falseSharingMask]); \
} \
}
#define FALSE_SHARING_MODIFY(_cpu,_pA) \
if (falseSharing) { FalseSharingModify(_cpu,_pA);}
#else
#define FALSE_SHARING_ACCESS(_cpu, _fshE, _pA)
#define FALSE_SHARING_MODIFY(_cpu,_pA)
#endif
/************************************************************************
* False vs. True Sharing data structures. These are accessed directy by
* some time-critical macros.
************************************************************************/
typedef uint FalseSharingBV; /* 32 bits. Cluster words if cache line >128 */
typedef struct FalseSharingEntry {
FalseSharingBV accessedWords; /* bitvector modified on every access */
int categ; /* Type of last miss --> used to classify */
int valid;
VA PC;
VA vAddr;
PA pAddr;
int stall;
struct StatRecordSnapshot *snap;
} FalseSharingEntry;
extern void FalseSharingEarlyInit(void);
extern void FalseSharingLateInit(void);
extern void FalseSharingEvict(int cpuNum, PA pAddr, int way, int type);
extern void FalseSharingDefine(int cpuNum, PA pAddr, int way, VA pc, VA vAddr,int stall);
extern void FalseSharingDefineOffset(int cpuNum,PA pAddr,int way, int off);
extern void FalseSharingModify(int cpuNum, PA pAddr);
extern FalseSharingEntry *SCacheLineToFalseSharing(int cpuNum, PA pAddr,
int way);
extern void FalseSharingCleanup(void);
extern FalseSharingBV *falseSharingMaskEntries[MAX_MACHINES];
extern uint falseSharingMask;
extern bool falseSharing;
#endif /* _FALSE_SHARING_H */