Code quality: more cleaning of files architecture
This commit is contained in:
@@ -6,7 +6,7 @@ add_custom_target( MAKE_HEADERS_VISIBLE SOURCES ${MAKE_HEADERS_VISIBLE_SRC} )
|
||||
|
||||
#Modules
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/lib/external/)
|
||||
|
||||
#CUDA and OpenCL
|
||||
find_package(CUDA QUIET)
|
||||
|
@@ -1,7 +0,0 @@
|
||||
find_path(
|
||||
VIENNACL_INCLUDE_DIR
|
||||
NAMES viennacl/vector.hpp
|
||||
)
|
||||
|
||||
set(VIENNACL_INCLUDE_DIRS ${VIENNACL_INCLUDE_DIR})
|
||||
mark_as_advanced(VIENNACL_INCLUDE_DIRS)
|
@@ -115,7 +115,7 @@ def main():
|
||||
include ='${INCLUDE_DIRECTORIES_STR}'.split() + ['external/boost/include', os.path.join(find_module("numpy")[1], "core", "include")]
|
||||
|
||||
#Source files
|
||||
src = '${LIBISAAC_SRC_STR}'.split() + [os.path.join('src', 'wrap', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
||||
src = '${LIBISAAC_SRC_STR}'.split() + [os.path.join('src', 'bind', 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]
|
||||
|
@@ -19,6 +19,7 @@ struct database
|
||||
public:
|
||||
typedef std::map<std::pair<expression_type, numeric_type>, std::shared_ptr<model> > map_type;
|
||||
private:
|
||||
static std::shared_ptr<templates::base> create(std::string const & template_name, std::vector<int> const & x);
|
||||
static void import(std::string const & fname, driver::CommandQueue const & queue);
|
||||
static map_type & init(driver::CommandQueue const & queue);
|
||||
public:
|
||||
|
@@ -5,7 +5,6 @@ CODE_TO_H(SOURCES ${JSON_FILES} VARNAME json_files EXTENSION "hpp" OUTPUT_DIR "$
|
||||
NAMESPACE "isaac presets" TARGET database EOF "1")
|
||||
|
||||
#Compilation
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/tools")
|
||||
if(ANDROID)
|
||||
add_library(isaac STATIC ${LIBISAAC_SRC})
|
||||
else()
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "helpers/ocl/infos.hpp"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
@@ -28,7 +28,7 @@ std::string Platform::version() const
|
||||
case CUDA:
|
||||
int version;
|
||||
cuDriverGetVersion(&version);
|
||||
return tools::to_string(version);
|
||||
return std::to_string(version);
|
||||
#endif
|
||||
case OPENCL: return ocl::info<CL_PLATFORM_VERSION>(cl_platform_);
|
||||
default: throw;
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#include "isaac/exception/unknown_datatype.h"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
|
||||
unknown_datatype::unknown_datatype(int v) :
|
||||
message_("ISAAC: The data-type provided was not recognized. The datatype code provided is " + tools::to_string(v)) {}
|
||||
message_("ISAAC: The data-type provided was not recognized. The datatype code provided is " + std::to_string(v)) {}
|
||||
|
||||
const char* unknown_datatype::what() const throw()
|
||||
{ return message_.c_str(); }
|
||||
|
@@ -1,12 +1,10 @@
|
||||
#ifndef ISAAC_MODEL_TOOLS_HPP
|
||||
#define ISAAC_MODEL_TOOLS_HPP
|
||||
#ifndef ISAAC_RAPIDJSON_TO_ARRAY_HPP
|
||||
#define ISAAC_RAPIDJSON_TO_ARRAY_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
namespace json
|
||||
namespace rapidjson
|
||||
{
|
||||
|
||||
template<class T>
|
||||
@@ -27,7 +25,6 @@ std::vector<T> to_float_array(rapidjson::Value const & a)
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -8,7 +8,7 @@
|
||||
#include "isaac/kernels/stream.h"
|
||||
#include "isaac/symbolic/expression.h"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
#include "find_and_replace.hpp"
|
||||
|
||||
namespace isaac
|
||||
@@ -56,7 +56,7 @@ mapped_object::node_info::node_info(mapping_type const * _mapping, isaac::array_
|
||||
mapped_object::mapped_object(std::string const & scalartype, unsigned int id, std::string const & type_key) : type_key_(type_key)
|
||||
{
|
||||
register_attribute(scalartype_, "#scalartype", scalartype);
|
||||
register_attribute(name_, "#name", "obj" + tools::to_string(id));
|
||||
register_attribute(name_, "#name", "obj" + std::to_string(id));
|
||||
}
|
||||
|
||||
mapped_object::~mapped_object()
|
||||
@@ -158,10 +158,10 @@ void mapped_host_scalar::preprocess(std::string & str) const
|
||||
mapped_host_scalar::mapped_host_scalar(std::string const & scalartype, unsigned int id) : mapped_object(scalartype, id, "host_scalar"){ }
|
||||
|
||||
//
|
||||
mapped_tuple::mapped_tuple(std::string const & scalartype, unsigned int id, size_t size) : mapped_object(scalartype, id, "tuple"+tools::to_string(size)), size_(size), names_(size)
|
||||
mapped_tuple::mapped_tuple(std::string const & scalartype, unsigned int id, size_t size) : mapped_object(scalartype, id, "tuple"+std::to_string(size)), size_(size), names_(size)
|
||||
{
|
||||
for(size_t i = 0 ; i < size_ ; ++i)
|
||||
register_attribute(names_[i], "#tuplearg"+tools::to_string(i), name_ + tools::to_string(i));
|
||||
register_attribute(names_[i], "#tuplearg"+std::to_string(i), name_ + std::to_string(i));
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include "tools/vector_types.hpp"
|
||||
#include "tools/arguments.hpp"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
@@ -37,7 +37,7 @@ std::string axpy::generate_impl(std::string const & suffix, expressions_tuple co
|
||||
std::string _size_t = size_type(device);
|
||||
|
||||
kernel_generation_stream stream;
|
||||
std::string str_simd_width = tools::to_string(p_.simd_width);
|
||||
std::string str_simd_width = std::to_string(p_.simd_width);
|
||||
std::string dtype = append_width("#scalartype",p_.simd_width);
|
||||
|
||||
switch(backend)
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "tools/map.hpp"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
@@ -39,7 +39,6 @@ bool base::requires_fallback(expressions_tuple const & expressions)
|
||||
|
||||
int_t base::vector_size(array_expression::node const & node)
|
||||
{
|
||||
using namespace tools;
|
||||
if (node.op.type==OPERATOR_MATRIX_DIAG_TYPE)
|
||||
return std::min<int_t>(node.lhs.array->shape()[0], node.lhs.array->shape()[1]);
|
||||
else if (node.op.type==OPERATOR_MATRIX_ROW_TYPE)
|
||||
@@ -83,7 +82,7 @@ std::string base::generate(std::string const & suffix, expressions_tuple const &
|
||||
std::vector<mapping_type>::iterator mit;
|
||||
|
||||
if(int err = is_invalid(expressions, device))
|
||||
throw operation_not_supported_exception("The supplied parameters for this template are invalid : err " + tools::to_string(err));
|
||||
throw operation_not_supported_exception("The supplied parameters for this template are invalid : err " + std::to_string(err));
|
||||
|
||||
//Create mapping
|
||||
std::vector<mapping_type> mappings(expressions.data().size());
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "tools/vector_types.hpp"
|
||||
#include "tools/arguments.hpp"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace isaac
|
||||
@@ -83,10 +83,10 @@ std::string dot::generate_impl(std::string const & suffix, expressions_tuple con
|
||||
if (exprs[k]->is_index_dot())
|
||||
{
|
||||
arguments += exprs[k]->process(Global(backend).get() + " unsigned int* #name_temp, ");
|
||||
arguments += exprs[k]->process(Global(backend).get() + " " + tools::to_string(numeric_type) + "* #name_temp_value, ");
|
||||
arguments += exprs[k]->process(Global(backend).get() + " " + numeric_type + "* #name_temp_value, ");
|
||||
}
|
||||
else
|
||||
arguments += exprs[k]->process(Global(backend).get() + " " + tools::to_string(numeric_type) + "* #name_temp, ");
|
||||
arguments += exprs[k]->process(Global(backend).get() + " " + numeric_type + "* #name_temp, ");
|
||||
}
|
||||
|
||||
std::string name[2] = {"prod", "reduce"};
|
||||
@@ -121,14 +121,14 @@ std::string dot::generate_impl(std::string const & suffix, expressions_tuple con
|
||||
{
|
||||
if (exprs[k]->is_index_dot())
|
||||
{
|
||||
stream << exprs[k]->process(Local(backend).get() + " #scalartype #name_buf_value[" + tools::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << exprs[k]->process(Local(backend).get() + " #scalartype #name_buf_value[" + std::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << exprs[k]->process("#scalartype #name_acc_value = " + neutral_element(exprs[k]->root_op(), backend, "#scalartype") + ";") << std::endl;
|
||||
stream << exprs[k]->process(Local(backend).get() + " unsigned int #name_buf[" + tools::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << exprs[k]->process(Local(backend).get() + " unsigned int #name_buf[" + std::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << exprs[k]->process("unsigned int #name_acc = 0;") << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << exprs[k]->process(Local(backend).get() + " #scalartype #name_buf[" + tools::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << exprs[k]->process(Local(backend).get() + " #scalartype #name_buf[" + std::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << exprs[k]->process("#scalartype #name_acc = " + neutral_element(exprs[k]->root_op(), backend, "#scalartype") + ";") << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -164,8 +164,8 @@ std::string dot::generate_impl(std::string const & suffix, expressions_tuple con
|
||||
accessors["array0"] = "#namereg";
|
||||
std::string value = elem->evaluate_recursive(LHS_NODE_TYPE, accessors);
|
||||
if (elem->is_index_dot())
|
||||
compute_index_dot(stream, elem->process("#name_acc"), "i*" + tools::to_string(simd_width) + "+"
|
||||
+ tools::to_string(a), elem->process("#name_acc_value"), value,elem->root_op());
|
||||
compute_index_dot(stream, elem->process("#name_acc"), "i*" + std::to_string(simd_width) + "+"
|
||||
+ std::to_string(a), elem->process("#name_acc_value"), value,elem->root_op());
|
||||
else
|
||||
compute_dot(stream, elem->process("#name_acc"), value,elem->root_op());
|
||||
}
|
||||
@@ -216,14 +216,14 @@ std::string dot::generate_impl(std::string const & suffix, expressions_tuple con
|
||||
{
|
||||
if (e->is_index_dot())
|
||||
{
|
||||
stream << e->process(Local(backend).get() + " unsigned int #name_buf[" + tools::to_string(p_.local_size_0) + "];");
|
||||
stream << e->process(Local(backend).get() + " unsigned int #name_buf[" + std::to_string(p_.local_size_0) + "];");
|
||||
stream << e->process("unsigned int #name_acc = 0;") << std::endl;
|
||||
stream << e->process(Local(backend).get() + " #scalartype #name_buf_value[" + tools::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << e->process(Local(backend).get() + " #scalartype #name_buf_value[" + std::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << e->process("#scalartype #name_acc_value = " + neutral_element(e->root_op(), backend, "#scalartype") + ";");
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << e->process(Local(backend).get() + " #scalartype #name_buf[" + tools::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << e->process(Local(backend).get() + " #scalartype #name_buf[" + std::to_string(p_.local_size_0) + "];") << std::endl;
|
||||
stream << e->process("#scalartype #name_acc = " + neutral_element(e->root_op(), backend, "#scalartype") + ";");
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "tools/arguments.hpp"
|
||||
#include "tools/vector_types.hpp"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
#include "align.hpp"
|
||||
|
||||
namespace isaac
|
||||
@@ -103,7 +103,7 @@ gemm_parameters::gemm_parameters(unsigned int simd_width
|
||||
std::string gemm::generate_impl(std::string const & suffix, expressions_tuple const & expressions, driver::Device const & device, std::vector<mapping_type> const &) const
|
||||
{
|
||||
using std::string;
|
||||
using tools::to_string;
|
||||
using std::to_string;
|
||||
|
||||
driver::backend_type backend = device.backend();
|
||||
bool has_depth = p_.depth > 1;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "tools/reductions.hpp"
|
||||
#include "tools/vector_types.hpp"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
@@ -38,7 +38,7 @@ unsigned int gemv::lmem_usage(const expressions_tuple &) const
|
||||
|
||||
std::string gemv::generate_impl(std::string const & suffix, expressions_tuple const & expressions, driver::Device const & device, std::vector<mapping_type> const & mappings) const
|
||||
{
|
||||
using tools::to_string;
|
||||
using std::to_string;
|
||||
|
||||
|
||||
std::vector<mapped_gemv*> dots;
|
||||
@@ -67,10 +67,10 @@ std::string gemv::generate_impl(std::string const & suffix, expressions_tuple co
|
||||
if (e->is_index_dot())
|
||||
{
|
||||
arguments += e->process(Global(backend).get() + " unsigned int* #name_temp, ");
|
||||
arguments += e->process(Global(backend).get() + " " + to_string(numeric_type) + "* #name_temp_value,");
|
||||
arguments += e->process(Global(backend).get() + " " + numeric_type + "* #name_temp_value,");
|
||||
}
|
||||
else
|
||||
arguments += e->process(Global(backend).get() + " " + to_string(numeric_type) + "* #name_temp, ");
|
||||
arguments += e->process(Global(backend).get() + " " + numeric_type + "* #name_temp, ");
|
||||
}
|
||||
|
||||
switch(backend)
|
||||
|
@@ -1,7 +1,9 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "isaac/model/database.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/to_array.hpp"
|
||||
|
||||
#include "isaac/model/database.h"
|
||||
#include "isaac/kernels/parse.h"
|
||||
#include "isaac/kernels/templates/axpy.h"
|
||||
#include "isaac/kernels/templates/dot.h"
|
||||
@@ -9,50 +11,43 @@
|
||||
#include "isaac/kernels/templates/gemv.h"
|
||||
#include "isaac/kernels/templates/gemm.h"
|
||||
|
||||
#include "json/rapidjson/document.h"
|
||||
#include "json/to_array.hpp"
|
||||
|
||||
#include "presets/broadwell.hpp"
|
||||
|
||||
#include "getenv.hpp"
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
|
||||
namespace detail
|
||||
|
||||
std::shared_ptr<templates::base> database::create(std::string const & template_name, std::vector<int> const & x)
|
||||
{
|
||||
static std::shared_ptr<templates::base> create(std::string const & template_name, std::vector<int> const & a)
|
||||
{
|
||||
templates::fetching_policy_type fetch[] = {templates::FETCH_FROM_LOCAL, templates::FETCH_FROM_GLOBAL_STRIDED, templates::FETCH_FROM_GLOBAL_CONTIGUOUS};
|
||||
if(template_name=="axpy")
|
||||
return std::shared_ptr<templates::base>(new templates::axpy(a[0], a[1], a[2], fetch[a[3]]));
|
||||
else if(template_name=="dot")
|
||||
return std::shared_ptr<templates::base>(new templates::dot(a[0], a[1], a[2], fetch[a[3]]));
|
||||
else if(template_name=="ger")
|
||||
return std::shared_ptr<templates::base>(new templates::ger(a[0], a[1], a[2], a[3], a[4], fetch[a[5]]));
|
||||
else if(template_name.find("gemv_n")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemv_n(a[0], a[1], a[2], a[3], a[4], fetch[a[5]]));
|
||||
else if(template_name.find("gemv_t")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemv_t(a[0], a[1], a[2], a[3], a[4], fetch[a[5]]));
|
||||
else if(template_name.find("gemm_nn")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_nn(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], fetch[a[8]], fetch[a[9]], a[10], a[11]));
|
||||
else if(template_name.find("gemm_tn")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_tn(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], fetch[a[8]], fetch[a[9]], a[10], a[11]));
|
||||
else if(template_name.find("gemm_nt")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_nt(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], fetch[a[8]], fetch[a[9]], a[10], a[11]));
|
||||
else if(template_name.find("gemm_tt")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_tt(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], fetch[a[8]], fetch[a[9]], a[10], a[11]));
|
||||
else
|
||||
throw std::invalid_argument("Invalid expression: " + template_name);
|
||||
}
|
||||
templates::fetching_policy_type fetch[] = {templates::FETCH_FROM_LOCAL, templates::FETCH_FROM_GLOBAL_STRIDED, templates::FETCH_FROM_GLOBAL_CONTIGUOUS};
|
||||
if(template_name=="axpy")
|
||||
return std::shared_ptr<templates::base>(new templates::axpy(x[0], x[1], x[2], fetch[x[3]]));
|
||||
else if(template_name=="dot")
|
||||
return std::shared_ptr<templates::base>(new templates::dot(x[0], x[1], x[2], fetch[x[3]]));
|
||||
else if(template_name=="ger")
|
||||
return std::shared_ptr<templates::base>(new templates::ger(x[0], x[1], x[2], x[3], x[4], fetch[x[5]]));
|
||||
else if(template_name.find("gemv_n")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemv_n(x[0], x[1], x[2], x[3], x[4], fetch[x[5]]));
|
||||
else if(template_name.find("gemv_t")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemv_t(x[0], x[1], x[2], x[3], x[4], fetch[x[5]]));
|
||||
else if(template_name.find("gemm_nn")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_nn(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], fetch[x[8]], fetch[x[9]], x[10], x[11]));
|
||||
else if(template_name.find("gemm_tn")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_tn(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], fetch[x[8]], fetch[x[9]], x[10], x[11]));
|
||||
else if(template_name.find("gemm_nt")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_nt(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], fetch[x[8]], fetch[x[9]], x[10], x[11]));
|
||||
else if(template_name.find("gemm_tt")!=std::string::npos)
|
||||
return std::shared_ptr<templates::base>(new templates::gemm_tt(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], fetch[x[8]], fetch[x[9]], x[10], x[11]));
|
||||
else
|
||||
throw std::invalid_argument("Invalid expression: " + template_name);
|
||||
}
|
||||
|
||||
void database::import(std::string const & str, driver::CommandQueue const & queue)
|
||||
{
|
||||
namespace js = rapidjson;
|
||||
map_type & result = cache_[queue];
|
||||
//Parse the JSON document
|
||||
js::Document document;
|
||||
rapidjson::Document document;
|
||||
document.Parse<0>(str.c_str());
|
||||
//Deserialize
|
||||
std::vector<std::string> operations = {"axpy", "dot", "ger", "gemv_n", "gemv_t", "gemm_nn", "gemm_tn", "gemm_nt", "gemm_tt"};
|
||||
@@ -71,9 +66,9 @@ void database::import(std::string const & str, driver::CommandQueue const & queu
|
||||
numeric_type dtype = numeric_type_from_string(elem);
|
||||
// Get profiles
|
||||
std::vector<std::shared_ptr<templates::base> > templates;
|
||||
js::Value const & profiles = document[opcstr][dtcstr]["profiles"];
|
||||
for (js::SizeType id = 0 ; id < profiles.Size() ; ++id)
|
||||
templates.push_back(detail::create(operation, json::to_int_array<int>(profiles[id])));
|
||||
rapidjson::Value const & profiles = document[opcstr][dtcstr]["profiles"];
|
||||
for (rapidjson::SizeType id = 0 ; id < profiles.Size() ; ++id)
|
||||
templates.push_back(create(operation, rapidjson::to_int_array<int>(profiles[id])));
|
||||
if(templates.size()>1)
|
||||
{
|
||||
// Get predictor
|
||||
@@ -138,16 +133,4 @@ void database::set(driver::CommandQueue const & queue, expression_type operation
|
||||
|
||||
std::map<driver::CommandQueue, database::map_type> database::cache_;
|
||||
|
||||
//Presets
|
||||
|
||||
#define DATABASE_ENTRY(VENDOR, ARCHITECTURE, STRING) \
|
||||
{std::make_tuple(driver::Device::Vendor::VENDOR, driver::Device::Architecture::ARCHITECTURE), STRING}
|
||||
|
||||
const std::map<std::tuple<driver::Device::Vendor, driver::Device::Architecture> , const char *> database::presets_ =
|
||||
{ DATABASE_ENTRY(INTEL, BROADWELL, presets::broadwell) };
|
||||
|
||||
|
||||
#undef DATABASE_ENTRY
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "isaac/model/predictors/random_forest.h"
|
||||
#include "../json/to_array.hpp"
|
||||
#include "rapidjson/to_array.hpp"
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
@@ -10,12 +10,12 @@ namespace predictors
|
||||
|
||||
random_forest::tree::tree(rapidjson::Value const & treerep)
|
||||
{
|
||||
children_left_ = json::to_int_array<int>(treerep["children_left"]);
|
||||
children_right_ = json::to_int_array<int>(treerep["children_right"]);
|
||||
threshold_ = json::to_float_array<float>(treerep["threshold"]);
|
||||
feature_ = json::to_float_array<float>(treerep["feature"]);
|
||||
children_left_ = rapidjson::to_int_array<int>(treerep["children_left"]);
|
||||
children_right_ = rapidjson::to_int_array<int>(treerep["children_right"]);
|
||||
threshold_ = rapidjson::to_float_array<float>(treerep["threshold"]);
|
||||
feature_ = rapidjson::to_float_array<float>(treerep["feature"]);
|
||||
for(rapidjson::SizeType i = 0 ; i < treerep["value"].Size() ; i++)
|
||||
value_.push_back(json::to_float_array<float>(treerep["value"][i]));
|
||||
value_.push_back(rapidjson::to_float_array<float>(treerep["value"][i]));
|
||||
D_ = value_[0].size();
|
||||
}
|
||||
|
||||
|
19
lib/model/presets.cpp
Normal file
19
lib/model/presets.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "isaac/driver/device.h"
|
||||
#include "isaac/model/database.h"
|
||||
|
||||
#include "presets/broadwell.hpp"
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
|
||||
|
||||
#define DATABASE_ENTRY(VENDOR, ARCHITECTURE, STRING) \
|
||||
{std::make_tuple(driver::Device::Vendor::VENDOR, driver::Device::Architecture::ARCHITECTURE), STRING}
|
||||
|
||||
const std::map<std::tuple<driver::Device::Vendor, driver::Device::Architecture> , const char *> database::presets_ =
|
||||
{ DATABASE_ENTRY(INTEL, BROADWELL, presets::broadwell) };
|
||||
|
||||
|
||||
#undef DATABASE_ENTRY
|
||||
|
||||
}
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "isaac/symbolic/io.h"
|
||||
|
||||
#include "to_string.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
@@ -25,9 +25,9 @@ inline std::string to_string(lhs_rhs_element const & e)
|
||||
{
|
||||
if(e.type_family==COMPOSITE_OPERATOR_FAMILY)
|
||||
{
|
||||
return"COMPOSITE [" + tools::to_string(e.node_index) + "]";
|
||||
return"COMPOSITE [" + std::to_string(e.node_index) + "]";
|
||||
}
|
||||
return tools::to_string(e.subtype);
|
||||
return std::to_string(e.subtype);
|
||||
}
|
||||
|
||||
inline std::ostream & operator<<(std::ostream & os, array_expression::node const & s_node)
|
||||
|
@@ -112,10 +112,10 @@ def main():
|
||||
library_dirs = [config['lib'] for config in [opencl_config, cuda_config] if config is not None]
|
||||
|
||||
#Include directories
|
||||
include =' src/include'.split() + ['external/boost/include', os.path.join(find_module("numpy")[1], "core", "include")]
|
||||
include =' src/include src/lib/external'.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/database.cpp src/lib/model/predictors/random_forest.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/program_cache.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/kernels/templates/gemv.cpp src/lib/kernels/templates/axpy.cpp src/lib/kernels/templates/gemm.cpp src/lib/kernels/templates/ger.cpp src/lib/kernels/templates/dot.cpp src/lib/kernels/templates/base.cpp src/lib/kernels/mapped_object.cpp src/lib/kernels/stream.cpp src/lib/kernels/parse.cpp src/lib/kernels/keywords.cpp src/lib/kernels/binder.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/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/presets.cpp src/lib/model/database.cpp src/lib/model/predictors/random_forest.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/program_cache.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/kernels/templates/gemv.cpp src/lib/kernels/templates/axpy.cpp src/lib/kernels/templates/gemm.cpp src/lib/kernels/templates/ger.cpp src/lib/kernels/templates/dot.cpp src/lib/kernels/templates/base.cpp src/lib/kernels/mapped_object.cpp src/lib/kernels/stream.cpp src/lib/kernels/parse.cpp src/lib/kernels/keywords.cpp src/lib/kernels/binder.cpp src/lib/wrap/clBLAS.cpp '.split() + [os.path.join('src', 'bind', 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]
|
||||
|
@@ -51,11 +51,11 @@ namespace detail
|
||||
|
||||
struct model_map_indexing
|
||||
{
|
||||
static isc::model& get_item(isc::models::map_type& container, bp::tuple i_)
|
||||
static isc::model& get_item(isc::database::map_type& container, bp::tuple i_)
|
||||
{
|
||||
isc::expression_type expression = tools::extract_template_type(i_[0]);
|
||||
isc::numeric_type dtype = tools::extract_dtype(i_[1]);
|
||||
isc::models::map_type::iterator i = container.find(std::make_pair(expression, dtype));
|
||||
isc::database::map_type::iterator i = container.find(std::make_pair(expression, dtype));
|
||||
if (i == container.end())
|
||||
{
|
||||
PyErr_SetString(PyExc_KeyError, "Invalid key");
|
||||
@@ -64,7 +64,7 @@ namespace detail
|
||||
return *i->second;
|
||||
}
|
||||
|
||||
static void set_item(isc::models::map_type& container, bp::tuple i_, isc::model const & v)
|
||||
static void set_item(isc::database::map_type& container, bp::tuple i_, isc::model const & v)
|
||||
{
|
||||
isc::expression_type expression = tools::extract_template_type(i_[0]);
|
||||
isc::numeric_type dtype = tools::extract_dtype(i_[1]);
|
||||
@@ -94,7 +94,7 @@ namespace detail
|
||||
isc::array_expression::container_type::value_type root = expression.tree()[expression.root()];
|
||||
if(isc::detail::is_assignment(root.op))
|
||||
{
|
||||
isc::execute(isc::control(expression, execution_options, dispatcher_options, compilation_options), isaac::models::get(execution_options.queue(expression.context())));
|
||||
isc::execute(isc::control(expression, execution_options, dispatcher_options, compilation_options), isaac::database::get(execution_options.queue(expression.context())));
|
||||
return bp::make_tuple(bp::ptr(root.lhs.array), tools::to_list(events.begin(), events.end()));
|
||||
}
|
||||
else
|
||||
@@ -118,7 +118,7 @@ void export_driver()
|
||||
.def("append", &bp::vector_indexing_suite<queues_t>::append)
|
||||
;
|
||||
|
||||
bp::class_<isc::models::map_type>("models")
|
||||
bp::class_<isc::database::map_type>("models")
|
||||
.def("__getitem__", &detail::model_map_indexing::get_item, bp::return_internal_reference<>())
|
||||
.def("__setitem__", &detail::model_map_indexing::set_item, bp::with_custodian_and_ward<1,2>())
|
||||
;
|
||||
@@ -145,10 +145,10 @@ void export_driver()
|
||||
|
||||
bp::enum_<isaac::driver::Device::Vendor>
|
||||
("vendor")
|
||||
.value("AMD", isc::driver::Device::AMD)
|
||||
.value("INTEL", isc::driver::Device::INTEL)
|
||||
.value("NVIDIA", isc::driver::Device::NVIDIA)
|
||||
.value("UNKNOWN", isc::driver::Device::UNKNOWN)
|
||||
.value("AMD", isc::driver::Device::Vendor::AMD)
|
||||
.value("INTEL", isc::driver::Device::Vendor::INTEL)
|
||||
.value("NVIDIA", isc::driver::Device::Vendor::NVIDIA)
|
||||
.value("UNKNOWN", isc::driver::Device::Vendor::UNKNOWN)
|
||||
;
|
||||
|
||||
bp::class_<isc::driver::Device>("device", bp::no_init)
|
||||
@@ -168,7 +168,7 @@ void export_driver()
|
||||
|
||||
bp::class_<isc::driver::CommandQueue>("command_queue", bp::init<isc::driver::Context const &, isc::driver::Device const &>())
|
||||
.def("synchronize", &isc::driver::CommandQueue::synchronize)
|
||||
.add_property("models", bp::make_function(&isc::models::get, bp::return_internal_reference<>()))
|
||||
.add_property("models", bp::make_function(&isc::database::get, bp::return_internal_reference<>()))
|
||||
.add_property("device", bp::make_function(&isc::driver::CommandQueue::device, bp::return_internal_reference<>()))
|
||||
;
|
||||
|
@@ -9,7 +9,7 @@ void android_main(struct android_app* state)
|
||||
app_dummy(); // Make sure glue isn't stripped
|
||||
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", "This is a test");
|
||||
isaac::array test(5, isaac::FLOAT_TYPE);
|
||||
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", isaac::tools::to_string(test).c_str());
|
||||
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", isaac::std::to_string(test).c_str());
|
||||
ANativeActivity_finish(state->activity);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user