Code quality: fixed implicit conversions from size_t to int_t

This commit is contained in:
Philippe Tillet
2015-08-13 14:30:11 -07:00
parent 9fda50863a
commit f7cb4ac960
11 changed files with 44 additions and 44 deletions

View File

@@ -232,8 +232,8 @@ ISAAC_DECLARE_DOT((max))
ISAAC_DECLARE_DOT((min)) ISAAC_DECLARE_DOT((min))
ISAAC_DECLARE_DOT(argmin) ISAAC_DECLARE_DOT(argmin)
ISAACAPI array_expression eye(std::size_t, std::size_t, isaac::numeric_type, driver::Context const & context = driver::backend::contexts::get_default()); ISAACAPI array_expression eye(int_t, int_t, isaac::numeric_type, driver::Context const & context = driver::backend::contexts::get_default());
ISAACAPI array_expression zeros(std::size_t M, std::size_t N, numeric_type dtype, driver::Context const & context = driver::backend::contexts::get_default()); ISAACAPI array_expression zeros(int_t M, int_t N, numeric_type dtype, driver::Context const & context = driver::backend::contexts::get_default());
ISAACAPI array_expression reshape(array const &, int_t, int_t); ISAACAPI array_expression reshape(array const &, int_t, int_t);
// //

View File

@@ -20,7 +20,7 @@ class ISAACAPI Buffer
friend class Kernel; friend class Kernel;
public: public:
Buffer(cl_mem Buffer, bool take_ownership = true); Buffer(cl_mem Buffer, bool take_ownership = true);
Buffer(Context const & context, std::size_t size); Buffer(Context const & context, int_t size);
Context const & context() const; Context const & context() const;
bool operator<(Buffer const &) const; bool operator<(Buffer const &) const;
bool operator==(Buffer const &) const; bool operator==(Buffer const &) const;

View File

@@ -28,14 +28,14 @@ class scalar;
class traversal_functor class traversal_functor
{ {
public: public:
void call_before_expansion(array_expression const &, int_t) const { } void call_before_expansion(array_expression const &, std::size_t) const { }
void call_after_expansion(array_expression const &, int_t) const { } void call_after_expansion(array_expression const &, std::size_t) const { }
}; };
/** @brief Recursively execute a functor on a array_expression */ /** @brief Recursively execute a functor on a array_expression */
template<class Fun> template<class Fun>
inline void traverse(isaac::array_expression const & array_expression, int_t root_idx, Fun const & fun, bool inspect) inline void traverse(isaac::array_expression const & array_expression, std::size_t root_idx, Fun const & fun, bool inspect)
{ {
array_expression::node const & root_node = array_expression.tree()[root_idx]; array_expression::node const & root_node = array_expression.tree()[root_idx];
bool recurse = detail::is_node_leaf(root_node.op)?inspect:true; bool recurse = detail::is_node_leaf(root_node.op)?inspect:true;
@@ -109,13 +109,13 @@ private:
public: public:
evaluate_expression_traversal(std::map<std::string, std::string> const & accessors, std::string & str, mapping_type const & mapping); evaluate_expression_traversal(std::map<std::string, std::string> const & accessors, std::string & str, mapping_type const & mapping);
void call_before_expansion(isaac::array_expression const & array_expression, int_t root_idx) const; void call_before_expansion(isaac::array_expression const & array_expression, std::size_t root_idx) const;
void call_after_expansion(array_expression const & /*array_expression*/, int_t /*root_idx*/) const; void call_after_expansion(array_expression const & /*array_expression*/, std::size_t /*root_idx*/) const;
void operator()(isaac::array_expression const & array_expression, int_t root_idx, leaf_t leaf) const; void operator()(isaac::array_expression const & array_expression, std::size_t root_idx, leaf_t leaf) const;
}; };
std::string evaluate(leaf_t leaf, std::map<std::string, std::string> const & accessors, std::string evaluate(leaf_t leaf, std::map<std::string, std::string> const & accessors,
isaac::array_expression const & array_expression, int_t root_idx, mapping_type const & mapping); isaac::array_expression const & array_expression, std::size_t root_idx, mapping_type const & mapping);
void evaluate(kernel_generation_stream & stream, leaf_t leaf, std::map<std::string, std::string> const & accessors, void evaluate(kernel_generation_stream & stream, leaf_t leaf, std::map<std::string, std::string> const & accessors,
expressions_tuple const & expressions, std::vector<mapping_type> const & mappings); expressions_tuple const & expressions, std::vector<mapping_type> const & mappings);
@@ -126,7 +126,7 @@ class process_traversal : public traversal_functor
public: public:
process_traversal(std::map<std::string, std::string> const & accessors, kernel_generation_stream & stream, process_traversal(std::map<std::string, std::string> const & accessors, kernel_generation_stream & stream,
mapping_type const & mapping, std::set<std::string> & already_processed); mapping_type const & mapping, std::set<std::string> & already_processed);
void operator()(array_expression const & array_expression, int_t root_idx, leaf_t leaf) const; void operator()(array_expression const & array_expression, std::size_t root_idx, leaf_t leaf) const;
private: private:
std::map<std::string, std::string> accessors_; std::map<std::string, std::string> accessors_;
kernel_generation_stream & stream_; kernel_generation_stream & stream_;
@@ -149,7 +149,7 @@ private:
public: public:
array_expression_representation_functor(symbolic_binder & binder, char *& ptr); array_expression_representation_functor(symbolic_binder & binder, char *& ptr);
void append(char*& p, const char * str) const; void append(char*& p, const char * str) const;
void operator()(isaac::array_expression const & array_expression, int_t root_idx, leaf_t leaf_t) const; void operator()(isaac::array_expression const & array_expression, std::size_t root_idx, leaf_t leaf_t) const;
private: private:
symbolic_binder & binder_; symbolic_binder & binder_;
char *& ptr_; char *& ptr_;

