diff --git a/bench/blas.cpp b/bench/blas.cpp index cdfacc782..a8399ac8c 100644 --- a/bench/blas.cpp +++ b/bench/blas.cpp @@ -304,7 +304,7 @@ void bench(sc::numeric_type dtype, std::string operation) void handle_misusage(){ std::cerr << "Usage : blas-bench [--dtype {float32, float64}] [--device DEVICE_IDX] [--help]" << std::endl; -// std::cerr << "--op: operation to benchmark" << std::endl; + std::cerr << "--op: operation to benchmark" << std::endl; std::cerr << "--dtype: data-type to benchmark" << std::endl; std::cerr << "--device: index of isaac device in [0, ..., ndevices - 1]" << std::endl; std::cerr << "--help: display this message" << std::endl; @@ -341,7 +341,7 @@ int main(int argc, char* argv[]) if(std::find(args.begin(), args.end(), "--help") != args.end()) handle_misusage(); - std::string operation = "gemm"; + std::string operation = getopt(args, "--op", {"axpy", "dot", "gemv", "gemm"}, "gemm"); std::string dtype = getopt(args, "--dtype", {"float32", "float64"}, "float32"); int device; try{ diff --git a/build/bench/bench-blas b/build/bench/bench-blas index 8decf3f0a..dbd0236e6 100755 Binary files a/build/bench/bench-blas and b/build/bench/bench-blas differ diff --git a/include/isaac/array.h b/include/isaac/array.h index 91ebbd11d..06ab5b631 100644 --- a/include/isaac/array.h +++ b/include/isaac/array.h @@ -106,7 +106,6 @@ public: array_base& operator/=(expression_tree const &); //Indexing (1D) - expression_tree operator[](placeholder idx) const; const scalar operator[](int_t) const; scalar operator[](int_t); view operator[](slice const &); @@ -208,22 +207,14 @@ template ISAACAPI void copy(array_base const & gA, std::vector & cA, #define ISAAC_DECLARE_ELEMENT_BINARY_OPERATOR(OPNAME) \ ISAACAPI expression_tree OPNAME (array_base const & x, expression_tree const & y);\ ISAACAPI expression_tree OPNAME (array_base const & x, value_scalar const & y);\ -ISAACAPI expression_tree OPNAME (array_base const & x, placeholder const & y);\ ISAACAPI expression_tree OPNAME (array_base const & x, array_base const & y);\ \ ISAACAPI expression_tree OPNAME (expression_tree const & x, expression_tree const & y);\ ISAACAPI expression_tree OPNAME (expression_tree const & x, value_scalar const & y);\ -ISAACAPI expression_tree OPNAME (expression_tree const & x, placeholder const & y);\ ISAACAPI expression_tree OPNAME (expression_tree const & x, array_base const & y);\ \ ISAACAPI expression_tree OPNAME (value_scalar const & y, expression_tree const & x);\ -ISAACAPI expression_tree OPNAME (value_scalar const & y, placeholder const & x);\ ISAACAPI expression_tree OPNAME (value_scalar const & y, array_base const & x);\ -\ -ISAACAPI expression_tree OPNAME (placeholder const & y, expression_tree const & x);\ -ISAACAPI expression_tree OPNAME (placeholder const & y, placeholder const & x);\ -ISAACAPI expression_tree OPNAME (placeholder const & y, value_scalar const & x);\ -ISAACAPI expression_tree OPNAME (placeholder const & y, array_base const & x); ISAAC_DECLARE_ELEMENT_BINARY_OPERATOR(operator +) ISAAC_DECLARE_ELEMENT_BINARY_OPERATOR(operator -) @@ -321,19 +312,6 @@ ISAACAPI expression_tree mean(expression_tree const &, int_t axis = -1); //Fusion ISAACAPI expression_tree fuse(expression_tree const & x, expression_tree const & y); -//For -ISAACAPI expression_tree sfor(expression_tree const & start, expression_tree const & end, expression_tree const & inc, expression_tree const & expression); -static const placeholder _i0{0}; -static const placeholder _i1{1}; -static const placeholder _i2{2}; -static const placeholder _i3{3}; -static const placeholder _i4{4}; -static const placeholder _i5{5}; -static const placeholder _i6{6}; -static const placeholder _i7{7}; -static const placeholder _i8{8}; -static const placeholder _i9{9}; - //Initializers ISAACAPI expression_tree eye(int_t, int_t, isaac::numeric_type, driver::Context const & context = driver::backend::contexts::get_default()); ISAACAPI expression_tree zeros(tuple const & shape, numeric_type dtype, driver::Context const & context = driver::backend::contexts::get_default()); diff --git a/include/isaac/jit/syntax/expression/expression.h b/include/isaac/jit/syntax/expression/expression.h index 28e6881c1..9aa3a3389 100644 --- a/include/isaac/jit/syntax/expression/expression.h +++ b/include/isaac/jit/syntax/expression/expression.h @@ -46,19 +46,6 @@ namespace isaac class array_base; -struct placeholder -{ - expression_tree operator=(value_scalar const & ) const; - expression_tree operator=(expression_tree const & ) const; - - expression_tree operator+=(value_scalar const & ) const; - expression_tree operator-=(value_scalar const & ) const; - expression_tree operator*=(value_scalar const & ) const; - expression_tree operator/=(value_scalar const & ) const; - - int level; -}; - struct invalid_node{}; enum node_type @@ -67,7 +54,6 @@ enum node_type COMPOSITE_OPERATOR_TYPE, VALUE_SCALAR_TYPE, DENSE_ARRAY_TYPE, - PLACEHOLDER_TYPE }; union handle_t @@ -92,7 +78,6 @@ public: //Constructors node(); node(invalid_node); - node(placeholder x); node(value_scalar const & x); node(array_base const & x); node(int_t lhs, op_element op, int_t rhs, numeric_type dtype, tuple const & shape); @@ -116,8 +101,6 @@ public: values_holder scalar; //Array array_holder array; - //Placeholder - placeholder ph; }; }; @@ -134,7 +117,7 @@ public: data_type const & data() const; std::size_t root() const; driver::Context const & context() const; - numeric_type dtype() const; + numeric_type const & dtype() const; node const & operator[](size_t) const; node & operator[](size_t); diff --git a/lib/array.cpp b/lib/array.cpp index 8f986161c..d6b01c2bd 100644 --- a/lib/array.cpp +++ b/lib/array.cpp @@ -164,8 +164,7 @@ array_base & array_base::operator=(array_base const & rhs) { if(min(shape_)==0) return *this; assert(dtype_ == rhs.dtype()); - expression_tree expression(*this, rhs, op_element(BINARY_ARITHMETIC, ASSIGN_TYPE), &context_, dtype_, shape_); - runtime::execute(expression); + runtime::execute(assign(*this, rhs)); return *this; } @@ -173,8 +172,7 @@ array_base & array_base::operator=(value_scalar const & rhs) { if(min(shape_)==0) return *this; assert(dtype_ == rhs.dtype()); - expression_tree expression(*this, rhs, op_element(BINARY_ARITHMETIC, ASSIGN_TYPE), &context_, dtype_, shape_); - runtime::execute(expression); + runtime::execute(assign(*this, rhs)); return *this; } @@ -183,8 +181,7 @@ array_base& array_base::operator=(runtime::execution_handler const & c) { if(min(shape_)==0) return *this; assert(dtype_ == c.x().dtype()); - expression_tree expression(*this, c.x(), op_element(BINARY_ARITHMETIC, ASSIGN_TYPE), &context_, dtype_, shape_); - runtime::execute(runtime::execution_handler(expression, c.execution_options(), c.dispatcher_options(), c.compilation_options())); + runtime::execute(runtime::execution_handler(assign(*this, c.x()), c.execution_options(), c.dispatcher_options(), c.compilation_options())); return *this; } @@ -267,11 +264,6 @@ array_base & array_base::operator/=(expression_tree const & rhs) /*--- Indexing operators -----*/ //--------------------------------------- -expression_tree array_base::operator[](placeholder idx) const -{ - return expression_tree(*this, idx, op_element(BINARY_ARITHMETIC, ACCESS_INDEX_TYPE), &context_, dtype_, {1}); -} - scalar array_base::operator [](int_t idx) { assert(dim()<=1); @@ -534,10 +526,6 @@ expression_tree OPNAME (array_base const & x, array_base const & y) \ expression_tree OPNAME (array_base const & x, value_scalar const & y) \ { return expression_tree(x, y, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); }\ \ -expression_tree OPNAME (array_base const & x, placeholder const & y) \ -{ return expression_tree(x, y, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); }\ -\ -\ expression_tree OPNAME (expression_tree const & x, expression_tree const & y) \ { return broadcast(x, y, op_element(BINARY_ARITHMETIC, OP), DTYPE); } \ \ @@ -547,9 +535,6 @@ expression_tree OPNAME (expression_tree const & x, array_base const & y) \ expression_tree OPNAME (expression_tree const & x, value_scalar const & y) \ { return expression_tree(x, y, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); } \ \ -expression_tree OPNAME (expression_tree const & x, placeholder const & y) \ -{ return expression_tree(x, y, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); } \ -\ \ expression_tree OPNAME (value_scalar const & y, expression_tree const & x) \ { return expression_tree(y, x, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); } \ @@ -557,22 +542,6 @@ expression_tree OPNAME (value_scalar const & y, expression_tree const & x) \ expression_tree OPNAME (value_scalar const & y, array_base const & x) \ { return expression_tree(y, x, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); }\ \ -expression_tree OPNAME (value_scalar const & x, placeholder const & y) \ -{ return expression_tree(x, y, op_element(BINARY_ARITHMETIC, OP), NULL, DTYPE, {1}); }\ -\ -\ -expression_tree OPNAME (placeholder const & y, expression_tree const & x) \ -{ return expression_tree(y, x, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); } \ -\ -expression_tree OPNAME (placeholder const & y, value_scalar const & x) \ -{ return expression_tree(y, x, op_element(BINARY_ARITHMETIC, OP), NULL, DTYPE, {1}); } \ -\ -expression_tree OPNAME (placeholder const & y, array_base const & x) \ -{ return expression_tree(y, x, op_element(BINARY_ARITHMETIC, OP), &x.context(), DTYPE, x.shape()); }\ -\ -expression_tree OPNAME (placeholder const & y, placeholder const & x) \ -{ return expression_tree(y, x, op_element(BINARY_ARITHMETIC, OP), NULL, INVALID_NUMERIC_TYPE, {1}); } - DEFINE_ELEMENT_BINARY_OPERATOR(ADD_TYPE, operator +, x.dtype()) DEFINE_ELEMENT_BINARY_OPERATOR(SUB_TYPE, operator -, x.dtype()) @@ -583,7 +552,7 @@ DEFINE_ELEMENT_BINARY_OPERATOR(ELEMENT_MAX_TYPE, maximum, x.dtype()) DEFINE_ELEMENT_BINARY_OPERATOR(ELEMENT_MIN_TYPE, minimum, x.dtype()) DEFINE_ELEMENT_BINARY_OPERATOR(ELEMENT_POW_TYPE, pow, x.dtype()) -DEFINE_ELEMENT_BINARY_OPERATOR(ASSIGN_TYPE, assign, x.dtype()) +DEFINE_ELEMENT_BINARY_OPERATOR(ASSIGN_TYPE, assign, y.dtype()) DEFINE_ELEMENT_BINARY_OPERATOR(ELEMENT_GREATER_TYPE, operator >, INT_TYPE) @@ -841,7 +810,7 @@ namespace detail { int_t M = A.shape()[0]; int_t N = A.shape()[1]; - expression_tree::node & A_root = (expression_tree::node &)A[A.root()]; + expression_tree::node A_root = (expression_tree::node &)A[A.root()]; bool A_trans = A_root.binary_operator.op.type==TRANS_TYPE; while(A_root.type==COMPOSITE_OPERATOR_TYPE){ A_root = A[A_root.binary_operator.lhs]; diff --git a/lib/jit/syntax/engine/process.cpp b/lib/jit/syntax/engine/process.cpp index 461785b11..d2dd22066 100644 --- a/lib/jit/syntax/engine/process.cpp +++ b/lib/jit/syntax/engine/process.cpp @@ -185,8 +185,6 @@ symbols_table symbolize(isaac::expression_tree const & tree) bool is_assigned = std::find(assignee.begin(), assignee.end(), root)!=assignee.end(); table.insert({root, make_symbolic(context, dtype, binder->get(node.array.handle, is_assigned), node.shape, node.ld)}); } - else if(node.type==PLACEHOLDER_TYPE) - table.insert({root, make_symbolic(context, node.ph.level)}); else if(node.type==COMPOSITE_OPERATOR_TYPE) { unsigned int id = binder->get(); diff --git a/lib/jit/syntax/expression/expression.cpp b/lib/jit/syntax/expression/expression.cpp index 78e636062..004107448 100644 --- a/lib/jit/syntax/expression/expression.cpp +++ b/lib/jit/syntax/expression/expression.cpp @@ -38,9 +38,6 @@ expression_tree::node::node(){} expression_tree::node::node(invalid_node) : type(INVALID_SUBTYPE), dtype(INVALID_NUMERIC_TYPE) {} -expression_tree::node::node(placeholder x) : type(PLACEHOLDER_TYPE), dtype(INVALID_NUMERIC_TYPE), shape{1}, ph(x) -{} - expression_tree::node::node(value_scalar const & x) : type(VALUE_SCALAR_TYPE), dtype(x.dtype()), shape{1}, scalar(x.values()) {} @@ -116,7 +113,7 @@ std::size_t expression_tree::root() const driver::Context const & expression_tree::context() const { return *context_; } -numeric_type expression_tree::dtype() const +numeric_type const & expression_tree::dtype() const { return tree_[root_].dtype; } tuple expression_tree::shape() const @@ -137,15 +134,6 @@ expression_tree::node const & expression_tree::operator[](size_t idx) const expression_tree::node & expression_tree::operator[](size_t idx) { return tree_[idx]; } -// -expression_tree placeholder::operator=(value_scalar const & r) const { return expression_tree(*this, r, op_element(BINARY_ARITHMETIC,ASSIGN_TYPE), NULL, r.dtype(), {1}); } -expression_tree placeholder::operator=(expression_tree const & r) const { return expression_tree(*this, r, op_element(BINARY_ARITHMETIC,ASSIGN_TYPE), &r.context(), r.dtype(), r.shape()); } - -expression_tree placeholder::operator+=(value_scalar const & r) const { return *this = *this + r; } -expression_tree placeholder::operator-=(value_scalar const & r) const { return *this = *this - r; } -expression_tree placeholder::operator*=(value_scalar const & r) const { return *this = *this * r; } -expression_tree placeholder::operator/=(value_scalar const & r) const { return *this = *this / r; } - //io #define ISAAC_MAP_TO_STRING(NAME) case NAME: return #NAME