YARP
Yet Another Robot Platform
physicresource.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 
11 #include <cstring>
12 
13 
14 using namespace yarp::manager;
15 using namespace std;
16 
17 
22 {
23  cores = (size_t)0;
24  frequency = (double)0.0;
25  globalMemory = (Capacity)0;
26  sharedMemory = (Capacity)0;
27  constantMemory = (Capacity)0;
28  registerPerBlock = (size_t)0;
29  threadPerBlock = (size_t)0;
30  bOverlap = false;
31 }
32 
33 
34 GPU::GPU(const char* szName) : GenericResource("GPU")
35 {
36  setName(szName);
37  cores = (size_t)0;
38  frequency = (double)0.0;
39  globalMemory = (Capacity)0;
40  sharedMemory = (Capacity)0;
41  constantMemory = (Capacity)0;
42  registerPerBlock = (size_t)0;
43  threadPerBlock = (size_t)0;
44  bOverlap = false;
45 }
46 
47 
48 GPU::GPU(const GPU &resource) : GenericResource(resource)
49 {
50  compCompatibility = resource.compCompatibility;
51  cores = resource.cores;
52  frequency = resource.frequency;
53  globalMemory = resource.globalMemory;
54  sharedMemory = resource.sharedMemory;
55  constantMemory = resource.constantMemory;
56  registerPerBlock = resource.registerPerBlock;
57  threadPerBlock = resource.threadPerBlock;
58  bOverlap = resource.bOverlap;
59 }
60 
61 
63 {
64  GPU* resource = new GPU(*this);
65  return resource;
66 }
67 
68 
70 {
71  if(!getAvailability() || getDisable())
72  return false;
73 
74  GPU* gpu = dynamic_cast<GPU*>(resource);
75  if(!gpu)
76  return false;
77  bool ret = (!strlen(gpu->getCompCompatibility()))? true : (compCompatibility == string(gpu->getCompCompatibility()));
78  ret &= (cores >= gpu->getCores());
79  ret &= (frequency >= gpu->getFrequency());
80  ret &= (globalMemory >= gpu->getGlobalMemory());
81  ret &= (sharedMemory >= gpu->getSharedMemory());
82  ret &= (constantMemory >= gpu->getConstantMemory());
83  //ret &= (registerPerBlock == gpu->getRegisterPerBlock());
84  //ret &= (threadPerBlock == gpu->getThreadPerBlock());
85  ret &= (!gpu->getOverlap())? true : (bOverlap == gpu->getOverlap());
86  return ret;
87 }
88 
89 GPU::~GPU() = default;
yarp::manager::GPU::~GPU
~GPU() override
yarp::manager::GPU::GPU
GPU()
Class GPU.
Definition: physicresource.cpp:21
yarp::manager::GPU::getGlobalMemory
Capacity getGlobalMemory()
Definition: physicresource.h:45
yarp::manager::GPU::getOverlap
bool getOverlap()
Definition: physicresource.h:50
yarp::manager
Definition: application.h:24
yarp::manager::GenericResource::getDisable
bool getDisable()
Definition: resource.h:29
ret
bool ret
Definition: ImplementAxisInfo.cpp:72
yarp::manager::GPU::satisfy
bool satisfy(GenericResource *resource) override
Definition: physicresource.cpp:69
yarp::manager::GPU::getConstantMemory
Capacity getConstantMemory()
Definition: physicresource.h:47
yarp::manager::GPU
Definition: physicresource.h:22
yarp::manager::GPU::getCores
size_t getCores()
Definition: physicresource.h:42
yarp::manager::Node
a Node of a Graph
Definition: node.h:68
yarp::manager::Capacity
size_t Capacity
Definition: primresource.h:22
yarp::manager::GenericResource::getAvailability
bool getAvailability()
Definition: resource.h:27
yarp::manager::GPU::getSharedMemory
Capacity getSharedMemory()
Definition: physicresource.h:46
yarp::manager::GenericResource
Definition: resource.h:21
yarp::manager::GPU::clone
Node * clone() override
Definition: physicresource.cpp:62
yarp::manager::GPU::getFrequency
double getFrequency()
Definition: physicresource.h:43
yarp::manager::GPU::getCompCompatibility
const char * getCompCompatibility()
Definition: physicresource.h:44
physicresource.h
yarp::manager::GenericResource::setName
void setName(const char *szName)
Definition: resource.h:31