CpuNeighborList.h 1.6 KB
Newer Older
1
2
3
4
#ifndef OPENMM_CPU_NEIGHBORLIST_H_
#define OPENMM_CPU_NEIGHBORLIST_H_

#include "windowsExportCpu.h"
5
#include <pthread.h>
6
7
8
9
10
11
12
13
#include <set>
#include <utility>
#include <vector>

namespace OpenMM {
    
class OPENMM_EXPORT_CPU CpuNeighborList {
public:
14
15
    class ThreadData;
    class VoxelHash;
16
    static const int BlockSize;
17
18
19
20
    CpuNeighborList();
    ~CpuNeighborList();
    void computeNeighborList(int numAtoms, const std::vector<float>& atomLocations, const std::vector<std::set<int> >& exclusions,
            const float* periodicBoxSize, bool usePeriodic, float maxDistance);
21
22
23
24
    int getNumBlocks() const;
    const std::vector<int>& getSortedAtoms() const;
    const std::vector<int>& getBlockNeighbors(int blockIndex) const;
    const std::vector<char>& getBlockExclusions(int blockIndex) const;
25
26
27
    /**
     * This routine contains the code executed by each thread.
     */
28
    void runThread(int index);
29
private:
30
31
    bool isDeleted;
    int numThreads, waitCount;
32
33
34
    std::vector<int> sortedAtoms;
    std::vector<std::vector<int> > blockNeighbors;
    std::vector<std::vector<char> > blockExclusions;
35
36
37
38
39
40
41
42
43
44
45
46
    std::vector<pthread_t> thread;
    std::vector<ThreadData*> threadData;
    pthread_cond_t startCondition, endCondition;
    pthread_mutex_t lock;
    // The following variables are used to make information accessible to the individual threads.
    VoxelHash* voxelHash;
    const std::vector<std::set<int> >* exclusions;
    const float* atomLocations;
    const float* periodicBoxSize;
    int numAtoms;
    bool usePeriodic;
    float maxDistance;
47
48
49
50
51
};

} // namespace OpenMM

#endif // OPENMM_REFERENCE_NEIGHBORLIST_H_