Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'unstable' of github.com:Neverlord/libcppa into unstable

  • Loading branch information...
commit 2aea804aa84095d64414717eb18fffc583742d5b 2 parents 006f414 + 2c9553f
@Neverlord Neverlord authored
View
4 cppa/opencl/actor_facade.hpp
@@ -103,9 +103,7 @@ class actor_facade<Ret(Args...)> : public actor {
&err));
if (err != CL_SUCCESS) {
std::ostringstream oss;
- oss << "clCreateKernel: '"
- << get_opencl_error(err)
- << "'.";
+ oss << "clCreateKernel: " << get_opencl_error(err);
CPPA_LOGM_ERROR(detail::demangle<actor_facade>(), oss.str());
throw std::runtime_error(oss.str());
}
View
54 src/opencl/command_dispatcher.cpp
@@ -79,16 +79,14 @@ struct command_dispatcher::worker {
cl_int err{clFlush(cmd_q)};
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "clFlush: '"
- << get_opencl_error(err)
- << "'.";
+ oss << "clFlush: " << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
}
catch (exception& e) {
ostringstream oss;
- oss << "worker loop, e.what(): '" << e.what() << "'.";
+ oss << "worker loop, e.what(): " << e.what();
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -129,9 +127,7 @@ void command_dispatcher::initialize() {
err = clGetPlatformIDs(ids.size(), ids.data(), &number_of_platforms);
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "clGetPlatformIDs: '"
- << get_opencl_error(err)
- << "'.";
+ oss << "clGetPlatformIDs: " << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw logic_error(oss.str());
}
@@ -155,9 +151,7 @@ void command_dispatcher::initialize() {
}
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "clGetDeviceIDs: '"
- << get_opencl_error(err)
- << "'.";
+ oss << "clGetDeviceIDs: " << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -165,9 +159,7 @@ void command_dispatcher::initialize() {
err = clGetDeviceIDs(ids[pid], dev_type, num_devices, devices.data(), nullptr);
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "clGetDeviceIDs: '"
- << get_opencl_error(err)
- << "'.";
+ oss << "clGetDeviceIDs: " << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -176,9 +168,7 @@ void command_dispatcher::initialize() {
m_context.adopt(clCreateContext(0, 1, devices.data(), nullptr, nullptr, &err));
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "clCreateContext: '"
- << get_opencl_error(err)
- << "'.";
+ oss << "clCreateContext: " << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -193,11 +183,7 @@ void command_dispatcher::initialize() {
char buf[buf_size];
err = clGetDeviceInfo(device.get(), CL_DEVICE_NAME, buf_size, buf, &return_size);
if (err != CL_SUCCESS) {
- ostringstream oss;
- oss << "clGetDeviceInfo (CL_DEVICE_NAME): '"
- << get_opencl_error(err)
- << "'.";
- CPPA_LOG_ERROR(oss.str());
+ CPPA_LOG_ERROR("clGetDeviceInfo (CL_DEVICE_NAME): " << get_opencl_error(err));
fill(buf, buf+buf_size, 0);
}
command_queue_ptr cmd_queue;
@@ -207,8 +193,7 @@ void command_dispatcher::initialize() {
&err));
if (err != CL_SUCCESS) {
CPPA_LOG_DEBUG("Could not create command queue for device "
- << buf << ": '" << get_opencl_error(err)
- << "'.");
+ << buf << ": " << get_opencl_error(err));
}
else {
size_t max_work_group_size{0};
@@ -219,10 +204,9 @@ void command_dispatcher::initialize() {
&return_size);
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "[!!!] clGetDeviceInfo ("
- << id
- << ":CL_DEVICE_MAX_WORK_GROUP_SIZE): '"
- << get_opencl_error(err) << "'.";
+ oss << "clGetDeviceInfo (" << id
+ << ":CL_DEVICE_MAX_WORK_GROUP_SIZE): "
+ << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -234,10 +218,9 @@ void command_dispatcher::initialize() {
&return_size);
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "[!!!] clGetDeviceInfo ("
- << id
- << ":CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS): '"
- << get_opencl_error(err) << "'.";
+ oss << "clGetDeviceInfo (" << id
+ << ":CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS): "
+ << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -249,10 +232,9 @@ void command_dispatcher::initialize() {
&return_size);
if (err != CL_SUCCESS) {
ostringstream oss;
- oss << "[!!!] clGetDeviceInfo ("
- << id
- << ":CL_DEVICE_MAX_WORK_ITEM_SIZES): '"
- << get_opencl_error(err) << "'.";
+ oss << "clGetDeviceInfo (" << id
+ << ":CL_DEVICE_MAX_WORK_ITEM_SIZES): "
+ << get_opencl_error(err);
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
}
@@ -267,7 +249,7 @@ void command_dispatcher::initialize() {
}
if (m_devices.empty()) {
ostringstream oss;
- oss << "[!!!] Could not create a command queue for "
+ oss << "Could not create a command queue for "
<< "any of the present devices.";
CPPA_LOG_ERROR(oss.str());
throw runtime_error(oss.str());
View
16 src/opencl/program.cpp
@@ -36,8 +36,6 @@
namespace cppa { namespace opencl {
-//program::program() : m_context(nullptr), pptr(nullptr) { }
-
program::program(context_ptr context, program_ptr program)
: m_context(std::move(context)), m_program(std::move(program)) { }
@@ -56,9 +54,8 @@ program program::create(const char* kernel_source) {
&err));
if (err != CL_SUCCESS) {
- throw std::runtime_error("clCreateProgramWithSource: '"
- + get_opencl_error(err)
- + "'.");
+ throw std::runtime_error("clCreateProgramWithSource: "
+ + get_opencl_error(err));
}
// build programm from program object
@@ -90,10 +87,8 @@ program program::create(const char* kernel_source) {
nullptr);
build_log[ret_val_size] = '\0';
std::ostringstream oss;
- oss << "clBuildProgram: '"
- << get_opencl_error(err)
- << "'. Build log: "
- << build_log.data();
+ oss << "clBuildProgram: " << get_opencl_error(err)
+ << ", build log: " << build_log.data();
CPPA_LOGM_ERROR(detail::demangle<program>(), oss.str());
throw std::runtime_error(oss.str());
}
@@ -124,7 +119,8 @@ program program::create(const char* kernel_source) {
build_log.data(),
nullptr);
build_log[ret_val_size] = '\0';
- CPPA_LOG_DEBUG("clBuildProgram log: '" << build_log.data());
+ CPPA_LOG_DEBUG("clBuildProgram build log: "
+ << build_log.data());
# endif
}
return {cptr, pptr};
View
61 unit_testing/test_opencl.cpp
@@ -23,7 +23,6 @@ constexpr const char* kernel_name = "matrix_square";
constexpr const char* kernel_source = R"__(
__kernel void matrix_square(__global int* matrix,
__global int* output) {
- // we only use square matrices, hence: width == height
size_t size = get_global_size(0); // == get_global_size_(1);
size_t x = get_global_id(0);
size_t y = get_global_id(1);
@@ -107,6 +106,7 @@ int main() {
,152,174,196,218
,248,286,324,362
,344,398,452,506};
+
auto worker1 = spawn_cl<ivec(ivec&)>(program::create(kernel_source),
kernel_name,
{matrix_size,matrix_size});
@@ -119,25 +119,52 @@ int main() {
}
);
- CPPA_CHECKPOINT();
+ auto worker2 = spawn_cl<ivec(ivec&)>(kernel_source,
+ kernel_name,
+ {matrix_size,matrix_size});
+ ivec m2(matrix_size * matrix_size);
+ iota(m2.begin(), m2.end(), 0);
+ send(worker2, move(m2));
+ receive (
+ on_arg_match >> [&] (const ivec& result) {
+ CPPA_CHECK(equal(begin(expected1), end(expected1), begin(result)));
+ }
+ );
+
const matrix_type expected2(move(expected1));
- matrix_type m2;
- m2.iota_fill();
- auto worker2 = spawn_cl(kernel_source, kernel_name,
- [] (any_tuple msg) -> option<cow_tuple<ivec>> {
- auto opt = tuple_cast<matrix_type>(msg);
- if (opt) {
- return {move(get_ref<0>(*opt).data())};
- }
- return {};
- },
- [] (ivec& result) -> any_tuple {
- return make_any_tuple(matrix_type{move(result)});
- },
- {matrix_size, matrix_size}
+
+ auto map_args = [] (any_tuple msg) -> option<cow_tuple<ivec>> {
+ auto opt = tuple_cast<matrix_type>(msg);
+ if (opt) {
+ return {move(get_ref<0>(*opt).data())};
+ }
+ return {};
+ };
+
+ auto map_results = [] (ivec& result) -> any_tuple {
+ return make_any_tuple(matrix_type{move(result)});
+ };
+
+ matrix_type m3;
+ m3.iota_fill();
+ auto worker3 = spawn_cl(program::create(kernel_source), kernel_name,
+ map_args, map_results,
+ {matrix_size, matrix_size});
+ send(worker3, move(m3));
+ receive (
+ on_arg_match >> [&] (const matrix_type& result) {
+ CPPA_CHECK(expected2 == result);
+ }
);
- send(worker2, move(m2));
+
+ matrix_type m4;
+ m4.iota_fill();
+ auto worker4 = spawn_cl(kernel_source, kernel_name,
+ map_args, map_results,
+ {matrix_size, matrix_size}
+ );
+ send(worker4, move(m4));
receive (
on_arg_match >> [&] (const matrix_type& result) {
CPPA_CHECK(expected2 == result);
Please sign in to comment.
Something went wrong with that request. Please try again.