当前位置: 首页>>代码示例>>C++>>正文


C++ ocl::context类代码示例

本文整理汇总了C++中viennacl::ocl::context的典型用法代码示例。如果您正苦于以下问题:C++ context类的具体用法?C++ context怎么用?C++ context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了context类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

          static void init(viennacl::ocl::context & ctx)
          {
            viennacl::ocl::DOUBLE_PRECISION_CHECKER<TYPE>::apply(ctx);
            std::string numeric_string = viennacl::ocl::type_to_string<TYPE>::apply();

            static std::map<cl_context, bool> init_done;
            if (!init_done[ctx.handle().get()])
            {
              std::string source;
              source.reserve(8192);

              viennacl::ocl::append_double_precision_pragma<TYPE>(ctx, source);

              // fully parametrized kernels:
              generate_asbs(source, numeric_string);
              generate_scalar_swap(source, numeric_string);


              std::string prog_name = program_name();
              #ifdef VIENNACL_BUILD_INFO
              std::cout << "Creating program " << prog_name << std::endl;
              #endif
              ctx.add_program(source, prog_name);
              init_done[ctx.handle().get()] = true;
            } //if
          } //init
开发者ID:GnsP,项目名称:viennacl-dev,代码行数:26,代码来源:scalar.hpp

示例2: init

          static void init(viennacl::ocl::context & ctx)
          {
            viennacl::ocl::DOUBLE_PRECISION_CHECKER<NumericT>::apply(ctx);
            std::string numeric_string = viennacl::ocl::type_to_string<NumericT>::apply();

            static std::map<cl_context, bool> init_done;
            if (!init_done[ctx.handle().get()])
            {
              std::string source;
              source.reserve(1024);

              viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);

              generate_coordinate_matrix_vec_mul(source, numeric_string);
              generate_coordinate_matrix_dense_matrix_multiplication(source, numeric_string);
              generate_coordinate_matrix_row_info_extractor(source, numeric_string);

              std::string prog_name = program_name();
              #ifdef VIENNACL_BUILD_INFO
              std::cout << "Creating program " << prog_name << std::endl;
              #endif
              ctx.add_program(source, prog_name);
              init_done[ctx.handle().get()] = true;
            } //if
          } //init
开发者ID:GnsP,项目名称:viennacl-dev,代码行数:25,代码来源:coordinate_matrix.hpp

示例3: init

          static void init(viennacl::ocl::context & ctx)
          {
            viennacl::ocl::DOUBLE_PRECISION_CHECKER<NumericT>::apply(ctx);
            std::string numeric_string = viennacl::ocl::type_to_string<NumericT>::apply();

            static std::map<cl_context, bool> init_done;
            if (!init_done[ctx.handle().get()])
            {
              std::string source;
              source.reserve(8192);

              viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);

              // only generate for floating points (forces error for integers)
              if (numeric_string == "float" || numeric_string == "double")
              {
                generate_nmf_el_wise_mul_div(source, numeric_string);
              }

              std::string prog_name = program_name();
              #ifdef VIENNACL_BUILD_INFO
              std::cout << "Creating program " << prog_name << std::endl;
              #endif
              ctx.add_program(source, prog_name);
              init_done[ctx.handle().get()] = true;
            } //if
          } //init
开发者ID:YannCobigo,项目名称:viennacl-dev,代码行数:27,代码来源:nmf.hpp

示例4: init

  static void init(viennacl::ocl::context & ctx)
  {
    viennacl::ocl::DOUBLE_PRECISION_CHECKER<NumericT>::apply(ctx);
    std::string numeric_string = viennacl::ocl::type_to_string<NumericT>::apply();

    static std::map<cl_context, bool> init_done;
    if (!init_done[ctx.handle().get()])
    {
      std::string source;
      source.reserve(8192);
      bool is_row_major = viennacl::is_row_major<F>::value;

      viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);

      // unary operations
      if (numeric_string == "float" || numeric_string == "double")
      {
        generate_matrix_unary_element_ops(source, numeric_string, "acos",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "acosh", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "asin",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "asinh", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "atan",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "atanh", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "ceil",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "cos",   is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "cosh",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "erf",   is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "erfc",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "exp",   is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "exp2",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "exp10", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "fabs",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "floor", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "log",   is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "log2",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "log10", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "round", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "rsqrt", is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "sign",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "sin",   is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "sinh",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "sqrt",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "tan",   is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "tanh",  is_row_major);
        generate_matrix_unary_element_ops(source, numeric_string, "trunc", is_row_major);
      }
      else
      {
        generate_matrix_unary_element_ops(source, numeric_string, "abs", is_row_major);
      }

      std::string prog_name = program_name();
      #ifdef VIENNACL_BUILD_INFO
      std::cout << "Creating program " << prog_name << std::endl;
      #endif
      ctx.add_program(source, prog_name);
      init_done[ctx.handle().get()] = true;
    } //if
  } //init
