本文整理汇总了C++中StringT::append方法的典型用法代码示例。如果您正苦于以下问题:C++ StringT::append方法的具体用法?C++ StringT::append怎么用?C++ StringT::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringT
的用法示例。
在下文中一共展示了StringT::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generate_scalar_swap
void generate_scalar_swap(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void swap( \n");
source.append(" __global "); source.append(numeric_string); source.append(" * s1, \n");
source.append(" __global "); source.append(numeric_string); source.append(" * s2) \n");
source.append("{ \n");
source.append(" "); source.append(numeric_string); source.append(" tmp = *s2; \n");
source.append(" *s2 = *s1; \n");
source.append(" *s1 = tmp; \n");
source.append("} \n");
}
示例2: generate_fft_complex_to_real
void generate_fft_complex_to_real(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void complex_to_real(__global "); source.append(numeric_string); source.append("2 *in, \n");
source.append(" __global "); source.append(numeric_string); source.append(" *out, \n");
source.append(" unsigned int size) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) \n");
source.append(" out[i] = in[i].x; \n");
source.append("} \n");
}
示例3: generate_fft_div_vec_scalar
void generate_fft_div_vec_scalar(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void fft_div_vec_scalar(__global "); source.append(numeric_string); source.append("2 *input1, \n");
source.append(" unsigned int size, \n");
source.append(" "); source.append(numeric_string); source.append(" factor) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) \n");
source.append(" input1[i] /= factor; \n");
source.append("} \n");
}
示例4: generate_asbs_impl3
void generate_asbs_impl3(StringT & source, char sign_a, char sign_b, asbs_config const & cfg, bool mult_alpha, bool mult_beta)
{
source.append(" *s1 "); source.append(cfg.assign_op); source.append(1, sign_a); source.append(" *s2 ");
if (mult_alpha)
source.append("* alpha ");
else
source.append("/ alpha ");
if (cfg.b != VIENNACL_ASBS_NONE)
{
source.append(1, sign_b); source.append(" *s3 ");
if (mult_beta)
source.append("* beta");
else
source.append("/ beta");
}
source.append("; \n");
}
示例5: generate_asbs_impl2
void generate_asbs_impl2(StringT & source, char sign_a, char sign_b, asbs_config const & cfg)
{
source.append(" if (options2 & (1 << 1)) { \n");
if (cfg.b != VIENNACL_ASBS_NONE)
{
source.append(" if (options3 & (1 << 1)) \n");
generate_asbs_impl3(source, sign_a, sign_b, cfg, false, false);
source.append(" else \n");
generate_asbs_impl3(source, sign_a, sign_b, cfg, false, true);
}
else
generate_asbs_impl3(source, sign_a, sign_b, cfg, false, true);
source.append(" } else { \n");
if (cfg.b != VIENNACL_ASBS_NONE)
{
source.append(" if (options3 & (1 << 1)) \n");
generate_asbs_impl3(source, sign_a, sign_b, cfg, true, false);
source.append(" else \n");
generate_asbs_impl3(source, sign_a, sign_b, cfg, true, true);
}
else
generate_asbs_impl3(source, sign_a, sign_b, cfg, true, true);
source.append(" } \n");
}
示例6: generate_amg_pmis2_reset_state
void generate_amg_pmis2_reset_state(StringT & source)
{
source.append("__kernel void amg_pmis2_reset_state( \n");
source.append(" __global unsigned int *point_types, \n");
source.append(" unsigned int size) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) { \n");
source.append(" if (point_types[i] != 1) point_types[i] = 0;\n"); // mind mapping of POINT_TYPE_COARSE and POINT_TYPE_UNDECIDED
source.append(" } \n");
source.append("} \n");
}
示例7: generate_amg_agg_merge_undecided_2
void generate_amg_agg_merge_undecided_2(StringT & source)
{
source.append(" __kernel void amg_agg_merge_undecided_2( \n");
source.append(" __global unsigned int *point_types, \n");
source.append(" unsigned int size) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) \n");
source.append(" if (point_types[i] == 0) point_types[i] = 2; \n"); // POINT_TYPE_UNDECIDED to POINT_TYPE_FINE
source.append("} \n");
}
示例8: generate_fft_real_to_complex
void generate_fft_real_to_complex(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void real_to_complex(__global "); source.append(numeric_string); source.append(" *in, \n");
source.append(" __global "); source.append(numeric_string); source.append("2 *out, \n");
source.append(" unsigned int size) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) { \n");
source.append(" "); source.append(numeric_string); source.append("2 val = 0; \n");
source.append(" val.x = in[i]; \n");
source.append(" out[i] = val; \n");
source.append(" } \n");
source.append("} \n");
}
示例9: generate_fft_mult_vec
void generate_fft_mult_vec(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void fft_mult_vec(__global const "); source.append(numeric_string); source.append("2 *input1, \n");
source.append(" __global const "); source.append(numeric_string); source.append("2 *input2, \n");
source.append(" __global "); source.append(numeric_string); source.append("2 *output, \n");
source.append(" unsigned int size) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) { \n");
source.append(" "); source.append(numeric_string); source.append("2 in1 = input1[i]; \n");
source.append(" "); source.append(numeric_string); source.append("2 in2 = input2[i]; \n");
source.append(" output[i] = ("); source.append(numeric_string); source.append("2)(in1.x * in2.x - in1.y * in2.y, in1.x * in2.y + in1.y * in2.x); \n");
source.append(" } \n");
source.append("} \n");
}
示例10: generate_amg_pmis2_init_workdata
void generate_amg_pmis2_init_workdata(StringT & source)
{
source.append("__kernel void amg_pmis2_init_workdata( \n");
source.append(" __global unsigned int *work_state, \n");
source.append(" __global unsigned int *work_random, \n");
source.append(" __global unsigned int *work_index, \n");
source.append(" __global unsigned int const *point_types, \n");
source.append(" __global unsigned int const *random_weights, \n");
source.append(" unsigned int size) { \n");
source.append(" for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) { \n");
source.append(" switch (point_types[i]) { \n");
source.append(" case 0: work_state[i] = 1; break; \n"); //viennacl::linalg::detail::amg::amg_level_context::POINT_TYPE_UNDECIDED
source.append(" case 1: work_state[i] = 2; break; \n"); //viennacl::linalg::detail::amg::amg_level_context::POINT_TYPE_COARSE
source.append(" case 2: work_state[i] = 0; break; \n"); //viennacl::linalg::detail::amg::amg_level_context::POINT_TYPE_FINE
source.append(" default: break; // do nothing \n");
source.append(" } \n");
source.append(" work_random[i] = random_weights[i]; \n");
source.append(" work_index[i] = i; \n");
source.append(" } \n");
source.append("} \n");
}
示例11: generate_ilu_scale_kernel_2
void generate_ilu_scale_kernel_2(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void ilu_scale_kernel_2( \n");
source.append(" __global unsigned int const *R_row_indices, \n");
source.append(" __global unsigned int const *R_col_indices, \n");
source.append(" __global "); source.append(numeric_string); source.append(" *R_elements, \n");
source.append(" unsigned int R_size1, \n");
source.append(" __global "); source.append(numeric_string); source.append(" const *D_elements) { \n");
source.append(" for (unsigned int row = get_global_id(0); \n");
source.append(" row < R_size1; \n");
source.append(" row += get_global_size(0)) \n");
source.append(" { \n");
source.append(" unsigned int row_begin = R_row_indices[row]; \n");
source.append(" unsigned int row_end = R_row_indices[row+1]; \n");
source.append(" "); source.append(numeric_string); source.append(" D_row = D_elements[row]; \n");
source.append(" for (unsigned int j=row_begin; j<row_end; ++j) \n");
source.append(" R_elements[j] *= D_row * D_elements[R_col_indices[j]]; \n");
source.append(" } \n");
source.append("} \n");
}
示例12: generate_hyb_vec_mul
void generate_hyb_vec_mul(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void vec_mul( \n");
source.append(" const __global int* ell_coords, \n");
source.append(" const __global "); source.append(numeric_string); source.append("* ell_elements, \n");
source.append(" const __global uint* csr_rows, \n");
source.append(" const __global uint* csr_cols, \n");
source.append(" const __global "); source.append(numeric_string); source.append("* csr_elements, \n");
source.append(" const __global "); source.append(numeric_string); source.append(" * x, \n");
source.append(" uint4 layout_x, \n");
source.append(" __global "); source.append(numeric_string); source.append(" * result, \n");
source.append(" uint4 layout_result, \n");
source.append(" unsigned int row_num, \n");
source.append(" unsigned int internal_row_num, \n");
source.append(" unsigned int items_per_row, \n");
source.append(" unsigned int aligned_items_per_row) \n");
source.append("{ \n");
source.append(" uint glb_id = get_global_id(0); \n");
source.append(" uint glb_sz = get_global_size(0); \n");
source.append(" for (uint row_id = glb_id; row_id < row_num; row_id += glb_sz) { \n");
source.append(" "); source.append(numeric_string); source.append(" sum = 0; \n");
source.append(" uint offset = row_id; \n");
source.append(" for (uint item_id = 0; item_id < items_per_row; item_id++, offset += internal_row_num) { \n");
source.append(" "); source.append(numeric_string); source.append(" val = ell_elements[offset]; \n");
source.append(" if (val != ("); source.append(numeric_string); source.append(")0) { \n");
source.append(" int col = ell_coords[offset]; \n");
source.append(" sum += (x[col * layout_x.y + layout_x.x] * val); \n");
source.append(" } \n");
source.append(" } \n");
source.append(" uint col_begin = csr_rows[row_id]; \n");
source.append(" uint col_end = csr_rows[row_id + 1]; \n");
source.append(" for (uint item_id = col_begin; item_id < col_end; item_id++) { \n");
source.append(" sum += (x[csr_cols[item_id] * layout_x.y + layout_x.x] * csr_elements[item_id]); \n");
source.append(" } \n");
source.append(" result[row_id * layout_result.y + layout_result.x] = sum; \n");
source.append(" } \n");
source.append("} \n");
}
示例13: generate_fft_bluestein_post
void generate_fft_bluestein_post(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void bluestein_post(__global "); source.append(numeric_string); source.append("2 *Z, \n");
source.append(" __global "); source.append(numeric_string); source.append("2 *out, \n");
source.append(" unsigned int size) \n");
source.append("{ \n");
source.append(" unsigned int glb_id = get_global_id(0); \n");
source.append(" unsigned int glb_sz = get_global_size(0); \n");
source.append(" unsigned int double_size = size << 1; \n");
source.append(" "); source.append(numeric_string); source.append(" sn_a, cs_a; \n");
source.append(" const "); source.append(numeric_string); source.append(" NUM_PI = 3.14159265358979323846; \n");
source.append(" for (unsigned int i = glb_id; i < size; i += glb_sz) { \n");
source.append(" unsigned int rm = i * i % (double_size); \n");
source.append(" "); source.append(numeric_string); source.append(" angle = ("); source.append(numeric_string); source.append(")rm / size * (-NUM_PI); \n");
source.append(" sn_a = sincos(angle, &cs_a); \n");
source.append(" "); source.append(numeric_string); source.append("2 b_i = ("); source.append(numeric_string); source.append("2)(cs_a, sn_a); \n");
source.append(" out[i] = ("); source.append(numeric_string); source.append("2)(Z[i].x * b_i.x - Z[i].y * b_i.y, Z[i].x * b_i.y + Z[i].y * b_i.x); \n");
source.append(" } \n");
source.append("} \n");
}
示例14: generate_fft_vandermonde_prod
void generate_fft_vandermonde_prod(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void vandermonde_prod(__global "); source.append(numeric_string); source.append(" *vander, \n");
source.append(" __global "); source.append(numeric_string); source.append(" *vector, \n");
source.append(" __global "); source.append(numeric_string); source.append(" *result, \n");
source.append(" uint size) { \n");
source.append(" for (uint i = get_global_id(0); i < size; i+= get_global_size(0)) { \n");
source.append(" "); source.append(numeric_string); source.append(" mul = vander[i]; \n");
source.append(" "); source.append(numeric_string); source.append(" pwr = 1; \n");
source.append(" "); source.append(numeric_string); source.append(" val = 0; \n");
source.append(" for (uint j = 0; j < size; j++) { \n");
source.append(" val = val + pwr * vector[j]; \n");
source.append(" pwr *= mul; \n");
source.append(" } \n");
source.append(" result[i] = val; \n");
source.append(" } \n");
source.append("} \n");
}
示例15: generate_asbs_impl
void generate_asbs_impl(StringT & source, std::string const & numeric_string, asbs_config const & cfg)
{
source.append("__kernel void as");
if (cfg.b != VIENNACL_ASBS_NONE)
source.append("bs");
if (cfg.assign_op != "=")
source.append("_s");
if (cfg.a == VIENNACL_ASBS_CPU)
source.append("_cpu");
else if (cfg.a == VIENNACL_ASBS_GPU)
source.append("_gpu");
if (cfg.b == VIENNACL_ASBS_CPU)
source.append("_cpu");
else if (cfg.b == VIENNACL_ASBS_GPU)
source.append("_gpu");
source.append("( \n");
source.append(" __global "); source.append(numeric_string); source.append(" * s1, \n");
source.append(" \n");
if (cfg.a == VIENNACL_ASBS_CPU)
{
source.append(" "); source.append(numeric_string); source.append(" fac2, \n");
}
else if (cfg.a == VIENNACL_ASBS_GPU)
{
source.append(" __global "); source.append(numeric_string); source.append(" * fac2, \n");
}
source.append(" unsigned int options2, \n"); // 0: no action, 1: flip sign, 2: take inverse, 3: flip sign and take inverse
source.append(" __global const "); source.append(numeric_string); source.append(" * s2");
if (cfg.b != VIENNACL_ASBS_NONE)
{
source.append(", \n\n");
if (cfg.b == VIENNACL_ASBS_CPU)
{
source.append(" "); source.append(numeric_string); source.append(" fac3, \n");
}
else if (cfg.b == VIENNACL_ASBS_GPU)
{
source.append(" __global "); source.append(numeric_string); source.append(" * fac3, \n");
}
source.append(" unsigned int options3, \n"); // 0: no action, 1: flip sign, 2: take inverse, 3: flip sign and take inverse
source.append(" __global const "); source.append(numeric_string); source.append(" * s3");
}
source.append(") \n{ \n");
if (cfg.a == VIENNACL_ASBS_CPU)
{
source.append(" "); source.append(numeric_string); source.append(" alpha = fac2; \n");
}
else if (cfg.a == VIENNACL_ASBS_GPU)
{
source.append(" "); source.append(numeric_string); source.append(" alpha = fac2[0]; \n");
}
source.append(" \n");
if (cfg.b == VIENNACL_ASBS_CPU)
{
source.append(" "); source.append(numeric_string); source.append(" beta = fac3; \n");
}
else if (cfg.b == VIENNACL_ASBS_GPU)
{
source.append(" "); source.append(numeric_string); source.append(" beta = fac3[0]; \n");
}
source.append(" if (options2 & (1 << 0)) { \n");
if (cfg.b != VIENNACL_ASBS_NONE)
{
source.append(" if (options3 & (1 << 0)) { \n");
generate_asbs_impl2(source, '-', '-', cfg);
source.append(" } else { \n");
generate_asbs_impl2(source, '-', '+', cfg);
source.append(" } \n");
}
else
generate_asbs_impl2(source, '-', '+', cfg);
source.append(" } else { \n");
if (cfg.b != VIENNACL_ASBS_NONE)
{
source.append(" if (options3 & (1 << 0)) { \n");
generate_asbs_impl2(source, '+', '-', cfg);
source.append(" } else { \n");
generate_asbs_impl2(source, '+', '+', cfg);
source.append(" } \n");
}
else
generate_asbs_impl2(source, '+', '+', cfg);
source.append(" } \n");
source.append("} \n");
}