clover: Replace a bunch of double underscores with single underscores.

Identifiers with double underscores are reserved, and using them has
undefined behavior according to the C++ spec.  It's unlikely to make
any difference, but...

Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
Francisco Jerez
2013-09-17 23:13:48 -07:00
parent ebfdce079b
commit 8e14b82fd2
27 changed files with 208 additions and 206 deletions
@@ -25,7 +25,9 @@
using namespace clover;
static platform __platform;
namespace {
platform _clover_platform;
}
PUBLIC cl_int
clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
@@ -37,7 +39,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
if (num_platforms)
*num_platforms = 1;
if (platforms)
*platforms = &__platform;
*platforms = &_clover_platform;
return CL_SUCCESS;
}
@@ -45,7 +47,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
PUBLIC cl_int
clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
size_t size, void *buf, size_t *size_ret) {
if (platform != &__platform)
if (platform != &_clover_platform)
return CL_INVALID_PLATFORM;
switch (param_name) {
@@ -67,9 +67,9 @@ namespace {
/// \a T. The return value of get() should be implicitly
/// convertible to \a void *.
///
template<typename T> struct __map;
template<typename T> struct _map;
template<> struct __map<void *> {
template<> struct _map<void *> {
static void *
get(cl_command_queue q, void *obj, cl_map_flags flags,
size_t offset, size_t size) {
@@ -77,7 +77,7 @@ namespace {
}
};
template<> struct __map<const void *> {
template<> struct _map<const void *> {
static const void *
get(cl_command_queue q, const void *obj, cl_map_flags flags,
size_t offset, size_t size) {
@@ -85,7 +85,7 @@ namespace {
}
};
template<> struct __map<memory_obj *> {
template<> struct _map<memory_obj *> {
static mapping
get(cl_command_queue q, memory_obj *obj, cl_map_flags flags,
size_t offset, size_t size) {
@@ -104,9 +104,9 @@ namespace {
S src_obj, const point &src_orig, const point &src_pitch,
const point &region) {
return [=](event &) {
auto dst = __map<T>::get(q, dst_obj, CL_MAP_WRITE,
auto dst = _map<T>::get(q, dst_obj, CL_MAP_WRITE,
dst_pitch(dst_orig), dst_pitch(region));
auto src = __map<S>::get(q, src_obj, CL_MAP_READ,
auto src = _map<S>::get(q, src_obj, CL_MAP_READ,
src_pitch(src_orig), src_pitch(region));
point p;
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CL_UTIL_HPP__
#define __CL_UTIL_HPP__
#ifndef _CL_UTIL_HPP_
#define _CL_UTIL_HPP_
#include <cstdint>
#include <cstring>
+19 -19
View File
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_BASE_HPP__
#define __CORE_BASE_HPP__
#ifndef _CORE_BASE_HPP_
#define _CORE_BASE_HPP_
#include <stdexcept>
#include <atomic>
@@ -59,22 +59,22 @@ namespace clover {
///
class ref_counter {
public:
ref_counter() : __ref_count(1) {}
ref_counter() : _ref_count(1) {}
unsigned ref_count() {
return __ref_count;
return _ref_count;
}
void retain() {
__ref_count++;
_ref_count++;
}
bool release() {
return (--__ref_count) == 0;
return (--_ref_count) == 0;
}
private:
std::atomic<unsigned> __ref_count;
std::atomic<unsigned> _ref_count;
};
///
@@ -138,17 +138,17 @@ namespace clover {
}
template<typename T, typename S, int N>
struct __iter_helper {
struct _iter_helper {
template<typename F, typename Its, typename... Args>
static T
step(F op, S state, Its its, Args... args) {
return __iter_helper<T, S, N - 1>::step(
return _iter_helper<T, S, N - 1>::step(
op, state, its, *(std::get<N>(its)++), args...);
}
};
template<typename T, typename S>
struct __iter_helper<T, S, 0> {
struct _iter_helper<T, S, 0> {
template<typename F, typename Its, typename... Args>
static T
step(F op, S state, Its its, Args... args) {
@@ -156,19 +156,19 @@ namespace clover {
}
};
struct __empty {};
struct _empty {};
template<typename T>
struct __iter_helper<T, __empty, 0> {
struct _iter_helper<T, _empty, 0> {
template<typename F, typename Its, typename... Args>
static T
step(F op, __empty state, Its its, Args... args) {
step(F op, _empty state, Its its, Args... args) {
return op(*(std::get<0>(its)++), args...);
}
};
template<typename F, typename... Its>
struct __result_helper {
struct _result_helper {
typedef typename std::remove_const<
typename std::result_of<
F (typename std::iterator_traits<Its>::value_type...)
@@ -187,7 +187,7 @@ namespace clover {
F
for_each(F op, It0 it0, It0 end0, Its... its) {
while (it0 != end0)
__iter_helper<void, __empty, sizeof...(Its)>::step(
_iter_helper<void, _empty, sizeof...(Its)>::step(
op, {}, std::tie(it0, its...));
return op;
@@ -203,14 +203,14 @@ namespace clover {
///
template<typename F, typename It0, typename... Its,
typename C = std::vector<
typename __result_helper<F, It0, Its...>::type>>
typename _result_helper<F, It0, Its...>::type>>
C
map(F op, It0 it0, It0 end0, Its... its) {
C c;
while (it0 != end0)
c.push_back(
__iter_helper<typename C::value_type, __empty, sizeof...(Its)>
_iter_helper<typename C::value_type, _empty, sizeof...(Its)>
::step(op, {}, std::tie(it0, its...)));
return c;
@@ -228,7 +228,7 @@ namespace clover {
T
fold(F op, T a, It0 it0, It0 end0, Its... its) {
while (it0 != end0)
a = __iter_helper<T, T, sizeof...(Its)>::step(
a = _iter_helper<T, T, sizeof...(Its)>::step(
op, a, std::tie(it0, its...));
return a;
@@ -245,7 +245,7 @@ namespace clover {
bool
any_of(F op, It0 it0, It0 end0, Its... its) {
while (it0 != end0)
if (__iter_helper<bool, __empty, sizeof...(Its)>::step(
if (_iter_helper<bool, _empty, sizeof...(Its)>::step(
op, {}, std::tie(it0, its...)))
return true;
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_COMPAT_HPP__
#define __CORE_COMPAT_HPP__
#ifndef _CORE_COMPAT_HPP_
#define _CORE_COMPAT_HPP_
#include <new>
#include <cstring>
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_COMPILER_HPP__
#define __CORE_COMPILER_HPP__
#ifndef _CORE_COMPILER_HPP_
#define _CORE_COMPILER_HPP_
#include "core/compat.hpp"
#include "core/module.hpp"
@@ -28,7 +28,7 @@ using namespace clover;
_cl_context::_cl_context(const std::vector<cl_context_properties> &props,
const std::vector<device *> &devs) :
devs(devs), __props(props) {
devs(devs), _props(props) {
}
bool
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_CONTEXT_HPP__
#define __CORE_CONTEXT_HPP__
#ifndef _CORE_CONTEXT_HPP_
#define _CORE_CONTEXT_HPP_
#include "core/base.hpp"
#include "core/device.hpp"
@@ -39,13 +39,13 @@ public:
bool has_device(clover::device *dev) const;
const std::vector<cl_context_properties> &props() const {
return __props;
return _props;
}
const std::vector<clover::device *> devs;
private:
std::vector<cl_context_properties> __props;
std::vector<cl_context_properties> _props;
};
#endif
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_DEVICE_HPP__
#define __CORE_DEVICE_HPP__
#ifndef _CORE_DEVICE_HPP_
#define _CORE_DEVICE_HPP_
#include <set>
#include <vector>
@@ -28,7 +28,7 @@ using namespace clover;
_cl_event::_cl_event(clover::context &ctx,
std::vector<clover::event *> deps,
action action_ok, action action_fail) :
ctx(ctx), __status(0), wait_count(1),
ctx(ctx), _status(0), wait_count(1),
action_ok(action_ok), action_fail(action_fail) {
for (auto ev : deps)
ev->chain(this);
@@ -42,21 +42,21 @@ _cl_event::trigger() {
if (!--wait_count) {
action_ok(*this);
while (!__chain.empty()) {
__chain.back()->trigger();
__chain.pop_back();
while (!_chain.empty()) {
_chain.back()->trigger();
_chain.pop_back();
}
}
}
void
_cl_event::abort(cl_int status) {
__status = status;
_status = status;
action_fail(*this);
while (!__chain.empty()) {
__chain.back()->abort(status);
__chain.pop_back();
while (!_chain.empty()) {
_chain.back()->abort(status);
_chain.pop_back();
}
}
@@ -69,7 +69,7 @@ void
_cl_event::chain(clover::event *ev) {
if (wait_count) {
ev->wait_count++;
__chain.push_back(ev);
_chain.push_back(ev);
}
ev->deps.push_back(this);
}
@@ -77,7 +77,7 @@ _cl_event::chain(clover::event *ev) {
hard_event::hard_event(clover::command_queue &q, cl_command_type command,
std::vector<clover::event *> deps, action action) :
_cl_event(q.ctx, deps, profile(q, action), [](event &ev){}),
__queue(q), __command(command), __fence(NULL) {
_queue(q), _command(command), _fence(NULL) {
if (q.profiling_enabled())
_time_queued = timestamp::current(q);
@@ -87,20 +87,20 @@ hard_event::hard_event(clover::command_queue &q, cl_command_type command,
hard_event::~hard_event() {
pipe_screen *screen = queue()->dev.pipe;
screen->fence_reference(screen, &__fence, NULL);
screen->fence_reference(screen, &_fence, NULL);
}
cl_int
hard_event::status() const {
pipe_screen *screen = queue()->dev.pipe;
if (__status < 0)
return __status;
if (_status < 0)
return _status;
else if (!__fence)
else if (!_fence)
return CL_QUEUED;
else if (!screen->fence_signalled(screen, __fence))
else if (!screen->fence_signalled(screen, _fence))
return CL_SUBMITTED;
else
@@ -109,12 +109,12 @@ hard_event::status() const {
cl_command_queue
hard_event::queue() const {
return &__queue;
return &_queue;
}
cl_command_type
hard_event::command() const {
return __command;
return _command;
}
void
@@ -124,8 +124,8 @@ hard_event::wait() const {
if (status() == CL_QUEUED)
queue()->flush();
if (!__fence ||
!screen->fence_finish(screen, __fence, PIPE_TIMEOUT_INFINITE))
if (!_fence ||
!screen->fence_finish(screen, _fence, PIPE_TIMEOUT_INFINITE))
throw error(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
}
@@ -152,7 +152,7 @@ hard_event::time_end() const {
void
hard_event::fence(pipe_fence_handle *fence) {
pipe_screen *screen = queue()->dev.pipe;
screen->fence_reference(screen, &__fence, fence);
screen->fence_reference(screen, &_fence, fence);
}
event::action
@@ -176,16 +176,16 @@ hard_event::profile(command_queue &q, const action &action) const {
soft_event::soft_event(clover::context &ctx,
std::vector<clover::event *> deps,
bool __trigger, action action) :
bool _trigger, action action) :
_cl_event(ctx, deps, action, action) {
if (__trigger)
if (_trigger)
trigger();
}
cl_int
soft_event::status() const {
if (__status < 0)
return __status;
if (_status < 0)
return _status;
else if (!signalled() ||
any_of([](const ref_ptr<event> &ev) {
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_EVENT_HPP__
#define __CORE_EVENT_HPP__
#ifndef _CORE_EVENT_HPP_
#define _CORE_EVENT_HPP_
#include <functional>
@@ -73,14 +73,14 @@ public:
protected:
void chain(clover::event *ev);
cl_int __status;
cl_int _status;
std::vector<clover::ref_ptr<clover::event>> deps;
private:
unsigned wait_count;
action action_ok;
action action_fail;
std::vector<clover::ref_ptr<clover::event>> __chain;
std::vector<clover::ref_ptr<clover::event>> _chain;
};
namespace clover {
@@ -119,9 +119,9 @@ namespace clover {
virtual void fence(pipe_fence_handle *fence);
action profile(command_queue &q, const action &action) const;
clover::command_queue &__queue;
cl_command_type __command;
pipe_fence_handle *__fence;
clover::command_queue &_queue;
cl_command_type _command;
pipe_fence_handle *_fence;
lazy<cl_ulong> _time_queued, _time_submit, _time_start, _time_end;
};
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_FORMAT_HPP__
#define __CORE_FORMAT_HPP__
#ifndef _CORE_FORMAT_HPP_
#define _CORE_FORMAT_HPP_
#include <set>
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_GEOMETRY_HPP__
#define __CORE_GEOMETRY_HPP__
#ifndef _CORE_GEOMETRY_HPP_
#define _CORE_GEOMETRY_HPP_
#include <array>
#include <algorithm>
@@ -30,7 +30,7 @@ using namespace clover;
_cl_kernel::_cl_kernel(clover::program &prog,
const std::string &name,
const std::vector<clover::module::argument> &margs) :
prog(prog), __name(name), exec(*this) {
prog(prog), _name(name), exec(*this) {
for (auto marg : margs) {
if (marg.type == module::argument::scalar)
args.emplace_back(new scalar_argument(marg.size));
@@ -85,7 +85,7 @@ _cl_kernel::launch(clover::command_queue &q,
q.pipe->launch_grid(q.pipe,
pad_vector<uint>(q, block_size, 1).data(),
pad_vector<uint>(q, grid_size, 1).data(),
module(q).sym(__name).offset,
module(q).sym(_name).offset,
exec.input.data());
q.pipe->set_global_binding(q.pipe, 0, exec.g_buffers.size(), NULL, NULL);
@@ -120,7 +120,7 @@ _cl_kernel::max_block_size() const {
const std::string &
_cl_kernel::name() const {
return __name;
return _name;
}
std::vector<size_t>
@@ -143,8 +143,8 @@ _cl_kernel::exec_context::~exec_context() {
}
void *
_cl_kernel::exec_context::bind(clover::command_queue *__q) {
std::swap(q, __q);
_cl_kernel::exec_context::bind(clover::command_queue *_q) {
std::swap(q, _q);
// Bind kernel arguments.
auto margs = kern.module(*q).sym(kern.name()).args;
@@ -154,11 +154,11 @@ _cl_kernel::exec_context::bind(clover::command_queue *__q) {
}, kern.args.begin(), kern.args.end(), margs.begin());
// Create a new compute state if anything changed.
if (!st || q != __q ||
if (!st || q != _q ||
cs.req_local_mem != mem_local ||
cs.req_input_mem != input.size()) {
if (st)
__q->pipe->delete_compute_state(__q->pipe, st);
_q->pipe->delete_compute_state(_q->pipe, st);
cs.prog = kern.module(*q).sec(module::section::text).data.begin();
cs.req_local_mem = mem_local;
@@ -259,12 +259,12 @@ namespace {
}
}
_cl_kernel::argument::argument() : __set(false) {
_cl_kernel::argument::argument() : _set(false) {
}
bool
_cl_kernel::argument::set() const {
return __set;
return _set;
}
size_t
@@ -281,7 +281,7 @@ _cl_kernel::scalar_argument::set(size_t size, const void *value) {
throw error(CL_INVALID_ARG_SIZE);
v = { (uint8_t *)value, (uint8_t *)value + size };
__set = true;
_set = true;
}
void
@@ -308,7 +308,7 @@ _cl_kernel::global_argument::set(size_t size, const void *value) {
if (!obj)
throw error(CL_INVALID_MEM_OBJECT);
__set = true;
_set = true;
}
void
@@ -325,7 +325,7 @@ _cl_kernel::global_argument::unbind(exec_context &ctx) {
size_t
_cl_kernel::local_argument::storage() const {
return __storage;
return _storage;
}
void
@@ -333,8 +333,8 @@ _cl_kernel::local_argument::set(size_t size, const void *value) {
if (value)
throw error(CL_INVALID_ARG_VALUE);
__storage = size;
__set = true;
_storage = size;
_set = true;
}
void
@@ -347,7 +347,7 @@ _cl_kernel::local_argument::bind(exec_context &ctx,
align(ctx.input, marg.target_align);
insert(ctx.input, v);
ctx.mem_local += __storage;
ctx.mem_local += _storage;
}
void
@@ -363,7 +363,7 @@ _cl_kernel::constant_argument::set(size_t size, const void *value) {
if (!obj)
throw error(CL_INVALID_MEM_OBJECT);
__set = true;
_set = true;
}
void
@@ -394,7 +394,7 @@ _cl_kernel::image_rd_argument::set(size_t size, const void *value) {
if (!obj)
throw error(CL_INVALID_MEM_OBJECT);
__set = true;
_set = true;
}
void
@@ -425,7 +425,7 @@ _cl_kernel::image_wr_argument::set(size_t size, const void *value) {
if (!obj)
throw error(CL_INVALID_MEM_OBJECT);
__set = true;
_set = true;
}
void
@@ -453,7 +453,7 @@ _cl_kernel::sampler_argument::set(size_t size, const void *value) {
throw error(CL_INVALID_ARG_SIZE);
obj = *(cl_sampler *)value;
__set = true;
_set = true;
}
void
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_KERNEL_HPP__
#define __CORE_KERNEL_HPP__
#ifndef _CORE_KERNEL_HPP_
#define _CORE_KERNEL_HPP_
#include <memory>
@@ -88,7 +88,7 @@ public:
virtual void unbind(exec_context &ctx) = 0;
protected:
bool __set;
bool _set;
};
_cl_kernel(clover::program &prog,
@@ -149,7 +149,7 @@ private:
virtual void unbind(exec_context &ctx);
private:
size_t __storage;
size_t _storage;
};
class constant_argument : public argument {
@@ -200,7 +200,7 @@ private:
void *st;
};
std::string __name;
std::string _name;
exec_context exec;
};
@@ -27,35 +27,35 @@ using namespace clover;
_cl_mem::_cl_mem(clover::context &ctx, cl_mem_flags flags,
size_t size, void *host_ptr) :
ctx(ctx), __flags(flags),
__size(size), __host_ptr(host_ptr),
__destroy_notify([]{}) {
ctx(ctx), _flags(flags),
_size(size), _host_ptr(host_ptr),
_destroy_notify([]{}) {
if (flags & CL_MEM_COPY_HOST_PTR)
data.append((char *)host_ptr, size);
}
_cl_mem::~_cl_mem() {
__destroy_notify();
_destroy_notify();
}
void
_cl_mem::destroy_notify(std::function<void ()> f) {
__destroy_notify = f;
_destroy_notify = f;
}
cl_mem_flags
_cl_mem::flags() const {
return __flags;
return _flags;
}
size_t
_cl_mem::size() const {
return __size;
return _size;
}
void *
_cl_mem::host_ptr() const {
return __host_ptr;
return _host_ptr;
}
buffer::buffer(clover::context &ctx, cl_mem_flags flags,
@@ -93,7 +93,7 @@ sub_buffer::sub_buffer(clover::root_buffer &parent, cl_mem_flags flags,
size_t offset, size_t size) :
buffer(parent.ctx, flags, size,
(char *)parent.host_ptr() + offset),
parent(parent), __offset(offset) {
parent(parent), _offset(offset) {
}
clover::resource &
@@ -111,7 +111,7 @@ sub_buffer::resource(cl_command_queue q) {
size_t
sub_buffer::offset() const {
return __offset;
return _offset;
}
image::image(clover::context &ctx, cl_mem_flags flags,
@@ -120,8 +120,8 @@ image::image(clover::context &ctx, cl_mem_flags flags,
size_t row_pitch, size_t slice_pitch, size_t size,
void *host_ptr) :
memory_obj(ctx, flags, size, host_ptr),
__format(*format), __width(width), __height(height), __depth(depth),
__row_pitch(row_pitch), __slice_pitch(slice_pitch) {
_format(*format), _width(width), _height(height), _depth(depth),
_row_pitch(row_pitch), _slice_pitch(slice_pitch) {
}
clover::resource &
@@ -142,32 +142,32 @@ image::resource(cl_command_queue q) {
cl_image_format
image::format() const {
return __format;
return _format;
}
size_t
image::width() const {
return __width;
return _width;
}
size_t
image::height() const {
return __height;
return _height;
}
size_t
image::depth() const {
return __depth;
return _depth;
}
size_t
image::row_pitch() const {
return __row_pitch;
return _row_pitch;
}
size_t
image::slice_pitch() const {
return __slice_pitch;
return _slice_pitch;
}
image2d::image2d(clover::context &ctx, cl_mem_flags flags,
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_MEMORY_HPP__
#define __CORE_MEMORY_HPP__
#ifndef _CORE_MEMORY_HPP_
#define _CORE_MEMORY_HPP_
#include <functional>
#include <map>
@@ -57,10 +57,10 @@ public:
clover::context &ctx;
private:
cl_mem_flags __flags;
size_t __size;
void *__host_ptr;
std::function<void ()> __destroy_notify;
cl_mem_flags _flags;
size_t _size;
void *_host_ptr;
std::function<void ()> _destroy_notify;
protected:
std::string data;
@@ -99,7 +99,7 @@ namespace clover {
clover::root_buffer &parent;
private:
size_t __offset;
size_t _offset;
std::map<clover::device *,
std::unique_ptr<clover::sub_resource>> resources;
};
@@ -122,12 +122,12 @@ namespace clover {
size_t slice_pitch() const;
private:
cl_image_format __format;
size_t __width;
size_t __height;
size_t __depth;
size_t __row_pitch;
size_t __slice_pitch;
cl_image_format _format;
size_t _width;
size_t _height;
size_t _depth;
size_t _row_pitch;
size_t _slice_pitch;
std::map<clover::device *,
std::unique_ptr<clover::root_resource>> resources;
};
@@ -29,34 +29,34 @@ using namespace clover;
namespace {
template<typename T, typename = void>
struct __serializer;
struct _serializer;
/// Serialize the specified object.
template<typename T>
void
__proc(compat::ostream &os, const T &x) {
__serializer<T>::proc(os, x);
_proc(compat::ostream &os, const T &x) {
_serializer<T>::proc(os, x);
}
/// Deserialize the specified object.
template<typename T>
void
__proc(compat::istream &is, T &x) {
__serializer<T>::proc(is, x);
_proc(compat::istream &is, T &x) {
_serializer<T>::proc(is, x);
}
template<typename T>
T
__proc(compat::istream &is) {
_proc(compat::istream &is) {
T x;
__serializer<T>::proc(is, x);
_serializer<T>::proc(is, x);
return x;
}
/// (De)serialize a scalar value.
template<typename T>
struct __serializer<T, typename std::enable_if<
std::is_scalar<T>::value>::type> {
struct _serializer<T, typename std::enable_if<
std::is_scalar<T>::value>::type> {
static void
proc(compat::ostream &os, const T &x) {
os.write(reinterpret_cast<const char *>(&x), sizeof(x));
@@ -70,69 +70,69 @@ namespace {
/// (De)serialize a vector.
template<typename T>
struct __serializer<compat::vector<T>> {
struct _serializer<compat::vector<T>> {
static void
proc(compat::ostream &os, const compat::vector<T> &v) {
__proc<uint32_t>(os, v.size());
_proc<uint32_t>(os, v.size());
for (size_t i = 0; i < v.size(); i++)
__proc<T>(os, v[i]);
_proc<T>(os, v[i]);
}
static void
proc(compat::istream &is, compat::vector<T> &v) {
v.reserve(__proc<uint32_t>(is));
v.reserve(_proc<uint32_t>(is));
for (size_t i = 0; i < v.size(); i++)
new(&v[i]) T(__proc<T>(is));
new(&v[i]) T(_proc<T>(is));
}
};
/// (De)serialize a module::section.
template<>
struct __serializer<module::section> {
struct _serializer<module::section> {
template<typename S, typename QT>
static void
proc(S &s, QT &x) {
__proc(s, x.id);
__proc(s, x.type);
__proc(s, x.size);
__proc(s, x.data);
_proc(s, x.id);
_proc(s, x.type);
_proc(s, x.size);
_proc(s, x.data);
}
};
/// (De)serialize a module::argument.
template<>
struct __serializer<module::argument> {
struct _serializer<module::argument> {
template<typename S, typename QT>
static void
proc(S &s, QT &x) {
__proc(s, x.type);
__proc(s, x.size);
_proc(s, x.type);
_proc(s, x.size);
}
};
/// (De)serialize a module::symbol.
template<>
struct __serializer<module::symbol> {
struct _serializer<module::symbol> {
template<typename S, typename QT>
static void
proc(S &s, QT &x) {
__proc(s, x.name);
__proc(s, x.section);
__proc(s, x.offset);
__proc(s, x.args);
_proc(s, x.name);
_proc(s, x.section);
_proc(s, x.offset);
_proc(s, x.args);
}
};
/// (De)serialize a module.
template<>
struct __serializer<module> {
struct _serializer<module> {
template<typename S, typename QT>
static void
proc(S &s, QT &x) {
__proc(s, x.syms);
__proc(s, x.secs);
_proc(s, x.syms);
_proc(s, x.secs);
}
};
};
@@ -140,12 +140,12 @@ namespace {
namespace clover {
void
module::serialize(compat::ostream &os) const {
__proc(os, *this);
_proc(os, *this);
}
module
module::deserialize(compat::istream &is) {
return __proc<module>(is);
return _proc<module>(is);
}
const module::symbol &
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_MODULE_HPP__
#define __CORE_MODULE_HPP__
#ifndef _CORE_MODULE_HPP_
#define _CORE_MODULE_HPP_
#include "core/compat.hpp"
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_PLATFORM_HPP__
#define __CORE_PLATFORM_HPP__
#ifndef _CORE_PLATFORM_HPP_
#define _CORE_PLATFORM_HPP_
#include <vector>
@@ -27,7 +27,7 @@ using namespace clover;
_cl_program::_cl_program(clover::context &ctx,
const std::string &source) :
ctx(ctx), __source(source) {
ctx(ctx), _source(source) {
}
_cl_program::_cl_program(clover::context &ctx,
@@ -35,7 +35,7 @@ _cl_program::_cl_program(clover::context &ctx,
const std::vector<clover::module> &binaries) :
ctx(ctx) {
for_each([&](clover::device *dev, const clover::module &bin) {
__binaries.insert({ dev, bin });
_binaries.insert({ dev, bin });
},
devs.begin(), devs.end(), binaries.begin());
}
@@ -45,20 +45,20 @@ _cl_program::build(const std::vector<clover::device *> &devs,
const char *opts) {
for (auto dev : devs) {
__binaries.erase(dev);
__logs.erase(dev);
__opts.erase(dev);
_binaries.erase(dev);
_logs.erase(dev);
_opts.erase(dev);
__opts.insert({ dev, opts });
_opts.insert({ dev, opts });
try {
auto module = (dev->ir_format() == PIPE_SHADER_IR_TGSI ?
compile_program_tgsi(__source) :
compile_program_llvm(__source, dev->ir_format(),
compile_program_tgsi(_source) :
compile_program_llvm(_source, dev->ir_format(),
dev->ir_target(), build_opts(dev)));
__binaries.insert({ dev, module });
_binaries.insert({ dev, module });
} catch (build_error &e) {
__logs.insert({ dev, e.what() });
_logs.insert({ dev, e.what() });
throw error(CL_BUILD_PROGRAM_FAILURE);
} catch (invalid_option_error &e) {
throw error(CL_INVALID_BUILD_OPTIONS);
@@ -68,25 +68,25 @@ _cl_program::build(const std::vector<clover::device *> &devs,
const std::string &
_cl_program::source() const {
return __source;
return _source;
}
const std::map<clover::device *, clover::module> &
_cl_program::binaries() const {
return __binaries;
return _binaries;
}
cl_build_status
_cl_program::build_status(clover::device *dev) const {
return __binaries.count(dev) ? CL_BUILD_SUCCESS : CL_BUILD_NONE;
return _binaries.count(dev) ? CL_BUILD_SUCCESS : CL_BUILD_NONE;
}
std::string
_cl_program::build_opts(clover::device *dev) const {
return __opts.count(dev) ? __opts.find(dev)->second : "";
return _opts.count(dev) ? _opts.find(dev)->second : "";
}
std::string
_cl_program::build_log(clover::device *dev) const {
return __logs.count(dev) ? __logs.find(dev)->second : "";
return _logs.count(dev) ? _logs.find(dev)->second : "";
}
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_PROGRAM_HPP__
#define __CORE_PROGRAM_HPP__
#ifndef _CORE_PROGRAM_HPP_
#define _CORE_PROGRAM_HPP_
#include <map>
@@ -53,10 +53,10 @@ public:
clover::context &ctx;
private:
std::map<clover::device *, clover::module> __binaries;
std::map<clover::device *, std::string> __logs;
std::map<clover::device *, std::string> __opts;
std::string __source;
std::map<clover::device *, clover::module> _binaries;
std::map<clover::device *, std::string> _logs;
std::map<clover::device *, std::string> _opts;
std::string _source;
};
#endif
@@ -31,7 +31,7 @@ using namespace clover;
_cl_command_queue::_cl_command_queue(context &ctx, device &dev,
cl_command_queue_properties props) :
ctx(ctx), dev(dev), __props(props) {
ctx(ctx), dev(dev), _props(props) {
pipe = dev.pipe->context_create(dev.pipe, NULL);
if (!pipe)
throw error(CL_INVALID_DEVICE);
@@ -62,12 +62,12 @@ _cl_command_queue::flush() {
cl_command_queue_properties
_cl_command_queue::props() const {
return __props;
return _props;
}
bool
_cl_command_queue::profiling_enabled() const {
return __props & CL_QUEUE_PROFILING_ENABLE;
return _props & CL_QUEUE_PROFILING_ENABLE;
}
void
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_QUEUE_HPP__
#define __CORE_QUEUE_HPP__
#ifndef _CORE_QUEUE_HPP_
#define _CORE_QUEUE_HPP_
#include "core/base.hpp"
#include "core/context.hpp"
@@ -64,7 +64,7 @@ private:
/// and push it to the pending list.
void sequence(clover::hard_event *ev);
cl_command_queue_properties __props;
cl_command_queue_properties _props;
pipe_context *pipe;
typedef clover::ref_ptr<clover::hard_event> event_ptr;
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_RESOURCE_HPP__
#define __CORE_RESOURCE_HPP__
#ifndef _CORE_RESOURCE_HPP_
#define _CORE_RESOURCE_HPP_
#include <list>
@@ -28,23 +28,23 @@ using namespace clover;
_cl_sampler::_cl_sampler(clover::context &ctx, bool norm_mode,
cl_addressing_mode addr_mode,
cl_filter_mode filter_mode) :
ctx(ctx), __norm_mode(norm_mode),
__addr_mode(addr_mode), __filter_mode(filter_mode) {
ctx(ctx), _norm_mode(norm_mode),
_addr_mode(addr_mode), _filter_mode(filter_mode) {
}
bool
_cl_sampler::norm_mode() {
return __norm_mode;
return _norm_mode;
}
cl_addressing_mode
_cl_sampler::addr_mode() {
return __addr_mode;
return _addr_mode;
}
cl_filter_mode
_cl_sampler::filter_mode() {
return __filter_mode;
return _filter_mode;
}
void *
@@ -20,8 +20,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
#ifndef __CORE_SAMPLER_HPP__
#define __CORE_SAMPLER_HPP__
#ifndef _CORE_SAMPLER_HPP_
#define _CORE_SAMPLER_HPP_
#include "core/base.hpp"
#include "core/queue.hpp"
@@ -47,9 +47,9 @@ private:
void *bind(clover::command_queue &q);
void unbind(clover::command_queue &q, void *st);
bool __norm_mode;
cl_addressing_mode __addr_mode;
cl_filter_mode __filter_mode;
bool _norm_mode;
cl_addressing_mode _addr_mode;
cl_filter_mode _filter_mode;
};
#endif