Feature: Merged kernel-fusion branch

* Fuses multiple AXPY kernel
* Possibility to add thread-wise for loops in AXPY-like kernels
This commit is contained in:
Philippe Tillet
2015-09-30 15:31:41 -04:00
parent 149441b9e2
commit feeb1e9862
64 changed files with 10047 additions and 1119 deletions

View File

@@ -276,11 +276,11 @@ void export_core()
.def(bp::self OP bp::self)\
ADD_SCALAR_HANDLING(OP)
bp::class_<sc::expressions_tuple>
("array_expression_container", bp::init<sc::array_expression const &>())
bp::class_<sc::math_expression>
("math_expression_container", bp::init<sc::math_expression const &>())
;
bp::class_<sc::array_expression >("array_expression", bp::no_init)
bp::class_<sc::math_expression >("math_expression", bp::no_init)
ADD_ARRAY_OPERATOR(+)
ADD_ARRAY_OPERATOR(-)
ADD_ARRAY_OPERATOR(*)
@@ -291,7 +291,7 @@ void export_core()
ADD_ARRAY_OPERATOR(<=)
ADD_ARRAY_OPERATOR(==)
ADD_ARRAY_OPERATOR(!=)
.add_property("context", bp::make_function(&sc::array_expression::context, bp::return_internal_reference<>()))
.add_property("context", bp::make_function(&sc::math_expression::context, bp::return_internal_reference<>()))
.def(bp::self_ns::abs(bp::self))
// .def(bp::self_ns::pow(bp::self))
;
@@ -299,15 +299,15 @@ void export_core()
#define ADD_ARRAY_OPERATOR(OP) \
.def(bp::self OP bp::self)\
.def(bp::self OP bp::other<sc::array_expression>())\
.def(bp::other<sc::array_expression>() OP bp::self) \
.def(bp::self OP bp::other<sc::math_expression>())\
.def(bp::other<sc::math_expression>() OP bp::self) \
ADD_SCALAR_HANDLING(OP)
bp::class_<sc::array,
std::shared_ptr<sc::array> >
( "array", bp::no_init)
.def("__init__", bp::make_constructor(detail::create_array, bp::default_call_policies(), (bp::arg("obj"), bp::arg("dtype") = bp::scope().attr("float32"), bp::arg("context")= bp::object())))
.def(bp::init<sc::array_expression>())
.def(bp::init<sc::math_expression>())
.add_property("dtype", &sc::array::dtype)
.add_property("context", bp::make_function(&sc::array::context, bp::return_internal_reference<>()))
.add_property("T", &sc::array::T)
@@ -336,15 +336,15 @@ void export_core()
bp::def("empty", &detail::create_empty_array, (bp::arg("shape"), bp::arg("dtype") = bp::scope().attr("float32"), bp::arg("context")=bp::object()));
//Assign
bp::def("assign", static_cast<sc::array_expression (*)(sc::array const &, sc::array const &)>(&sc::assign));\
bp::def("assign", static_cast<sc::array_expression (*)(sc::array const &, sc::array_expression const &)>(&sc::assign));\
bp::def("assign", static_cast<sc::math_expression (*)(sc::array const &, sc::array const &)>(&sc::assign));\
bp::def("assign", static_cast<sc::math_expression (*)(sc::array const &, sc::math_expression const &)>(&sc::assign));\
//Binary
#define MAP_FUNCTION(name) \
bp::def(#name, static_cast<sc::array_expression (*)(sc::array const &, sc::array const &)>(&sc::name));\
bp::def(#name, static_cast<sc::array_expression (*)(sc::array_expression const &, sc::array const &)>(&sc::name));\
bp::def(#name, static_cast<sc::array_expression (*)(sc::array const &, sc::array_expression const &)>(&sc::name));\
bp::def(#name, static_cast<sc::array_expression (*)(sc::array_expression const &, sc::array_expression const &)>(&sc::name));
bp::def(#name, static_cast<sc::math_expression (*)(sc::array const &, sc::array const &)>(&sc::name));\
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &, sc::array const &)>(&sc::name));\
bp::def(#name, static_cast<sc::math_expression (*)(sc::array const &, sc::math_expression const &)>(&sc::name));\
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &, sc::math_expression const &)>(&sc::name));
MAP_FUNCTION(maximum)
MAP_FUNCTION(minimum)
@@ -354,8 +354,8 @@ void export_core()
//Unary
#define MAP_FUNCTION(name) \
bp::def(#name, static_cast<sc::array_expression (*)(sc::array const &)>(&sc::name));\
bp::def(#name, static_cast<sc::array_expression (*)(sc::array_expression const &)>(&sc::name));
bp::def(#name, static_cast<sc::math_expression (*)(sc::array const &)>(&sc::name));\
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &)>(&sc::name));
bp::def("zeros", &detail::create_zeros_array, (bp::arg("shape"), bp::arg("dtype") = bp::scope().attr("float32"), bp::arg("context")=bp::object()));
@@ -380,8 +380,8 @@ void export_core()
/*--- Reduction operators----*/
//---------------------------------------
#define MAP_FUNCTION(name) \
bp::def(#name, static_cast<sc::array_expression (*)(sc::array const &, sc::int_t)>(&sc::name));\
bp::def(#name, static_cast<sc::array_expression (*)(sc::array_expression const &, sc::int_t)>(&sc::name));
bp::def(#name, static_cast<sc::math_expression (*)(sc::array const &, sc::int_t)>(&sc::name));\
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &, sc::int_t)>(&sc::name));
MAP_FUNCTION(sum)
MAP_FUNCTION(max)