Go to the documentation of this file.00001 #ifndef _VIENNACL_MATRIX_SOLVE_ROW_ROW_KERNELS_HPP_
00002 #define _VIENNACL_MATRIX_SOLVE_ROW_ROW_KERNELS_HPP_
00003 #include "viennacl/tools/tools.hpp"
00004 #include "viennacl/ocl/kernel.hpp"
00005 #include "viennacl/ocl/platform.hpp"
00006 #include "viennacl/ocl/utils.hpp"
00007 #include "viennacl/linalg/kernels/matrix_solve_row_row_source.h"
00008
00009
00010 namespace viennacl
00011 {
00012 namespace linalg
00013 {
00014 namespace kernels
00015 {
00016 template<class TYPE, unsigned int alignment>
00017 struct matrix_solve_row_row;
00018
00019
00021 template <>
00022 struct matrix_solve_row_row<float, 1>
00023 {
00024 static std::string program_name()
00025 {
00026 return "f_matrix_solve_row_row_1";
00027 }
00028 static void init()
00029 {
00030 viennacl::ocl::DOUBLE_PRECISION_CHECKER<float>::apply();
00031 static std::map<cl_context, bool> init_done;
00032 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00033 if (!init_done[context_.handle()])
00034 {
00035 std::string source;
00036 source.append(matrix_solve_row_row_align1_upper_trans_solve);
00037 source.append(matrix_solve_row_row_align1_trans_upper_trans_solve);
00038 source.append(matrix_solve_row_row_align1_unit_lower_solve);
00039 source.append(matrix_solve_row_row_align1_trans_unit_upper_trans_solve);
00040 source.append(matrix_solve_row_row_align1_trans_upper_solve);
00041 source.append(matrix_solve_row_row_align1_unit_lower_trans_solve);
00042 source.append(matrix_solve_row_row_align1_trans_unit_upper_solve);
00043 source.append(matrix_solve_row_row_align1_trans_unit_lower_trans_solve);
00044 source.append(matrix_solve_row_row_align1_lower_trans_solve);
00045 source.append(matrix_solve_row_row_align1_upper_solve);
00046 source.append(matrix_solve_row_row_align1_trans_lower_trans_solve);
00047 source.append(matrix_solve_row_row_align1_lower_solve);
00048 source.append(matrix_solve_row_row_align1_trans_lower_solve);
00049 source.append(matrix_solve_row_row_align1_unit_upper_trans_solve);
00050 source.append(matrix_solve_row_row_align1_unit_upper_solve);
00051 source.append(matrix_solve_row_row_align1_trans_unit_lower_solve);
00052 std::string prog_name = program_name();
00053 #ifdef VIENNACL_BUILD_INFO
00054 std::cout << "Creating program " << prog_name << std::endl;
00055 #endif
00056 context_.add_program(source, prog_name);
00057 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00058 prog_.add_kernel("upper_trans_solve");
00059 prog_.add_kernel("trans_upper_trans_solve");
00060 prog_.add_kernel("unit_lower_solve");
00061 prog_.add_kernel("trans_unit_upper_trans_solve");
00062 prog_.add_kernel("trans_upper_solve");
00063 prog_.add_kernel("unit_lower_trans_solve");
00064 prog_.add_kernel("trans_unit_upper_solve");
00065 prog_.add_kernel("trans_unit_lower_trans_solve");
00066 prog_.add_kernel("lower_trans_solve");
00067 prog_.add_kernel("upper_solve");
00068 prog_.add_kernel("trans_lower_trans_solve");
00069 prog_.add_kernel("lower_solve");
00070 prog_.add_kernel("trans_lower_solve");
00071 prog_.add_kernel("unit_upper_trans_solve");
00072 prog_.add_kernel("unit_upper_solve");
00073 prog_.add_kernel("trans_unit_lower_solve");
00074 init_done[context_.handle()] = true;
00075 }
00076 }
00077 };
00078
00079
00080
00082 template <>
00083 struct matrix_solve_row_row<double, 1>
00084 {
00085 static std::string program_name()
00086 {
00087 return "d_matrix_solve_row_row_1";
00088 }
00089 static void init()
00090 {
00091 viennacl::ocl::DOUBLE_PRECISION_CHECKER<double>::apply();
00092 static std::map<cl_context, bool> init_done;
00093 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00094 if (!init_done[context_.handle()])
00095 {
00096 std::string source;
00097 std::string fp64_ext = viennacl::ocl::current_device().double_support_extension();
00098 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_upper_trans_solve, fp64_ext));
00099 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_upper_trans_solve, fp64_ext));
00100 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_unit_lower_solve, fp64_ext));
00101 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_unit_upper_trans_solve, fp64_ext));
00102 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_upper_solve, fp64_ext));
00103 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_unit_lower_trans_solve, fp64_ext));
00104 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_unit_upper_solve, fp64_ext));
00105 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_unit_lower_trans_solve, fp64_ext));
00106 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_lower_trans_solve, fp64_ext));
00107 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_upper_solve, fp64_ext));
00108 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_lower_trans_solve, fp64_ext));
00109 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_lower_solve, fp64_ext));
00110 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_lower_solve, fp64_ext));
00111 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_unit_upper_trans_solve, fp64_ext));
00112 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_unit_upper_solve, fp64_ext));
00113 source.append(viennacl::tools::make_double_kernel(matrix_solve_row_row_align1_trans_unit_lower_solve, fp64_ext));
00114 std::string prog_name = program_name();
00115 #ifdef VIENNACL_BUILD_INFO
00116 std::cout << "Creating program " << prog_name << std::endl;
00117 #endif
00118 context_.add_program(source, prog_name);
00119 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00120 prog_.add_kernel("upper_trans_solve");
00121 prog_.add_kernel("trans_upper_trans_solve");
00122 prog_.add_kernel("unit_lower_solve");
00123 prog_.add_kernel("trans_unit_upper_trans_solve");
00124 prog_.add_kernel("trans_upper_solve");
00125 prog_.add_kernel("unit_lower_trans_solve");
00126 prog_.add_kernel("trans_unit_upper_solve");
00127 prog_.add_kernel("trans_unit_lower_trans_solve");
00128 prog_.add_kernel("lower_trans_solve");
00129 prog_.add_kernel("upper_solve");
00130 prog_.add_kernel("trans_lower_trans_solve");
00131 prog_.add_kernel("lower_solve");
00132 prog_.add_kernel("trans_lower_solve");
00133 prog_.add_kernel("unit_upper_trans_solve");
00134 prog_.add_kernel("unit_upper_solve");
00135 prog_.add_kernel("trans_unit_lower_solve");
00136 init_done[context_.handle()] = true;
00137 }
00138 }
00139 };
00140
00141
00142 }
00143 }
00144 }
00145 #endif