Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nodefileparser.h
Go to the documentation of this file.
1 #ifndef NODEFILEPARSER_H
2 #define NODEFILEPARSER_H
3 
4 #include <QStringList>
5 #include <QVector>
6 #include <QString>
7 #include <QObject>
8 #include <QDebug>
9 #include <QList>
10 #include <QMap>
11 
12 namespace LangmuirCore {
13 
17 class NodeFileParser : public QObject
18 {
19  Q_OBJECT
20 public:
27  explicit NodeFileParser(const QString& nodefile="", const QString& gpufile="", QObject *parent = 0);
28 
38  void setPaths(const QString& nodefile="", const QString& gpufile="");
39 
44  void setHostName(const QString& hostName);
45 
49  void setHostName();
50 
54  void setDefault();
55 
62  void createNode(const QString &name, int cores=0, QList<int> gpus = QList<int>());
63 
67  void clear();
68 
72  friend QDebug operator<<(QDebug dbg,const NodeFileParser& nfp);
73 
77  int numProc();
78 
83  int numProc(const QString& name);
84 
88  const QMap<QString,int>& procs();
89 
93  int numGPUS();
94 
99  int numGPUs(const QString& name);
100 
106  int GPUid(const QString &name, int i);
107 
112  const QList<int>& gpus(const QString& name);
113 
117  int numCPUs();
118 
122  const QStringList& cpus();
123 
127  const QString& hostName();
128 
129 private:
131  QStringList m_names;
132 
134  QMap<QString,int> m_cores;
135 
137  QMap<QString,QList<int> > m_gpus;
138 
140  QString m_nodefile;
141 
143  QString m_gpufile;
144 
146  QString m_hostName;
147 
155  bool parse(QString &filename, bool ignoreCores = false, bool ignoreGPUs = true);
156 };
157 
158 }
159 
160 #endif // NODEFILEPARSER_H
A class to parse the PBS_NODEFILE and PBS_GPUFILE.
Definition: nodefileparser.h:17
friend QDebug operator<<(QDebug dbg, const NodeFileParser &nfp)
operator overload for QDebug
const QString & hostName()
get the hostname of this cpu
void createNode(const QString &name, int cores=0, QList< int > gpus=QList< int >())
add cpu to records
NodeFileParser(const QString &nodefile="", const QString &gpufile="", QObject *parent=0)
create NodeFileParser
int GPUid(const QString &name, int i)
get the ith gpu id on host
void clear()
clear the records
bool parse(QString &filename, bool ignoreCores=false, bool ignoreGPUs=true)
QMap< QString, QList< int > > m_gpus
list of gpu ids per cpu
Definition: nodefileparser.h:137
int numGPUs(const QString &name)
get the number of gpus on host
void setDefault()
set the default based on QThreadPool and hostname
void setHostName()
set the name of this CPU using boost::asio::ip::hostname()
int numCPUs()
get the number of hosts
void setPaths(const QString &nodefile="", const QString &gpufile="")
aquire the paths of the GPUFILE and the NODEFILE and parse them
QString m_nodefile
path to NODEFILE
Definition: nodefileparser.h:140
QStringList m_names
list of cpu names
Definition: nodefileparser.h:131
Definition: agent.h:12
QString m_hostName
hostname of this computer
Definition: nodefileparser.h:146
int numProc()
get the number of processes on all hosts
const QStringList & cpus()
get the hostnames
QMap< QString, int > m_cores
list of core counts per cpu
Definition: nodefileparser.h:134
const QList< int > & gpus(const QString &name)
get the number of gpus on host
const QMap< QString, int > & procs()
get the number of processes on all hosts
QString m_gpufile
path to GPUFILE
Definition: nodefileparser.h:143
int numGPUS()
get the number of gpus on all hosts