Cleaning: Largely renamed templates to BLAS-like names
This commit is contained in:
@@ -115,7 +115,7 @@ def main():
|
||||
include =' src/include'.split() + ['external/boost/include', os.path.join(find_module("numpy")[1], "core", "include")]
|
||||
|
||||
#Source files
|
||||
src = 'src/lib/symbolic/preset.cpp src/lib/symbolic/execute.cpp src/lib/symbolic/io.cpp src/lib/symbolic/expression.cpp src/lib/model/model.cpp src/lib/model/predictors/random_forest.cpp src/lib/backend/templates/mreduction.cpp src/lib/backend/templates/reduction.cpp src/lib/backend/templates/mproduct.cpp src/lib/backend/templates/maxpy.cpp src/lib/backend/templates/base.cpp src/lib/backend/templates/vaxpy.cpp src/lib/backend/mapped_object.cpp src/lib/backend/stream.cpp src/lib/backend/parse.cpp src/lib/backend/keywords.cpp src/lib/backend/binder.cpp src/lib/array.cpp src/lib/value_scalar.cpp src/lib/driver/backend.cpp src/lib/driver/device.cpp src/lib/driver/kernel.cpp src/lib/driver/buffer.cpp src/lib/driver/platform.cpp src/lib/driver/check.cpp src/lib/driver/program.cpp src/lib/driver/command_queue.cpp src/lib/driver/context.cpp src/lib/driver/event.cpp src/lib/driver/ndrange.cpp src/lib/driver/handle.cpp src/lib/exception/unknown_datatype.cpp src/lib/exception/operation_not_supported.cpp src/lib/wrap/clBLAS.cpp '.split() + [os.path.join('src', 'wrap', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||
src = 'src/lib/array.cpp src/lib/value_scalar.cpp src/lib/wrap/clBLAS.cpp src/lib/symbolic/execute.cpp src/lib/symbolic/preset.cpp src/lib/symbolic/expression.cpp src/lib/symbolic/io.cpp src/lib/model/model.cpp src/lib/model/predictors/random_forest.cpp src/lib/exception/unknown_datatype.cpp src/lib/exception/operation_not_supported.cpp src/lib/driver/program.cpp src/lib/driver/context.cpp src/lib/driver/command_queue.cpp src/lib/driver/check.cpp src/lib/driver/buffer.cpp src/lib/driver/event.cpp src/lib/driver/device.cpp src/lib/driver/backend.cpp src/lib/driver/platform.cpp src/lib/driver/ndrange.cpp src/lib/driver/kernel.cpp src/lib/driver/handle.cpp src/lib/backend/parse.cpp src/lib/backend/mapped_object.cpp src/lib/backend/templates/axpy.cpp src/lib/backend/templates/ger.cpp src/lib/backend/templates/gemm.cpp src/lib/backend/templates/dot.cpp src/lib/backend/templates/gemv.cpp src/lib/backend/templates/base.cpp src/lib/backend/stream.cpp src/lib/backend/keywords.cpp src/lib/backend/binder.cpp '.split() + [os.path.join('src', 'wrap', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||
boostsrc = 'external/boost/libs/'
|
||||
for s in ['numpy','python','smart_ptr','system','thread']:
|
||||
src = src + [x for x in recursive_glob('external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
||||
|
@@ -20,6 +20,6 @@ BOOST_PYTHON_MODULE(_isaac)
|
||||
|
||||
export_driver();
|
||||
export_exceptions();
|
||||
export_model();
|
||||
export_templates();
|
||||
export_core();
|
||||
}
|
||||
|
@@ -70,15 +70,15 @@ namespace tools
|
||||
else
|
||||
name = bp::extract<std::string>(odtype.attr("__class__").attr("__name__"))();
|
||||
|
||||
if(name=="vaxpy") return isc::VECTOR_AXPY_TYPE;
|
||||
else if(name=="maxpy") return isc::MATRIX_AXPY_TYPE;
|
||||
else if(name=="reduction") return isc::REDUCTION_TYPE;
|
||||
else if(name=="mreduction_rows") return isc::ROW_WISE_REDUCTION_TYPE;
|
||||
else if(name=="mreduction_cols") return isc::COL_WISE_REDUCTION_TYPE;
|
||||
else if(name=="mproduct_nn") return isc::MATRIX_PRODUCT_NN_TYPE;
|
||||
else if(name=="mproduct_tn") return isc::MATRIX_PRODUCT_TN_TYPE;
|
||||
else if(name=="mproduct_nt") return isc::MATRIX_PRODUCT_NT_TYPE;
|
||||
else if(name=="mproduct_tt") return isc::MATRIX_PRODUCT_TT_TYPE;
|
||||
if(name=="axpy") return isc::AXPY_TYPE;
|
||||
else if(name=="ger") return isc::GER_TYPE;
|
||||
else if(name=="dot") return isc::DOT_TYPE;
|
||||
else if(name=="gemv_n") return isc::GEMV_N_TYPE;
|
||||
else if(name=="gemm_t") return isc::GEMV_T_TYPE;
|
||||
else if(name=="gemm_nn") return isc::GEMM_NN_TYPE;
|
||||
else if(name=="gemm_tn") return isc::GEMM_TN_TYPE;
|
||||
else if(name=="gemm_nt") return isc::GEMM_NT_TYPE;
|
||||
else if(name=="gemm_tt") return isc::GEMM_TT_TYPE;
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Template type not understood");
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#include "isaac/model/model.h"
|
||||
#include "common.hpp"
|
||||
#include "core.h"
|
||||
|
||||
@@ -79,6 +80,11 @@ unsigned int size(datatype<T> const & dt)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
std::shared_ptr<isc::model> construct_model(bp::object dtype, bp::object const & tp, isc::driver::CommandQueue & queue)
|
||||
{
|
||||
return std::shared_ptr<isc::model>(new isc::model(tools::extract_template_type(tp), tools::extract_dtype(dtype), (isaac::templates::base const &)bp::extract<isaac::templates::base>(tp), queue));
|
||||
}
|
||||
|
||||
std::shared_ptr<isc::array>
|
||||
ndarray_to_iscarray(const np::ndarray& array, const isc::driver::Context& ctx)
|
||||
{
|
||||
@@ -172,7 +178,6 @@ namespace detail
|
||||
bp::throw_error_already_set();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +188,10 @@ namespace detail
|
||||
void export_core()
|
||||
{
|
||||
|
||||
bp::class_<isaac::model>("model", bp::no_init)
|
||||
.def("__init__", bp::make_constructor(detail::construct_model))
|
||||
.def("execute", &isc::model::execute);
|
||||
|
||||
bp::class_<isc::value_scalar>("value_scalar", bp::no_init)
|
||||
.add_property("dtype", &isc::value_scalar::dtype);
|
||||
|
||||
@@ -206,15 +215,15 @@ void export_core()
|
||||
#undef INSTANTIATE
|
||||
|
||||
bp::enum_<isc::expression_type>("operations")
|
||||
MAP_ENUM(VECTOR_AXPY_TYPE, isc)
|
||||
MAP_ENUM(MATRIX_AXPY_TYPE, isc)
|
||||
MAP_ENUM(REDUCTION_TYPE, isc)
|
||||
MAP_ENUM(ROW_WISE_REDUCTION_TYPE, isc)
|
||||
MAP_ENUM(COL_WISE_REDUCTION_TYPE, isc)
|
||||
MAP_ENUM(VECTOR_AXPY_TYPE, isc)
|
||||
MAP_ENUM(VECTOR_AXPY_TYPE, isc)
|
||||
MAP_ENUM(VECTOR_AXPY_TYPE, isc)
|
||||
MAP_ENUM(VECTOR_AXPY_TYPE, isc);
|
||||
MAP_ENUM(AXPY_TYPE, isc)
|
||||
MAP_ENUM(GER_TYPE, isc)
|
||||
MAP_ENUM(DOT_TYPE, isc)
|
||||
MAP_ENUM(GEMV_N_TYPE, isc)
|
||||
MAP_ENUM(GEMV_T_TYPE, isc)
|
||||
MAP_ENUM(GEMM_NN_TYPE, isc)
|
||||
MAP_ENUM(GEMM_TN_TYPE, isc)
|
||||
MAP_ENUM(GEMM_NT_TYPE, isc)
|
||||
MAP_ENUM(GEMM_TT_TYPE, isc);
|
||||
|
||||
#define ADD_SCALAR_HANDLING(OP)\
|
||||
.def(bp::self OP int())\
|
||||
|
@@ -1,70 +1,71 @@
|
||||
#include "isaac/backend/templates/vaxpy.h"
|
||||
#include "isaac/backend/templates/maxpy.h"
|
||||
#include "isaac/backend/templates/reduction.h"
|
||||
#include "isaac/backend/templates/mreduction.h"
|
||||
#include "isaac/backend/templates/mproduct.h"
|
||||
#include "isaac/backend/templates/axpy.h"
|
||||
#include "isaac/backend/templates/ger.h"
|
||||
#include "isaac/backend/templates/dot.h"
|
||||
#include "isaac/backend/templates/gemv.h"
|
||||
#include "isaac/backend/templates/gemm.h"
|
||||
#include "isaac/model/model.h"
|
||||
|
||||
#include "common.hpp"
|
||||
#include "model.h"
|
||||
|
||||
|
||||
namespace tpt = isaac::templates;
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
bp::list input_sizes(isaac::base & temp, isc::expressions_tuple const & tree)
|
||||
bp::list input_sizes(tpt::base & temp, isc::expressions_tuple const & tree)
|
||||
{
|
||||
std::vector<int> tmp = temp.input_sizes(tree);
|
||||
return tools::to_list(tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
std::shared_ptr<isc::model> construct_model(bp::object dtype, bp::object const & tp, isc::driver::CommandQueue & queue)
|
||||
{
|
||||
return std::shared_ptr<isc::model>(new isc::model(tools::extract_template_type(tp), tools::extract_dtype(dtype), (isc::base const &)bp::extract<isc::base>(tp), queue));
|
||||
}
|
||||
}
|
||||
|
||||
void export_model()
|
||||
void export_templates()
|
||||
{
|
||||
|
||||
bp::class_<isaac::model>("model", bp::no_init)
|
||||
.def("__init__", bp::make_constructor(detail::construct_model))
|
||||
.def("execute", &isc::model::execute);
|
||||
bp::object templates_module(bp::handle<>(bp::borrowed(PyImport_AddModule("isaac.templates"))));
|
||||
bp::scope().attr("templates") = templates_module;
|
||||
bp::scope template_scope = templates_module;
|
||||
|
||||
bp::enum_<isaac::fetching_policy_type>
|
||||
|
||||
bp::enum_<tpt::fetching_policy_type>
|
||||
("fetching_policy_type")
|
||||
.value("FETCH_FROM_LOCAL", isc::FETCH_FROM_LOCAL)
|
||||
.value("FETCH_FROM_GLOBAL_STRIDED", isc::FETCH_FROM_GLOBAL_STRIDED)
|
||||
.value("FETCH_FROM_GLOBAL_CONTIGUOUS", isc::FETCH_FROM_GLOBAL_CONTIGUOUS)
|
||||
.value("FETCH_FROM_LOCAL", tpt::FETCH_FROM_LOCAL)
|
||||
.value("FETCH_FROM_GLOBAL_STRIDED", tpt::FETCH_FROM_GLOBAL_STRIDED)
|
||||
.value("FETCH_FROM_GLOBAL_CONTIGUOUS", tpt::FETCH_FROM_GLOBAL_CONTIGUOUS)
|
||||
;
|
||||
|
||||
//Base
|
||||
{
|
||||
#define __PROP(name) .def_readonly(#name, &isaac::base::parameters_type::name)
|
||||
bp::class_<isaac::base, boost::noncopyable>("base", bp::no_init)
|
||||
.def("lmem_usage", &isaac::base::lmem_usage)
|
||||
.def("registers_usage", &isaac::base::registers_usage)
|
||||
.def("is_invalid", &isaac::base::is_invalid)
|
||||
#define __PROP(name) .def_readonly(#name, &tpt::base::parameters_type::name)
|
||||
bp::class_<tpt::base, boost::noncopyable>("base", bp::no_init)
|
||||
.def("lmem_usage", &tpt::base::lmem_usage)
|
||||
.def("registers_usage", &tpt::base::registers_usage)
|
||||
.def("is_invalid", &tpt::base::is_invalid)
|
||||
.def("input_sizes", &detail::input_sizes)
|
||||
;
|
||||
#undef __PROP
|
||||
}
|
||||
|
||||
#define WRAP_BASE(name) bp::class_<isaac::base_impl<isaac::name, isaac::name::parameters_type>, bp::bases<isaac::base>, boost::noncopyable>(#name, bp::no_init);
|
||||
#define WRAP_TEMPLATE(name, basename, ...) bp::class_<isaac::name, bp::bases<isaac::base_impl<isaac::basename, isaac::basename::parameters_type> > >(#name, bp::init<__VA_ARGS__>())\
|
||||
.add_property("local_size_0", &isc::name::local_size_0)\
|
||||
.add_property("local_size_1", &isc::name::local_size_1);
|
||||
#define WRAP_BASE(name) bp::class_<tpt::base_impl<tpt::name, tpt::name::parameters_type>, bp::bases<tpt::base>, boost::noncopyable>(#name, bp::no_init);
|
||||
#define WRAP_TEMPLATE(name, basename, ...) bp::class_<tpt::name, bp::bases<tpt::base_impl<tpt::basename, tpt::basename::parameters_type> > >(#name, bp::init<__VA_ARGS__>())\
|
||||
.add_property("local_size_0", &tpt::name::local_size_0)\
|
||||
.add_property("local_size_1", &tpt::name::local_size_1);
|
||||
#define WRAP_SINGLE_TEMPLATE(name, ...) WRAP_BASE(name) WRAP_TEMPLATE(name, name, __VA_ARGS__)
|
||||
|
||||
//Vector AXPY
|
||||
WRAP_SINGLE_TEMPLATE(vaxpy, uint, uint, uint, isaac::fetching_policy_type)
|
||||
WRAP_SINGLE_TEMPLATE(maxpy, uint, uint, uint, uint, uint, isaac::fetching_policy_type)
|
||||
WRAP_SINGLE_TEMPLATE(reduction, uint, uint, uint, isaac::fetching_policy_type)
|
||||
WRAP_BASE(mreduction)
|
||||
WRAP_TEMPLATE(mreduction_rows, mreduction, uint, uint, uint, uint, uint, isaac::fetching_policy_type)
|
||||
WRAP_TEMPLATE(mreduction_cols, mreduction, uint, uint, uint, uint, uint, isaac::fetching_policy_type)
|
||||
WRAP_BASE(mproduct)
|
||||
WRAP_TEMPLATE(mproduct_nn, mproduct, uint, uint, uint, uint, uint, uint, uint, uint, isaac::fetching_policy_type, isaac::fetching_policy_type, uint, uint)
|
||||
WRAP_TEMPLATE(mproduct_tn, mproduct, uint, uint, uint, uint, uint, uint, uint, uint, isaac::fetching_policy_type, isaac::fetching_policy_type, uint, uint)
|
||||
WRAP_TEMPLATE(mproduct_nt, mproduct, uint, uint, uint, uint, uint, uint, uint, uint, isaac::fetching_policy_type, isaac::fetching_policy_type, uint, uint)
|
||||
WRAP_TEMPLATE(mproduct_tt, mproduct, uint, uint, uint, uint, uint, uint, uint, uint, isaac::fetching_policy_type, isaac::fetching_policy_type, uint, uint)
|
||||
WRAP_SINGLE_TEMPLATE(axpy, uint, uint, uint, tpt::fetching_policy_type)
|
||||
WRAP_SINGLE_TEMPLATE(ger, uint, uint, uint, uint, uint, tpt::fetching_policy_type)
|
||||
WRAP_SINGLE_TEMPLATE(dot, uint, uint, uint, tpt::fetching_policy_type)
|
||||
WRAP_BASE(gemv)
|
||||
WRAP_TEMPLATE(gemv_n, gemv, uint, uint, uint, uint, uint, tpt::fetching_policy_type)
|
||||
WRAP_TEMPLATE(gemv_t, gemv, uint, uint, uint, uint, uint, tpt::fetching_policy_type)
|
||||
WRAP_BASE(gemm)
|
||||
WRAP_TEMPLATE(gemm_nn, gemm, uint, uint, uint, uint, uint, uint, uint, uint, tpt::fetching_policy_type, tpt::fetching_policy_type, uint, uint)
|
||||
WRAP_TEMPLATE(gemm_tn, gemm, uint, uint, uint, uint, uint, uint, uint, uint, tpt::fetching_policy_type, tpt::fetching_policy_type, uint, uint)
|
||||
WRAP_TEMPLATE(gemm_nt, gemm, uint, uint, uint, uint, uint, uint, uint, uint, tpt::fetching_policy_type, tpt::fetching_policy_type, uint, uint)
|
||||
WRAP_TEMPLATE(gemm_tt, gemm, uint, uint, uint, uint, uint, uint, uint, uint, tpt::fetching_policy_type, tpt::fetching_policy_type, uint, uint)
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifndef ISAAC_PYTHON_MODEL_HPP
|
||||
#define ISAAC_PYTHON_MODEL_HPP
|
||||
|
||||
void export_model();
|
||||
void export_templates();
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user