开发者ID:idgitid,项目名称:viennacl-dev,代码行数:59,代码来源:matrix_element.hpp

示例5: execute

inline void execute(template_base const & T, statements_container const & statements, viennacl::ocl::context & ctx = viennacl::ocl::current_context(), bool force_compilation = false)
{
  //Generate program name
  std::string program_name = tree_parsing::statements_representation(statements, BIND_TO_HANDLE);
  execution_handler handler(program_name, ctx, ctx.current_device(), force_compilation);
  handler.add(program_name, T, statements);
  handler.execute(program_name, statements);
}
开发者ID:10imaging,项目名称:viennacl,代码行数:8,代码来源:execute.hpp

示例6: init

          static void init(viennacl::ocl::context & ctx)
          {
            viennacl::ocl::DOUBLE_PRECISION_CHECKER<TYPE>::apply(ctx);
            std::string numeric_string = viennacl::ocl::type_to_string<TYPE>::apply();

            static std::map<cl_context, bool> init_done;
            if (!init_done[ctx.handle().get()])
            {
              std::string source;
              source.reserve(8192);

              viennacl::ocl::append_double_precision_pragma<TYPE>(ctx, source);

              // unary operations
              generate_vector_unary_element_ops(source, numeric_string, "acos");
              generate_vector_unary_element_ops(source, numeric_string, "asin");
              generate_vector_unary_element_ops(source, numeric_string, "atan");
              generate_vector_unary_element_ops(source, numeric_string, "ceil");
              generate_vector_unary_element_ops(source, numeric_string, "cos");
              generate_vector_unary_element_ops(source, numeric_string, "cosh");
              generate_vector_unary_element_ops(source, numeric_string, "exp");
              generate_vector_unary_element_ops(source, numeric_string, "fabs");
              generate_vector_unary_element_ops(source, numeric_string, "floor");
              generate_vector_unary_element_ops(source, numeric_string, "log");
              generate_vector_unary_element_ops(source, numeric_string, "log10");
              generate_vector_unary_element_ops(source, numeric_string, "sin");
              generate_vector_unary_element_ops(source, numeric_string, "sinh");
              generate_vector_unary_element_ops(source, numeric_string, "sqrt");
              generate_vector_unary_element_ops(source, numeric_string, "tan");
              generate_vector_unary_element_ops(source, numeric_string, "tanh");

              // binary operations
              generate_vector_binary_element_ops(source, numeric_string);

              std::string prog_name = program_name();
              #ifdef VIENNACL_BUILD_INFO
              std::cout << "Creating program " << prog_name << std::endl;
              #endif
              ctx.add_program(source, prog_name);
              init_done[ctx.handle().get()] = true;
            } //if
          } //init
开发者ID:rollingstone,项目名称:viennamos-dev,代码行数:42,代码来源:vector_element.hpp

示例7: init

          static void init(viennacl::ocl::context & ctx)
          {
            viennacl::ocl::DOUBLE_PRECISION_CHECKER<NumericT>::apply(ctx);
            std::string numeric_string = viennacl::ocl::type_to_string<NumericT>::apply();
            bool row_major_A = viennacl::is_row_major<F_A>::value;
            bool row_major_B = viennacl::is_row_major<F_B>::value;
            bool row_major_C = viennacl::is_row_major<F_C>::value;


            static std::map<cl_context, bool> init_done;
            if (!init_done[ctx.handle().get()])
            {
              std::string source;
              source.reserve(8192);

              viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);

              // only generate for floating points (forces error for integers)
              if (numeric_string == "float" || numeric_string == "double")
              {
                generate_matrix_prod_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, false, false);
                generate_matrix_prod_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, false, true);
                generate_matrix_prod_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, true, false);
                generate_matrix_prod_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, true, true);

                generate_matrix_prod16_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, false, false);
                generate_matrix_prod16_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, false, true);
                generate_matrix_prod16_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, true, false);
                generate_matrix_prod16_blas3(source, numeric_string, row_major_A, row_major_B, row_major_C, true, true);

              }

              std::string prog_name = program_name();
              #ifdef VIENNACL_BUILD_INFO
              std::cout << "Creating program " << prog_name << std::endl;
              #endif
              ctx.add_program(source, prog_name);
              init_done[ctx.handle().get()] = true;
            } //if
          } //init
开发者ID:GnsP,项目名称:viennacl-dev,代码行数:40,代码来源:matrix_prod.hpp

