Go to the documentation of this file.00001 #ifndef _VIENNACL_COORDINATE_MATRIX_KERNELS_HPP_
00002 #define _VIENNACL_COORDINATE_MATRIX_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/coordinate_matrix_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 coordinate_matrix;
00018
00019
00021 template <>
00022 struct coordinate_matrix<float, 128>
00023 {
00024 static std::string program_name()
00025 {
00026 return "f_coordinate_matrix_128";
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(coordinate_matrix_align1_vec_mul);
00037 std::string prog_name = program_name();
00038 #ifdef VIENNACL_BUILD_INFO
00039 std::cout << "Creating program " << prog_name << std::endl;
00040 #endif
00041 context_.add_program(source, prog_name);
00042 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00043 prog_.add_kernel("vec_mul");
00044 init_done[context_.handle()] = true;
00045 }
00046 }
00047 };
00048
00049 template <>
00050 struct coordinate_matrix<float, 1>
00051 {
00052 static std::string program_name()
00053 {
00054 return "f_coordinate_matrix_1";
00055 }
00056 static void init()
00057 {
00058 viennacl::ocl::DOUBLE_PRECISION_CHECKER<float>::apply();
00059 static std::map<cl_context, bool> init_done;
00060 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00061 if (!init_done[context_.handle()])
00062 {
00063 std::string source;
00064 source.append(coordinate_matrix_align1_vec_mul);
00065 std::string prog_name = program_name();
00066 #ifdef VIENNACL_BUILD_INFO
00067 std::cout << "Creating program " << prog_name << std::endl;
00068 #endif
00069 context_.add_program(source, prog_name);
00070 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00071 prog_.add_kernel("vec_mul");
00072 init_done[context_.handle()] = true;
00073 }
00074 }
00075 };
00076
00077
00078
00080 template <>
00081 struct coordinate_matrix<double, 128>
00082 {
00083 static std::string program_name()
00084 {
00085 return "d_coordinate_matrix_128";
00086 }
00087 static void init()
00088 {
00089 viennacl::ocl::DOUBLE_PRECISION_CHECKER<double>::apply();
00090 static std::map<cl_context, bool> init_done;
00091 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00092 if (!init_done[context_.handle()])
00093 {
00094 std::string source;
00095 std::string fp64_ext = viennacl::ocl::current_device().double_support_extension();
00096 source.append(viennacl::tools::make_double_kernel(coordinate_matrix_align1_vec_mul, fp64_ext));
00097 std::string prog_name = program_name();
00098 #ifdef VIENNACL_BUILD_INFO
00099 std::cout << "Creating program " << prog_name << std::endl;
00100 #endif
00101 context_.add_program(source, prog_name);
00102 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00103 prog_.add_kernel("vec_mul");
00104 init_done[context_.handle()] = true;
00105 }
00106 }
00107 };
00108
00109 template <>
00110 struct coordinate_matrix<double, 1>
00111 {
00112 static std::string program_name()
00113 {
00114 return "d_coordinate_matrix_1";
00115 }
00116 static void init()
00117 {
00118 viennacl::ocl::DOUBLE_PRECISION_CHECKER<double>::apply();
00119 static std::map<cl_context, bool> init_done;
00120 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00121 if (!init_done[context_.handle()])
00122 {
00123 std::string source;
00124 std::string fp64_ext = viennacl::ocl::current_device().double_support_extension();
00125 source.append(viennacl::tools::make_double_kernel(coordinate_matrix_align1_vec_mul, fp64_ext));
00126 std::string prog_name = program_name();
00127 #ifdef VIENNACL_BUILD_INFO
00128 std::cout << "Creating program " << prog_name << std::endl;
00129 #endif
00130 context_.add_program(source, prog_name);
00131 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00132 prog_.add_kernel("vec_mul");
00133 init_done[context_.handle()] = true;
00134 }
00135 }
00136 };
00137
00138
00139 }
00140 }
00141 }
00142 #endif