Better exception handling, lowered CMake requirement ; blas-bench now benchmarks square matrices
This commit is contained in:
@@ -141,7 +141,7 @@ void bench(ad::numeric_type dtype)
|
|||||||
for(std::vector<int_t>::const_iterator Nit = BLAS3_N.begin() ; Nit != BLAS3_N.end() ; ++Nit)
|
for(std::vector<int_t>::const_iterator Nit = BLAS3_N.begin() ; Nit != BLAS3_N.end() ; ++Nit)
|
||||||
for(std::vector<int_t>::const_iterator Kit = BLAS3_K.begin() ; Kit != BLAS3_K.end() ; ++Kit)
|
for(std::vector<int_t>::const_iterator Kit = BLAS3_K.begin() ; Kit != BLAS3_K.end() ; ++Kit)
|
||||||
{
|
{
|
||||||
int_t M = *Mit, N = *Nit, K = *Kit;
|
int_t M = *Kit, N = *Kit, K = *Kit;
|
||||||
std::cout << M << "," << N << "," << K;
|
std::cout << M << "," << N << "," << K;
|
||||||
/* ATIDLAS */
|
/* ATIDLAS */
|
||||||
ad::array C(M, N, dtype), A(M, K, dtype), B(N, K, dtype);
|
ad::array C(M, N, dtype), A(M, K, dtype), B(N, K, dtype);
|
||||||
|
@@ -6,6 +6,8 @@
|
|||||||
#include "atidlas/model/model.h"
|
#include "atidlas/model/model.h"
|
||||||
#include "atidlas/symbolic/execute.h"
|
#include "atidlas/symbolic/execute.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace atidlas
|
namespace atidlas
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -523,26 +525,26 @@ array_expression repmat(array_expression const & A, int_t const & rep1, int_t co
|
|||||||
#define DEFINE_REDUCTION(OP, OPNAME)\
|
#define DEFINE_REDUCTION(OP, OPNAME)\
|
||||||
array_expression OPNAME(array const & x, int_t axis)\
|
array_expression OPNAME(array const & x, int_t axis)\
|
||||||
{\
|
{\
|
||||||
if(axis==-1)\
|
if(axis < -1 || axis > x.nshape())\
|
||||||
|
throw std::out_of_range("The axis entry is out of bounds");\
|
||||||
|
else if(axis==-1)\
|
||||||
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_VECTOR_REDUCTION_TYPE_FAMILY, OP), x.context(), x.dtype(), size4(1));\
|
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_VECTOR_REDUCTION_TYPE_FAMILY, OP), x.context(), x.dtype(), size4(1));\
|
||||||
else if(axis==0)\
|
else if(axis==0)\
|
||||||
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_ROWS_REDUCTION_TYPE_FAMILY, OP), x.context(), x.dtype(), size4(x.shape()._1));\
|
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_ROWS_REDUCTION_TYPE_FAMILY, OP), x.context(), x.dtype(), size4(x.shape()._1));\
|
||||||
else if(axis==1)\
|
|
||||||
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_COLUMNS_REDUCTION_TYPE_FAMILY, OP), x.context(), x.dtype(), size4(x.shape()._2));\
|
|
||||||
else\
|
else\
|
||||||
throw ;\
|
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_COLUMNS_REDUCTION_TYPE_FAMILY, OP), x.context(), x.dtype(), size4(x.shape()._2));\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
array_expression OPNAME(array_expression const & x, int_t axis)\
|
array_expression OPNAME(array_expression const & x, int_t axis)\
|
||||||
{\
|
{\
|
||||||
|
if(axis < -1 || axis > x.nshape())\
|
||||||
|
throw std::out_of_range("The axis entry is out of bounds");\
|
||||||
if(axis==-1)\
|
if(axis==-1)\
|
||||||
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_VECTOR_REDUCTION_TYPE_FAMILY, OP), size4(1));\
|
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_VECTOR_REDUCTION_TYPE_FAMILY, OP), size4(1));\
|
||||||
else if(axis==0)\
|
else if(axis==0)\
|
||||||
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_ROWS_REDUCTION_TYPE_FAMILY, OP), size4(x.shape()._1));\
|
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_ROWS_REDUCTION_TYPE_FAMILY, OP), size4(x.shape()._1));\
|
||||||
else if(axis==1)\
|
|
||||||
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_COLUMNS_REDUCTION_TYPE_FAMILY, OP), size4(x.shape()._2));\
|
|
||||||
else\
|
else\
|
||||||
throw ;\
|
return array_expression(x, lhs_rhs_element(), op_element(OPERATOR_COLUMNS_REDUCTION_TYPE_FAMILY, OP), size4(x.shape()._2));\
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_REDUCTION(OPERATOR_ADD_TYPE, sum)
|
DEFINE_REDUCTION(OPERATOR_ADD_TYPE, sum)
|
||||||
|
@@ -130,7 +130,7 @@ void base::set_arguments_functor::set_arguments(numeric_type dtype, values_holde
|
|||||||
case ULONG_TYPE: kernel_.setArg(current_arg_++, scal.uint64); break;
|
case ULONG_TYPE: kernel_.setArg(current_arg_++, scal.uint64); break;
|
||||||
case FLOAT_TYPE: kernel_.setArg(current_arg_++, scal.float32); break;
|
case FLOAT_TYPE: kernel_.setArg(current_arg_++, scal.float32); break;
|
||||||
case DOUBLE_TYPE: kernel_.setArg(current_arg_++, scal.float64); break;
|
case DOUBLE_TYPE: kernel_.setArg(current_arg_++, scal.float64); break;
|
||||||
default: throw ;
|
default: throw unknown_datatype(dtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ void base::set_arguments_functor::set_arguments(lhs_rhs_element const & lhs_rhs)
|
|||||||
case VALUE_TYPE_FAMILY: return set_arguments(lhs_rhs.dtype, lhs_rhs.vscalar);
|
case VALUE_TYPE_FAMILY: return set_arguments(lhs_rhs.dtype, lhs_rhs.vscalar);
|
||||||
case ARRAY_TYPE_FAMILY: return set_arguments(lhs_rhs.array);
|
case ARRAY_TYPE_FAMILY: return set_arguments(lhs_rhs.array);
|
||||||
case INFOS_TYPE_FAMILY: return set_arguments(lhs_rhs.tuple);
|
case INFOS_TYPE_FAMILY: return set_arguments(lhs_rhs.tuple);
|
||||||
default: throw ;
|
default: throw invalid_exception("Unrecognized type family");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
#include "atidlas/backend/parse.h"
|
#include "atidlas/backend/parse.h"
|
||||||
#include "atidlas/backend/templates/vaxpy.h"
|
#include "atidlas/backend/templates/vaxpy.h"
|
||||||
@@ -7,6 +9,7 @@
|
|||||||
#include "atidlas/backend/templates/maxpy.h"
|
#include "atidlas/backend/templates/maxpy.h"
|
||||||
#include "atidlas/backend/templates/mreduction.h"
|
#include "atidlas/backend/templates/mreduction.h"
|
||||||
#include "atidlas/backend/templates/mproduct.h"
|
#include "atidlas/backend/templates/mproduct.h"
|
||||||
|
#include "atidlas/exception/unknown_datatype.h"
|
||||||
#include "atidlas/exception/operation_not_supported.h"
|
#include "atidlas/exception/operation_not_supported.h"
|
||||||
#include "atidlas/model/model.h"
|
#include "atidlas/model/model.h"
|
||||||
#include "atidlas/tools/make_vector.hpp"
|
#include "atidlas/tools/make_vector.hpp"
|
||||||
@@ -150,14 +153,14 @@ namespace detail
|
|||||||
if(name=="gemmNT") return MATRIX_PRODUCT_NT_TYPE;
|
if(name=="gemmNT") return MATRIX_PRODUCT_NT_TYPE;
|
||||||
if(name=="gemmTN") return MATRIX_PRODUCT_TN_TYPE;
|
if(name=="gemmTN") return MATRIX_PRODUCT_TN_TYPE;
|
||||||
if(name=="gemmTT") return MATRIX_PRODUCT_TT_TYPE;
|
if(name=="gemmTT") return MATRIX_PRODUCT_TT_TYPE;
|
||||||
throw ;
|
throw std::invalid_argument("Invalid expression: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static numeric_type get_dtype(std::string const & name)
|
static numeric_type get_dtype(std::string const & name)
|
||||||
{
|
{
|
||||||
if(name=="float32") return FLOAT_TYPE;
|
if(name=="float32") return FLOAT_TYPE;
|
||||||
if(name=="float64") return DOUBLE_TYPE;
|
if(name=="float64") return DOUBLE_TYPE;
|
||||||
throw;
|
throw std::invalid_argument("Invalid datatype: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static tools::shared_ptr<base> create(std::string const & template_name, std::vector<int> const & a)
|
static tools::shared_ptr<base> create(std::string const & template_name, std::vector<int> const & a)
|
||||||
@@ -182,7 +185,7 @@ namespace detail
|
|||||||
else if(template_name.find("gemmTT")!=std::string::npos)
|
else if(template_name.find("gemmTT")!=std::string::npos)
|
||||||
return tools::shared_ptr<base>(new mproduct_tt(a[0], a[1], a[2], a[3], a[4], a[5], a[6], fetch[a[7]], fetch[a[8]], a[9], a[10]));
|
return tools::shared_ptr<base>(new mproduct_tt(a[0], a[1], a[2], a[3], a[4], a[5], a[6], fetch[a[7]], fetch[a[8]], a[9], a[10]));
|
||||||
else
|
else
|
||||||
throw operation_not_supported_exception("Cannot create the given operation");
|
throw std::invalid_argument("Invalid expression: " + template_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
#include "atidlas/types.h"
|
#include "atidlas/types.h"
|
||||||
#include "atidlas/array.h"
|
#include "atidlas/array.h"
|
||||||
#include <CL/cl.hpp>
|
#include <CL/cl.hpp>
|
||||||
@@ -196,7 +197,7 @@ namespace atidlas
|
|||||||
case MATRIX_PRODUCT_TN_TYPE: tmp = tools::shared_ptr<obj_base>(new array(node.lhs.array.shape2, node.rhs.array.shape2, dtype, context)); break;
|
case MATRIX_PRODUCT_TN_TYPE: tmp = tools::shared_ptr<obj_base>(new array(node.lhs.array.shape2, node.rhs.array.shape2, dtype, context)); break;
|
||||||
case MATRIX_PRODUCT_TT_TYPE: tmp = tools::shared_ptr<obj_base>(new array(node.lhs.array.shape2, node.rhs.array.shape1, dtype, context)); break;
|
case MATRIX_PRODUCT_TT_TYPE: tmp = tools::shared_ptr<obj_base>(new array(node.lhs.array.shape2, node.rhs.array.shape1, dtype, context)); break;
|
||||||
|
|
||||||
default: throw ;
|
default: throw std::invalid_argument("Unrecognized operation");
|
||||||
}
|
}
|
||||||
temporaries_.push_back(tmp);
|
temporaries_.push_back(tmp);
|
||||||
|
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
find_program(PYTHON "python")
|
find_program(PYTHON "python")
|
||||||
|
|
||||||
get_property(LIBATIDLAS_PATH TARGET atidlas PROPERTY LOCATION)
|
|
||||||
get_filename_component(LIBATIDLAS_DIR ${LIBATIDLAS_PATH} DIRECTORY)
|
|
||||||
|
|
||||||
if(PYTHON)
|
if(PYTHON)
|
||||||
add_subdirectory(pyatidlas)
|
add_subdirectory(pyatidlas)
|
||||||
add_subdirectory(autotune)
|
add_subdirectory(autotune)
|
||||||
|
@@ -129,6 +129,7 @@ class GeneticOperators(object):
|
|||||||
def evaluate(self, individual):
|
def evaluate(self, individual):
|
||||||
if tuple(individual) not in self.cache:
|
if tuple(individual) not in self.cache:
|
||||||
parameters = self.decode(individual)
|
parameters = self.decode(individual)
|
||||||
|
parameters = [2,16,16,16,6,1,6,atd.fetching_policy_type.FETCH_FROM_LOCAL,atd.fetching_policy_type.FETCH_FROM_LOCAL,16,16]
|
||||||
template = self.Template(*parameters)
|
template = self.Template(*parameters)
|
||||||
try:
|
try:
|
||||||
tt = misc_tools.benchmark(template, self.symbolic)
|
tt = misc_tools.benchmark(template, self.symbolic)
|
||||||
|
Binary file not shown.
Binary file not shown.
1
python/preinstall.py
Executable file
1
python/preinstall.py
Executable file
@@ -0,0 +1 @@
|
|||||||
|
|
@@ -53,7 +53,7 @@ def main():
|
|||||||
INCLUDE_DIRS = ['${CMAKE_CURRENT_SOURCE_DIR}/external/boost/include',
|
INCLUDE_DIRS = ['${CMAKE_CURRENT_SOURCE_DIR}/external/boost/include',
|
||||||
os.path.join(find_module("numpy")[1], "core", "include"),
|
os.path.join(find_module("numpy")[1], "core", "include"),
|
||||||
'${PROJECT_SOURCE_DIR}/include']
|
'${PROJECT_SOURCE_DIR}/include']
|
||||||
LIBRARY_DIRS = ['${LIBATIDLAS_DIR}']
|
LIBRARY_DIRS = ['${CMAKE_BINARY_DIR}/lib']
|
||||||
|
|
||||||
src = [os.path.join('${CMAKE_CURRENT_SOURCE_DIR}', 'src', sf) for sf in ['_atidlas.cpp']]
|
src = [os.path.join('${CMAKE_CURRENT_SOURCE_DIR}', 'src', sf) for sf in ['_atidlas.cpp']]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user