示例8: init

  static void init(viennacl::ocl::context & ctx)
  {
    static std::map<cl_context, bool> init_done;
    if (!init_done[ctx.handle().get()])
    {
      viennacl::ocl::DOUBLE_PRECISION_CHECKER<NumericT>::apply(ctx);
      std::string numeric_string = viennacl::ocl::type_to_string<NumericT>::apply();

      std::string source;
      source.reserve(1024);

      viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);

      // only generate for floating points (forces error for integers)
      if (numeric_string == "float" || numeric_string == "double")
      {
        generate_ilu_level_scheduling_substitute(source, numeric_string);

        generate_icc_extract_L_1(source);
        generate_icc_extract_L_2(source, numeric_string);
        generate_icc_chow_patel_sweep_kernel(source, numeric_string);

        generate_ilu_extract_LU_1(source);
        generate_ilu_extract_LU_2(source, numeric_string);
        generate_ilu_scale_kernel_1(source, numeric_string);
        generate_ilu_scale_kernel_2(source, numeric_string);
        generate_ilu_chow_patel_sweep_kernel(source, numeric_string);
        generate_ilu_form_neumann_matrix_kernel(source, numeric_string);
      }

      std::string prog_name = program_name();
      #ifdef VIENNACL_BUILD_INFO
      std::cout << "Creating program " << prog_name << std::endl;
      #endif
      ctx.add_program(source, prog_name);
      init_done[ctx.handle().get()] = true;
    } //if
  } //init
开发者ID:Rombur,项目名称:viennacl-dev,代码行数:38,代码来源:ilu.hpp

示例9: init

  static void init(viennacl::ocl::context & ctx)
  {
    static std::map<cl_context, bool> init_done;
    if (!init_done[ctx.handle().get()])
    {
      viennacl::ocl::DOUBLE_PRECISION_CHECKER<NumericT>::apply(ctx);
      std::string numeric_string = viennacl::ocl::type_to_string<NumericT>::apply();

      std::string source;
      source.reserve(8192);

      viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);

      // unary operations
      if (numeric_string == "float" || numeric_string == "double")
      {
        generate_fft_bluestein_post(source, numeric_string);
        generate_fft_bluestein_pre(source, numeric_string);
        generate_fft_complex_to_real(source, numeric_string);
        generate_fft_div_vec_scalar(source, numeric_string);
        generate_fft_mult_vec(source, numeric_string);
        generate_fft_real_to_complex(source, numeric_string);
        generate_fft_reverse_inplace(source, numeric_string);
        generate_fft_transpose(source, numeric_string);
        generate_fft_transpose_inplace(source, numeric_string);
        generate_fft_vandermonde_prod(source, numeric_string);
        generate_fft_zero2(source, numeric_string);
      }

      std::string prog_name = program_name();
      #ifdef VIENNACL_BUILD_INFO
      std::cout << "Creating program " << prog_name << std::endl;
      #endif
      ctx.add_program(source, prog_name);
      init_done[ctx.handle().get()] = true;
    } //if
  } //init
开发者ID:aanchan,项目名称:viennacl-dev,代码行数:37,代码来源:fft.hpp

示例10:

 inline void append_double_precision_pragma<double>(viennacl::ocl::context const & ctx, std::string & source)
 {
   source.append("#pragma OPENCL EXTENSION " + ctx.current_device().double_support_extension() + " : enable\n\n");
 }
开发者ID:rollingstone,项目名称:viennamos-dev,代码行数:4,代码来源:utils.hpp

示例11: apply

 static void apply(viennacl::ocl::context const & ctx)
 {
   if (!ctx.current_device().double_support())
     throw viennacl::ocl::double_precision_not_provided_error();
 }
开发者ID:rollingstone,项目名称:viennamos-dev,代码行数:5,代码来源:utils.hpp

示例12: memory_create

 /** @brief Creates an array of the specified size in the current OpenCL context. If the second argument is provided, the buffer is initialized with data from that pointer.
  *
  * @param size_in_bytes   Number of bytes to allocate
  * @param host_ptr        Pointer to data which will be copied to the new array. Must point to at least 'size_in_bytes' bytes of data.
  * @param ctx             Optional context in which the matrix is created (one out of multiple OpenCL contexts, CUDA, host)
  *
  */
 inline cl_mem memory_create(viennacl::ocl::context const & ctx, vcl_size_t size_in_bytes, const void * host_ptr = NULL)
 {
   //std::cout << "Creating buffer (" << size_in_bytes << " bytes) host buffer " << host_ptr << " in context " << &ctx << std::endl;
   return ctx.create_memory_without_smart_handle(CL_MEM_READ_WRITE, static_cast<unsigned int>(size_in_bytes), const_cast<void *>(host_ptr));
 }
开发者ID:wpk1124,项目名称:CompressedSensing,代码行数:12,代码来源:opencl.hpp


注:本文中的viennacl::ocl::context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。