Xmipp  v3.23.11-Nereus
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members

#include <cpu.h>

Inheritance diagram for CPU:
Inheritance graph
[legend]
Collaboration diagram for CPU:
Collaboration graph
[legend]

Public Member Functions

 CPU (unsigned cores=1)
 
void synch () const
 
void synchAll () const
 
void updateMemoryInfo ()
 
void lockMemory (const void *h_mem, size_t bytes) override
 
void unlockMemory (const void *h_mem) override
 
bool isMemoryLocked (const void *h_mem) override
 
- Public Member Functions inherited from HW
 HW (unsigned parallelUnits)
 
virtual ~HW ()
 
unsigned noOfParallUnits () const
 
virtual void set ()
 
virtual size_t lastFreeBytes () const
 
virtual size_t totalBytes () const
 
virtual size_t lastUsedBytes () const
 
virtual std::string getUUID () const
 

Static Public Member Functions

static unsigned findCores ()
 

Protected Member Functions

void obtainUUID ()
 

Additional Inherited Members

- Protected Attributes inherited from HW
unsigned m_parallUnits
 
size_t m_totalBytes
 
size_t m_lastFreeBytes
 
std::string m_uuid
 

Detailed Description

Definition at line 37 of file cpu.h.

Constructor & Destructor Documentation

◆ CPU()

CPU::CPU ( unsigned  cores = 1)
inline

Definition at line 39 of file cpu.h.

39 : HW(cores) {}
HW(unsigned parallelUnits)
Definition: hw.h:37

Member Function Documentation

◆ findCores()

static unsigned CPU::findCores ( )
inlinestatic

Definition at line 41 of file cpu.h.

41  {
42  return std::max(std::thread::hardware_concurrency(), 1u);
43  }
void max(Image< double > &op1, const Image< double > &op2)
doublereal * u

◆ isMemoryLocked()

bool CPU::isMemoryLocked ( const void *  h_mem)
inlineoverridevirtual

Implements HW.

Definition at line 58 of file cpu.h.

58  {
59  // FIXME DS implement
60  return false;
61  }

◆ lockMemory()

void CPU::lockMemory ( const void *  h_mem,
size_t  bytes 
)
inlineoverridevirtual

Implements HW.

Definition at line 50 of file cpu.h.

50  {
51  // FIXME DS implement
52  }

◆ obtainUUID()

void CPU::obtainUUID ( )
protectedvirtual

Implements HW.

Definition at line 49 of file cpu.cpp.

49  {
50  // https://stackoverflow.com/a/6491964/5484355
51  unsigned eax = 0;
52  unsigned ebx = 0;
53  unsigned ecx = 0;
54  unsigned edx = 0;
55 
56  std::stringstream ss;
57 
58  eax = 1; /* processor info and feature bits */
59  native_cpuid(&eax, &ebx, &ecx, &edx);
60 
61  ss << (eax & 0xF); ss << " "; // stepping
62  ss << ((eax >> 4) & 0xF); ss << " "; // model
63  ss << ((eax >> 8) & 0xF); ss << " "; // family
64  ss << ((eax >> 12) & 0x3); ss << " "; // processor type
65  ss << ((eax >> 16) & 0xF); ss << " "; // extended model
66  ss << ((eax >> 20) & 0xFF); ss << " "; // extended family
67 
68  m_uuid = ss.str();
69 }
#define xF
std::string m_uuid
Definition: hw.h:82

◆ synch()

void CPU::synch ( ) const
inlinevirtual

Implements HW.

Definition at line 45 of file cpu.h.

45 {}; // nothing to do

◆ synchAll()

void CPU::synchAll ( ) const
inlinevirtual

Implements HW.

Definition at line 46 of file cpu.h.

46 {}; // nothing to do

◆ unlockMemory()

void CPU::unlockMemory ( const void *  h_mem)
inlineoverridevirtual

Implements HW.

Definition at line 54 of file cpu.h.

54  {
55  // FIXME DS implement
56  }

◆ updateMemoryInfo()

void CPU::updateMemoryInfo ( )
virtual

Implements HW.

Definition at line 41 of file cpu.cpp.

41  {
42  size_t pages = sysconf(_SC_PHYS_PAGES);
43  size_t page_size = sysconf(_SC_PAGE_SIZE);
44  size_t total = pages * page_size;
45  m_totalBytes = total;
46  m_lastFreeBytes = total; // assume we own all memory
47 }
size_t m_totalBytes
Definition: hw.h:80
size_t m_lastFreeBytes
Definition: hw.h:81

The documentation for this class was generated from the following files: