本文整理汇总了C++中tl::Symbol类的典型用法代码示例。如果您正苦于以下问题:C++ Symbol类的具体用法?C++ Symbol怎么用?C++ Symbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void visit(const Nodecl::ObjectInit& node)
{
TL::Symbol sym = node.get_symbol();
if (sym.get_value().is_null())
return;
walk(sym.get_value());
}
示例2: visit
void VectorizerVisitorPostprocessor::visit(const Nodecl::ObjectInit& n)
{
TL::Symbol sym = n.get_symbol();
Nodecl::NodeclBase init = sym.get_value();
if(!init.is_null())
{
walk(init);
}
}
示例3: visit
void visit(const Nodecl::Symbol& node)
{
TL::Symbol sym = node.get_symbol();
if ((_data_sharing.get_data_sharing(sym, /* check_enclosing */ false) & ~DS_IMPLICIT)
== DS_UNDEFINED)
{
// Mark this as an implicit firstprivate
_data_sharing.set_data_sharing(sym, TL::OpenMP::DataSharingAttribute( DS_FIRSTPRIVATE | DS_IMPLICIT) );
std::cerr << node.get_locus_str() << ": warning: assuming '" << sym.get_qualified_name() << "' as firstprivate" << std::endl;
}
}
示例4: visit
void SSEVectorLegalization::visit(const Nodecl::ObjectInit& node)
{
TL::Source intrin_src;
TL::Symbol sym = node.get_symbol();
fix_mask_symbol(sym);
// Vectorizing initialization
Nodecl::NodeclBase init = sym.get_value();
if (!init.is_null())
{
walk(init);
}
}
示例5: append_module_to_scope
void Fortran::append_module_to_scope(TL::Symbol module,
TL::Scope scope)
{
ERROR_CONDITION(!module.is_valid() || !module.is_fortran_module(), "Symbol must be a Fortran module", 0);
scope_entry_t* used_modules_info
= ::get_or_create_used_modules_symbol_info(scope.get_decl_context());
P_LIST_ADD_ONCE(used_modules_info->entity_specs.related_symbols,
used_modules_info->entity_specs.num_related_symbols,
module.get_internal_symbol());
if (!module.get_internal_symbol()->entity_specs.is_builtin)
fortran_load_module(module.get_internal_symbol()->symbol_name, /* intrinsic */ 0, make_locus("", 0, 0));
}
示例6: visit
void NeonVectorBackend::visit(const Nodecl::ObjectInit& n)
{
TL::Source intrin_src;
if(n.has_symbol())
{
TL::Symbol sym = n.get_symbol();
// Vectorizing initialization
Nodecl::NodeclBase init = sym.get_value();
if(!init.is_null())
{
walk(init);
}
}
}
示例7: build_empty_body_for_function
void build_empty_body_for_function(
TL::Symbol function_symbol,
Nodecl::NodeclBase &function_code,
Nodecl::NodeclBase &empty_stmt)
{
empty_stmt = Nodecl::EmptyStatement::make(make_locus("", 0, 0));
Nodecl::List stmt_list = Nodecl::List::make(empty_stmt);
if (IS_C_LANGUAGE || IS_CXX_LANGUAGE)
{
Nodecl::CompoundStatement compound_statement =
Nodecl::CompoundStatement::make(stmt_list,
/* destructors */ Nodecl::NodeclBase::null(),
make_locus("", 0, 0));
stmt_list = Nodecl::List::make(compound_statement);
}
Nodecl::NodeclBase context = Nodecl::Context::make(
stmt_list,
function_symbol.get_related_scope(), make_locus("", 0, 0));
function_symbol.get_internal_symbol()->defined = 1;
if (function_symbol.is_dependent_function())
{
function_code = Nodecl::TemplateFunctionCode::make(context,
// Initializers
Nodecl::NodeclBase::null(),
function_symbol,
make_locus("", 0, 0));
}
else
{
function_code = Nodecl::FunctionCode::make(context,
// Initializers
Nodecl::NodeclBase::null(),
function_symbol,
make_locus("", 0, 0));
}
function_symbol.get_internal_symbol()->entity_specs.function_code = function_code.get_internal_nodecl();
}
示例8: new_function_symbol
TL::Symbol new_function_symbol(TL::Symbol function)
{
TL::ObjectList<TL::Type> parameter_types = function.get_type().parameters();
TL::ObjectList<std::string> parameter_names;
TL::ObjectList<TL::Symbol> function_related_symbols = function.get_related_symbols();
for (TL::ObjectList<TL::Symbol>::iterator it = function_related_symbols.begin();
it != function_related_symbols.end();
it++)
{
parameter_names.append(it->get_name());
}
TL::Symbol new_function = SymbolUtils::new_function_symbol(
function,
function.get_name(),
function.get_type().returns(),
parameter_names,
parameter_types);
return new_function;
}
示例9: copy_stuff_to_device_file
void DeviceFPGA::copy_stuff_to_device_file(
const TL::ObjectList<Nodecl::NodeclBase>& stuff_to_be_copied)
{
for (TL::ObjectList<Nodecl::NodeclBase>::const_iterator it = stuff_to_be_copied.begin();
it != stuff_to_be_copied.end();
++it)
{
if (it->is<Nodecl::FunctionCode>()
|| it->is<Nodecl::TemplateFunctionCode>())
{
TL::Symbol function = it->get_symbol();
TL::Symbol new_function = SymbolUtils::new_function_symbol(function, function.get_name() + "_hls");
Nodecl::Utils::SimpleSymbolMap symbol_map;
symbol_map.add_map(function, new_function);
_fpga_file_code.append(Nodecl::Utils::deep_copy(*it, *it, symbol_map));
}
else
{
_fpga_file_code.append(Nodecl::Utils::deep_copy(*it, *it));
}
}
}
示例10: visit
void SimdVisitor::visit(const Nodecl::OpenMP::SimdFunction& simd_node)
{
Nodecl::FunctionCode function_code = simd_node.get_statement()
.as<Nodecl::FunctionCode>();
// Remove SimdFunction node
simd_node.replace(function_code);
TL::Symbol sym = function_code.get_symbol();
Nodecl::FunctionCode vectorized_func_code =
Nodecl::Utils::deep_copy(function_code, function_code).as<Nodecl::FunctionCode>();
// Vectorize function
_vectorizer.vectorize(vectorized_func_code,
_device_name, _vector_length, NULL);
// Set new name
std::stringstream vectorized_func_name;
vectorized_func_name <<"__"
<< sym.get_name()
<< "_"
<< _device_name
<< "_"
<< _vector_length;
vectorized_func_code.get_symbol().set_name(vectorized_func_name.str());
// Add SIMD version to vector function versioning
_vectorizer.add_vector_function_version(sym.get_name(), vectorized_func_code,
_device_name, _vector_length, NULL, TL::Vectorization::SIMD_FUNC_PRIORITY);
// Append vectorized function code to scalar function
simd_node.append_sibling(vectorized_func_code);
}
示例11: vectorize_reduction
void VectorizerVectorReduction::vectorize_reduction(const TL::Symbol& scalar_symbol,
TL::Symbol& vector_symbol,
const Nodecl::NodeclBase& reduction_initializer,
const std::string& reduction_name,
const TL::Type& reduction_type,
Nodecl::List& pre_nodecls,
Nodecl::List& post_nodecls)
{
// Step1: ADD REDUCTION SYMBOLS
vector_symbol.set_value(Nodecl::VectorPromotion::make(
reduction_initializer.shallow_copy(),
vector_symbol.get_type()));
// Add new ObjectInit with the initialization
Nodecl::ObjectInit reduction_object_init =
Nodecl::ObjectInit::make(vector_symbol);
pre_nodecls.append(reduction_object_init);
// Step2: ADD VECTOR REDUCTION INSTRUCTIONS
if(reduction_name.compare("+") == 0)
{
Nodecl::ExpressionStatement post_reduction_stmt =
Nodecl::ExpressionStatement::make(
Nodecl::VectorReductionAdd::make(
scalar_symbol.make_nodecl(true),
vector_symbol.make_nodecl(true),
scalar_symbol.get_type()));
post_nodecls.append(post_reduction_stmt);
}
else if (reduction_name.compare("-") == 0)
{
Nodecl::ExpressionStatement post_reduction_stmt =
Nodecl::ExpressionStatement::make(
Nodecl::VectorReductionMinus::make(
scalar_symbol.make_nodecl(true),
vector_symbol.make_nodecl(true),
scalar_symbol.get_type()));
post_nodecls.append(post_reduction_stmt);
}
}
示例12: loop_spawn_worksharing
void LoweringVisitor::loop_spawn_worksharing(OutlineInfo& outline_info,
Nodecl::NodeclBase construct,
Nodecl::List distribute_environment,
Nodecl::RangeLoopControl& range,
const std::string& outline_name,
TL::Symbol structure_symbol,
TL::Symbol slicer_descriptor,
Nodecl::NodeclBase task_label)
{
Symbol enclosing_function = Nodecl::Utils::get_enclosing_function(construct);
Nodecl::OpenMP::Schedule schedule = distribute_environment.find_first<Nodecl::OpenMP::Schedule>();
ERROR_CONDITION(schedule.is_null(), "Schedule tree is missing", 0);
Nodecl::NodeclBase lower = range.get_lower();
Nodecl::NodeclBase upper = range.get_upper();
Nodecl::NodeclBase step = range.get_step();
Source struct_size, dynamic_size, struct_arg_type_name;
struct_arg_type_name
<< ((structure_symbol.get_type().is_template_specialized_type()
&& structure_symbol.get_type().is_dependent()) ? "typename " : "")
<< structure_symbol.get_qualified_name(enclosing_function.get_scope())
;
struct_size << "sizeof( " << struct_arg_type_name << " )" << dynamic_size;
Source immediate_decl;
allocate_immediate_structure(
structure_symbol.get_user_defined_type(),
outline_info,
struct_arg_type_name,
struct_size,
// out
immediate_decl,
dynamic_size);
Source call_outline_function;
Source schedule_setup;
schedule_setup
<< "int nanos_chunk;"
;
if (schedule.get_text() == "runtime")
{
schedule_setup
<< "nanos_omp_sched_t nanos_runtime_sched;"
<< "nanos_err = nanos_omp_get_schedule(&nanos_runtime_sched, &nanos_chunk);"
<< "if (nanos_err != NANOS_OK)"
<< "nanos_handle_error(nanos_err);"
<< "nanos_ws_t current_ws_policy = nanos_omp_find_worksharing(nanos_runtime_sched);"
;
}
else
{
Source schedule_name;
if (Nanos::Version::interface_is_at_least("openmp", 8))
{
schedule_name << "nanos_omp_sched_" << schedule.get_text();
}
else
{
// We used nanos_omp_sched in versions prior to 8
schedule_name << "omp_sched_" << schedule.get_text();
}
schedule_setup
<< "nanos_ws_t current_ws_policy = nanos_omp_find_worksharing(" << schedule_name << ");"
<< "if (current_ws_policy == 0)"
<< "nanos_handle_error(NANOS_UNIMPLEMENTED);"
<< "nanos_chunk = " << as_expression(schedule.get_chunk()) << ";"
;
}
Source worksharing_creation;
if (IS_CXX_LANGUAGE)
{
worksharing_creation
<< as_statement(Nodecl::CxxDef::make(Nodecl::NodeclBase::null(), slicer_descriptor));
}
worksharing_creation
<< "nanos_err = nanos_worksharing_create("
<< "&" << as_symbol(slicer_descriptor) << ","
<< "current_ws_policy,"
<< "(void**)&nanos_setup_info_loop,"
<< "&single_guard);"
<< "if (nanos_err != NANOS_OK)"
<< "nanos_handle_error(nanos_err);"
;
Nodecl::NodeclBase fill_outline_arguments_tree, fill_immediate_arguments_tree;
TL::Source pm_specific_code;
if (!_lowering->in_ompss_mode())
{
// OpenMP
//.........这里部分代码省略.........
示例13: do_blocking
TL::Source LoopBlocking::do_blocking()
{
Source result, block_loops;
result
<< block_loops
;
ObjectList<ForStatement> nest_loops = _for_nest_info.get_nest_list();
_nesting = std::min(_nest_factors.size(), nest_loops.size());
TL::Source *current_innermost_part = &block_loops;
// For every loop declare its block loop variable and the inter-block loop
ObjectList<TL::Expression>::iterator current_factor = _nest_factors.begin();
ObjectList<TL::ForStatement>::iterator current_for = nest_loops.begin();
for (int current_nest = 0;
current_nest < _nesting;
current_nest++, current_for++, current_factor++)
{
TL::IdExpression induction_var = current_for->get_induction_variable();
TL::Symbol sym = induction_var.get_symbol();
TL::Type type = sym.get_type();
std::string var = "_blk_" + sym.get_name();
TL::Source *new_innermost_part = new TL::Source();
(*current_innermost_part)
<< "for(" << type.get_declaration(sym.get_scope(), var) << " = " << current_for->get_lower_bound() << ";"
<< var << current_for->get_bound_operator() << current_for->get_upper_bound() << ";"
<< var << "+= ( " << current_for->get_step() << ") * " << current_factor->prettyprint() << ")"
<< (*new_innermost_part)
;
current_innermost_part = new_innermost_part;
}
// Now for every loop, declare the intra-loop
current_factor = _nest_factors.begin();
current_for = nest_loops.begin();
for (int current_nest = 0;
current_nest < _nesting;
current_nest++, current_for++, current_factor++)
{
TL::IdExpression induction_var = current_for->get_induction_variable();
TL::Symbol sym = induction_var.get_symbol();
TL::Type type = sym.get_type();
std::string var = induction_var.prettyprint();
std::string init_var = var;
// If the loop declares the iterator in the for statement
// declare it again
AST_t loop_init = current_for->get_iterating_init();
if (Declaration::predicate(loop_init))
{
// Fix init_var to be a declaration
init_var = type.get_declaration(sym.get_scope(), var);
}
std::string blk_var = "_blk_" + sym.get_name();
TL::Source min_code;
TL::Source *new_innermost_part = new TL::Source();
(*current_innermost_part)
<< "for(" << init_var << " = " << blk_var << ";"
<< var << current_for->get_bound_operator() << min_code << ";"
<< var << "+= ( " << current_for->get_step() << "))"
<< (*new_innermost_part)
;
TL::Source a, b;
min_code
<< "((" << a << ") < (" << b << ") ? (" << a << ") : (" << b << "))"
;
a << blk_var << " + (" << current_for->get_step() << ") * (" << current_factor->prettyprint() << " - 1 )";
b << current_for->get_upper_bound();
current_innermost_part = new_innermost_part;
}
// And now the innermost loop
(*current_innermost_part)
<< nest_loops[_nesting - 1].get_loop_body()
;
return result;
}
示例14: old_generate_ndrange_code
// Old version - Deprecated. Kept here for compatibility with old runtimes (Nanos++ 0.7)
void DeviceOpenCL::old_generate_ndrange_code(
const TL::Symbol& called_task,
const TL::Symbol& unpacked_function,
const TargetInformation& target_info,
const std::string filename,
const std::string kernel_name,
const TL::ObjectList<OutlineDataItem*>& data_items,
Nodecl::Utils::SimpleSymbolMap* called_fun_to_outline_data_map,
Nodecl::Utils::SimpleSymbolMap* outline_data_to_unpacked_fun_map,
// Out
TL::Source& code_ndrange)
{
// The arguments of the clauses 'ndrange' and 'shmem' must be updated because
// they are not expressed in terms of the unpacked function parameters
TL::ObjectList<Nodecl::NodeclBase> new_ndrange, new_shmem;
update_ndrange_and_shmem_expressions(
unpacked_function.get_related_scope(),
target_info,
outline_data_to_unpacked_fun_map,
new_ndrange,
new_shmem);
int num_args_ndrange = new_ndrange.size();
TL::Source code_ndrange_aux;
Nodecl::Utils::SimpleSymbolMap called_fun_to_unpacked_fun_map;
const std::map<TL::Symbol, TL::Symbol>* called_fun_to_outline_data_map_simple =
called_fun_to_outline_data_map->get_simple_symbol_map();
for (std::map<TL::Symbol, TL::Symbol>::const_iterator it = called_fun_to_outline_data_map_simple->begin();
it != called_fun_to_outline_data_map_simple->end();
it++)
{
TL::Symbol key = it->first;
TL::Symbol value = outline_data_to_unpacked_fun_map->map(it->second.get_internal_symbol());
called_fun_to_unpacked_fun_map.add_map(key, value);
}
bool dim_const = new_ndrange[0].is_constant();
char is_null_ended = 0;
bool check_dim = !(new_ndrange[num_args_ndrange - 1].is_constant()
&& const_value_is_string(new_ndrange[num_args_ndrange - 1].get_constant())
&& (strcmp(const_value_string_unpack_to_string(new_ndrange[num_args_ndrange-1].get_constant(), &is_null_ended),
"noCheckDim") == 0));
int num_dim = 0;
if (dim_const)
{
num_dim = const_value_cast_to_4(new_ndrange[0].get_constant());
ERROR_CONDITION(num_dim < 1 || num_dim > 3,
"invalid number of dimensions for 'ndrange' clause. Valid values: 1, 2 and 3." , 0);
ERROR_CONDITION((((num_dim * 3) + 1 + !check_dim) != num_args_ndrange)
&& (((num_dim * 2) + 1 + !check_dim) != num_args_ndrange),
"invalid number of arguments for 'ndrange' clause", 0);
}
std::string compiler_opts;
if (CURRENT_CONFIGURATION->opencl_build_options != NULL)
{
compiler_opts = std::string(CURRENT_CONFIGURATION->opencl_build_options);
}
//Create OCL Kernel
code_ndrange_aux << "nanos_err_t nanos_err;"
<< "void* ompss_kernel_ocl = nanos_create_current_kernel(\""
<< kernel_name << "\",\""
<< filename << "\",\""
<< compiler_opts << "\");";
//Prepare setArgs
unsigned int index_local = 0;
TL::ObjectList<TL::Symbol> parameters_called = called_task.get_function_parameters();
for (unsigned int i = 0; i < parameters_called.size(); ++i)
{
TL::Symbol unpacked_argument = called_fun_to_unpacked_fun_map.map(parameters_called[i]);
// The attribute __global is deduced: the current argument will be __global if it has any copies
bool is_global = false;
if (unpacked_argument.get_type().no_ref().is_pointer()
|| unpacked_argument.get_type().no_ref().is_array())
{
for (TL::ObjectList<OutlineDataItem*>::const_iterator it = data_items.begin();
it != data_items.end() && !is_global;
++it)
{
TL::Symbol outline_data_item_sym = (*it)->get_symbol();
// If the outline data item has not a valid symbol, skip it
if (!outline_data_item_sym.is_valid())
continue;
// If the symbol of the current outline data item is not the
// same as the unpacked_argument, skip it
if(outline_data_to_unpacked_fun_map->map(outline_data_item_sym.get_internal_symbol()) != unpacked_argument)
continue;
//.........这里部分代码省略.........
示例15: create_basic_reduction_function_fortran
TL::Symbol LoweringVisitor::create_basic_reduction_function_fortran(OpenMP::Reduction* red, Nodecl::NodeclBase construct)
{
reduction_map_t::iterator it = _basic_reduction_map_openmp.find(red);
if (it != _basic_reduction_map_openmp.end())
{
return it->second;
}
std::string fun_name;
{
std::stringstream ss;
ss << "nanos_red_" << red << "_" << simple_hash_str(construct.get_filename().c_str());
fun_name = ss.str();
}
Nodecl::NodeclBase function_body;
Source src;
src << "SUBROUTINE " << fun_name << "(omp_out, omp_in, num_scalars)\n"
<< "IMPLICIT NONE\n"
<< as_type(red->get_type()) << " :: omp_out(num_scalars)\n"
<< as_type(red->get_type()) << " :: omp_in(num_scalars)\n"
<< "INTEGER, VALUE :: num_scalars\n"
<< "INTEGER :: I\n"
<< statement_placeholder(function_body) << "\n"
<< "END SUBROUTINE " << fun_name << "\n";
;
Nodecl::NodeclBase function_code = src.parse_global(construct);
TL::Scope inside_function = ReferenceScope(function_body).get_scope();
TL::Symbol param_omp_in = inside_function.get_symbol_from_name("omp_in");
ERROR_CONDITION(!param_omp_in.is_valid(), "Symbol omp_in not found", 0);
TL::Symbol param_omp_out = inside_function.get_symbol_from_name("omp_out");
ERROR_CONDITION(!param_omp_out.is_valid(), "Symbol omp_out not found", 0);
TL::Symbol function_sym = inside_function.get_symbol_from_name(fun_name);
ERROR_CONDITION(!function_sym.is_valid(), "Symbol %s not found", fun_name.c_str());
TL::Symbol index = inside_function.get_symbol_from_name("i");
ERROR_CONDITION(!index.is_valid(), "Symbol %s not found", "i");
TL::Symbol num_scalars = inside_function.get_symbol_from_name("num_scalars");
ERROR_CONDITION(!num_scalars.is_valid(), "Symbol %s not found", "num_scalars");
Nodecl::NodeclBase num_scalars_ref = Nodecl::Symbol::make(num_scalars);
num_scalars_ref.set_type(num_scalars.get_type().no_ref().get_lvalue_reference_to());
Nodecl::Symbol nodecl_index = Nodecl::Symbol::make(index);
nodecl_index.set_type(index.get_type().get_lvalue_reference_to());
Nodecl::NodeclBase loop_header = Nodecl::RangeLoopControl::make(
nodecl_index,
const_value_to_nodecl(const_value_get_signed_int(1)),
num_scalars_ref,
Nodecl::NodeclBase::null());
Nodecl::NodeclBase expanded_combiner =
red->get_combiner().shallow_copy();
BasicReductionExpandVisitor expander_visitor(
red->get_omp_in(),
param_omp_in,
red->get_omp_out(),
param_omp_out,
index);
expander_visitor.walk(expanded_combiner);
function_body.replace(
Nodecl::ForStatement::make(loop_header,
Nodecl::List::make(
Nodecl::ExpressionStatement::make(
expanded_combiner)),
Nodecl::NodeclBase::null()));
_basic_reduction_map_openmp[red] = function_sym;
if (IS_FORTRAN_LANGUAGE)
{
Nodecl::Utils::Fortran::append_used_modules(construct.retrieve_context(),
function_sym.get_related_scope());
}
Nodecl::Utils::append_to_enclosing_top_level_location(construct, function_code);
return function_sym;
}