Go to the documentation of this file.00001 #ifndef _VIENNACL_FFT_KERNELS_HPP_
00002 #define _VIENNACL_FFT_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/fft_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 fft;
00018
00019
00021 template <>
00022 struct fft<float, 1>
00023 {
00024 static std::string program_name()
00025 {
00026 return "f_fft_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(fft_align1_real_to_complex);
00037 source.append(fft_align1_fft_mult_vec);
00038 source.append(fft_align1_fft_div_vec_scalar);
00039 source.append(fft_align1_zero2);
00040 source.append(fft_align1_vandermonde_prod);
00041 source.append(fft_align1_bluestein_pre);
00042 source.append(fft_align1_transpose);
00043 source.append(fft_align1_complex_to_real);
00044 source.append(fft_align1_reverse_inplace);
00045 source.append(fft_align1_transpose_inplace);
00046 source.append(fft_align1_bluestein_post);
00047 std::string prog_name = program_name();
00048 #ifdef VIENNACL_BUILD_INFO
00049 std::cout << "Creating program " << prog_name << std::endl;
00050 #endif
00051 context_.add_program(source, prog_name);
00052 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00053 prog_.add_kernel("real_to_complex");
00054 prog_.add_kernel("fft_mult_vec");
00055 prog_.add_kernel("fft_div_vec_scalar");
00056 prog_.add_kernel("zero2");
00057 prog_.add_kernel("vandermonde_prod");
00058 prog_.add_kernel("bluestein_pre");
00059 prog_.add_kernel("transpose");
00060 prog_.add_kernel("complex_to_real");
00061 prog_.add_kernel("reverse_inplace");
00062 prog_.add_kernel("transpose_inplace");
00063 prog_.add_kernel("bluestein_post");
00064 init_done[context_.handle()] = true;
00065 }
00066 }
00067 };
00068
00069
00070
00072 template <>
00073 struct fft<double, 1>
00074 {
00075 static std::string program_name()
00076 {
00077 return "d_fft_1";
00078 }
00079 static void init()
00080 {
00081 viennacl::ocl::DOUBLE_PRECISION_CHECKER<double>::apply();
00082 static std::map<cl_context, bool> init_done;
00083 viennacl::ocl::context & context_ = viennacl::ocl::current_context();
00084 if (!init_done[context_.handle()])
00085 {
00086 std::string source;
00087 std::string fp64_ext = viennacl::ocl::current_device().double_support_extension();
00088 source.append(viennacl::tools::make_double_kernel(fft_align1_real_to_complex, fp64_ext));
00089 source.append(viennacl::tools::make_double_kernel(fft_align1_fft_mult_vec, fp64_ext));
00090 source.append(viennacl::tools::make_double_kernel(fft_align1_fft_div_vec_scalar, fp64_ext));
00091 source.append(viennacl::tools::make_double_kernel(fft_align1_zero2, fp64_ext));
00092 source.append(viennacl::tools::make_double_kernel(fft_align1_vandermonde_prod, fp64_ext));
00093 source.append(viennacl::tools::make_double_kernel(fft_align1_bluestein_pre, fp64_ext));
00094 source.append(viennacl::tools::make_double_kernel(fft_align1_transpose, fp64_ext));
00095 source.append(viennacl::tools::make_double_kernel(fft_align1_complex_to_real, fp64_ext));
00096 source.append(viennacl::tools::make_double_kernel(fft_align1_reverse_inplace, fp64_ext));
00097 source.append(viennacl::tools::make_double_kernel(fft_align1_transpose_inplace, fp64_ext));
00098 source.append(viennacl::tools::make_double_kernel(fft_align1_bluestein_post, fp64_ext));
00099 std::string prog_name = program_name();
00100 #ifdef VIENNACL_BUILD_INFO
00101 std::cout << "Creating program " << prog_name << std::endl;
00102 #endif
00103 context_.add_program(source, prog_name);
00104 viennacl::ocl::program & prog_ = context_.get_program(prog_name);
00105 prog_.add_kernel("real_to_complex");
00106 prog_.add_kernel("fft_mult_vec");
00107 prog_.add_kernel("fft_div_vec_scalar");
00108 prog_.add_kernel("zero2");
00109 prog_.add_kernel("vandermonde_prod");
00110 prog_.add_kernel("bluestein_pre");
00111 prog_.add_kernel("transpose");
00112 prog_.add_kernel("complex_to_real");
00113 prog_.add_kernel("reverse_inplace");
00114 prog_.add_kernel("transpose_inplace");
00115 prog_.add_kernel("bluestein_post");
00116 init_done[context_.handle()] = true;
00117 }
00118 }
00119 };
00120
00121
00122 }
00123 }
00124 }
00125 #endif