Commit 7d19ec4f authored by Matthieu Dorier's avatar Matthieu Dorier

put some consistencies in tabs/spaces

parent b3564f76
......@@ -31,7 +31,6 @@ private:
margo_request m_request;
engine* m_engine;
hg_handle_t m_handle;
buffer m_buffer;
bool m_ignore_response;
/**
......@@ -64,7 +63,6 @@ public:
: m_request(other.m_request)
, m_engine(other.m_engine)
, m_handle(other.m_handle)
, m_buffer(std::move(other.m_buffer))
, m_ignore_response(other.m_ignore_response) {
other.m_request = MARGO_REQUEST_NULL;
other.m_engine = nullptr;
......
......@@ -40,10 +40,10 @@ class barrier_exception : public exception {
* @brief Wrapper for Argobots' ABT_barrier.
*/
class barrier {
ABT_barrier m_barrier;
public:
ABT_barrier m_barrier;
public:
/**
* @brief Native handle type (ABT_barrier)
......
......@@ -31,7 +31,7 @@ class bulk {
private:
engine* m_engine;
hg_bulk_t m_bulk;
hg_bulk_t m_bulk;
bool m_is_local;
bool m_eager_mode;
......@@ -45,8 +45,8 @@ private:
* @param local Whether the bulk handle referes to memory that is
* local to this process.
*/
bulk(engine& e, hg_bulk_t b, bool local)
: m_engine(&e), m_bulk(b), m_is_local(local), m_eager_mode(false) {}
bulk(engine& e, hg_bulk_t b, bool local)
: m_engine(&e), m_bulk(b), m_is_local(local), m_eager_mode(false) {}
/**
* @brief The bulk_segment class represents a portion
......@@ -141,7 +141,7 @@ public:
/**
* @brief Copy constructor.
*/
bulk(const bulk& other)
bulk(const bulk& other)
: m_engine(other.m_engine), m_bulk(other.m_bulk),
m_is_local(other.m_is_local), m_eager_mode(other.m_eager_mode) {
if(other.m_bulk != HG_BULK_NULL) {
......@@ -153,17 +153,17 @@ public:
/**
* @brief Move constructor.
*/
bulk(bulk&& other)
: m_engine(other.m_engine), m_bulk(other.m_bulk),
bulk(bulk&& other)
: m_engine(other.m_engine), m_bulk(other.m_bulk),
m_is_local(other.m_is_local),
m_eager_mode(other.m_eager_mode) {
other.m_bulk = HG_BULK_NULL;
}
other.m_bulk = HG_BULK_NULL;
}
/**
* @brief Copy-assignment operator.
*/
bulk& operator=(const bulk& other) {
bulk& operator=(const bulk& other) {
if(this == &other) return *this;
if(m_bulk != HG_BULK_NULL) {
hg_return_t ret = margo_bulk_free(m_bulk);
......@@ -183,7 +183,7 @@ public:
/**
* @brief Move-assignment operator.
*/
bulk& operator=(bulk&& other) {
bulk& operator=(bulk&& other) {
if(this == &other) return *this;
if(m_bulk != HG_BULK_NULL) {
hg_return_t ret = margo_bulk_free(m_bulk);
......@@ -196,11 +196,11 @@ public:
other.m_bulk = HG_BULK_NULL;
return *this;
}
/**
* @brief Destructor.
*/
~bulk() {
~bulk() {
if(m_bulk != HG_BULK_NULL) {
hg_return_t ret = margo_bulk_free(m_bulk);
MARGO_ASSERT_TERMINATE(ret, margo_bulk_free, -1);
......
......@@ -32,12 +32,12 @@ class endpoint;
*/
class callable_remote_procedure {
friend class remote_procedure;
friend class remote_procedure;
friend class async_response;
private:
engine* m_engine;
hg_handle_t m_handle;
hg_handle_t m_handle;
bool m_ignore_response;
uint16_t m_provider_id;
......@@ -50,7 +50,7 @@ private:
* @param ep endpoint on which to call the RPC.
* @param ignore_resp whether the response should be ignored.
*/
callable_remote_procedure(engine& e, hg_id_t id, const endpoint& ep,
callable_remote_procedure(engine& e, hg_id_t id, const endpoint& ep,
bool ignore_resp, uint16_t provider_id=0);
/**
......@@ -73,7 +73,7 @@ private:
ret = margo_free_output(m_handle, &output); // won't do anything on a buffer type
MARGO_ASSERT(ret, margo_free_output);
return packed_response(std::move(output), *m_engine);
}
}
/**
* @brief Sends the RPC to the endpoint (calls margo_iforward), passing a buffer
......@@ -97,63 +97,63 @@ public:
/**
* @brief Copy-constructor.
*/
callable_remote_procedure(const callable_remote_procedure& other) {
callable_remote_procedure(const callable_remote_procedure& other) {
hg_return_t ret;
m_handle = other.m_handle;
if(m_handle != HG_HANDLE_NULL) {
m_handle = other.m_handle;
if(m_handle != HG_HANDLE_NULL) {
ret = margo_ref_incr(m_handle);
MARGO_ASSERT(ret, margo_ref_incr);
}
}
}
}
/**
* @brief Move-constructor.
*/
callable_remote_procedure(callable_remote_procedure&& other) {
m_handle = other.m_handle;
other.m_handle = HG_HANDLE_NULL;
}
callable_remote_procedure(callable_remote_procedure&& other) {
m_handle = other.m_handle;
other.m_handle = HG_HANDLE_NULL;
}
/**
* @brief Copy-assignment operator.
*/
callable_remote_procedure& operator=(const callable_remote_procedure& other) {
callable_remote_procedure& operator=(const callable_remote_procedure& other) {
hg_return_t ret;
if(&other == this) return *this;
if(m_handle != HG_HANDLE_NULL) {
if(&other == this) return *this;
if(m_handle != HG_HANDLE_NULL) {
ret = margo_destroy(m_handle);
MARGO_ASSERT(ret, margo_destroy);
}
m_handle = other.m_handle;
ret = margo_ref_incr(m_handle);
}
m_handle = other.m_handle;
ret = margo_ref_incr(m_handle);
MARGO_ASSERT(ret, margo_ref_incr);
return *this;
}
return *this;
}
/**
* @brief Move-assignment operator.
*/
callable_remote_procedure& operator=(callable_remote_procedure&& other) {
if(&other == this) return *this;
if(m_handle != HG_HANDLE_NULL) {
hg_return_t ret = margo_destroy(m_handle);
callable_remote_procedure& operator=(callable_remote_procedure&& other) {
if(&other == this) return *this;
if(m_handle != HG_HANDLE_NULL) {
hg_return_t ret = margo_destroy(m_handle);
MARGO_ASSERT(ret, margo_destroy);
}
m_handle = other.m_handle;
other.m_handle = HG_HANDLE_NULL;
return *this;
}
}
m_handle = other.m_handle;
other.m_handle = HG_HANDLE_NULL;
return *this;
}
/**
* @brief Destructor.
*/
~callable_remote_procedure() {
if(m_handle != HG_HANDLE_NULL) {
~callable_remote_procedure() {
if(m_handle != HG_HANDLE_NULL) {
hg_return_t ret = margo_destroy(m_handle);
MARGO_ASSERT_TERMINATE(ret, margo_destroy, -1);
}
}
}
}
/**
* @brief Operator to call the RPC. Will serialize the arguments
......@@ -164,13 +164,13 @@ public:
*
* @return a packed_response object containing the returned value.
*/
template<typename ... T>
packed_response operator()(T&& ... t) const {
buffer b;
template<typename ... T>
packed_response operator()(T&& ... t) const {
buffer b;
buffer_output_archive arch(b, *m_engine);
serialize_many(arch, std::forward<T>(t)...);
return forward(b);
}
return forward(b);
}
/**
* @brief Operator to call the RPC without any argument.
......
......@@ -41,10 +41,10 @@ class condition_variable_exception : public exception {
* @brief Wrapper for Argobots' ABT_cond.
*/
class condition_variable {
ABT_cond m_cond;
public:
ABT_cond m_cond;
public:
/**
* @brief Native handle type.
......
......@@ -30,15 +30,15 @@ class remote_bulk;
*/
class endpoint {
friend class engine;
friend class engine;
friend class request;
friend class callable_remote_procedure;
friend class callable_remote_procedure;
friend class remote_bulk;
private:
engine* m_engine;
hg_addr_t m_addr;
engine* m_engine;
hg_addr_t m_addr;
public:
......@@ -49,7 +49,7 @@ public:
* @param e Engine that created the endpoint.
* @param addr Mercury address.
*/
endpoint(engine& e, hg_addr_t addr, bool take_ownership=true);
endpoint(engine& e, hg_addr_t addr, bool take_ownership=true);
/**
* @brief Default constructor defined so that endpoints can
......@@ -61,37 +61,37 @@ public:
/**
* @brief Copy constructor.
*/
endpoint(const endpoint& other);
endpoint(const endpoint& other);
/**
* @brief Move constructor.
*/
endpoint(endpoint&& other)
: m_engine(other.m_engine), m_addr(other.m_addr) {
other.m_addr = HG_ADDR_NULL;
}
endpoint(endpoint&& other)
: m_engine(other.m_engine), m_addr(other.m_addr) {
other.m_addr = HG_ADDR_NULL;
}
/**
* @brief Copy-assignment operator.
*/
endpoint& operator=(const endpoint& other);
endpoint& operator=(const endpoint& other);
/**
* @brief Move-assignment operator.
*/
endpoint& operator=(endpoint&& other);
endpoint& operator=(endpoint&& other);
/**
* @brief Destructor.
*/
~endpoint();
~endpoint();
/**
* @brief Creates a string representation of the endpoint's address.
*
* @return A string representation of the endpoint's address.
*/
operator std::string() const;
operator std::string() const;
/**
* @brief Indicates whether the endpoint is null or not.
......
......@@ -42,10 +42,10 @@ class engine {
friend class request;
friend class bulk;
friend class endpoint;
friend class endpoint;
friend class remote_bulk;
friend class remote_procedure;
friend class callable_remote_procedure;
friend class callable_remote_procedure;
template<typename T>
friend class provider;
......@@ -53,7 +53,7 @@ private:
using rpc_t = std::function<void(const request&, const buffer&)>;
margo_instance_id m_mid;
margo_instance_id m_mid;
std::unordered_map<hg_id_t, rpc_t> m_rpcs;
bool m_is_server;
bool m_owns_mid;
......@@ -88,27 +88,27 @@ private:
* @tparam disable_response whether the caller expects a response.
* @param handle handle of the RPC.
*/
template<typename F, bool disable_response>
static void rpc_handler_ult(hg_handle_t handle) {
using G = typename std::remove_reference<F>::type;
const struct hg_info* info = margo_get_info(handle);
template<typename F, bool disable_response>
static void rpc_handler_ult(hg_handle_t handle) {
using G = typename std::remove_reference<F>::type;
const struct hg_info* info = margo_get_info(handle);
THALLIUM_ASSERT_CONDITION(info != nullptr, "margo_get_info returned null");
margo_instance_id mid = margo_hg_handle_get_instance(handle);
margo_instance_id mid = margo_hg_handle_get_instance(handle);
THALLIUM_ASSERT_CONDITION(mid != 0, "margo_hg_handle_get_instance returned null");
void* data = margo_registered_data(mid, info->id);
void* data = margo_registered_data(mid, info->id);
THALLIUM_ASSERT_CONDITION(data != nullptr, "margo_registered_data returned null");
auto cb_data = static_cast<rpc_callback_data*>(data);
auto f = function_cast<G>(cb_data->m_function);
request req(*(cb_data->m_engine), handle, disable_response);
buffer input;
hg_return_t ret;
auto f = function_cast<G>(cb_data->m_function);
request req(*(cb_data->m_engine), handle, disable_response);
buffer input;
hg_return_t ret;
ret = margo_get_input(handle, &input);
MARGO_ASSERT(ret, margo_get_input);
(*f)(req, input);
(*f)(req, input);
ret = margo_free_input(handle, &input);
MARGO_ASSERT(ret, margo_free_input);
margo_destroy(handle); // because of margo_ref_incr in rpc_callback
}
}
/**
* @brief Callback called when an RPC is received.
......@@ -160,20 +160,20 @@ public:
* @param rpc_thread_count number of threads to use for servicing RPCs.
* Use -1 to indicate that RPCs should be serviced in the progress ES.
*/
engine(const std::string& addr, int mode,
bool use_progress_thread = false,
std::int32_t rpc_thread_count = 0) {
engine(const std::string& addr, int mode,
bool use_progress_thread = false,
std::int32_t rpc_thread_count = 0) {
m_is_server = (mode == THALLIUM_SERVER_MODE);
m_finalize_called = false;
m_mid = margo_init(addr.c_str(), mode,
use_progress_thread ? 1 : 0,
rpc_thread_count);
m_mid = margo_init(addr.c_str(), mode,
use_progress_thread ? 1 : 0,
rpc_thread_count);
// XXX throw an exception if m_mid not initialized
m_owns_mid = true;
margo_push_finalize_callback(m_mid,
&engine::on_finalize_cb, static_cast<void*>(this));
}
}
engine(const std::string& addr, int mode,
const pool& progress_pool,
......@@ -222,28 +222,28 @@ public:
/**
* @brief Copy-constructor is deleted.
*/
engine(const engine& other) = delete;
engine(const engine& other) = delete;
/**
* @brief Move-constructor is deleted.
*/
engine(engine&& other) = delete;
engine(engine&& other) = delete;
/**
* @brief Move-assignment operator is deleted.
*/
engine& operator=(engine&& other) = delete;
engine& operator=(engine&& other) = delete;
/**
* @brief Copy-assignment operator is deleted.
*/
engine& operator=(const engine& other) = delete;
engine& operator=(const engine& other) = delete;
/**
* @brief Destructor.
*/
~engine() {
~engine() {
if(m_owns_mid) {
if(m_is_server) {
if(!m_finalize_called)
......@@ -253,7 +253,7 @@ public:
margo_finalize(m_mid);
}
}
}
}
/**
* @brief Get the underlying margo instance. Useful
......@@ -269,13 +269,13 @@ public:
/**
* @brief Finalize the engine. Can be called by any thread.
*/
void finalize() {
margo_finalize(m_mid);
void finalize() {
margo_finalize(m_mid);
if(m_hg_context)
HG_Context_destroy(m_hg_context);
if(m_hg_class)
HG_Finalize(m_hg_class);
}
}
/**
* @brief Makes the calling thread block until someone calls
......@@ -292,7 +292,7 @@ public:
*
* @return An endpoint corresponding to this engine.
*/
endpoint self() const;
endpoint self() const;
/**
* @brief Defines an RPC with a name, without providing a
......@@ -302,7 +302,7 @@ public:
*
* @return a remote_procedure object.
*/
remote_procedure define(const std::string& name);
remote_procedure define(const std::string& name);
/**
* @brief Defines an RPC with a name and an std::function
......@@ -316,8 +316,8 @@ public:
*
* @return a remote_procedure object.
*/
template<typename ... Args>
remote_procedure define(const std::string& name,
template<typename ... Args>
remote_procedure define(const std::string& name,
const std::function<void(const request&, Args...)>& fun,
uint16_t provider_id=0, const pool& p = pool());
......@@ -345,7 +345,7 @@ public:
*
* @return an endpoint object associated with the given address.
*/
endpoint lookup(const std::string& address) const;
endpoint lookup(const std::string& address) const;
/**
* @brief Exposes a series of memory segments for bulk operations.
......
......@@ -43,9 +43,9 @@ class eventual_exception : public exception {
*/
template<typename T>
class eventual {
public:
public:
/**
* @brief Type of value stored by the eventual.
......@@ -58,7 +58,7 @@ class eventual {
private:
ABT_eventual m_eventual;
ABT_eventual m_eventual;
value_type m_value;
public:
......@@ -163,8 +163,8 @@ class eventual {
*/
template<>
class eventual<void> {
public:
public:
/**
* @brief Native handle type.
......@@ -173,7 +173,7 @@ class eventual<void> {
private:
ABT_eventual m_eventual;
ABT_eventual m_eventual;
public:
......
......@@ -20,7 +20,7 @@ namespace thallium {
*/
template<typename F>
F* function_cast(void* f) {
return reinterpret_cast<F*>(reinterpret_cast<std::intptr_t>(f));
return reinterpret_cast<F*>(reinterpret_cast<std::intptr_t>(f));
}
/**
......@@ -33,7 +33,7 @@ F* function_cast(void* f) {
*/
template<typename F>
void* void_cast(F&& fun) {
return reinterpret_cast<void*>(reinterpret_cast<std::intptr_t>(fun));
return reinterpret_cast<void*>(reinterpret_cast<std::intptr_t>(fun));
}
}
......
......@@ -43,9 +43,9 @@ class future_exception : public exception {
*/
template<typename T>
class future {
uint32_t m_num_compartments;
ABT_future m_future;
ABT_future m_future;
static void when_ready(void** arg) {
auto f = static_cast<std::function<void(const std::vector<T*>&)>*>(arg[0]);
......@@ -56,7 +56,7 @@ class future {
delete f;
}
public:
public:
/**
* @brief Type of the underlying native handle.
......
......@@ -41,10 +41,10 @@ class mutex_exception : public exception {
* but build around Argobot's mutex.
*/
class mutex {
ABT_mutex m_mutex;
public:
ABT_mutex m_mutex;
public:
/**
* @brief Type of the underlying native handle.
......@@ -56,20 +56,20 @@ class mutex {
*
* @param recursive whether the mutex is recursive or not.
*/
explicit mutex(bool recursive = false) {
explicit mutex(bool recursive = false) {
ABT_mutex_attr attr;
TL_MUTEX_ASSERT(ABT_mutex_attr_create(&attr));
if(recursive) {
TL_MUTEX_ASSERT(ABT_mutex_attr_create(&attr));
if(recursive) {
TL_MUTEX_ASSERT(ABT_mutex_attr_set_recursive(attr, ABT_TRUE));
}
TL_MUTEX_ASSERT(ABT_mutex_create_with_attr(attr, &m_mutex));
TL_MUTEX_ASSERT(ABT_mutex_create_with_attr(attr, &m_mutex));
TL_MUTEX_ASSERT(ABT_mutex_attr_free(&attr));
}
}
/**
* @brief Copy constructor is deleted.
*/
mutex(const mutex& other) = delete;
mutex(const mutex& other) = delete;
/**
* @brief Copy assignment operator is deleted.
......@@ -91,46 +91,46 @@ class mutex {
/**
* @brief Move constructor.
*/
mutex(mutex&& other) {
m_mutex = other.m_mutex;
other.m_mutex = ABT_MUTEX_NULL;
}
mutex(mutex&& other) {
m_mutex = other.m_mutex;
other.m_mutex = ABT_MUTEX_NULL;
}
/**
* @brief Destructor.
*/
virtual ~mutex() noexcept {
if(m_mutex != ABT_MUTEX_NULL)
ABT_mutex_free(&m_mutex);
}
virtual ~mutex() noexcept {
if(m_mutex != ABT_MUTEX_NULL)
ABT_mutex_free(&m_mutex);
}
/**
* @brief Lock the mutex.
*/
void lock() {
void lock() {
TL_MUTEX_ASSERT(ABT_mutex_lock(m_mutex));
}
}
/**
* @brief Lock the mutex in low priority.
*/
void lock_low() {
TL_MUTEX_ASSERT(ABT_mutex_lock_low(m_mutex));
}
void lock_low() {
TL_MUTEX_ASSERT(ABT_mutex_lock_low(m_mutex));
}
/**
* @brief Lock the mutex without context switch.
*/
void spin_lock() {
TL_MUTEX_ASSERT(ABT_mutex_spinlock(m_mutex));
}
void spin_lock() {
TL_MUTEX_ASSERT(ABT_mutex_spinlock(m_mutex));
}
/**
* @brief Try locking the mutex without blocking.
*
* @return true if it managed to lock the mutex.
*/
bool try_lock() {
bool try_lock() {
int ret = ABT_mutex_trylock(m_mutex);
if(ABT_SUCCESS == ret) {
return true;
......@@ -140,21 +140,21 @@ class mutex {
TL_MUTEX_EXCEPTION(ABT_mutex_trylock(m_mutex), ret);
}
return false;
}
}
/**
* @brief Unlock the mutex.
*/
void unlock() {
TL_MUTEX_ASSERT(ABT_mutex_unlock(m_mutex));
}
void unlock() {
TL_MUTEX_ASSERT(ABT_mutex_unlock(m_mutex));