Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
matrix_pool.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef MATRIX_POOL_H
4 #define MATRIX_POOL_H
5 
6 #include <list>
7 #include <boost/unordered_map.hpp>
8 
9 struct mzd_t;
10 struct clmatrix_t;
11 struct clm4rm_conditions;
12 
13 namespace frechet { namespace data {
14 
26 class MatrixPool {
27 private:
28  typedef std::pair<int,int> Key;
29  typedef std::list<mzd_t*> mzdList;
30  typedef std::list<clmatrix_t*> clmatrixList;
31 
32  typedef boost::unordered_map<Key,mzdList> mzdMap;
33  typedef boost::unordered_map<Key,clmatrixList> clmatrixMap;
34 
39 
40 public:
42  MatrixPool();
44  ~MatrixPool();
45 
52  mzd_t* new_mzd_t (int rows, int cols);
60  clmatrix_t* new_clmatrix_t (int rows, int cols, clm4rm_conditions* cond);
61 
65  void reclaim(mzd_t*);
69  void reclaim(clmatrix_t*);
70 
74  void clear();
75 
76 private:
78  mzdList& getMzdFreeList(int rows, int cols);
80  clmatrixList& getClmatrixFreeList(int rows, int cols);
81 };
82 
90 mzd_t* new_mzd (int rows, int cols, MatrixPool* pool);
99 clmatrix_t* new_clmatrix(int rows, int cols, MatrixPool* pool, clm4rm_conditions* cond);
100 
106 void reclaim(mzd_t* m, MatrixPool* pool);
112 void reclaim(clmatrix_t* clm, MatrixPool* pool);
113 
114 } } // namespace frechet::data
115 
116 #endif // MATRIX_POOL_H
clmatrix_t * new_clmatrix(int rows, int cols, MatrixPool *pool, clm4rm_conditions *cond)
allocate a new clmatrix_t structure (a matrix for the CLM4RM algorithms)
OpenCL boolean matrix data structure. Data is arranged in 32 bit words.
Definition: clm4rm.h:98
mzdMap free_mzd
set of recyclable mzd_t objects
Definition: matrix_pool.h:36
std::pair< int, int > Key
Definition: matrix_pool.h:28
global definitions for all algorithms.
MatrixPool()
empty constructor
Definition: matrix_pool.cpp:19
std::list< mzd_t * > mzdList
Definition: matrix_pool.h:29
clmatrix_t * new_clmatrix_t(int rows, int cols, clm4rm_conditions *cond)
allocate a new clmatrix_t structure (a matrix for the CLM4RM algorithms)
Definition: matrix_pool.cpp:66
Manages OpenCL event dependencies; necessary when the queue is out-of-order; dependencies must be est...
Definition: clm4rm.h:227
mzd_t * new_mzd(int rows, int cols, MatrixPool *pool)
allocate a new mzd_t structure (a matrix for the M4RI algorithms)
boost::unordered_map< Key, clmatrixList > clmatrixMap
Definition: matrix_pool.h:33
void clear()
release all resources
Definition: matrix_pool.cpp:94
std::list< clmatrix_t * > clmatrixList
Definition: matrix_pool.h:30
mzd_t * new_mzd_t(int rows, int cols)
allocate a new mzd_t structure (a matrix for the M4RI algorithms)
Definition: matrix_pool.cpp:46
clmatrixList & getClmatrixFreeList(int rows, int cols)
Definition: matrix_pool.cpp:36
memory pool for matrix objects (M4RI matrices mzd_t* and OpenCL matrices clm4rm_t*)
Definition: matrix_pool.h:26
void reclaim(mzd_t *m, MatrixPool *pool)
reclaim an object (i.e. put it into the recycling list)
~MatrixPool()
destructor; releases all resources
Definition: matrix_pool.cpp:23
clmatrixMap free_clmatrix
set of recyclable clmatrix_t objects
Definition: matrix_pool.h:38
void reclaim(mzd_t *)
reclaim an object (i.e. put it into the recycling list)
Definition: matrix_pool.cpp:84
boost::unordered_map< Key, mzdList > mzdMap
Definition: matrix_pool.h:32
mzdList & getMzdFreeList(int rows, int cols)
Definition: matrix_pool.cpp:27