Xmipp  v3.23.11-Nereus
hw.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: David Strelak (davidstrelak@gmail.com)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef LIBRARIES_DATA_HW_H_
27 #define LIBRARIES_DATA_HW_H_
28 
29 #include <string>
30 #include <cstddef>
31 
35 class HW {
36 public:
37  explicit HW(unsigned parallelUnits) :
38  m_parallUnits(parallelUnits),
39  m_lastFreeBytes(0),
40  m_totalBytes(0) {}
41 
42  virtual ~HW(){};
43 
44  inline unsigned noOfParallUnits() const {
45  return m_parallUnits;
46  }
47 
48  virtual void synch() const = 0;
49  virtual void synchAll() const = 0;
50  virtual void set() {
52  obtainUUID();
53  }
54 
55  virtual void updateMemoryInfo() = 0;
56 
57  virtual inline size_t lastFreeBytes() const {
58  return m_lastFreeBytes;
59  }
60 
61  virtual inline size_t totalBytes() const {
62  return m_totalBytes;
63  }
64 
65  virtual inline size_t lastUsedBytes() const {
67  }
68 
69  virtual std::string getUUID() const {
70  return m_uuid;
71  }
72 
73  virtual void lockMemory(const void *h_mem, size_t bytes) = 0;
74 
75  virtual void unlockMemory(const void *h_mem) = 0;
76 
77  virtual bool isMemoryLocked(const void *h_mem) = 0;
78 protected:
79  unsigned m_parallUnits;
80  size_t m_totalBytes;
82  std::string m_uuid;
83 
84  virtual void obtainUUID() = 0;
85 };
87 #endif /* LIBRARIES_DATA_HW_H_ */
virtual void lockMemory(const void *h_mem, size_t bytes)=0
unsigned m_parallUnits
Definition: hw.h:79
virtual bool isMemoryLocked(const void *h_mem)=0
virtual size_t lastUsedBytes() const
Definition: hw.h:65
Definition: hw.h:35
virtual void obtainUUID()=0
virtual std::string getUUID() const
Definition: hw.h:69
unsigned noOfParallUnits() const
Definition: hw.h:44
virtual size_t lastFreeBytes() const
Definition: hw.h:57
HW(unsigned parallelUnits)
Definition: hw.h:37
size_t m_totalBytes
Definition: hw.h:80
virtual size_t totalBytes() const
Definition: hw.h:61
size_t m_lastFreeBytes
Definition: hw.h:81
virtual ~HW()
Definition: hw.h:42
virtual void synch() const =0
std::string m_uuid
Definition: hw.h:82
virtual void updateMemoryInfo()=0
virtual void unlockMemory(const void *h_mem)=0
virtual void synchAll() const =0