Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
ResourceAllocator.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2011-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Elijah Roberts
38 */
39
40#ifndef LM_MAIN_RESOURCEALLOCATOR_H_
41#define LM_MAIN_RESOURCEALLOCATOR_H_
42
43#include <string>
44#include <vector>
45#include "thread/Thread.h"
46
47using std::string;
48using std::vector;
50
51namespace lm {
52namespace main {
53
57{
58public:
62 {
63 public:
65 vector<int> cpuCores;
66 vector<int> cudaDevices;
67 string toString();
68 };
69
70public:
82 ResourceAllocator(int processNumber, int numberCpuCores, float cpuCoresPerReplicate, vector<int> cudaDevices, float cudaDevicesPerReplicate);
83 virtual ~ResourceAllocator();
84
86 virtual int getMaxSimultaneousReplicates();
90 virtual ComputeResources assignReplicate(int replicate);
93 virtual void removeReplicate(int replicate);
96 virtual int reserveCpuCore();
97
100 static vector<int> getAvailableCpuCores();
101
102private:
103 void initialize(float cpuCoresPerReplicate, float cudaDevicesPerReplicate);
104 static vector<int> parseCpuList(const string& cpuList);
105
106protected:
107 pthread_mutex_t mutex;
111 vector<int> availableCpuCores;
112 vector<int> cudaDevices;
117
118 int ** cpuSlots;
119 int ** cudaSlots;
120};
121
122}
123}
124
125#endif
float cpuCoresPerReplicate
Definition Globals.cpp:91
A representation for the resources for a given node.
Definition ResourceAllocator.h:62
vector< int > cudaDevices
Definition ResourceAllocator.h:66
int processNumber
Definition ResourceAllocator.h:64
vector< int > cpuCores
Definition ResourceAllocator.h:65
string toString()
Definition ResourceAllocator.cpp:297
int cudaSlotsPerDevice
Definition ResourceAllocator.h:115
int processNumber
Definition ResourceAllocator.h:108
int ** cudaSlots
Definition ResourceAllocator.h:119
int cpuSlotsPerReplicate
Definition ResourceAllocator.h:114
virtual int reserveCpuCore()
Reserve a particular core.
Definition ResourceAllocator.cpp:224
ResourceAllocator(int processNumber, int numberCpuCores, float cpuCoresPerReplicate)
Create a ResourceAllocator.
Definition ResourceAllocator.cpp:58
int ** cpuSlots
Definition ResourceAllocator.h:118
int numberCpuCores
Definition ResourceAllocator.h:109
int reservedCpuCores
Definition ResourceAllocator.h:110
vector< int > availableCpuCores
Definition ResourceAllocator.h:111
virtual ~ResourceAllocator()
Definition ResourceAllocator.cpp:138
static vector< int > getAvailableCpuCores()
Parse CPU affinity list from /proc/self/status.
Definition ResourceAllocator.cpp:339
virtual int getMaxSimultaneousReplicates()
Get maximum number of replicates that can run at a time on the available resources based on cudaDevic...
Definition ResourceAllocator.cpp:161
vector< int > cudaDevices
Definition ResourceAllocator.h:112
int cpuSlotsPerCore
Definition ResourceAllocator.h:113
int cudaSlotsPerReplicate
Definition ResourceAllocator.h:116
virtual void removeReplicate(int replicate)
Remove a replicate from those that are running.
Definition ResourceAllocator.cpp:264
virtual ComputeResources assignReplicate(int replicate)
Assign a replicate to free resources.
Definition ResourceAllocator.cpp:174
pthread_mutex_t mutex
Definition ResourceAllocator.h:107
An Exception class for handling pthread exceptions.
Definition Thread.h:53
Definition CheckpointSignaler.cpp:57
Definition Capsule.cpp:46