Go to the documentation of this file.00001 #ifndef _VIENNACL_SPAI_KERNELS_HPP_
00002 #define _VIENNACL_SPAI_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/spai_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 spai;
00018
00019
00021 template <>
00022 struct spai<float, 1>
00023 {
00024 static std::string program_name()
00025 {
00026 return "f_spai_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(spai_align1_block_qr_assembly_1);
00037 source.append(spai_align1_block_qr_assembly);
00038 source.append(spai_align1_block_bv_assembly);
00039 source.append(spai_align1_block_least_squares);
00040 source.append(spai_align1_block_qr);
00041 source.append(spai_align1_block_r_assembly);
00042 source.append(spai_align1_block_q_mult);
00043 source.append(spai_align1_assemble_blocks);
00044 std::string prog_name = program_name();
00045 #ifdef VIENNACL_BUILD_INFO
00046 std::cout << "Creating program " << prog_name << std::endl;
00047 #endif
00048 context_.add_program(source, prog_name);
00049 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00050 prog_.add_kernel("block_qr_assembly_1");
00051 prog_.add_kernel("block_qr_assembly");
00052 prog_.add_kernel("block_bv_assembly");
00053 prog_.add_kernel("block_least_squares");
00054 prog_.add_kernel("block_qr");
00055 prog_.add_kernel("block_r_assembly");
00056 prog_.add_kernel("block_q_mult");
00057 prog_.add_kernel("assemble_blocks");
00058 init_done[context_.handle()] = true;
00059 }
00060 }
00061 };
00062
00063
00064
00066 template <>
00067 struct spai<double, 1>
00068 {
00069 static std::string program_name()
00070 {
00071 return "d_spai_1";
00072 }
00073 static void init()
00074 {
00075 viennacl::ocl::DOUBLE_PRECISION_CHECKER<double>::apply();
00076 static std::map<cl_context, bool> init_done;
00077 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00078 if (!init_done[context_.handle()])
00079 {
00080 std::string source;
00081 std::string fp64_ext = viennacl::ocl::current_device().double_support_extension();
00082 source.append(viennacl::tools::make_double_kernel(spai_align1_block_qr_assembly_1, fp64_ext));
00083 source.append(viennacl::tools::make_double_kernel(spai_align1_block_qr_assembly, fp64_ext));
00084 source.append(viennacl::tools::make_double_kernel(spai_align1_block_bv_assembly, fp64_ext));
00085 source.append(viennacl::tools::make_double_kernel(spai_align1_block_least_squares, fp64_ext));
00086 source.append(viennacl::tools::make_double_kernel(spai_align1_block_qr, fp64_ext));
00087 source.append(viennacl::tools::make_double_kernel(spai_align1_block_r_assembly, fp64_ext));
00088 source.append(viennacl::tools::make_double_kernel(spai_align1_block_q_mult, fp64_ext));
00089 source.append(viennacl::tools::make_double_kernel(spai_align1_assemble_blocks, fp64_ext));
00090 std::string prog_name = program_name();
00091 #ifdef VIENNACL_BUILD_INFO
00092 std::cout << "Creating program " << prog_name << std::endl;
00093 #endif
00094 context_.add_program(source, prog_name);
00095 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00096 prog_.add_kernel("block_qr_assembly_1");
00097 prog_.add_kernel("block_qr_assembly");
00098 prog_.add_kernel("block_bv_assembly");
00099 prog_.add_kernel("block_least_squares");
00100 prog_.add_kernel("block_qr");
00101 prog_.add_kernel("block_r_assembly");
00102 prog_.add_kernel("block_q_mult");
00103 prog_.add_kernel("assemble_blocks");
00104 init_done[context_.handle()] = true;
00105 }
00106 }
00107 };
00108
00109
00110 }
00111 }
00112 }
00113 #endif