From df9f6142ef26857516ed6ee72b337132b257b5b7 Mon Sep 17 00:00:00 2001 From: Philippe Tillet Date: Wed, 5 Aug 2015 17:01:42 -0700 Subject: [PATCH] Models: added basic database structure --- CMakeLists.txt | 3 + cmake/helpers/CodeToH.cmake | 2 +- cmake/helpers/bin2cpp.cpp | 16 +- include/isaac/driver/device.h | 13 +- include/isaac/model/model.h | 1 + lib/CMakeLists.txt | 12 +- lib/driver/device.cpp | 43 ++- lib/kernels/templates/gemm.cpp | 10 +- lib/model/database/broadwell.hpp | 390 +++++++++++++++++++++++++ lib/model/database/json/broadwell.json | 1 + lib/model/model.cpp | 7 +- python/setup.py | 340 ++++++++++----------- 12 files changed, 639 insertions(+), 199 deletions(-) create mode 100644 lib/model/database/broadwell.hpp create mode 100644 lib/model/database/json/broadwell.json mode change 100755 => 100644 python/setup.py diff --git a/CMakeLists.txt b/CMakeLists.txt index a456afdae..9cdaf40ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,9 @@ endif() #Binary to convert .cu files to const char * add_executable(bin2cpp ${CMAKE_MODULE_PATH}/helpers/bin2cpp.cpp) +include("${CMAKE_MODULE_PATH}/helpers/CodeToH.cmake") + +#Source files file(GLOB_RECURSE LIBISAAC_SRC lib/*.cpp) #Python wrapper diff --git a/cmake/helpers/CodeToH.cmake b/cmake/helpers/CodeToH.cmake index 0a1a7dccb..039e3e2cb 100644 --- a/cmake/helpers/CodeToH.cmake +++ b/cmake/helpers/CodeToH.cmake @@ -51,7 +51,7 @@ function(CODE_TO_H) DEPENDS ${_input_file} ${BIN2CPP_PROGRAM} COMMAND ${CMAKE_COMMAND} -E make_directory "${_output_path}" COMMAND ${CMAKE_COMMAND} -E echo "\\#include \\<${_path}/${_name_we}.hpp\\>" >>"${_output_file}" - COMMAND ${BIN2CPP_PROGRAM} --file ${_name} --namespace ${_namespace} --output ${_output_file} --name ${var_name} --eof ${ARGS_EOF} + COMMAND ${BIN2CPP_PROGRAM} --file ${_name} --namespace ${_namespace} --output ${_output_file} --name ${var_name} --eof ${ARGS_EOF} --extension ${ARGS_EXTENSION} WORKING_DIRECTORY "${_path}" COMMENT "Compiling ${_input_file} to C++ source" ) diff --git a/cmake/helpers/bin2cpp.cpp b/cmake/helpers/bin2cpp.cpp index f2849b3e2..f93f1e346 100644 --- a/cmake/helpers/bin2cpp.cpp +++ b/cmake/helpers/bin2cpp.cpp @@ -11,6 +11,7 @@ #include #include #include +#include using namespace std; typedef map opt_t; @@ -70,6 +71,7 @@ parse_options(const vector& args) { options["--type"] = ""; options["--file"] = ""; options["--output"] = ""; + options["--extension"] = ""; options["--namespace"] = ""; options["--eof"] = ""; @@ -132,9 +134,11 @@ int main(int argc, const char * const * const argv) cout.rdbuf(outfile->rdbuf()); } - cout << "#pragma once\n"; + if(options["--extension"] != "cpp") + cout << "#pragma once\n"; + cout << "\n"; cout << "#include \n"; // defines size_t - + cout << "\n"; int ns_cnt = 0; int level = 0; if(options["--namespace"] != "") { @@ -143,7 +147,8 @@ int main(int argc, const char * const * const argv) namespaces >> name; do { add_tabs(level++); - cout << "namespace " << name << " { \n"; + cout << "namespace " << name << "\n"; + cout << "{\n"; ns_cnt++; namespaces >> name; } while(!namespaces.fail()); @@ -153,6 +158,7 @@ int main(int argc, const char * const * const argv) options["--type"] = "char"; } add_tabs(level); + cout << "\n"; cout << "static const " << options["--type"] << " " << options["--name"] << "[] = {\n"; @@ -176,7 +182,9 @@ int main(int argc, const char * const * const argv) cout << "};\n"; add_tabs(--level); - cout << "static const size_t " << options["--name"] << "_len" << " = " << std::dec << char_cnt << ";\n"; + cout << "\n"; + cout << "static const std::size_t " << options["--name"] << "_len" << " = " << std::dec << char_cnt << ";\n"; + cout << "\n"; while(ns_cnt--) { add_tabs(--level); diff --git a/include/isaac/driver/device.h b/include/isaac/driver/device.h index 2b9905c86..7123bcca8 100644 --- a/include/isaac/driver/device.h +++ b/include/isaac/driver/device.h @@ -20,7 +20,7 @@ private: friend class CommandQueue; public: - enum ISAACAPI VENDOR + enum class ISAACAPI VENDOR { AMD, INTEL, @@ -28,6 +28,13 @@ public: UNKNOWN }; + enum class ISAACAPI ARCHITECTURE + { + HASWELL, + BROADWELL, + UNKNOWN + }; + private: #ifdef ISAAC_WITH_CUDA template @@ -42,13 +49,15 @@ public: bool operator==(Device const &) const; bool operator<(Device const &) const; + VENDOR vendor() const; + ARCHITECTURE architecture() const; + backend_type backend() const; size_t clock_rate() const; unsigned int address_bits() const; driver::Platform platform() const; std::string name() const; std::string vendor_str() const; - VENDOR vendor() const; std::vector max_work_item_sizes() const; device_type type() const; std::string extensions() const; diff --git a/include/isaac/model/model.h b/include/isaac/model/model.h index 786546b07..36a26fcdf 100644 --- a/include/isaac/model/model.h +++ b/include/isaac/model/model.h @@ -50,6 +50,7 @@ namespace isaac static void set(driver::CommandQueue const & queue, expression_type operation, numeric_type dtype, std::shared_ptr const & model); private: static std::map data_; + static const std::map , const char *> database_; }; extern std::map, std::shared_ptr > fallbacks; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index c1637a878..d95990fe8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,3 +1,10 @@ +#Database +set(DATABASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/model/database/") +file(GLOB_RECURSE JSON_FILES "${DATABASE_PATH}/json/*.json") +CODE_TO_H(SOURCES ${JSON_FILES} VARNAME json_files EXTENSION "hpp" OUTPUT_DIR "${DATABASE_PATH}" + NAMESPACE "isaac database" TARGET database EOF "0") + +#Compilation if(ANDROID) add_library(isaac STATIC ${LIBISAAC_SRC}) else() @@ -8,6 +15,7 @@ else() endif() endif() +#Linkage if(OPENCL_FOUND) target_link_libraries(isaac ${OPENCL_LIBRARIES}) endif() @@ -17,13 +25,11 @@ if(CUDA_FOUND) #Cuda JIT headers to file set(CUDA_HELPERS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/driver/helpers/cuda/) file(GLOB_RECURSE CUDA_HELPERS_SRC ${CUDA_HELPERS_PATH}/*.cu) - include("${CMAKE_MODULE_PATH}/helpers/CodeToH.cmake") CODE_TO_H(SOURCES ${CUDA_HELPERS_SRC} VARNAME kernel_files EXTENSION "hpp" OUTPUT_DIR ${CUDA_HELPERS_PATH} NAMESPACE "isaac helpers cuda" TARGET cuda_headers EOF "0") endif() - - +#Installation install(TARGETS isaac LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) set(INSTALL_INCLUDE_DIR /usr/local/include) install(DIRECTORY isaac "${PROJECT_SOURCE_DIR}/include/isaac" diff --git a/lib/driver/device.cpp b/lib/driver/device.cpp index f50bd9a0b..0309fdd11 100644 --- a/lib/driver/device.cpp +++ b/lib/driver/device.cpp @@ -39,6 +39,36 @@ bool Device::operator<(Device const & other) const } + +Device::VENDOR Device::vendor() const +{ + std::string vname = vendor_str(); + std::transform(vname.begin(), vname.end(), vname.begin(), ::tolower); + if(vname.find("nvidia")!=std::string::npos) + return VENDOR::NVIDIA; + else if(vname.find("intel")!=std::string::npos) + return VENDOR::INTEL; + else if(vname.find("amd")!=std::string::npos || vname.find("advanced micro devices")!=std::string::npos) + return VENDOR::AMD; + else + return VENDOR::UNKNOWN; +} + +Device::ARCHITECTURE Device::architecture() const +{ + switch(vendor()) + { + case VENDOR::INTEL: + { + return ARCHITECTURE::BROADWELL; + } + default: + { + return ARCHITECTURE::UNKNOWN; + } + } +} + backend_type Device::backend() const { return backend_; } @@ -95,19 +125,6 @@ std::string Device::vendor_str() const } } -Device::VENDOR Device::vendor() const -{ - std::string vname = vendor_str(); - std::transform(vname.begin(), vname.end(), vname.begin(), ::tolower); - if(vname.find("nvidia")!=std::string::npos) - return NVIDIA; - else if(vname.find("intel")!=std::string::npos) - return INTEL; - else if(vname.find("amd")!=std::string::npos || vname.find("advanced micro devices")!=std::string::npos) - return AMD; - else - return UNKNOWN; -} std::vector Device::max_work_item_sizes() const { diff --git a/lib/kernels/templates/gemm.cpp b/lib/kernels/templates/gemm.cpp index bb3e7c6c8..450bbdbbd 100644 --- a/lib/kernels/templates/gemm.cpp +++ b/lib/kernels/templates/gemm.cpp @@ -43,16 +43,16 @@ gemm_parameters::gemm_parameters(unsigned int simd_width return N*size_of(numeric_t); } - int gemm::is_invalid_impl(driver::Device const &, expressions_tuple const & expressions) const + int gemm::is_invalid_impl(driver::Device const &, expressions_tuple const & ) const { - std::vector MNK = input_sizes(expressions); - int_t M = MNK[0]; int_t N = MNK[1]; +// std::vector MNK = input_sizes(expressions); +// int_t M = MNK[0]; int_t N = MNK[1]; if(p_.A_fetching_policy!=FETCH_FROM_LOCAL || p_.B_fetching_policy!=FETCH_FROM_LOCAL) throw operation_not_supported_exception("Only local memory is supported for GEMM"); - if(p_.depth > 1 && M*N*p_.depth > 2e6) - throw operation_not_supported_exception("This would necessitate a temporary larger than 1MB"); +// if(p_.depth > 1 && M*N*p_.depth > 2e6) +// throw operation_not_supported_exception("This would necessitate a temporary larger than 1MB"); if ((p_.mS % p_.simd_width) > 0 || (p_.nS % p_.simd_width) > 0) return TEMPLATE_MS_NS_MUST_BE_SIMD_WIDTH_MULTIPLE; diff --git a/lib/model/database/broadwell.hpp b/lib/model/database/broadwell.hpp new file mode 100644 index 000000000..92489e72b --- /dev/null +++ b/lib/model/database/broadwell.hpp @@ -0,0 +1,390 @@ +#pragma once + +#include + +namespace isaac +{ +namespace database +{ + +static const char broadwell[] = { +0x7b, 0x22, 0x67, 0x65, 0x6d, 0x6d, 0x5f, 0x6e, 0x74, 0x22, +0x3a, 0x20, 0x7b, 0x22, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, +0x32, 0x22, 0x3a, 0x20, 0x7b, 0x22, 0x70, 0x72, 0x65, 0x64, +0x69, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x3a, 0x20, 0x5b, 0x7b, +0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, +0x72, 0x69, 0x67, 0x68, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, +0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, +0x20, 0x22, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, +0x64, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x38, 0x38, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, +0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, +0x66, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, +0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x66, +0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x3a, 0x20, 0x5b, +0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, +0x20, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, +0x5b, 0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x37, +0x33, 0x2e, 0x39, 0x36, 0x2c, 0x20, 0x32, 0x37, 0x36, 0x2e, +0x37, 0x34, 0x2c, 0x20, 0x32, 0x36, 0x37, 0x2e, 0x36, 0x32, +0x2c, 0x20, 0x32, 0x37, 0x35, 0x2e, 0x37, 0x31, 0x5d, 0x2c, +0x20, 0x5b, 0x33, 0x33, 0x34, 0x2e, 0x39, 0x35, 0x2c, 0x20, +0x33, 0x34, 0x34, 0x2e, 0x34, 0x34, 0x2c, 0x20, 0x33, 0x34, +0x35, 0x2e, 0x32, 0x38, 0x2c, 0x20, 0x33, 0x33, 0x31, 0x2e, +0x37, 0x32, 0x5d, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x63, +0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, 0x69, +0x67, 0x68, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2c, 0x20, +0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, +0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, +0x3a, 0x20, 0x5b, 0x32, 0x38, 0x38, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, +0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, +0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, 0x66, 0x74, +0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x2c, +0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x66, 0x65, 0x61, +0x74, 0x75, 0x72, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, +0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x36, 0x39, 0x2e, +0x31, 0x33, 0x2c, 0x20, 0x32, 0x37, 0x31, 0x2e, 0x35, 0x34, +0x2c, 0x20, 0x32, 0x36, 0x31, 0x2e, 0x34, 0x34, 0x2c, 0x20, +0x32, 0x37, 0x31, 0x2e, 0x35, 0x39, 0x5d, 0x2c, 0x20, 0x5b, +0x33, 0x33, 0x34, 0x2e, 0x39, 0x35, 0x2c, 0x20, 0x33, 0x34, +0x34, 0x2e, 0x34, 0x34, 0x2c, 0x20, 0x33, 0x34, 0x35, 0x2e, +0x32, 0x38, 0x2c, 0x20, 0x33, 0x33, 0x31, 0x2e, 0x37, 0x32, +0x5d, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x63, 0x68, 0x69, +0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, 0x69, 0x67, 0x68, +0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2c, 0x20, 0x2d, 0x31, +0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x74, 0x68, +0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0x3a, 0x20, +0x5b, 0x31, 0x36, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, +0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, +0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, +0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x22, 0x3a, +0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, +0x31, 0x5d, 0x2c, 0x20, 0x22, 0x66, 0x65, 0x61, 0x74, 0x75, +0x72, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, +0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x76, 0x61, +0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x35, 0x34, 0x2e, 0x36, 0x36, +0x2c, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x39, 0x33, 0x2c, 0x20, +0x32, 0x34, 0x32, 0x2e, 0x38, 0x39, 0x2c, 0x20, 0x32, 0x35, +0x39, 0x2e, 0x32, 0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x38, +0x33, 0x2e, 0x36, 0x31, 0x2c, 0x20, 0x32, 0x38, 0x37, 0x2e, +0x31, 0x35, 0x2c, 0x20, 0x32, 0x37, 0x39, 0x2e, 0x39, 0x39, +0x2c, 0x20, 0x32, 0x38, 0x33, 0x2e, 0x39, 0x35, 0x5d, 0x5d, +0x7d, 0x5d, 0x2c, 0x20, 0x22, 0x70, 0x72, 0x6f, 0x66, 0x69, +0x6c, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x34, 0x2c, +0x20, 0x38, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x38, 0x2c, 0x20, +0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, +0x2c, 0x20, 0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x31, 0x36, +0x2c, 0x20, 0x34, 0x5d, 0x2c, 0x20, 0x5b, 0x34, 0x2c, 0x20, +0x38, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, +0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, +0x20, 0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x38, 0x2c, 0x20, +0x38, 0x5d, 0x2c, 0x20, 0x5b, 0x34, 0x2c, 0x20, 0x38, 0x2c, +0x20, 0x31, 0x36, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, +0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, +0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x38, +0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x2c, 0x20, 0x38, 0x2c, 0x20, +0x38, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, +0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x30, 0x2c, +0x20, 0x30, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x38, 0x5d, 0x5d, +0x7d, 0x7d, 0x2c, 0x20, 0x22, 0x76, 0x65, 0x72, 0x73, 0x69, +0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x2e, 0x30, 0x22, +0x2c, 0x20, 0x22, 0x67, 0x65, 0x6d, 0x6d, 0x5f, 0x74, 0x6e, +0x22, 0x3a, 0x20, 0x7b, 0x22, 0x66, 0x6c, 0x6f, 0x61, 0x74, +0x33, 0x32, 0x22, 0x3a, 0x20, 0x7b, 0x22, 0x70, 0x72, 0x65, +0x64, 0x69, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x3a, 0x20, 0x5b, +0x7b, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, +0x5f, 0x72, 0x69, 0x67, 0x68, 0x74, 0x22, 0x3a, 0x20, 0x5b, +0x32, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, +0x2c, 0x20, 0x22, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, +0x6c, 0x64, 0x22, 0x3a, 0x20, 0x5b, 0x34, 0x34, 0x39, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, +0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, +0x65, 0x66, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, +0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, +0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x3a, 0x20, +0x5b, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, +0x2c, 0x20, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, +0x20, 0x5b, 0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, +0x2c, 0x20, 0x5b, 0x31, 0x39, 0x39, 0x2e, 0x38, 0x36, 0x2c, +0x20, 0x31, 0x37, 0x34, 0x2e, 0x38, 0x37, 0x2c, 0x20, 0x37, +0x35, 0x2e, 0x33, 0x36, 0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x32, +0x35, 0x2e, 0x38, 0x34, 0x2c, 0x20, 0x31, 0x39, 0x30, 0x2e, +0x34, 0x33, 0x2c, 0x20, 0x31, 0x35, 0x31, 0x2e, 0x31, 0x37, +0x5d, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x63, 0x68, 0x69, +0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, 0x69, 0x67, 0x68, +0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2c, 0x20, 0x2d, 0x31, +0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x74, 0x68, +0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0x3a, 0x20, +0x5b, 0x31, 0x35, 0x39, 0x37, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, +0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, +0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x22, +0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, +0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x66, 0x65, 0x61, 0x74, +0x75, 0x72, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x76, +0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x30, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x32, +0x31, 0x38, 0x2e, 0x39, 0x36, 0x2c, 0x20, 0x31, 0x39, 0x32, +0x2e, 0x32, 0x34, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, +0x2c, 0x20, 0x5b, 0x31, 0x30, 0x37, 0x2e, 0x33, 0x35, 0x2c, +0x20, 0x31, 0x31, 0x31, 0x2e, 0x36, 0x37, 0x2c, 0x20, 0x31, +0x37, 0x35, 0x2e, 0x38, 0x31, 0x5d, 0x5d, 0x7d, 0x5d, 0x2c, +0x20, 0x22, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x73, +0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x31, 0x2c, 0x20, 0x34, 0x2c, +0x20, 0x34, 0x2c, 0x20, 0x31, 0x36, 0x2c, 0x20, 0x31, 0x2c, +0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, +0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x32, 0x2c, 0x20, 0x33, +0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x38, 0x2c, +0x20, 0x38, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, +0x34, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x30, +0x2c, 0x20, 0x30, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x38, 0x5d, +0x2c, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x31, 0x36, 0x2c, 0x20, +0x38, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x34, +0x2c, 0x20, 0x32, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x30, 0x2c, +0x20, 0x30, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x38, 0x5d, 0x5d, +0x7d, 0x7d, 0x2c, 0x20, 0x22, 0x67, 0x65, 0x6d, 0x6d, 0x5f, +0x6e, 0x6e, 0x22, 0x3a, 0x20, 0x7b, 0x22, 0x66, 0x6c, 0x6f, +0x61, 0x74, 0x33, 0x32, 0x22, 0x3a, 0x20, 0x7b, 0x22, 0x70, +0x72, 0x65, 0x64, 0x69, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x3a, +0x20, 0x5b, 0x7b, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, +0x65, 0x6e, 0x5f, 0x72, 0x69, 0x67, 0x68, 0x74, 0x22, 0x3a, +0x20, 0x5b, 0x32, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x34, +0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, +0x20, 0x22, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, +0x64, 0x22, 0x3a, 0x20, 0x5b, 0x37, 0x38, 0x31, 0x2e, 0x35, +0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x34, 0x34, 0x39, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, +0x5d, 0x2c, 0x20, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, +0x3a, 0x20, 0x5b, 0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x36, 0x39, 0x2e, +0x35, 0x39, 0x2c, 0x20, 0x32, 0x33, 0x39, 0x2e, 0x31, 0x38, +0x2c, 0x20, 0x31, 0x34, 0x32, 0x2e, 0x32, 0x32, 0x2c, 0x20, +0x31, 0x35, 0x32, 0x2e, 0x39, 0x39, 0x2c, 0x20, 0x31, 0x36, +0x33, 0x2e, 0x37, 0x33, 0x5d, 0x2c, 0x20, 0x5b, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, +0x31, 0x38, 0x33, 0x2e, 0x34, 0x32, 0x2c, 0x20, 0x31, 0x37, +0x38, 0x2e, 0x39, 0x37, 0x2c, 0x20, 0x32, 0x30, 0x31, 0x2e, +0x35, 0x30, 0x2c, 0x20, 0x32, 0x33, 0x31, 0x2e, 0x34, 0x32, +0x2c, 0x20, 0x32, 0x37, 0x35, 0x2e, 0x34, 0x30, 0x5d, 0x2c, +0x20, 0x5b, 0x32, 0x30, 0x36, 0x2e, 0x36, 0x30, 0x2c, 0x20, +0x33, 0x34, 0x31, 0x2e, 0x34, 0x35, 0x2c, 0x20, 0x32, 0x30, +0x37, 0x2e, 0x35, 0x34, 0x2c, 0x20, 0x32, 0x34, 0x32, 0x2e, +0x33, 0x37, 0x2c, 0x20, 0x32, 0x38, 0x38, 0x2e, 0x34, 0x34, +0x5d, 0x5d, 0x2c, 0x20, 0x22, 0x66, 0x65, 0x61, 0x74, 0x75, +0x72, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, +0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, +0x6c, 0x65, 0x66, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, +0x20, 0x2d, 0x31, 0x2c, 0x20, 0x33, 0x2c, 0x20, 0x2d, 0x31, +0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, +0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, +0x69, 0x67, 0x68, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2c, +0x20, 0x2d, 0x31, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x2d, 0x31, +0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x74, 0x68, +0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0x3a, 0x20, +0x5b, 0x31, 0x31, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, +0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x32, 0x35, 0x36, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, +0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, +0x20, 0x5b, 0x32, 0x36, 0x39, 0x2e, 0x35, 0x39, 0x2c, 0x20, +0x32, 0x33, 0x39, 0x2e, 0x31, 0x38, 0x2c, 0x20, 0x31, 0x34, +0x32, 0x2e, 0x32, 0x32, 0x2c, 0x20, 0x31, 0x35, 0x32, 0x2e, +0x39, 0x39, 0x2c, 0x20, 0x31, 0x36, 0x33, 0x2e, 0x37, 0x33, +0x5d, 0x2c, 0x20, 0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x31, 0x32, 0x31, 0x2e, +0x34, 0x34, 0x2c, 0x20, 0x31, 0x30, 0x38, 0x2e, 0x39, 0x33, +0x2c, 0x20, 0x31, 0x39, 0x35, 0x2e, 0x34, 0x32, 0x2c, 0x20, +0x32, 0x31, 0x30, 0x2e, 0x36, 0x31, 0x2c, 0x20, 0x32, 0x34, +0x34, 0x2e, 0x39, 0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x32, 0x34, +0x35, 0x2e, 0x34, 0x31, 0x2c, 0x20, 0x32, 0x34, 0x39, 0x2e, +0x30, 0x32, 0x2c, 0x20, 0x32, 0x30, 0x37, 0x2e, 0x35, 0x37, +0x2c, 0x20, 0x32, 0x35, 0x32, 0x2e, 0x32, 0x33, 0x2c, 0x20, +0x33, 0x30, 0x35, 0x2e, 0x38, 0x37, 0x5d, 0x5d, 0x2c, 0x20, +0x22, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x3a, +0x20, 0x5b, 0x31, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, +0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, +0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, 0x66, 0x74, +0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x2c, +0x20, 0x33, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, +0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x63, 0x68, 0x69, 0x6c, +0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, 0x69, 0x67, 0x68, 0x74, +0x22, 0x3a, 0x20, 0x5b, 0x34, 0x2c, 0x20, 0x33, 0x2c, 0x20, +0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x36, 0x2c, +0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, +0x22, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, +0x22, 0x3a, 0x20, 0x5b, 0x34, 0x34, 0x39, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x31, 0x36, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x31, 0x38, 0x37, 0x37, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x76, +0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x30, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, +0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, +0x2c, 0x20, 0x5b, 0x31, 0x32, 0x31, 0x2e, 0x34, 0x34, 0x2c, +0x20, 0x31, 0x30, 0x38, 0x2e, 0x39, 0x33, 0x2c, 0x20, 0x31, +0x39, 0x35, 0x2e, 0x34, 0x32, 0x2c, 0x20, 0x32, 0x31, 0x30, +0x2e, 0x36, 0x31, 0x2c, 0x20, 0x32, 0x34, 0x34, 0x2e, 0x39, +0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x31, 0x37, 0x31, 0x2e, 0x37, +0x32, 0x2c, 0x20, 0x31, 0x36, 0x37, 0x2e, 0x34, 0x30, 0x2c, +0x20, 0x31, 0x35, 0x31, 0x2e, 0x36, 0x36, 0x2c, 0x20, 0x32, +0x33, 0x32, 0x2e, 0x31, 0x36, 0x2c, 0x20, 0x32, 0x36, 0x37, +0x2e, 0x35, 0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x30, 0x2e, 0x30, +0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x32, +0x30, 0x36, 0x2e, 0x36, 0x30, 0x2c, 0x20, 0x33, 0x34, 0x31, +0x2e, 0x34, 0x35, 0x2c, 0x20, 0x32, 0x30, 0x37, 0x2e, 0x35, +0x34, 0x2c, 0x20, 0x32, 0x34, 0x32, 0x2e, 0x33, 0x37, 0x2c, +0x20, 0x32, 0x38, 0x38, 0x2e, 0x34, 0x34, 0x5d, 0x2c, 0x20, +0x5b, 0x32, 0x36, 0x39, 0x2e, 0x35, 0x39, 0x2c, 0x20, 0x32, +0x33, 0x39, 0x2e, 0x31, 0x38, 0x2c, 0x20, 0x31, 0x34, 0x32, +0x2e, 0x32, 0x32, 0x2c, 0x20, 0x31, 0x35, 0x32, 0x2e, 0x39, +0x39, 0x2c, 0x20, 0x31, 0x36, 0x33, 0x2e, 0x37, 0x33, 0x5d, +0x5d, 0x2c, 0x20, 0x22, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, +0x65, 0x22, 0x3a, 0x20, 0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x31, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, +0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, +0x6e, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x22, 0x3a, 0x20, 0x5b, +0x31, 0x2c, 0x20, 0x32, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, +0x2d, 0x31, 0x2c, 0x20, 0x35, 0x2c, 0x20, 0x2d, 0x31, 0x2c, +0x20, 0x2d, 0x31, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x63, +0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, 0x69, +0x67, 0x68, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2c, 0x20, +0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, +0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, +0x3a, 0x20, 0x5b, 0x31, 0x38, 0x37, 0x37, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, +0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x76, 0x61, +0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, +0x32, 0x30, 0x36, 0x2e, 0x36, 0x30, 0x2c, 0x20, 0x33, 0x34, +0x31, 0x2e, 0x34, 0x35, 0x2c, 0x20, 0x32, 0x30, 0x37, 0x2e, +0x35, 0x34, 0x2c, 0x20, 0x32, 0x34, 0x32, 0x2e, 0x33, 0x37, +0x2c, 0x20, 0x32, 0x38, 0x38, 0x2e, 0x34, 0x34, 0x5d, 0x2c, +0x20, 0x5b, 0x32, 0x36, 0x39, 0x2e, 0x35, 0x39, 0x2c, 0x20, +0x32, 0x33, 0x39, 0x2e, 0x31, 0x38, 0x2c, 0x20, 0x31, 0x34, +0x32, 0x2e, 0x32, 0x32, 0x2c, 0x20, 0x31, 0x35, 0x32, 0x2e, +0x39, 0x39, 0x2c, 0x20, 0x31, 0x36, 0x33, 0x2e, 0x37, 0x33, +0x5d, 0x5d, 0x2c, 0x20, 0x22, 0x66, 0x65, 0x61, 0x74, 0x75, +0x72, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, +0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, 0x68, +0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, 0x66, +0x74, 0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, 0x31, +0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x7d, 0x2c, 0x20, 0x7b, 0x22, +0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x72, +0x69, 0x67, 0x68, 0x74, 0x22, 0x3a, 0x20, 0x5b, 0x32, 0x2c, +0x20, 0x2d, 0x31, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x2d, 0x31, +0x2c, 0x20, 0x2d, 0x31, 0x5d, 0x2c, 0x20, 0x22, 0x74, 0x68, +0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0x3a, 0x20, +0x5b, 0x31, 0x31, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, +0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x31, 0x36, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, +0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x5b, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x5d, 0x2c, +0x20, 0x5b, 0x32, 0x36, 0x39, 0x2e, 0x35, 0x39, 0x2c, 0x20, +0x32, 0x33, 0x39, 0x2e, 0x31, 0x38, 0x2c, 0x20, 0x31, 0x34, +0x32, 0x2e, 0x32, 0x32, 0x2c, 0x20, 0x31, 0x35, 0x32, 0x2e, +0x39, 0x39, 0x2c, 0x20, 0x31, 0x36, 0x33, 0x2e, 0x37, 0x33, +0x5d, 0x2c, 0x20, 0x5b, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, +0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, +0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x30, 0x2e, +0x30, 0x30, 0x5d, 0x2c, 0x20, 0x5b, 0x31, 0x32, 0x31, 0x2e, +0x34, 0x34, 0x2c, 0x20, 0x31, 0x30, 0x38, 0x2e, 0x39, 0x33, +0x2c, 0x20, 0x31, 0x39, 0x35, 0x2e, 0x34, 0x32, 0x2c, 0x20, +0x32, 0x31, 0x30, 0x2e, 0x36, 0x31, 0x2c, 0x20, 0x32, 0x34, +0x34, 0x2e, 0x39, 0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x31, 0x37, +0x31, 0x2e, 0x37, 0x32, 0x2c, 0x20, 0x31, 0x36, 0x37, 0x2e, +0x34, 0x30, 0x2c, 0x20, 0x31, 0x35, 0x31, 0x2e, 0x36, 0x36, +0x2c, 0x20, 0x32, 0x33, 0x32, 0x2e, 0x31, 0x36, 0x2c, 0x20, +0x32, 0x36, 0x37, 0x2e, 0x35, 0x32, 0x5d, 0x5d, 0x2c, 0x20, +0x22, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x3a, +0x20, 0x5b, 0x31, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, +0x2e, 0x30, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x30, 0x2c, +0x20, 0x2d, 0x32, 0x2e, 0x30, 0x30, 0x2c, 0x20, 0x2d, 0x32, +0x2e, 0x30, 0x30, 0x5d, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x69, +0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x6c, 0x65, 0x66, 0x74, +0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x2d, 0x31, 0x2c, +0x20, 0x33, 0x2c, 0x20, 0x2d, 0x31, 0x2c, 0x20, 0x2d, 0x31, +0x5d, 0x7d, 0x5d, 0x2c, 0x20, 0x22, 0x70, 0x72, 0x6f, 0x66, +0x69, 0x6c, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x32, +0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, 0x36, 0x2c, 0x20, 0x38, +0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x32, 0x2c, +0x20, 0x34, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, +0x38, 0x2c, 0x20, 0x38, 0x5d, 0x2c, 0x20, 0x5b, 0x34, 0x2c, +0x20, 0x38, 0x2c, 0x20, 0x33, 0x32, 0x2c, 0x20, 0x31, 0x36, +0x2c, 0x20, 0x31, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x32, 0x2c, +0x20, 0x38, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, +0x34, 0x2c, 0x20, 0x33, 0x32, 0x5d, 0x2c, 0x20, 0x5b, 0x32, +0x2c, 0x20, 0x31, 0x36, 0x2c, 0x20, 0x31, 0x32, 0x38, 0x2c, +0x20, 0x31, 0x36, 0x2c, 0x20, 0x31, 0x2c, 0x20, 0x34, 0x2c, +0x20, 0x34, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x30, 0x2c, 0x20, +0x30, 0x2c, 0x20, 0x33, 0x32, 0x2c, 0x20, 0x38, 0x5d, 0x2c, +0x20, 0x5b, 0x34, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x31, 0x36, +0x2c, 0x20, 0x31, 0x36, 0x2c, 0x20, 0x32, 0x2c, 0x20, 0x38, +0x2c, 0x20, 0x34, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x30, 0x2c, +0x20, 0x30, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x31, 0x36, 0x5d, +0x2c, 0x20, 0x5b, 0x34, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x31, +0x36, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x38, +0x2c, 0x20, 0x32, 0x2c, 0x20, 0x38, 0x2c, 0x20, 0x30, 0x2c, +0x20, 0x30, 0x2c, 0x20, 0x34, 0x2c, 0x20, 0x31, 0x36, 0x5d, +0x5d, 0x7d, 0x7d, 0x2c, 0x20, 0x22, 0x67, 0x65, 0x72, 0x22, +0x3a, 0x20, 0x7b, 0x22, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, +0x32, 0x22, 0x3a, 0x20, 0x7b, 0x22, 0x70, 0x72, 0x6f, 0x66, +0x69, 0x6c, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0x5b, 0x31, +0x2c, 0x20, 0x31, 0x32, 0x38, 0x2c, 0x20, 0x31, 0x2c, 0x20, +0x31, 0x36, 0x2c, 0x20, 0x33, 0x32, 0x2c, 0x20, 0x31, 0x5d, +0x5d, 0x7d, 0x7d, 0x7d, }; + +static const std::size_t broadwell_len = 3744; + +} +} diff --git a/lib/model/database/json/broadwell.json b/lib/model/database/json/broadwell.json new file mode 100644 index 000000000..114ab1c21 --- /dev/null +++ b/lib/model/database/json/broadwell.json @@ -0,0 +1 @@ +{"gemm_nt": {"float32": {"predictor": [{"children_right": [2, -1, -1], "threshold": [288.00, -2.00, -2.00], "children_left": [1, -1, -1], "feature": [2.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00], [273.96, 276.74, 267.62, 275.71], [334.95, 344.44, 345.28, 331.72]]}, {"children_right": [2, -1, -1], "threshold": [288.00, -2.00, -2.00], "children_left": [1, -1, -1], "feature": [2.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00], [269.13, 271.54, 261.44, 271.59], [334.95, 344.44, 345.28, 331.72]]}, {"children_right": [2, -1, -1], "threshold": [160.00, -2.00, -2.00], "children_left": [1, -1, -1], "feature": [2.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00], [254.66, 255.93, 242.89, 259.22], [283.61, 287.15, 279.99, 283.95]]}], "profiles": [[4, 8, 4, 8, 1, 8, 1, 8, 0, 0, 16, 4], [4, 8, 8, 8, 1, 8, 1, 8, 0, 0, 8, 8], [4, 8, 16, 8, 1, 8, 1, 8, 0, 0, 8, 8], [2, 8, 8, 8, 1, 8, 1, 8, 0, 0, 8, 8]]}}, "version": "1.0", "gemm_tn": {"float32": {"predictor": [{"children_right": [2, -1, -1], "threshold": [449.00, -2.00, -2.00], "children_left": [1, -1, -1], "feature": [2.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00], [199.86, 174.87, 75.36], [225.84, 190.43, 151.17]]}, {"children_right": [2, -1, -1], "threshold": [1597.00, -2.00, -2.00], "children_left": [1, -1, -1], "feature": [2.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00], [218.96, 192.24, 0.00], [107.35, 111.67, 175.81]]}], "profiles": [[1, 4, 4, 16, 1, 8, 1, 8, 0, 0, 2, 32], [1, 8, 8, 8, 1, 4, 1, 8, 0, 0, 8, 8], [1, 16, 8, 4, 8, 4, 2, 8, 0, 0, 8, 8]]}}, "gemm_nn": {"float32": {"predictor": [{"children_right": [2, -1, 4, -1, -1], "threshold": [781.50, -2.00, 449.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00, 0.00], [269.59, 239.18, 142.22, 152.99, 163.73], [0.00, 0.00, 0.00, 0.00, 0.00], [183.42, 178.97, 201.50, 231.42, 275.40], [206.60, 341.45, 207.54, 242.37, 288.44]], "feature": [2.00, -2.00, 0.00, -2.00, -2.00], "children_left": [1, -1, 3, -1, -1]}, {"children_right": [2, -1, 4, -1, -1], "threshold": [112.00, -2.00, 256.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00, 0.00], [269.59, 239.18, 142.22, 152.99, 163.73], [0.00, 0.00, 0.00, 0.00, 0.00], [121.44, 108.93, 195.42, 210.61, 244.92], [245.41, 249.02, 207.57, 252.23, 305.87]], "feature": [1.00, -2.00, 1.00, -2.00, -2.00], "children_left": [1, -1, 3, -1, -1]}, {"children_right": [4, 3, -1, -1, 6, -1, -1], "threshold": [449.00, 160.00, -2.00, -2.00, 1877.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00, 0.00], [0.00, 0.00, 0.00, 0.00, 0.00], [121.44, 108.93, 195.42, 210.61, 244.92], [171.72, 167.40, 151.66, 232.16, 267.52], [0.00, 0.00, 0.00, 0.00, 0.00], [206.60, 341.45, 207.54, 242.37, 288.44], [269.59, 239.18, 142.22, 152.99, 163.73]], "feature": [0.00, 1.00, -2.00, -2.00, 0.00, -2.00, -2.00], "children_left": [1, 2, -1, -1, 5, -1, -1]}, {"children_right": [2, -1, -1], "threshold": [1877.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00, 0.00], [206.60, 341.45, 207.54, 242.37, 288.44], [269.59, 239.18, 142.22, 152.99, 163.73]], "feature": [0.00, -2.00, -2.00], "children_left": [1, -1, -1]}, {"children_right": [2, -1, 4, -1, -1], "threshold": [112.00, -2.00, 160.00, -2.00, -2.00], "value": [[0.00, 0.00, 0.00, 0.00, 0.00], [269.59, 239.18, 142.22, 152.99, 163.73], [0.00, 0.00, 0.00, 0.00, 0.00], [121.44, 108.93, 195.42, 210.61, 244.92], [171.72, 167.40, 151.66, 232.16, 267.52]], "feature": [1.00, -2.00, 1.00, -2.00, -2.00], "children_left": [1, -1, 3, -1, -1]}], "profiles": [[2, 8, 16, 8, 1, 8, 2, 4, 0, 0, 8, 8], [4, 8, 32, 16, 1, 8, 2, 8, 0, 0, 4, 32], [2, 16, 128, 16, 1, 4, 4, 4, 0, 0, 32, 8], [4, 4, 16, 16, 2, 8, 4, 4, 0, 0, 4, 16], [4, 8, 16, 8, 4, 8, 2, 8, 0, 0, 4, 16]]}}, "ger": {"float32": {"profiles": [[1, 128, 1, 16, 32, 1]]}}} \ No newline at end of file diff --git a/lib/model/model.cpp b/lib/model/model.cpp index 82306d156..26c0c391b 100644 --- a/lib/model/model.cpp +++ b/lib/model/model.cpp @@ -20,6 +20,8 @@ #include "isaac/tools/timer.hpp" #include "isaac/tools/getenv.hpp" +#include "database/broadwell.hpp" + #include "convert.hpp" @@ -278,7 +280,7 @@ std::map, std::shared_ptr, std::shared_ptr, std::shared_ptr > fallbacks = init_fallback(); +const std::map , const char *> + models::database_ = { { {driver::Device::VENDOR::INTEL, driver::Device::ARCHITECTURE::BROADWELL}, database::broadwell } }; + } diff --git a/python/setup.py b/python/setup.py old mode 100755 new mode 100644 index 3f0745a4a..613460c76 --- a/python/setup.py +++ b/python/setup.py @@ -1,170 +1,170 @@ -#Thanks to Andreas Knoeckler for providing stand-alone boost.python -#through PyOpenCL and PyCUDA - -import os, sys -from distutils.ccompiler import show_compilers,new_compiler -from distutils.command.build_ext import build_ext -from distutils.command.build_py import build_py -from distutils.core import setup, Extension -from distutils.sysconfig import get_python_inc -from distutils import sysconfig -from imp import find_module -from glob import glob -from os.path import dirname - -platform_cflags = {} -platform_ldflags = {} -platform_libs = {} - -class build_ext_subclass(build_ext): - def build_extensions(self): - c = self.compiler.compiler_type - if c in platform_cflags.keys(): - for e in self.extensions: - e.extra_compile_args = platform_cflags[c] - if c in platform_ldflags.keys(): - for e in self.extensions: - e.extra_link_args = platform_ldflags[c] - if c in platform_libs.keys(): - for e in self.extensions: - try: - e.libraries += platform_libs[c] - except: - e.libraries = platform_libs[c] - build_ext.build_extensions(self) - -def main(): - - def recursive_glob(rootdir='.', suffix=''): - return [os.path.join(looproot, filename) - for looproot, _, filenames in os.walk(rootdir) - for filename in filenames if filename.endswith(suffix)] - - def remove_prefixes(optlist, bad_prefixes): - for bad_prefix in bad_prefixes: - for i, flag in enumerate(optlist): - if flag.startswith(bad_prefix): - optlist.pop(i) - break - return optlist - - def find_library(name, cmake_glob_list): - cvars = sysconfig.get_config_vars() - compiler = new_compiler() - dirs = [] - for gpath in cmake_glob_list.split(';'): - path = glob(gpath) - if path: - dirs += [path[0]] - return compiler.find_library_file(cvars['LIBDIR'].split(';') + dirs, name) - - def find_opencl(): - cvars = sysconfig.get_config_vars() - is_on_android = '-mandroid' in cvars['PY_CFLAGS'] - lib = find_library('OpenCL', '' if is_on_android else '/opt/AMDAPPSDK*/lib/x86_64') - return {'include': '', 'lib': dirname(lib)} if lib else None - - def find_in_path(name, path): - "Find a file in a search path" - #adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/ - for dir in path.split(os.pathsep): - binpath = os.path.join(dir, name) - if os.path.exists(binpath): - return os.path.abspath(binpath) - return None - - def find_cuda(): - if 'CUDAHOME' in os.environ: - home = os.environ['CUDAHOME'] - nvcc = os.path.join(home, 'bin', 'nvcc') - else: - nvcc = find_in_path('nvcc', os.environ['PATH']) - - if nvcc: - home = dirname(os.path.dirname(nvcc)) - return {'include': os.path.join(home, 'include'), - 'lib': os.path.join(home, 'lib64')} - else: - return None - - - #Tweaks warning, because boost-numpy and boost-python won't compile cleanly without these changes - cvars = sysconfig.get_config_vars() - cvars['OPT'] = str.join(' ', remove_prefixes(cvars['OPT'].split(), ['-g', '-Wstrict-prototypes'])) - cvars["CFLAGS"] = cvars["BASECFLAGS"] + ' ' + cvars['OPT'] - cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"] - - #OpenCL - opencl_config = find_opencl() - - #CUDA - cuda_config = find_cuda() - - #Libraries - libraries = ['OpenCL'] - if cuda_config: libraries += ['cuda', 'nvrtc'] - - #Backends: - backend_defines = ['-DISAAC_WITH_OPENCL'] - if cuda_config: backend_defines += ['-DISAAC_WITH_CUDA'] - - #Library directories - 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")] - - #Source files - src = 'src/lib/wrap/clBLAS.cpp src/lib/value_scalar.cpp src/lib/symbolic/preset.cpp src/lib/symbolic/io.cpp src/lib/symbolic/expression.cpp src/lib/symbolic/execute.cpp src/lib/model/predictors/random_forest.cpp src/lib/model/model.cpp src/lib/kernels/templates/ger.cpp src/lib/kernels/templates/gemv.cpp src/lib/kernels/templates/gemm.cpp src/lib/kernels/templates/dot.cpp src/lib/kernels/templates/base.cpp src/lib/kernels/templates/axpy.cpp src/lib/kernels/stream.cpp src/lib/kernels/parse.cpp src/lib/kernels/mapped_object.cpp src/lib/kernels/keywords.cpp src/lib/kernels/binder.cpp src/lib/exception/unknown_datatype.cpp src/lib/exception/operation_not_supported.cpp src/lib/driver/program_cache.cpp src/lib/driver/program.cpp src/lib/driver/platform.cpp src/lib/driver/ndrange.cpp src/lib/driver/kernel.cpp src/lib/driver/handle.cpp src/lib/driver/event.cpp src/lib/driver/device.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/backend.cpp src/lib/array.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] - # make sure next line succeeds even on Windows - src = [f.replace("\\", "/") for f in src] - if sys.platform == "win32": - src += glob(boostsrc + "/thread/src/win32/*.cpp") - src += glob(boostsrc + "/thread/src/tss_null.cpp") - else: - src += glob(boostsrc + "/thread/src/pthread/*.cpp") - src= [f for f in src if not f.endswith("once_atomic.cpp")] - - #Setup - setup( - name='isaac', - version='1.0', - description="Input-specific architecture-aware computations", - author='Philippe Tillet', - author_email='ptillet@g.harvard.edu', - license='MPL 2.0', - packages=["isaac"], - ext_package="isaac", - ext_modules=[Extension( - '_isaac',src, - extra_compile_args= backend_defines + ['-std=c++11', '-Wno-unused-function', '-Wno-unused-local-typedefs', '-Wno-sign-compare'], - extra_link_args=['-Wl,-soname=_isaac.so'], - undef_macros=[], - include_dirs=include, - library_dirs=library_dirs, - libraries=libraries - )], - cmdclass={'build_py': build_py, 'build_ext': build_ext_subclass}, - classifiers=[ - 'Environment :: Console', - 'Development Status :: 1 - Experimental', - 'Intended Audience :: Developers', - 'Intended Audience :: Other Audience', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: C++', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Physics', - 'Topic :: Scientific/Engineering :: Machine Learning', - ] - ) - -if __name__ == "__main__": - main() +#Thanks to Andreas Knoeckler for providing stand-alone boost.python +#through PyOpenCL and PyCUDA + +import os, sys +from distutils.ccompiler import show_compilers,new_compiler +from distutils.command.build_ext import build_ext +from distutils.command.build_py import build_py +from distutils.core import setup, Extension +from distutils.sysconfig import get_python_inc +from distutils import sysconfig +from imp import find_module +from glob import glob +from os.path import dirname + +platform_cflags = {} +platform_ldflags = {} +platform_libs = {} + +class build_ext_subclass(build_ext): + def build_extensions(self): + c = self.compiler.compiler_type + if c in platform_cflags.keys(): + for e in self.extensions: + e.extra_compile_args = platform_cflags[c] + if c in platform_ldflags.keys(): + for e in self.extensions: + e.extra_link_args = platform_ldflags[c] + if c in platform_libs.keys(): + for e in self.extensions: + try: + e.libraries += platform_libs[c] + except: + e.libraries = platform_libs[c] + build_ext.build_extensions(self) + +def main(): + + def recursive_glob(rootdir='.', suffix=''): + return [os.path.join(looproot, filename) + for looproot, _, filenames in os.walk(rootdir) + for filename in filenames if filename.endswith(suffix)] + + def remove_prefixes(optlist, bad_prefixes): + for bad_prefix in bad_prefixes: + for i, flag in enumerate(optlist): + if flag.startswith(bad_prefix): + optlist.pop(i) + break + return optlist + + def find_library(name, cmake_glob_list): + cvars = sysconfig.get_config_vars() + compiler = new_compiler() + dirs = [] + for gpath in cmake_glob_list.split(';'): + path = glob(gpath) + if path: + dirs += [path[0]] + return compiler.find_library_file(cvars['LIBDIR'].split(';') + dirs, name) + + def find_opencl(): + cvars = sysconfig.get_config_vars() + is_on_android = '-mandroid' in cvars['PY_CFLAGS'] + lib = find_library('OpenCL', '' if is_on_android else '/opt/AMDAPPSDK*/lib/x86_64') + return {'include': '', 'lib': dirname(lib)} if lib else None + + def find_in_path(name, path): + "Find a file in a search path" + #adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/ + for dir in path.split(os.pathsep): + binpath = os.path.join(dir, name) + if os.path.exists(binpath): + return os.path.abspath(binpath) + return None + + def find_cuda(): + if 'CUDAHOME' in os.environ: + home = os.environ['CUDAHOME'] + nvcc = os.path.join(home, 'bin', 'nvcc') + else: + nvcc = find_in_path('nvcc', os.environ['PATH']) + + if nvcc: + home = dirname(os.path.dirname(nvcc)) + return {'include': os.path.join(home, 'include'), + 'lib': os.path.join(home, 'lib64')} + else: + return None + + + #Tweaks warning, because boost-numpy and boost-python won't compile cleanly without these changes + cvars = sysconfig.get_config_vars() + cvars['OPT'] = str.join(' ', remove_prefixes(cvars['OPT'].split(), ['-g', '-Wstrict-prototypes'])) + cvars["CFLAGS"] = cvars["BASECFLAGS"] + ' ' + cvars['OPT'] + cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"] + + #OpenCL + opencl_config = find_opencl() + + #CUDA + cuda_config = find_cuda() + + #Libraries + libraries = ['OpenCL'] + if cuda_config: libraries += ['cuda', 'nvrtc'] + + #Backends: + backend_defines = ['-DISAAC_WITH_OPENCL'] + if cuda_config: backend_defines += ['-DISAAC_WITH_CUDA'] + + #Library directories + 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")] + + #Source files + src = 'src/lib/wrap/clBLAS.cpp src/lib/value_scalar.cpp src/lib/kernels/parse.cpp src/lib/kernels/templates/gemm.cpp src/lib/kernels/templates/gemv.cpp src/lib/kernels/templates/ger.cpp src/lib/kernels/templates/dot.cpp src/lib/kernels/templates/axpy.cpp src/lib/kernels/templates/base.cpp src/lib/kernels/stream.cpp src/lib/kernels/mapped_object.cpp src/lib/kernels/keywords.cpp src/lib/kernels/binder.cpp src/lib/array.cpp src/lib/symbolic/preset.cpp src/lib/symbolic/expression.cpp src/lib/symbolic/execute.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/device.cpp src/lib/driver/program.cpp src/lib/driver/event.cpp src/lib/driver/context.cpp src/lib/driver/program_cache.cpp src/lib/driver/platform.cpp src/lib/driver/ndrange.cpp src/lib/driver/kernel.cpp src/lib/driver/handle.cpp src/lib/driver/command_queue.cpp src/lib/driver/check.cpp src/lib/driver/buffer.cpp src/lib/driver/backend.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] + # make sure next line succeeds even on Windows + src = [f.replace("\\", "/") for f in src] + if sys.platform == "win32": + src += glob(boostsrc + "/thread/src/win32/*.cpp") + src += glob(boostsrc + "/thread/src/tss_null.cpp") + else: + src += glob(boostsrc + "/thread/src/pthread/*.cpp") + src= [f for f in src if not f.endswith("once_atomic.cpp")] + + #Setup + setup( + name='isaac', + version='1.0', + description="Input-specific architecture-aware computations", + author='Philippe Tillet', + author_email='ptillet@g.harvard.edu', + license='MPL 2.0', + packages=["isaac"], + ext_package="isaac", + ext_modules=[Extension( + '_isaac',src, + extra_compile_args= backend_defines + ['-std=c++11', '-Wno-unused-function', '-Wno-unused-local-typedefs', '-Wno-sign-compare'], + extra_link_args=['-Wl,-soname=_isaac.so'], + undef_macros=[], + include_dirs=include, + library_dirs=library_dirs, + libraries=libraries + )], + cmdclass={'build_py': build_py, 'build_ext': build_ext_subclass}, + classifiers=[ + 'Environment :: Console', + 'Development Status :: 1 - Experimental', + 'Intended Audience :: Developers', + 'Intended Audience :: Other Audience', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: C++', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Topic :: Scientific/Engineering :: Physics', + 'Topic :: Scientific/Engineering :: Machine Learning', + ] + ) + +if __name__ == "__main__": + main()