本文整理汇总了C++中tl::Symbol::get_related_scope方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::get_related_scope方法的具体用法?C++ Symbol::get_related_scope怎么用?C++ Symbol::get_related_scope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tl::Symbol
的用法示例。
在下文中一共展示了Symbol::get_related_scope方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: generate_ndrange_code
void DeviceOpenCL::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)
{
if (!Nanos::Version::interface_is_at_least("opencl", 1003))
{
return old_generate_ndrange_code(
called_task,
unpacked_function,
target_info,
filename,
kernel_name,
data_items,
called_fun_to_outline_data_map,
outline_data_to_unpacked_fun_map,
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);
// Prepare mapping for the call to the kernel
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);
}
// The syntax of ndrange is
//
// ndrange(N, global-list [, local-list])
//
// Each X-list has as much as N elements
Nodecl::NodeclBase num_dims_expr = new_ndrange[0];
// N must be a constant
if (!num_dims_expr.is_constant())
{
fatal_printf_at(num_dims_expr.get_locus(),
"first argument in 'ndrange' clause must be constant\n");
}
// At this point we can remove "N" from the new_ndrange list (pop_front)
new_ndrange.erase(new_ndrange.begin());
// N must be between 1 and 3
int num_dims = const_value_cast_to_signed_int(num_dims_expr.get_constant());
if (num_dims < 1 || num_dims > 3)
{
fatal_printf_at(num_dims_expr.get_locus(),
"number of dimensions for 'ndrange' clause is not 1, 2 or 3\n");
}
// Checking the number of remaining expressions in the new_ndrange list
if (num_dims != (int)new_ndrange.size()
&& (num_dims * 2) != (int)new_ndrange.size())
{
fatal_printf_at(num_dims_expr.get_locus(),
"a 'ndrange(%d, argument-list)' clause requires %d or %d arguments in argument-list\n",
num_dims,
num_dims ,
num_dims * 2);
}
std::string compiler_options;
if (CURRENT_CONFIGURATION->opencl_build_options != NULL)
{
compiler_options = std::string(CURRENT_CONFIGURATION->opencl_build_options);
}
// Create OpenCL kernel
code_ndrange_aux << "nanos_err_t nanos_err;"
<< "void* ompss_kernel_ocl = nanos_create_current_kernel(\""
<< kernel_name << "\",\""
<< filename << "\","
<< "\"" << compiler_options << "\");";
//.........这里部分代码省略.........
示例3: 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;
//.........这里部分代码省略.........