Newer
Older
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
#ifndef BARNES_HUT_TREE_THREADED_HPP
#define BARNES_HUT_TREE_THREADED_HPP
#include <vector>
#include "BarnesHutTree.hpp"
namespace nbody {
using namespace std;
class BarnesHutTreeThreaded;
typedef struct _NodesToProcess {
pthread_mutex_t mutex;
vector<Node*> toProcess;
vector<pthread_t> processing;
BarnesHutTreeThreaded* tree;
pthread_barrier_t* barrier;
int iterations;
} NodesToProcess;
class BarnesHutTreeThreaded : public BarnesHutTree {
friend class PthreadSimulation;
friend class ContinuousPthreadSimulation;
protected:
NodesToProcess nodesToProcess;
static void splitSubtree(Node* root);
static void* build(void* data);
static void* computeMove(void* data);
static void updateNode(Node* current);
static void addNodeToProcess(Node* node, NodesToProcess* store);
static Node* getNodeToProcess(NodesToProcess* store);
static void checkNodeProcessingFinished(NodesToProcess* store);
static bool hasNodeProcessingFinished(NodesToProcess* store);
virtual void clearNodesToProcess();
public:
BarnesHutTreeThreaded(int parallelId);
virtual ~BarnesHutTreeThreaded();
virtual void build(vector<Body> bodies, Box domain);
virtual void computeMove();
};
}
#endif