View File

@@ -89,8 +89,8 @@ private:
public: public:
typedef ParametersType parameters_type; typedef ParametersType parameters_type;
base_impl(parameters_type const & parameters, binding_policy_t binding_policy); base_impl(parameters_type const & parameters, binding_policy_t binding_policy);
int_t local_size_0() const; unsigned int local_size_0() const;
int_t local_size_1() const; unsigned int local_size_1() const;
std::shared_ptr<base> clone() const; std::shared_ptr<base> clone() const;
/** @brief returns whether or not the profile has undefined behavior on particular device */ /** @brief returns whether or not the profile has undefined behavior on particular device */
int is_invalid(expressions_tuple const & expressions, driver::Device const & device) const; int is_invalid(expressions_tuple const & expressions, driver::Device const & device) const;

View File

@@ -162,7 +162,7 @@ struct lhs_rhs_element
numeric_type dtype; numeric_type dtype;
union union
{ {
unsigned int node_index; std::size_t node_index;
values_holder vscalar; values_holder vscalar;
repeat_infos tuple; repeat_infos tuple;
isaac::array* array; isaac::array* array;
@@ -172,7 +172,7 @@ struct lhs_rhs_element
struct invalid_node{}; struct invalid_node{};
void fill(lhs_rhs_element &x, invalid_node); void fill(lhs_rhs_element &x, invalid_node);
void fill(lhs_rhs_element & x, unsigned int node_index); void fill(lhs_rhs_element & x, std::size_t node_index);
void fill(lhs_rhs_element & x, array const & a); void fill(lhs_rhs_element & x, array const & a);
void fill(lhs_rhs_element & x, value_scalar const & v); void fill(lhs_rhs_element & x, value_scalar const & v);
void fill(lhs_rhs_element & x, repeat_infos const & r); void fill(lhs_rhs_element & x, repeat_infos const & r);

View File

@@ -566,10 +566,10 @@ array_expression cast(array const & x, numeric_type dtype)
array_expression cast(array_expression const & x, numeric_type dtype) array_expression cast(array_expression const & x, numeric_type dtype)
{ return array_expression(x, invalid_node(), op_element(OPERATOR_UNARY_TYPE_FAMILY, casted(dtype)), x.context(), dtype, x.shape()); } { return array_expression(x, invalid_node(), op_element(OPERATOR_UNARY_TYPE_FAMILY, casted(dtype)), x.context(), dtype, x.shape()); }
isaac::array_expression eye(std::size_t M, std::size_t N, isaac::numeric_type dtype, driver::Context const & ctx) isaac::array_expression eye(int_t M, int_t N, isaac::numeric_type dtype, driver::Context const & ctx)
{ return array_expression(value_scalar(1), value_scalar(0), op_element(OPERATOR_UNARY_TYPE_FAMILY, OPERATOR_VDIAG_TYPE), ctx, dtype, size4(M, N)); } { return array_expression(value_scalar(1), value_scalar(0), op_element(OPERATOR_UNARY_TYPE_FAMILY, OPERATOR_VDIAG_TYPE), ctx, dtype, size4(M, N)); }
isaac::array_expression zeros(std::size_t M, std::size_t N, isaac::numeric_type dtype, driver::Context const & ctx) isaac::array_expression zeros(int_t M, int_t N, isaac::numeric_type dtype, driver::Context const & ctx)
{ return array_expression(value_scalar(0, dtype), invalid_node(), op_element(OPERATOR_UNARY_TYPE_FAMILY, OPERATOR_ADD_TYPE), ctx, dtype, size4(M, N)); } { return array_expression(value_scalar(0, dtype), invalid_node(), op_element(OPERATOR_UNARY_TYPE_FAMILY, OPERATOR_ADD_TYPE), ctx, dtype, size4(M, N)); }
inline size4 flip(size4 const & shape) inline size4 flip(size4 const & shape)

View File

@@ -14,7 +14,7 @@ Buffer::Buffer(cl_mem buffer, bool take_ownership) : backend_(OPENCL), context_(
h_.cl() = buffer; h_.cl() = buffer;
} }
Buffer::Buffer(Context const & context, std::size_t size) : backend_(context.backend_), context_(context), h_(backend_, true) Buffer::Buffer(Context const & context, int_t size) : backend_(context.backend_), context_(context), h_(backend_, true)
{ {
switch(backend_) switch(backend_)
{ {

View File

@@ -234,7 +234,7 @@ evaluate_expression_traversal::evaluate_expression_traversal(std::map<std::strin
accessors_(accessors), str_(str), mapping_(mapping) accessors_(accessors), str_(str), mapping_(mapping)
{ } { }
void evaluate_expression_traversal::call_before_expansion(isaac::array_expression const & array_expression, int_t root_idx) const void evaluate_expression_traversal::call_before_expansion(isaac::array_expression const & array_expression, std::size_t root_idx) const
{ {
array_expression::node const & root_node = array_expression.tree()[root_idx]; array_expression::node const & root_node = array_expression.tree()[root_idx];
if(detail::is_cast(root_node.op)) if(detail::is_cast(root_node.op))
@@ -246,12 +246,12 @@ void evaluate_expression_traversal::call_before_expansion(isaac::array_expressio
} }
void evaluate_expression_traversal::call_after_expansion(array_expression const & /*array_expression*/, int_t /*root_idx*/) const void evaluate_expression_traversal::call_after_expansion(array_expression const & /*array_expression*/, std::size_t /*root_idx*/) const
{ {
str_+=")"; str_+=")";
} }
void evaluate_expression_traversal::operator()(isaac::array_expression const & array_expression, int_t root_idx, leaf_t leaf) const void evaluate_expression_traversal::operator()(isaac::array_expression const & array_expression, std::size_t root_idx, leaf_t leaf) const
{ {
array_expression::node const & root_node = array_expression.tree()[root_idx]; array_expression::node const & root_node = array_expression.tree()[root_idx];
mapping_type::key_type key = std::make_pair(root_idx, leaf); mapping_type::key_type key = std::make_pair(root_idx, leaf);
@@ -285,7 +285,7 @@ void evaluate_expression_traversal::operator()(isaac::array_expression const & a
std::string evaluate(leaf_t leaf, std::map<std::string, std::string> const & accessors, std::string evaluate(leaf_t leaf, std::map<std::string, std::string> const & accessors,
isaac::array_expression const & array_expression, int_t root_idx, mapping_type const & mapping) isaac::array_expression const & array_expression, std::size_t root_idx, mapping_type const & mapping)
{ {
std::string res; std::string res;
evaluate_expression_traversal traversal_functor(accessors, res, mapping); evaluate_expression_traversal traversal_functor(accessors, res, mapping);
@@ -326,7 +326,7 @@ process_traversal::process_traversal(std::map<std::string, std::string> const &
accessors_(accessors), stream_(stream), mapping_(mapping), already_processed_(already_processed) accessors_(accessors), stream_(stream), mapping_(mapping), already_processed_(already_processed)
{ } { }
void process_traversal::operator()(array_expression const & /*array_expression*/, int_t root_idx, leaf_t leaf) const void process_traversal::operator()(array_expression const & /*array_expression*/, std::size_t root_idx, leaf_t leaf) const
{ {
mapping_type::const_iterator it = mapping_.find(std::make_pair(root_idx, leaf)); mapping_type::const_iterator it = mapping_.find(std::make_pair(root_idx, leaf));
if (it!=mapping_.end()) if (it!=mapping_.end())
@@ -422,7 +422,7 @@ void array_expression_representation_functor::append(char*& p, const char * str)
p+=n; p+=n;
} }
void array_expression_representation_functor::operator()(isaac::array_expression const & array_expression, int_t root_idx, leaf_t leaf_t) const void array_expression_representation_functor::operator()(isaac::array_expression const & array_expression, std::size_t root_idx, leaf_t leaf_t) const
{ {
array_expression::node const & root_node = array_expression.tree()[root_idx]; array_expression::node const & root_node = array_expression.tree()[root_idx];
if (leaf_t==LHS_NODE_TYPE && root_node.lhs.type_family != COMPOSITE_OPERATOR_FAMILY) if (leaf_t==LHS_NODE_TYPE && root_node.lhs.type_family != COMPOSITE_OPERATOR_FAMILY)

View File

@@ -111,11 +111,11 @@ base_impl<TType, PType>::base_impl(parameters_type const & parameters, binding_p
{ } { }
template<class TType, class PType> template<class TType, class PType>
int_t base_impl<TType, PType>::local_size_0() const unsigned int base_impl<TType, PType>::local_size_0() const
{ return p_.local_size_0; } { return p_.local_size_0; }
template<class TType, class PType> template<class TType, class PType>
int_t base_impl<TType, PType>::local_size_1() const unsigned int base_impl<TType, PType>::local_size_1() const
{ return p_.local_size_1; } { return p_.local_size_1; }
template<class TType, class PType> template<class TType, class PType>

View File

@@ -15,7 +15,7 @@ void fill(lhs_rhs_element &x, invalid_node)
x.dtype = INVALID_NUMERIC_TYPE; x.dtype = INVALID_NUMERIC_TYPE;
} }
void fill(lhs_rhs_element & x, unsigned int node_index) void fill(lhs_rhs_element & x, std::size_t node_index)
{ {
x.type_family = COMPOSITE_OPERATOR_FAMILY; x.type_family = COMPOSITE_OPERATOR_FAMILY;
x.subtype = INVALID_SUBTYPE; x.subtype = INVALID_SUBTYPE;

View File

@@ -53,8 +53,8 @@ extern "C"
cl_uint numEventsInWaitList, const cl_event *eventWaitList, \ cl_uint numEventsInWaitList, const cl_event *eventWaitList, \
cl_event *events) \ cl_event *events) \
{ \ { \
is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx,false), offx, incx); \ is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx,false), (is::int_t)offx, incx); \
is::array y(N, TYPE_ISAAC, is::driver::Buffer(my,false), offy, incy); \ is::array y(N, TYPE_ISAAC, is::driver::Buffer(my,false), (is::int_t)offy, incy); \
execute(is::assign(y, alpha*x + y), y.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events); \ execute(is::assign(y, alpha*x + y), y.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events); \
return clblasSuccess; \ return clblasSuccess; \
} }
@@ -69,7 +69,7 @@ extern "C"
cl_uint numCommandQueues, cl_command_queue *commandQueues,\ cl_uint numCommandQueues, cl_command_queue *commandQueues,\
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *events)\ cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *events)\
{\ {\
is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx,false), offx, incx);\ is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx,false), (is::int_t)offx, incx);\
execute(is::assign(x, alpha*x), x.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events);\ execute(is::assign(x, alpha*x), x.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events);\
return clblasSuccess;\ return clblasSuccess;\
} }
@@ -85,8 +85,8 @@ extern "C"
cl_uint numCommandQueues, cl_command_queue *commandQueues,\ cl_uint numCommandQueues, cl_command_queue *commandQueues,\
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *events)\ cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *events)\
{\ {\
const is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx, false), offx, incx);\ const is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx, false), (is::int_t)offx, incx);\
is::array y(N, TYPE_ISAAC, is::driver::Buffer(my, false), offy, incy);\ is::array y(N, TYPE_ISAAC, is::driver::Buffer(my, false), (is::int_t)offy, incy);\
execute(is::assign(y, x), y.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events);\ execute(is::assign(y, x), y.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events);\
return clblasSuccess;\ return clblasSuccess;\
} }
@@ -103,9 +103,9 @@ extern "C"
cl_command_queue *commandQueues, cl_uint numEventsInWaitList, \ cl_command_queue *commandQueues, cl_uint numEventsInWaitList, \
const cl_event *eventWaitList, cl_event *events) \ const cl_event *eventWaitList, cl_event *events) \
{ \ { \
is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx, false), offx, incx); \ is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx, false), (is::int_t)offx, incx); \
is::array y(N, TYPE_ISAAC, is::driver::Buffer(my, false), offy, incy); \ is::array y(N, TYPE_ISAAC, is::driver::Buffer(my, false), (is::int_t)offy, incy); \
is::scalar s(TYPE_ISAAC, is::driver::Buffer(dotProduct, false), offDP); \ is::scalar s(TYPE_ISAAC, is::driver::Buffer(dotProduct, false), (is::int_t)offDP); \
execute(is::assign(s, dot(x,y)), s.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events); \ execute(is::assign(s, dot(x,y)), s.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events); \
return clblasSuccess; \ return clblasSuccess; \
} }
@@ -120,8 +120,8 @@ extern "C"
cl_mem /*scratchBuff*/, cl_uint numCommandQueues, cl_command_queue *commandQueues,\ cl_mem /*scratchBuff*/, cl_uint numCommandQueues, cl_command_queue *commandQueues,\
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *events)\ cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *events)\
{\ {\
is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx, false), offx, incx);\ is::array x(N, TYPE_ISAAC, is::driver::Buffer(mx, false), (is::int_t)offx, incx);\
is::scalar s(TYPE_ISAAC, is::driver::Buffer(asum, false), offAsum);\ is::scalar s(TYPE_ISAAC, is::driver::Buffer(asum, false), (is::int_t)offAsum);\
execute(is::assign(s, sum(abs(x))), s.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events);\ execute(is::assign(s, sum(abs(x))), s.context(), numCommandQueues, commandQueues, numEventsInWaitList, eventWaitList, events);\
return clblasSuccess;\ return clblasSuccess;\
} }
@@ -145,12 +145,12 @@ extern "C"
std::swap(M, N);\ std::swap(M, N);\
transA = (transA==clblasTrans)?clblasNoTrans:clblasTrans;\ transA = (transA==clblasTrans)?clblasNoTrans:clblasTrans;\
}\ }\
is::array A(M, N, TYPE_ISAAC, is::driver::Buffer(mA, false), offA, lda);\ is::array A(M, N, TYPE_ISAAC, is::driver::Buffer(mA, false), (is::int_t)offA, lda);\
\ \
is::int_t sx = N, sy = M;\ is::int_t sx = N, sy = M;\
if(transA) std::swap(sx, sy);\ if(transA) std::swap(sx, sy);\
is::array x(sx, TYPE_ISAAC, is::driver::Buffer(mx, false), offx, incx);\ is::array x(sx, TYPE_ISAAC, is::driver::Buffer(mx, false), (is::int_t)offx, incx);\
is::array y(sy, TYPE_ISAAC, is::driver::Buffer(my, false), offy, incy);\ is::array y(sy, TYPE_ISAAC, is::driver::Buffer(my, false), (is::int_t)offy, incy);\
\ \
is::driver::Context const & context = A.context();\ is::driver::Context const & context = A.context();\
if(transA==clblasTrans)\ if(transA==clblasTrans)\
@@ -191,9 +191,9 @@ extern "C"
if(transA==clblasTrans) std::swap(As1, As2);\ if(transA==clblasTrans) std::swap(As1, As2);\
if(transB==clblasTrans) std::swap(Bs1, Bs2);\ if(transB==clblasTrans) std::swap(Bs1, Bs2);\
/*Struct*/\ /*Struct*/\
is::array A(As1, As2, TYPE_ISAAC, is::driver::Buffer(mA, false), offA, lda);\ is::array A(As1, As2, TYPE_ISAAC, is::driver::Buffer(mA, false), (is::int_t)offA, lda);\
is::array B(Bs1, Bs2, TYPE_ISAAC, is::driver::Buffer(mB, false), offB, ldb);\ is::array B(Bs1, Bs2, TYPE_ISAAC, is::driver::Buffer(mB, false), (is::int_t)offB, ldb);\
is::array C(M, N, TYPE_ISAAC, is::driver::Buffer(mC, false), offC, ldc);\ is::array C(M, N, TYPE_ISAAC, is::driver::Buffer(mC, false), (is::int_t)offC, ldc);\
is::driver::Context const & context = C.context();\ is::driver::Context const & context = C.context();\
/*Operation*/\ /*Operation*/\
if((transA==clblasTrans) && (transB==clblasTrans))\ if((transA==clblasTrans) && (transB==clblasTrans))\