Commit 53017b58 authored by Vladislav Perepelkin's avatar Vladislav Perepelkin
Browse files

Merge branch 'refactor_mzykin' into 'master'

Refactor mzykin

See merge request luna/lo3!13
parents f70ebd2d fe7bc65e
...@@ -24,7 +24,7 @@ CXX_WARN ?= \ ...@@ -24,7 +24,7 @@ CXX_WARN ?= \
-Wall -Werror -Wpedantic -Wno-vla -Wno-sign-compare \ -Wall -Werror -Wpedantic -Wno-vla -Wno-sign-compare \
-Wno-unused-but-set-variable -Wno-unused-variable \ -Wno-unused-but-set-variable -Wno-unused-variable \
-Wno-unused-function -Wno-unused-function
PYTHON ?= python PYTHON ?= python2
MPICXX ?= mpicxx MPICXX ?= mpicxx
MPICH_CXX?=${CXX} MPICH_CXX?=${CXX}
CXX_FLAGS += \ CXX_FLAGS += \
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "serializable.h" #include "serializable.h"
class CF; class CF;
typedef std::shared_ptr<CF> CFPtr; using CFPtr = std::shared_ptr<CF>;
class CF : public Serializable class CF : public Serializable
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
class Comm class Comm
{ {
public: public:
typedef std::function<void (int, int, void *, size_t)> MsgHandler; using MsgHandler = std::function<void (int, int, void *, size_t)> ;
virtual ~Comm() {} virtual ~Comm() {}
...@@ -16,7 +16,7 @@ public: ...@@ -16,7 +16,7 @@ public:
void send_copy(int dest, int tag, const void *buf, size_t size); void send_copy(int dest, int tag, const void *buf, size_t size);
template <class T> template <typename T>
void send(int dest, int tag, const T &val) void send(int dest, int tag, const T &val)
{ {
send_copy(dest, tag, &val, sizeof(T)); send_copy(dest, tag, &val, sizeof(T));
...@@ -32,7 +32,7 @@ public: ...@@ -32,7 +32,7 @@ public:
virtual int next_rank() const; virtual int next_rank() const;
virtual bool is_root() const; virtual bool is_root() const noexcept;
virtual void barrier()=0; virtual void barrier()=0;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
const unsigned int constexpr unsigned int
DEFAULT_WORKER_THREADS_COUNT=4, DEFAULT_WORKER_THREADS_COUNT=4,
DEFAULT_COMM_REQUEST_THREADS_COUNT=1, DEFAULT_COMM_REQUEST_THREADS_COUNT=1,
DEFAULT_COMM_RECEIVE_THREADS_COUNT=1; DEFAULT_COMM_RECEIVE_THREADS_COUNT=1;
...@@ -22,8 +22,7 @@ public: ...@@ -22,8 +22,7 @@ public:
Config(int argc, char **argv); Config(int argc, char **argv);
RunMode get_run_mode() const; RunMode get_run_mode() const noexcept ;
const std::string &argv(unsigned int) const; const std::string &argv(unsigned int) const;
const std::string &get_fp_path() const; const std::string &get_fp_path() const;
...@@ -31,9 +30,9 @@ public: ...@@ -31,9 +30,9 @@ public:
std::string get_help() const; std::string get_help() const;
std::string get_version() const; std::string get_version() const;
unsigned int get_worker_threads_count() const; unsigned int get_worker_threads_count() const noexcept;
unsigned int get_comm_request_threads_count() const; unsigned int get_comm_request_threads_count() const noexcept;
unsigned int get_comm_recv_threads_count() const; unsigned int get_comm_recv_threads_count() const noexcept;
private: private:
std::string program_name_; std::string program_name_;
RunMode mode_; RunMode mode_;
......
...@@ -10,5 +10,5 @@ public: ...@@ -10,5 +10,5 @@ public:
CyclicLocator(int pos); CyclicLocator(int pos);
virtual int get_next_rank(Comm &) const; virtual int get_next_rank(Comm &) const noexcept;
}; };
...@@ -54,8 +54,8 @@ public: ...@@ -54,8 +54,8 @@ public:
DF operator>=(const DF &) const; DF operator>=(const DF &) const;
DF operator>(const DF &) const; DF operator>(const DF &) const;
bool is_set() const; bool is_set() const noexcept;
bool is_unset() const; bool is_unset() const noexcept;
ValueType get_type() const { return type_; } ValueType get_type() const { return type_; }
......
...@@ -11,7 +11,7 @@ class CF; ...@@ -11,7 +11,7 @@ class CF;
class FP class FP
{ {
public: public:
~FP() noexcept(false); ~FP() noexcept (false);
FP(const std::string &path); FP(const std::string &path);
Block operator[](unsigned int block_idx) const; Block operator[](unsigned int block_idx) const;
......
...@@ -19,7 +19,7 @@ public: ...@@ -19,7 +19,7 @@ public:
std::string to_string() const; std::string to_string() const;
virtual size_t get_serialization_size() const; virtual size_t get_serialization_size() const noexcept;
virtual size_t serialize(void *buf, size_t buf_size) const; virtual size_t serialize(void *buf, size_t buf_size) const;
virtual size_t deserialize(const void *buf, size_t buf_size); virtual size_t deserialize(const void *buf, size_t buf_size);
......
...@@ -34,4 +34,4 @@ int Comm::next_rank() const ...@@ -34,4 +34,4 @@ int Comm::next_rank() const
return (rank()+1)%size(); return (rank()+1)%size();
} }
bool Comm::is_root() const { return rank()==0; } bool Comm::is_root() const noexcept { return rank()==0; }
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
static struct timespec t_; namespace {
static struct timespec tt_; struct timespec t_;
struct timespec tt_;
}
int mpi_rank; int mpi_rank;
std::string logfilename; std::string logfilename;
......
...@@ -43,7 +43,7 @@ Config::Config(int argc, char **argv) ...@@ -43,7 +43,7 @@ Config::Config(int argc, char **argv)
} }
} }
Config::RunMode Config::get_run_mode() const { return mode_; } Config::RunMode Config::get_run_mode() const noexcept { return mode_; }
const std::string &Config::argv(unsigned int idx) const const std::string &Config::argv(unsigned int idx) const
{ {
...@@ -87,17 +87,17 @@ std::string Config::get_version() const ...@@ -87,17 +87,17 @@ std::string Config::get_version() const
return os.str(); return os.str();
} }
unsigned int Config::get_worker_threads_count() const unsigned int Config::get_worker_threads_count() const noexcept
{ {
return DEFAULT_WORKER_THREADS_COUNT; return DEFAULT_WORKER_THREADS_COUNT;
} }
unsigned int Config::get_comm_request_threads_count() const unsigned int Config::get_comm_request_threads_count() const noexcept
{ {
return DEFAULT_COMM_REQUEST_THREADS_COUNT; return DEFAULT_COMM_REQUEST_THREADS_COUNT;
} }
unsigned int Config::get_comm_recv_threads_count() const unsigned int Config::get_comm_recv_threads_count() const noexcept
{ {
return DEFAULT_COMM_RECEIVE_THREADS_COUNT; return DEFAULT_COMM_RECEIVE_THREADS_COUNT;
} }
...@@ -7,7 +7,7 @@ CyclicLocator::CyclicLocator(int pos) ...@@ -7,7 +7,7 @@ CyclicLocator::CyclicLocator(int pos)
{ {
} }
int CyclicLocator::get_next_rank(Comm &comm) const int CyclicLocator::get_next_rank(Comm &comm) const noexcept
{ {
if (pos_>=0) { if (pos_>=0) {
return pos_%comm.size(); return pos_%comm.size();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
std::vector<std::string> _STR_VT={ const std::vector<std::string> _STR_VT={
"(unset)", "int", "real", "string", "value", "name" "(unset)", "int", "real", "string", "value", "name"
}; };
...@@ -155,8 +155,8 @@ DEFINE_DF_OPERATOR(>=) ...@@ -155,8 +155,8 @@ DEFINE_DF_OPERATOR(>=)
#undef DEFINE_DF_OPERATOR #undef DEFINE_DF_OPERATOR
bool DF::is_set() const { return type_!=TYPE_UNDEFINED; } bool DF::is_set() const noexcept { return type_!=TYPE_UNDEFINED; }
bool DF::is_unset() const { return !is_set(); } bool DF::is_unset() const noexcept { return !is_set(); }
int DF::get_int() const int DF::get_int() const
{ {
......
...@@ -43,27 +43,23 @@ std::string Id::to_string() const ...@@ -43,27 +43,23 @@ std::string Id::to_string() const
std::ostringstream os; std::ostringstream os;
os << "ID<"; os << "ID<";
os << idx_[0];
for (auto i=0u; i<idx_.size(); i++) { for (auto i = 1u; i<idx_.size(); i++) {
if (i>0) { os << ", " << idx_[i];
os << ", ";
}
os << idx_[i];
} }
os << ">"; os << ">";
return os.str(); return os.str();
} }
size_t Id::get_serialization_size() const size_t Id::get_serialization_size() const noexcept
{ {
return sizeof(size_t)+idx_.size()*sizeof(int); return sizeof(size_t)+idx_.size()*sizeof(int);
} }
size_t Id::serialize(void *buf, size_t buf_size) const size_t Id::serialize(void *buf, size_t buf_size) const
{ {
size_t orig_buf_size=buf_size; auto orig_buf_size=buf_size;
assert(buf_size>=get_serialization_size()); assert(buf_size>=get_serialization_size());
put<size_t>(buf, buf_size, idx_.size()); put<size_t>(buf, buf_size, idx_.size());
......
...@@ -24,7 +24,6 @@ void init_mpi(int &argc, char **&argv) ...@@ -24,7 +24,6 @@ void init_mpi(int &argc, char **&argv)
void ctrl_c_handler(int sig_num) void ctrl_c_handler(int sig_num)
{ {
printf("%s\n", rts->get_status().c_str()); printf("%s\n", rts->get_status().c_str());
ABORT("Ctrl-C detected"); ABORT("Ctrl-C detected");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment