-
Notifications
You must be signed in to change notification settings - Fork 28
/
CacheInterface.h
113 lines (97 loc) · 4.11 KB
/
CacheInterface.h
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef __CACHEINTERFACE_H__
#define __CACHEINTERFACE_H__
/** @file CacheInterface.h
*
* Declares the interfaces used by the CacheManager: the software
* cache for requesting off processor particle and node data.
*/
#include <CkCache.h>
#include "config.h"
#include "gravity.h"
#include "GenericTreeNode.h"
#include "keytype.h"
/*********************************************************
* Gravity interface: Particles
*********************************************************/
/// @brief The data in a GravityParticle cache entry.
class CacheParticle {
public:
/// Message containing the data for this entry.
CkCacheFillMsg<KeyType> *msg;
/// Index of the first particle in the home processor's myParticles array.
int begin;
/// Index of the last particle in the home processor's myParticles array.
int end;
/// The rest of the structure is an array of particles. Declared as
/// length 1, but can be arbitrary length. It is assumed that these
/// particles are contiguous in the myParticles array.
ExternalGravityParticle part[1];
};
/// @brief Cache interface to particles for the gravity calculation.
/// This is a read-only cache of particles.
class EntryTypeGravityParticle : public CkCacheEntryType<KeyType> {
public:
EntryTypeGravityParticle();
/// @brief Request a bucket of particles from a TreePiece.
void * request(CkArrayIndexMax&, KeyType);
/// @brief Return data from fufilled cache request.
void * unpack(CkCacheFillMsg<KeyType> *, int, CkArrayIndexMax &);
/// @brief Do nothing: this is a read-only cache.
void writeback(CkArrayIndexMax&, KeyType, void *);
/// @brief free cached data.
void free(void *);
/// @brief return size of cached data.
int size(void *);
/// @brief callback to TreePiece after data is received.
static void callback(CkArrayID, CkArrayIndexMax&, KeyType, CkCacheUserData &, void*, int);
};
/*********************************************************
* Smooth interface: Particles
*********************************************************/
/// @brief particle data in the smooth particle cache messages
class CacheSmoothParticle {
public:
int begin; ///< Beginning particle number
int end; ///< ending Particle number
int nActual; ///< actual number of particles sent
KeyType key; ///< Key of this bucket (for writeback)
GravityParticle *partCached; ///< particle data
extraSPHData *extraSPHCached; ///< particle extraData
ExternalSmoothParticle partExt[1]; ///< particle data in the message
};
/// @brief Cache interface to the particles for smooth calculations.
/// This cache is a writeback cache.
class EntryTypeSmoothParticle : public CkCacheEntryType<KeyType> {
// N.B. can't have helpful attributes because of the static function.
public:
EntryTypeSmoothParticle();
/// @brief Request a bucket of particles from a TreePiece.
void * request(CkArrayIndexMax&, KeyType);
/// @brief Return data from fufilled cache request.
void * unpack(CkCacheFillMsg<KeyType> *, int, CkArrayIndexMax &);
void writeback(CkArrayIndexMax&, KeyType, void *);
/// @brief free cached data.
void free(void *);
/// @brief return size of cached data.
int size(void *);
/// @brief callback to TreePiece after data is received.
static void callback(CkArrayID, CkArrayIndexMax&, KeyType, CkCacheUserData &, void*, int);
};
/*********************************************************
* Gravity interface: Nodes
*********************************************************/
/// @brief Cache interface to the Tree Nodes.
class EntryTypeGravityNode : public CkCacheEntryType<KeyType> {
void *vptr; // For saving a copy of the virtual function table.
// It's use will be compiler dependent.
void unpackSingle(CkCacheFillMsg<KeyType> *, Tree::BinaryTreeNode *, int, CkArrayIndexMax &, bool);
public:
EntryTypeGravityNode();
void * request(CkArrayIndexMax&, KeyType);
void * unpack(CkCacheFillMsg<KeyType> *, int, CkArrayIndexMax &);
void writeback(CkArrayIndexMax&, KeyType, void *);
void free(void *);
int size(void *);
static void callback(CkArrayID, CkArrayIndexMax&, KeyType, CkCacheUserData &, void*, int);
};
#endif