Commit a31c0fc8 authored by Dominik Charousset's avatar Dominik Charousset

Apply clang-tidy to codebase

parent 219313d1
...@@ -127,14 +127,13 @@ public: ...@@ -127,14 +127,13 @@ public:
std::move(map_args), std::move(map_args),
std::move(map_result), std::move(map_result),
std::forward_as_tuple(xs...)); std::forward_as_tuple(xs...));
} else {
return make_actor<actor_facade, actor>(sys.next_actor_id(), sys.node(),
&sys, std::move(actor_cfg),
prog, itr->second, spawn_cfg,
std::move(map_args),
std::move(map_result),
std::forward_as_tuple(xs...));
} }
return make_actor<actor_facade, actor>(sys.next_actor_id(), sys.node(),
&sys, std::move(actor_cfg),
prog, itr->second, spawn_cfg,
std::move(map_args),
std::move(map_result),
std::forward_as_tuple(xs...));
} }
void enqueue(strong_actor_ptr sender, message_id mid, message content, void enqueue(strong_actor_ptr sender, message_id mid, message content,
...@@ -176,18 +175,18 @@ public: ...@@ -176,18 +175,18 @@ public:
actor_facade(actor_config actor_cfg, actor_facade(actor_config actor_cfg,
const program& prog, kernel_ptr kernel, const program& prog, kernel_ptr kernel,
const spawn_config& spawn_cfg, spawn_config spawn_cfg,
input_mapping map_args, output_mapping map_result, input_mapping map_args, output_mapping map_result,
std::tuple<Ts...> xs) std::tuple<Ts...> xs)
: monitorable_actor(actor_cfg), : monitorable_actor(actor_cfg),
kernel_(kernel), kernel_(std::move(kernel)),
program_(prog.program_), program_(prog.program_),
context_(prog.context_), context_(prog.context_),
queue_(prog.queue_), queue_(prog.queue_),
spawn_cfg_(spawn_cfg), spawn_cfg_(std::move(spawn_cfg)),
map_args_(std::move(map_args)), map_args_(std::move(map_args)),
map_results_(std::move(map_result)), map_results_(std::move(map_result)),
argument_types_(xs) { argument_types_(std::move(xs)) {
CAF_LOG_TRACE(CAF_ARG(this->id())); CAF_LOG_TRACE(CAF_ARG(this->id()));
default_output_size_ = std::accumulate(spawn_cfg_.dimensions().begin(), default_output_size_ = std::accumulate(spawn_cfg_.dimensions().begin(),
spawn_cfg_.dimensions().end(), spawn_cfg_.dimensions().end(),
......
...@@ -53,7 +53,7 @@ struct in_out { ...@@ -53,7 +53,7 @@ struct in_out {
template <class Arg> template <class Arg>
struct out { struct out {
out() { } out() = default;
template <class F> template <class F>
out(F fun) { out(F fun) {
fun_ = [fun](message& msg) -> optional<size_t> { fun_ = [fun](message& msg) -> optional<size_t> {
......
...@@ -49,17 +49,17 @@ public: ...@@ -49,17 +49,17 @@ public:
std::vector<cl_event> events, std::vector<mem_ptr> input_buffers, std::vector<cl_event> events, std::vector<mem_ptr> input_buffers,
std::vector<mem_ptr> output_buffers, std::vector<size_t> result_sizes, std::vector<mem_ptr> output_buffers, std::vector<size_t> result_sizes,
message msg) message msg)
: result_sizes_(result_sizes), : result_sizes_(std::move(result_sizes)),
handle_(handle), handle_(std::move(handle)),
actor_facade_(actor_facade), actor_facade_(std::move(actor_facade)),
mem_in_events_(std::move(events)), mem_in_events_(std::move(events)),
input_buffers_(std::move(input_buffers)), input_buffers_(std::move(input_buffers)),
output_buffers_(std::move(output_buffers)), output_buffers_(std::move(output_buffers)),
msg_(msg) { msg_(std::move(msg)) {
// nop // nop
} }
~command() { ~command() override {
for (auto& e : mem_in_events_) { for (auto& e : mem_in_events_) {
v1callcl(CAF_CLF(clReleaseEvent),e); v1callcl(CAF_CLF(clReleaseEvent),e);
} }
...@@ -95,7 +95,7 @@ public: ...@@ -95,7 +95,7 @@ public:
clReleaseEvent(event_k); clReleaseEvent(event_k);
this->deref(); this->deref();
return; return;
} else { }
enqueue_read_buffers(event_k, detail::get_indices(result_buffers_)); enqueue_read_buffers(event_k, detail::get_indices(result_buffers_));
cl_event marker; cl_event marker;
#if defined(__APPLE__) #if defined(__APPLE__)
...@@ -134,7 +134,7 @@ public: ...@@ -134,7 +134,7 @@ public:
} }
mem_out_events_.push_back(std::move(event_k)); mem_out_events_.push_back(std::move(event_k));
mem_out_events_.push_back(std::move(marker)); mem_out_events_.push_back(std::move(marker));
}
} }
private: private:
......
...@@ -37,7 +37,8 @@ public: ...@@ -37,7 +37,8 @@ public:
friend class manager; friend class manager;
/// Intialize a new device in a context using a sepcific device_id /// Intialize a new device in a context using a sepcific device_id
static device create(context_ptr context, device_ptr device_id, unsigned id); static device create(const context_ptr& context, const device_ptr& device_id,
unsigned id);
/// Get the id assigned by caf /// Get the id assigned by caf
inline unsigned get_id() const; inline unsigned get_id() const;
/// Returns device info on CL_DEVICE_ADDRESS_BITS /// Returns device info on CL_DEVICE_ADDRESS_BITS
...@@ -94,9 +95,16 @@ public: ...@@ -94,9 +95,16 @@ public:
private: private:
device(device_ptr device_id, command_queue_ptr queue, context_ptr context, device(device_ptr device_id, command_queue_ptr queue, context_ptr context,
unsigned id); unsigned id);
template <class T> template <class T>
static T info(device_ptr device_id, unsigned info_flag); static T info(const device_ptr& device_id, unsigned info_flag) {
static std::string info_string(device_ptr device_id, unsigned info_flag); T value;
clGetDeviceInfo(device_id.get(), info_flag, sizeof(T), &value, nullptr);
return value;
}
static std::string info_string(const device_ptr& device_id,
unsigned info_flag);
device_ptr device_id_; device_ptr device_id_;
command_queue_ptr command_queue_; command_queue_ptr command_queue_;
context_ptr context_; context_ptr context_;
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
manager(const manager&) = delete; manager(const manager&) = delete;
manager& operator=(const manager&) = delete; manager& operator=(const manager&) = delete;
/// Get the device with id, which is assigned sequientally. /// Get the device with id, which is assigned sequientally.
const optional<const device&> get_device(size_t id = 0) const; const optional<const device&> get_device(size_t dev_id = 0) const;
/// Get the first device that satisfies the predicate. /// Get the first device that satisfies the predicate.
/// The predicate should accept a `const device&` and return a bool; /// The predicate should accept a `const device&` and return a bool;
template <class UnaryPredicate> template <class UnaryPredicate>
...@@ -166,7 +166,7 @@ public: ...@@ -166,7 +166,7 @@ public:
protected: protected:
manager(actor_system& sys); manager(actor_system& sys);
~manager(); ~manager() override;
private: private:
actor_system& system_; actor_system& system_;
......
...@@ -98,7 +98,7 @@ public: ...@@ -98,7 +98,7 @@ public:
iota(data_.begin(), data_.end(), 0); iota(data_.begin(), data_.end(), 0);
} }
typedef typename fvec::const_iterator const_iterator; using const_iterator = typename fvec::const_iterator;
const_iterator begin() const { return data_.begin(); } const_iterator begin() const { return data_.begin(); }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
******************************************************************************/ ******************************************************************************/
#include <iostream> #include <iostream>
#include <utility>
#include "caf/logger.hpp" #include "caf/logger.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
...@@ -31,12 +32,13 @@ using namespace std; ...@@ -31,12 +32,13 @@ using namespace std;
namespace caf { namespace caf {
namespace opencl { namespace opencl {
device device::create(context_ptr context, device_ptr device_id, unsigned id) { device device::create(const context_ptr& context, const device_ptr& device_id,
unsigned id) {
CAF_LOG_DEBUG("creating device for opencl device with id:" << CAF_ARG(id)); CAF_LOG_DEBUG("creating device for opencl device with id:" << CAF_ARG(id));
// look up properties we need to create the command queue // look up properties we need to create the command queue
auto supported = info<cl_ulong>(device_id, CL_DEVICE_QUEUE_PROPERTIES); auto supported = info<cl_ulong>(device_id, CL_DEVICE_QUEUE_PROPERTIES);
bool profiling = supported & CL_QUEUE_PROFILING_ENABLE; bool profiling = (supported & CL_QUEUE_PROFILING_ENABLE) != 0u;
bool out_of_order = supported & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; bool out_of_order = (supported & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) != 0u;
unsigned properties = profiling ? CL_QUEUE_PROFILING_ENABLE : 0; unsigned properties = profiling ? CL_QUEUE_PROFILING_ENABLE : 0;
properties |= out_of_order ? CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE : 0; properties |= out_of_order ? CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE : 0;
// create the command queue // create the command queue
...@@ -94,14 +96,7 @@ device device::create(context_ptr context, device_ptr device_id, unsigned id) { ...@@ -94,14 +96,7 @@ device device::create(context_ptr context, device_ptr device_id, unsigned id) {
return dev; return dev;
} }
template <class T> string device::info_string(const device_ptr& device_id, unsigned info_flag) {
T device::info(device_ptr device_id, unsigned info_flag) {
T value;
clGetDeviceInfo(device_id.get(), info_flag, sizeof(T), &value, nullptr);
return value;
}
string device::info_string(device_ptr device_id, unsigned info_flag) {
size_t size; size_t size;
clGetDeviceInfo(device_id.get(), info_flag, 0, nullptr, &size); clGetDeviceInfo(device_id.get(), info_flag, 0, nullptr, &size);
vector<char> buffer(size); vector<char> buffer(size);
...@@ -112,9 +107,9 @@ string device::info_string(device_ptr device_id, unsigned info_flag) { ...@@ -112,9 +107,9 @@ string device::info_string(device_ptr device_id, unsigned info_flag) {
device::device(device_ptr device_id, command_queue_ptr queue, device::device(device_ptr device_id, command_queue_ptr queue,
context_ptr context, unsigned id) context_ptr context, unsigned id)
: device_id_(device_id), : device_id_(std::move(device_id)),
command_queue_(queue), command_queue_(std::move(queue)),
context_(context), context_(std::move(context)),
id_(id) { } id_(id) { }
} // namespace opencl } // namespace opencl
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include <utility>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
...@@ -90,7 +91,7 @@ platform::platform(cl_platform_id platform_id, context_ptr context, ...@@ -90,7 +91,7 @@ platform::platform(cl_platform_id platform_id, context_ptr context,
string name, string vendor, string version, string name, string vendor, string version,
vector<device> devices) vector<device> devices)
: platform_id_(platform_id), : platform_id_(platform_id),
context_(context), context_(std::move(context)),
name_(move(name)), name_(move(name)),
vendor_(move(vendor)), vendor_(move(vendor)),
version_(move(version)), version_(move(version)),
......
...@@ -140,7 +140,7 @@ public: ...@@ -140,7 +140,7 @@ public:
return data_[column + row * Size]; return data_[column + row * Size];
} }
typedef typename ivec::const_iterator const_iterator; using const_iterator = typename ivec::const_iterator;
const_iterator begin() const { const_iterator begin() const {
return data_.begin(); return data_.begin();
......
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