diff --git a/include/isaac/array.h b/include/isaac/array.h index 01890ccb4..91ebbd11d 100644 --- a/include/isaac/array.h +++ b/include/isaac/array.h @@ -62,6 +62,7 @@ public: array_base(tuple const & shape, std::vector
const & data, driver::Context const & context = driver::backend::contexts::get_default()); array_base(tuple const & shape, numeric_type dtype, driver::Context const & context = driver::backend::contexts::get_default()); array_base(tuple const & shape, numeric_type dtype, int_t start, tuple const & stride, driver::Context const & context = driver::backend::contexts::get_default()); + array_base(tuple const & shape, numeric_type dtype, int_t start, tuple const & stride, driver::Buffer const & data); explicit array_base(runtime::execution_handler const &); //Make the class virtual diff --git a/include/isaac/jit/syntax/expression/expression.h b/include/isaac/jit/syntax/expression/expression.h index 4286701ba..1085ba9ce 100644 --- a/include/isaac/jit/syntax/expression/expression.h +++ b/include/isaac/jit/syntax/expression/expression.h @@ -76,6 +76,7 @@ union handle_t CUdeviceptr cu; }; + struct array_holder { int_t start; diff --git a/lib/array.cpp b/lib/array.cpp index 8fc62f76c..acb5a1301 100644 --- a/lib/array.cpp +++ b/lib/array.cpp @@ -51,6 +51,11 @@ INSTANTIATE(float);\ INSTANTIATE(double); //General +array_base::array_base(tuple const & shape, numeric_type dtype, int_t start, tuple const & stride, driver::Buffer const & data) : + dtype_(dtype), shape_(shape), start_(start), stride_(stride), context_(data.context()), data_(data), + T(isaac::trans(*this)) +{} + array_base::array_base(tuple const & shape, numeric_type dtype, int_t start, tuple const & stride, driver::Context const & context) : dtype_(dtype), shape_(shape), start_(start), stride_(stride), context_(context), data_(context_, dsize()), T(isaac::trans(*this)) diff --git a/python/src/bind/driver.cpp b/python/src/bind/driver.cpp index b93e20165..f3d17f884 100644 --- a/python/src/bind/driver.cpp +++ b/python/src/bind/driver.cpp @@ -83,7 +83,7 @@ namespace detail std::shared_ptr make_context(sc::driver::Device const & dev) { return std::shared_ptr(new sc::driver::Context(dev)); } - bp::object enqueue(sc::expression_tree const & expression, unsigned int queue_id, bp::list dependencies, bool tune, int label, std::string const & program_name, bool force_recompile) + bp::object enqueue(sc::expression_tree const & tree, unsigned int queue_id, bp::list dependencies, bool tune, int label, std::string const & program_name, bool force_recompile) { std::list events; std::vector cdependencies = tools::to_vector(dependencies); @@ -91,15 +91,18 @@ namespace detail sc::execution_options_type execution_options(queue_id, &events, &cdependencies); sc::dispatcher_options_type dispatcher_options(tune, label); sc::compilation_options_type compilation_options(program_name, force_recompile); - sc::expression_tree::container_type::value_type root = expression.tree()[expression.root()]; - if(sc::detail::is_assignment(root.op)) + sc::expression_tree::node const & root = tree[tree.root()]; + if(sc::is_assignment(root.binary_operator.op.type)) { - sc::execute(sc::execution_handler(expression, execution_options, dispatcher_options, compilation_options), isaac::profiles::get(execution_options.queue(expression.context()))); - return bp::make_tuple(bp::ptr(root.lhs.array), tools::to_list(events.begin(), events.end())); + sc::symbolic::execute(sc::execution_handler(tree, execution_options, dispatcher_options, compilation_options), isaac::profiles::get(execution_options.queue(tree.context()))); + sc::expression_tree::node const & lhs = tree[root.binary_operator.lhs]; + sc::driver::Buffer const & data = sc::driver::make_buffer(tree.context().backend(), lhs.array.handle.cl, lhs.array.handle.cu, false); + std::shared_ptr parray(new sc::array(lhs.shape, lhs.dtype, lhs.array.start, lhs.ld, data)); + return bp::make_tuple(parray, tools::to_list(events.begin(), events.end())); } else { - std::shared_ptr parray(new sc::array(sc::execution_handler(expression, execution_options, dispatcher_options, compilation_options))); + std::shared_ptr parray(new sc::array(sc::execution_handler(tree, execution_options, dispatcher_options, compilation_options))); return bp::make_tuple(parray, tools::to_list(events.begin(), events.end())); } } diff --git a/python/src/bind/exceptions.cpp b/python/src/bind/exceptions.cpp index bfaca884d..15e5e4485 100644 --- a/python/src/bind/exceptions.cpp +++ b/python/src/bind/exceptions.cpp @@ -22,8 +22,8 @@ #include #include -#include "isaac/exception/operation_not_supported.h" -#include "isaac/driver/common.h" +#include "isaac/exception/api.h" +#include "isaac/exception/driver.h" #include "common.hpp" #include "exceptions.h" @@ -102,18 +102,20 @@ private: void export_exceptions() { + namespace exc = isaac::exception; #define BIND_EXCEPTION(CPPNAME, PYTHONNAME) \ wrap::exception(PYTHONNAME, bp::init())\ .def("__str__", &isaac::CPPNAME::what) BIND_EXCEPTION(operation_not_supported_exception, "OperationNotSupported"); + BIND_EXCEPTION(semantic_error, "SemanticError"); //OCL - wrap::exception("OclException", bp::no_init); + wrap::exception("OclException", bp::no_init); #define BIND_OCL_EXCEPTION(CPPNAME, PYTHONNAME) \ - wrap::exception >(PYTHONNAME)\ - .def("__str__", &isaac::driver::ocl::exception::CPPNAME::what) + wrap::exception >(PYTHONNAME)\ + .def("__str__", &exc::ocl::CPPNAME::what) BIND_OCL_EXCEPTION(out_of_resources, "OclLaunchOutOfResources"); @@ -123,10 +125,10 @@ void export_exceptions() BIND_OCL_EXCEPTION(invalid_value, "InvalidValue"); //CUDA - wrap::exception("CudaException", bp::no_init); + wrap::exception("CudaException", bp::no_init); #define BIND_CUDA_EXCEPTION(CPPNAME, PYTHONNAME) \ - wrap::exception >(PYTHONNAME)\ - .def("__str__", &isaac::driver::cuda::exception::CPPNAME::what) + wrap::exception >(PYTHONNAME)\ + .def("__str__", &exc::cuda::CPPNAME::what) BIND_CUDA_EXCEPTION(launch_out_of_resources, "CudaLaunchOutOfResources"); diff --git a/python/src/bind/kernels.cpp b/python/src/bind/kernels.cpp index a76b4fe32..2e8ef50b8 100644 --- a/python/src/bind/kernels.cpp +++ b/python/src/bind/kernels.cpp @@ -19,11 +19,11 @@ * MA 02110-1301 USA */ -#include "isaac/kernels/templates/elementwise_1d.h" -#include "isaac/kernels/templates/elementwise_2d.h" -#include "isaac/kernels/templates/reduce_1d.h" -#include "isaac/kernels/templates/reduce_2d.h" -#include "isaac/kernels/templates/matrix_product.h" +#include "isaac/templates/elementwise_1d.h" +#include "isaac/templates/elementwise_2d.h" +#include "isaac/templates/reduce_1d.h" +#include "isaac/templates/reduce_2d.h" +#include "isaac/templates/matrix_product.h" #include "common.hpp" #include "kernels.h"