Commit e1ffb3bf authored by Dominik Charousset's avatar Dominik Charousset

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

parents 73bc4883 65431a50
...@@ -63,7 +63,7 @@ class option { ...@@ -63,7 +63,7 @@ class option {
option(T value) : m_valid(false) { cr(std::move(value)); } option(T value) : m_valid(false) { cr(std::move(value)); }
template<typename T0, typename T1, typename... Ts> template<typename T0, typename T1, typename... Ts>
option(T0&& arg0, T1&& arg1, Ts&&... args) { option(T0&& arg0, T1&& arg1, Ts&&... args) : m_valid(false) {
cr(T(std::forward<T0>(arg0), cr(T(std::forward<T0>(arg0),
std::forward<T1>(arg1), std::forward<T1>(arg1),
std::forward<Ts>(args)...)); std::forward<Ts>(args)...));
......
...@@ -86,12 +86,12 @@ class square_matrix { ...@@ -86,12 +86,12 @@ class square_matrix {
} }
inline float& operator()(size_t row, size_t column) { inline float& operator()(size_t column, size_t row) {
return m_data[row + column * Size]; return m_data[column + row * Size];
} }
inline const float& operator()(size_t row, size_t column) const { inline const float& operator()(size_t column, size_t row) const {
return m_data[row + column * Size]; return m_data[column + row * Size];
} }
inline void iota_fill() { inline void iota_fill() {
...@@ -118,9 +118,9 @@ template<size_t Size> ...@@ -118,9 +118,9 @@ template<size_t Size>
string to_string(const square_matrix<Size>& m) { string to_string(const square_matrix<Size>& m) {
ostringstream oss; ostringstream oss;
oss.fill(' '); oss.fill(' ');
for (size_t column = 0; column < Size; ++column) { for (size_t row = 0; row < Size; ++row) {
for (size_t row = 0; row < Size; ++row) { for (size_t column = 0; column < Size; ++column) {
oss << fixed << setprecision(2) << setw(9) << m(row, column); oss << fixed << setprecision(2) << setw(9) << m(column, row);
} }
oss << '\n'; oss << '\n';
} }
......
...@@ -122,18 +122,28 @@ void command_dispatcher::initialize() { ...@@ -122,18 +122,28 @@ void command_dispatcher::initialize() {
cl_int err{0}; cl_int err{0};
/* find up to two available platforms */ /* find up to two available platforms */
vector<cl_platform_id> ids(2);
cl_uint number_of_platforms; cl_uint number_of_platforms;
err = clGetPlatformIDs(ids.size(), ids.data(), &number_of_platforms); err = clGetPlatformIDs(0, nullptr, &number_of_platforms);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
ostringstream oss; ostringstream oss;
oss << "clGetPlatformIDs: " << get_opencl_error(err); oss << "clGetPlatformIDs (getting number of platforms): "
<< get_opencl_error(err);
CPPA_LOGMF(CPPA_ERROR, self, oss.str()); CPPA_LOGMF(CPPA_ERROR, self, oss.str());
throw logic_error(oss.str()); throw logic_error(oss.str());
} }
else if (number_of_platforms < 1) { else if (number_of_platforms < 1) {
ostringstream oss; ostringstream oss;
oss << "clGetPlatformIDs: 'no platforms found'."; oss << "clGetPlatformIDs: no platforms found.";
CPPA_LOGMF(CPPA_ERROR, self, oss.str());
throw logic_error(oss.str());
}
vector<cl_platform_id> ids(number_of_platforms);
err = clGetPlatformIDs(ids.size(), ids.data(), nullptr);
if (err != CL_SUCCESS) {
ostringstream oss;
oss << "clGetPlatformIDs (getting platform ids): "
<< get_opencl_error(err);
CPPA_LOGMF(CPPA_ERROR, self, oss.str()); CPPA_LOGMF(CPPA_ERROR, self, oss.str());
throw logic_error(oss.str()); throw logic_error(oss.str());
} }
......
...@@ -30,7 +30,7 @@ constexpr const char* kernel_source = R"__( ...@@ -30,7 +30,7 @@ constexpr const char* kernel_source = R"__(
for (size_t idx = 0; idx < size; ++idx) { for (size_t idx = 0; idx < size; ++idx) {
result += matrix[idx + y * size] * matrix[x + idx * size]; result += matrix[idx + y * size] * matrix[x + idx * size];
} }
output[x+y*size] = result; output[x + y * size] = result;
} }
)__"; )__";
...@@ -54,12 +54,12 @@ class square_matrix { ...@@ -54,12 +54,12 @@ class square_matrix {
assert(m_data.size() == num_elements); assert(m_data.size() == num_elements);
} }
inline float& operator()(size_t row, size_t column) { inline float& operator()(size_t column, size_t row) {
return m_data[row + column * Size]; return m_data[column + row * Size];
} }
inline const float& operator()(size_t row, size_t column) const { inline const float& operator()(size_t column, size_t row) const {
return m_data[row + column * Size]; return m_data[column + row * Size];
} }
inline void iota_fill() { inline void iota_fill() {
......
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