26 #ifndef CASADI_BLAS_IMPL_HPP
27 #define CASADI_BLAS_IMPL_HPP
30 #include "plugin_interface.hpp"
31 #include "runtime/casadi_runtime.hpp"
33 namespace casadi {
class CodeGenerator; }
41 CASADI_BLAS_NO_TRANS = 111,
42 CASADI_BLAS_TRANS = 112
57 Blas :
public PluginInterface<Blas> {
60 typedef void (* Dgemm)(
int transa,
int transb,
61 casadi_int m, casadi_int n, casadi_int k,
63 const double* A, casadi_int lda,
64 const double* B, casadi_int ldb,
66 double*
C, casadi_int ldc);
69 typedef void (* CodegenMtimes)(CodeGenerator& g,
71 casadi_int m, casadi_int k,
72 const std::string& B, casadi_int n,
73 const std::string&
C);
76 typedef void (* Daxpy)(casadi_int n,
double alpha,
const double* x,
double* y);
77 typedef double (* Ddot )(casadi_int n,
const double* x,
const double* y);
78 typedef void (* Dscal)(casadi_int n,
double alpha,
double* x);
79 typedef double (* Dnrm2)(casadi_int n,
const double* x);
80 typedef double (* Dasum)(casadi_int n,
const double* x);
81 typedef void (* Dcopy)(
const double* x, casadi_int n,
double* y);
84 typedef void (* CodegenL1Aux)(CodeGenerator& g,
85 const std::vector<std::string>& inst);
88 typedef Blas* (*Creator)();
90 static const std::string meta_doc;
95 CodegenMtimes codegen_mtimes;
102 CodegenL1Aux codegen_axpy_aux;
103 CodegenL1Aux codegen_dot_aux;
104 CodegenL1Aux codegen_scal_aux;
105 CodegenL1Aux codegen_nrm2_aux;
106 CodegenL1Aux codegen_asum_aux;
110 static std::map<std::string, Plugin> solvers_;
113 static std::vector<const Plugin*> dispatch_;
116 static casadi_int default_;
119 static std::string getDefault();
122 static casadi_int shorthand_for(
const std::string& name);
125 static const char* name_for_shorthand(casadi_int shorthand);
127 friend class GlobalOptions;
130 static void setDefault(
const std::string& name);
134 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
135 static std::mutex mutex_solvers_;
139 static const std::string infix_;
142 static void dgemm(casadi_int shorthand,
143 int transa,
int transb,
144 casadi_int m, casadi_int n, casadi_int k,
146 const double* A, casadi_int lda,
147 const double* B, casadi_int ldb,
149 double* C, casadi_int ldc);
152 static void reference_dgemm(
int transa,
int transb,
153 casadi_int m, casadi_int n, casadi_int k,
155 const double* A, casadi_int lda,
156 const double* B, casadi_int ldb,
158 double* C, casadi_int ldc);
161 static void mtimes(casadi_int shorthand,
162 const double* A, casadi_int m, casadi_int k,
163 const double* B, casadi_int n,
167 static void codegen_mtimes(CodeGenerator& g, casadi_int shorthand,
168 const std::string& A,
169 casadi_int m, casadi_int k,
170 const std::string& B, casadi_int n,
171 const std::string& C);
174 static void codegen_copy_aux(CodeGenerator& g,
175 const std::vector<std::string>& inst);
177 static bool codegen_axpy_aux(CodeGenerator& g,
178 const std::vector<std::string>& inst);
180 static bool codegen_dot_aux(CodeGenerator& g,
181 const std::vector<std::string>& inst);
183 static bool codegen_scal_aux(CodeGenerator& g,
184 const std::vector<std::string>& inst);
186 static bool codegen_norm_2_aux(CodeGenerator& g,
187 const std::vector<std::string>& inst);
189 static bool codegen_norm_1_aux(CodeGenerator& g,
190 const std::vector<std::string>& inst);