void ESceneGroupTool::UngroupObjects(bool bUndo) { ObjectList lst = m_Objects; int sel_cnt = 0; if (!lst.empty()) { bool bModif = false; for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) { if ((*it)->Selected()) { sel_cnt++; CGroupObject* obj = dynamic_cast<CGroupObject*>(*it); VERIFY(obj); if (obj->CanUngroup(true)) { obj->UngroupObjects (); Scene->RemoveObject (obj,false,true); xr_delete (obj); bModif = true; }else ELog.DlgMsg (mtError,"Can't ungroup object: '%s'.",obj->Name); } } if (bUndo&&bModif) Scene->UndoSave(); } if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected."); }
virtual ReadResult readObject(std::istream& fin, const Options* options) const { loadWrappers(); fin.imbue(std::locale::classic()); Input fr; fr.attach(&fin); fr.setOptions(options); typedef std::vector<osg::Object*> ObjectList; ObjectList objectList; // load all nodes in file, placing them in a group. while(!fr.eof()) { Object *object = fr.readObject(); if (object) objectList.push_back(object); else fr.advanceOverCurrentFieldOrBlock(); } if (objectList.empty()) { return ReadResult("No data loaded"); } else if (objectList.size()==1) { return objectList.front(); } else { return objectList.front(); } }
void __fastcall TfraLeftBar::UpdateSnapList() { lbSnapList->Items->Clear(); ObjectList* lst = Scene->GetSnapList(true); if (lst&&!lst->empty()){ int idx=0; ObjectIt _F=lst->begin(); for (;_F!=lst->end(); _F++,idx++){ AnsiString s; s.sprintf("%d: %s",idx,(*_F)->Name); lbSnapList->Items->Add(s); } } Repaint(); }
ObjectList<TaskPart> TaskAggregation::get_task_parts(Statement stmt) { ObjectList<TaskPart> result; ObjectList<Statement> prologue; get_task_parts_aux(result, prologue, stmt); if (!prologue.empty()) { TaskPart last_part(prologue); result.append(last_part); } return result; }
void ESceneGroupTools::CloseGroups(bool bUndo) { ObjectList lst = m_Objects; int sel_cnt = 0; if (!lst.empty()) { for (ObjectIt it=lst.begin(); it!=lst.end(); it++) { if ((*it)->Selected()) { sel_cnt++; ((CGroupObject*)(*it))->CloseGroup(); } } if (bUndo) Scene->UndoSave(); } if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected."); }
ObjectPtr Game::findObjectByRect(ObjectList &matched_objs, int left, int top, int right, int bottom, unsigned int flags) { ObjectList &objs = this->getObjectList(); matched_objs.clear(); for(ObjectList::const_iterator it = objs.begin(); it != objs.end(); ++it) { const ObjectPtr &obj = *it; if(obj->insideRect(left, top, right, bottom)) { //fprintf(stderr, "adding object %s\n", obj->getObjectName()); matched_objs.addObject(obj); } } if(matched_objs.empty()) return ObjectPtr(); else return *matched_objs.begin(); }
void ESceneGroupTools::ReloadRefsSelectedObject() { ObjectList lst = m_Objects; int sel_cnt = 0; if (!lst.empty()){ bool bModif = false; for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ if ((*it)->Selected()){ sel_cnt++; CGroupObject* obj = dynamic_cast<CGroupObject*>(*it); VERIFY(obj); if (obj->UpdateReference()){ bModif = true; }else{ ELog.Msg (mtError,"Can't reload group: '%s'.",obj->Name); } } } if (bModif) Scene->UndoSave(); } if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected."); }
void ESceneGroupTool::ReloadRefsSelectedObject() { ObjectList lst = m_Objects; int sel_cnt = 0; if (!lst.empty()) { string_path temp_file_name_sector,temp_file_name_portal; GetTempFileName ( FS.get_path(_temp_)->m_Path, "tmp_sector", 0, temp_file_name_sector ); Scene->SaveToolLTX (OBJCLASS_SECTOR, temp_file_name_sector); GetTempFileName ( FS.get_path(_temp_)->m_Path, "tmp_portal", 0, temp_file_name_portal ); Scene->SaveToolLTX (OBJCLASS_PORTAL, temp_file_name_portal); bool bModif = false; for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) { if ((*it)->Selected()) { sel_cnt++; CGroupObject* obj = dynamic_cast<CGroupObject*>(*it); VERIFY (obj); if (obj->UpdateReference(true)) { bModif = true; }else { ELog.Msg (mtError,"Can't reload group: '%s'.",obj->Name); } } } if(bModif) Scene->UndoSave (); Scene->LoadToolLTX (OBJCLASS_SECTOR, temp_file_name_sector); Scene->LoadToolLTX (OBJCLASS_PORTAL, temp_file_name_portal); } if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected."); }
void ESceneGroupTools::OpenGroups(bool bUndo) { ObjectList lst = m_Objects; int sel_cnt = 0; if (!lst.empty()){ bool bModif = false; for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ if ((*it)->Selected()){ sel_cnt++; CGroupObject* obj = dynamic_cast<CGroupObject*>(*it); VERIFY(obj); if (obj->CanUngroup(true)){ obj->OpenGroup (); bModif = true; }else{ ELog.DlgMsg (mtError,"Can't open group: '%s'.",obj->Name); } } } if (bUndo&&bModif) Scene->UndoSave(); } if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected."); }
void OMPTransform::for_postorder(PragmaCustomConstruct ctr) { ForStatement for_statement(ctr.get_statement().get_ast(), ctr.get_scope_link()); Statement for_body = for_statement.get_loop_body(); OpenMP::DataSharingEnvironment& data_sharing = openmp_info->get_data_sharing(ctr.get_ast()); ObjectList<OpenMP::DependencyItem> dependences; data_sharing.get_all_dependences(dependences); Source loop_info_field; loop_info_field << "nanos_loop_info_t loop_info;" ; DataEnvironInfo data_environ_info; compute_data_environment( data_sharing, ctr, data_environ_info, _converted_vlas); std::string struct_arg_type_name; define_arguments_structure(ctr, struct_arg_type_name, data_environ_info, ObjectList<OpenMP::DependencyItem>(), loop_info_field); FunctionDefinition funct_def = ctr.get_enclosing_function(); Symbol function_symbol = funct_def.get_function_symbol(); int outline_num = TL::CounterManager::get_counter(NANOX_OUTLINE_COUNTER); TL::CounterManager::get_counter(NANOX_OUTLINE_COUNTER)++; std::stringstream ss; ss << "_ol_" << function_symbol.get_name() << "_" << outline_num; std::string outline_name = ss.str(); Source loop_distr_setup; loop_distr_setup << "int _nth_lower = _args->loop_info.lower;" << "int _nth_upper = _args->loop_info.upper;" << "int _nth_step = _args->loop_info.step;" << "int _nth_step_sign = 1;" << "if (_nth_step < 0)" << "_nth_step_sign = -1;" ; Source final_barrier; if ( (!ctr.get_clause("nowait").is_defined() && !ctr.get_clause("input").is_defined() && !ctr.get_clause("output").is_defined() && !ctr.get_clause("inout").is_defined() ) || !data_environ_info.get_reduction_symbols().empty()) { final_barrier << get_barrier_code(ctr.get_ast()); } Source induction_var_name = for_statement.get_induction_variable().prettyprint(); Source device_descriptor, device_description, device_description_line, num_devices, ancillary_device_description; device_descriptor << outline_name << "_devices"; device_description << ancillary_device_description << "nanos_device_t " << device_descriptor << "[] =" << "{" << device_description_line << "};" ; OutlineFlags outline_flags; DeviceHandler &device_handler = DeviceHandler::get_device_handler(); ObjectList<std::string> current_targets; data_sharing.get_all_devices(current_targets); for (ObjectList<std::string>::iterator it = current_targets.begin(); it != current_targets.end(); it++) { DeviceProvider* device_provider = device_handler.get_device(*it); if (device_provider == NULL) { internal_error("invalid device '%s' at '%s'\n", it->c_str(), ctr.get_ast().get_locus().c_str()); } Source initial_setup, replaced_body; device_provider->do_replacements(data_environ_info, for_statement.get_loop_body().get_ast(), ctr.get_scope_link(), initial_setup, replaced_body); Source outline_body; outline_body << loop_distr_setup << "for (" << induction_var_name << "= _nth_lower;" << "(_nth_step_sign * " << induction_var_name << ")" << "<= (_nth_step_sign * _nth_upper);" << induction_var_name << "+= _nth_step" << ")" << "{" << replaced_body << "}" ; device_provider->create_outline(outline_name, struct_arg_type_name, data_environ_info, outline_flags, ctr.get_statement().get_ast(), ctr.get_scope_link(), initial_setup, outline_body); device_provider->get_device_descriptor(outline_name, data_environ_info, outline_flags, ctr.get_statement().get_ast(), ctr.get_scope_link(), ancillary_device_description, device_description_line); } num_devices << current_targets.size(); Source fill_outline_arguments, fill_dependences_outline; Source dependency_array, num_dependences; fill_data_args("ol_args", data_environ_info, dependences, /* is_pointer */ true, fill_outline_arguments); bool env_is_runtime_sized = data_environ_info.environment_is_runtime_sized(); // Fill dependences, if any if (!dependences.empty()) { num_dependences << dependences.size(); Source dependency_defs_outline; fill_dependences_outline << "nanos_dependence_t _dependences[" << num_dependences << "] = {" << dependency_defs_outline << "};" ; dependency_array << "_dependences"; int num_dep = 0; for (ObjectList<OpenMP::DependencyItem>::iterator it = dependences.begin(); it != dependences.end(); it++) { Source dependency_flags; dependency_flags << "{"; OpenMP::DependencyDirection attr = it->get_kind(); if ((attr & OpenMP::DEP_DIR_INPUT) == OpenMP::DEP_DIR_INPUT) { dependency_flags << "1,"; } else { dependency_flags << "0,"; } if ((attr & OpenMP::DEP_DIR_OUTPUT) == OpenMP::DEP_DIR_OUTPUT) { dependency_flags << "1,"; } else { dependency_flags << "0,"; } Source dependency_field_name; DataReference data_ref = it->get_dependency_expression(); Symbol sym = data_ref.get_base_symbol(); DataEnvironItem data_env_item = data_environ_info.get_data_of_symbol(sym); if (data_env_item.get_symbol().is_valid()) { dependency_field_name << data_env_item.get_field_name(); } else { internal_error("symbol without data environment info %s", it->get_dependency_expression().prettyprint().c_str()); } // Can rename in this case dependency_flags << "1" ; dependency_flags << "}" ; DataReference dependency_expression = it->get_dependency_expression(); Source dep_size; dep_size << dependency_expression.get_sizeof(); Source dependency_offset; dependency_defs_outline << "{" << "(void**)&ol_args->" << dependency_field_name << "," << dependency_offset << "," << dependency_flags << "," << dep_size << "}" ; Source dep_expr_addr = data_ref.get_address(); dependency_offset << "((char*)(" << dep_expr_addr << ") - " << "(char*)ol_args->" << dependency_field_name << ")" ; if ((it + 1) != dependences.end()) { dependency_defs_outline << ","; } num_dep++; } } else { dependency_array << "0"; num_dependences << "0"; } Source tiedness, priority; PragmaCustomClause untied_clause = ctr.get_clause("untied"); if (untied_clause.is_defined()) { tiedness << "props.tied = 0;"; } else { tiedness << "props.tied = 1;"; } PragmaCustomClause priority_clause = ctr.get_clause("__priority"); if (priority_clause.is_defined()) { priority << "props.tied = " << priority_clause.get_arguments()[0] << ";" ; } Source struct_runtime_size, struct_size; if (env_is_runtime_sized) { struct_runtime_size << "int struct_runtime_size = " << "sizeof(" << struct_arg_type_name << ") + " << "(" << data_environ_info.sizeof_variable_part(ctr.get_scope()) << ")" << ";" ; struct_size << "struct_runtime_size" ; } else { struct_size << "sizeof(" << struct_arg_type_name << ")" ; } bool some_device_needs_copies = false; Source num_copies; ObjectList<OpenMP::CopyItem> copy_items = data_environ_info.get_copy_items(); Source copy_data, copy_decl, copy_setup; if (copy_items.empty() || !some_device_needs_copies) { num_copies << "0"; copy_data << "(nanos_copy_data_t**)0"; } else { num_copies << copy_items.size(); copy_decl << "nanos_copy_data_t* copy_data = (nanos_copy_data_t*)0;"; Source copy_items_src; copy_setup << copy_items_src; copy_data << "©_data"; int i = 0; for (ObjectList<OpenMP::CopyItem>::iterator it = copy_items.begin(); it != copy_items.end(); it++) { Source copy_direction_in, copy_direction_out; if (it->get_kind() == OpenMP::COPY_DIR_IN) { copy_direction_in << 1; copy_direction_out << 0; } else if (it->get_kind() == OpenMP::COPY_DIR_OUT) { copy_direction_in << 0; copy_direction_out << 1; } else if (it->get_kind() == OpenMP::COPY_DIR_INOUT) { copy_direction_in << 1; copy_direction_out << 1; } DataReference data_ref = it->get_copy_expression(); OpenMP::DataSharingAttribute data_attr = data_sharing.get_data_sharing(data_ref.get_base_symbol()); ERROR_CONDITION(data_attr == OpenMP::DS_UNDEFINED, "Invalid data sharing for copy", 0); bool has_shared_data_sharing = (data_attr & OpenMP::DS_SHARED) == OpenMP::DS_SHARED; Source copy_sharing; if (has_shared_data_sharing) { copy_sharing << "NANOS_SHARED"; } else { copy_sharing << "NANOS_PRIVATE"; } struct { Source *source; const char* array; const char* struct_name; } fill_copy_data_info[] = { { ©_items_src, "copy_data", "ol_args->" }, { NULL, "" }, }; for (int j = 0; fill_copy_data_info[j].source != NULL; j++) { Source expression_size, expression_address; const char* array_name = fill_copy_data_info[j].array; (*(fill_copy_data_info[j].source)) << array_name << "[" << i << "].address = (uintptr_t)(" << expression_address << ");" << array_name << "[" << i << "].sharing = " << copy_sharing << ";" << array_name << "[" << i << "].flags.input = " << copy_direction_in << ";" << array_name << "[" << i << "].flags.output = " << copy_direction_out << ";" << array_name << "[" << i << "].size = " << expression_size << ";" ; DataReference copy_expr = it->get_copy_expression(); if (has_shared_data_sharing) { expression_address << copy_expr.get_address(); } else { DataEnvironItem data_env_item = data_environ_info.get_data_of_symbol(copy_expr.get_base_symbol()); // We have to use the value of the argument structure if it // is private expression_address << "&(" << fill_copy_data_info[j].struct_name << data_env_item.get_field_name() << ")" ; } expression_size << copy_expr.get_sizeof(); } i++; } } Source current_slicer; Source chunk_value; chunk_value = Source("0"); current_slicer = Source("static_for"); PragmaCustomClause schedule_clause = ctr.get_clause("schedule"); if (schedule_clause.is_defined()) { ObjectList<std::string> args = schedule_clause.get_arguments(ExpressionTokenizerTrim()); current_slicer = args[0] + "_for"; if (args.size() > 1) { chunk_value = Source(args[1]); } } // FIXME - Move this to a tl-workshare.cpp Source spawn_source; // FIXME - This will be meaningful with 'copy_in' and 'copy_out' Source num_copies1, copy_data1; num_copies1 << "0"; copy_data1 << "(nanos_copy_data_t**)0"; Source creation; if ( current_targets.contains( "cuda" ) ) { creation << "props.mandatory_creation = 1;" ; } ObjectList<OpenMP::ReductionSymbol> reduction_symbols = data_environ_info.get_reduction_symbols(); Source reduction_join_arr_decls; if (!reduction_symbols.empty()) reduction_join_arr_decls << "int _nth_team = omp_get_num_threads();" ; if (!reduction_symbols.empty()) reduction_join_arr_decls << "int rs_i;" ; for(ObjectList<OpenMP::ReductionSymbol>::iterator it = reduction_symbols.begin(); it != reduction_symbols.end(); it++) { Symbol rs = it->get_symbol(); OpenMP::UDRInfoItem2 udr2 = it->get_udr_2(); Source auxiliar_initializer; if (rs.get_type().is_class()) { // When the symbol has class type, we must build an auxiliary variable initialized to the symbol's identity // in order to initialize the reduction's vector auxiliar_initializer << "aux_" << rs.get_name(); Source identity; reduction_join_arr_decls << rs.get_type().get_declaration(rs.get_scope(), "") << " " << auxiliar_initializer << identity << ";" ; if (udr2.has_identity()) { identity << udr2.get_identity().prettyprint() << ";" ; } } else { auxiliar_initializer << udr2.get_identity().prettyprint(); } reduction_join_arr_decls << rs.get_type().get_declaration(rs.get_scope(), "") << " rdv_" << rs.get_name() << "[_nth_team];" << "for(rs_i=0; rs_i<_nth_team; rs_i++)" << "{" ; CXX_LANGUAGE() { if (udr2.has_identity()) { if (udr2.get_need_equal_initializer()) { reduction_join_arr_decls << "rdv_" << rs.get_name() << "[rs_i] = " << auxiliar_initializer << ";" ; } else { if (udr2.get_is_constructor()) { reduction_join_arr_decls << "rdv_" << rs.get_name() << "[rs_i] " << auxiliar_initializer << ";" ; } else if (!rs.get_type().is_enum()) { reduction_join_arr_decls << "rdv_" << rs.get_name() << "[rs_i] (" << auxiliar_initializer << ");" ; } } } } C_LANGUAGE() { reduction_join_arr_decls << "rdv_" << rs.get_name() << "[rs_i] = " << auxiliar_initializer << ";" ; } reduction_join_arr_decls << "}"; } Source omp_reduction_join, omp_reduction_argument; // Get reduction code for (ObjectList<std::string>::iterator it = current_targets.begin(); it != current_targets.end(); it++) { DeviceProvider* device_provider = device_handler.get_device(*it); if (device_provider->get_name()=="smp") { omp_reduction_join << device_provider->get_reduction_code(reduction_symbols, ctr.get_scope_link()) ; } } // Fill outline variables for (ObjectList<OpenMP::ReductionSymbol>::iterator it = reduction_symbols.begin(); it != reduction_symbols.end(); it++) { omp_reduction_argument << "ol_args->rdv_" << it->get_symbol().get_name() << " = rdv_" << it->get_symbol().get_name() << ";"; } Source alignment, slicer_alignment; if (Nanos::Version::interface_is_at_least("master", 5004)) { alignment << "__alignof__(" << struct_arg_type_name << ")," ; slicer_alignment << "__alignof__(nanos_slicer_data_for_t)," ; } Source create_sliced_wd, loop_information, decl_slicer_data_if_needed; if (Nanos::Version::interface_is_at_least("master", 5008)) { create_sliced_wd <<"nanos_create_sliced_wd(&wd, " << /* num_devices */ "1, " << device_descriptor << ", " << "sizeof(" << struct_arg_type_name << ")," << alignment << "(void**)&ol_args," << "nanos_current_wd()," << current_slicer << "," << "&props," << num_copies1 << "," << copy_data1 << ");" ; loop_information << "ol_args->loop_info.lower = " << for_statement.get_lower_bound() << ";" << "ol_args->loop_info.upper = " << for_statement.get_upper_bound() << ";" << "ol_args->loop_info.step = " << for_statement.get_step() << ";" << "ol_args->loop_info.chunk = " << chunk_value << ";" ; } else { create_sliced_wd << "nanos_create_sliced_wd(&wd, " << /* num_devices */ "1, " << device_descriptor << ", " << "sizeof(" << struct_arg_type_name << ")," << alignment << "(void**)&ol_args," << "nanos_current_wd()," << current_slicer << "," << "sizeof(nanos_slicer_data_for_t)," << slicer_alignment << "(nanos_slicer_t*) &slicer_data_for," << "&props," << num_copies1 << "," << copy_data1 << ");" ; decl_slicer_data_if_needed << "nanos_slicer_data_for_t* slicer_data_for = (nanos_slicer_data_for_t*)0;" ; loop_information << "slicer_data_for->_lower = " << for_statement.get_lower_bound() << ";" << "slicer_data_for->_upper = " << for_statement.get_upper_bound() << ";" << "slicer_data_for->_step = " << for_statement.get_step() << ";" << "slicer_data_for->_chunk = " << chunk_value << ";" ; } if(!_no_nanox_calls) { spawn_source << "{" << get_single_guard("single_guard") << "if (err != NANOS_OK) nanos_handle_error(err);" << reduction_join_arr_decls << "if (single_guard)" << "{" << struct_arg_type_name << "* ol_args = (" << struct_arg_type_name << "*)0;" << struct_runtime_size << "nanos_wd_t wd = (nanos_wd_t)0;" << "nanos_wd_props_t props;" << "__builtin_memset(&props, 0, sizeof(props));" << creation << "props.mandatory_creation = 1;" << priority << tiedness << copy_decl << "static nanos_slicer_t " << current_slicer << " = 0;" << device_description << "if (!" << current_slicer << ") " << current_slicer << " = nanos_find_slicer(\"" << current_slicer << "\");" << decl_slicer_data_if_needed << "err = " << create_sliced_wd << "if (err != NANOS_OK) nanos_handle_error(err);" << fill_outline_arguments << omp_reduction_argument << fill_dependences_outline << copy_setup << loop_information << "err = nanos_submit(wd, " << num_dependences << ", (nanos_dependence_t*)" << dependency_array << ", (nanos_team_t)0);" << "if (err != NANOS_OK) nanos_handle_error (err);" << "}" << final_barrier << omp_reduction_join << "}" ; } else { if(current_targets.contains("smp")) { std::stringstream smp_device_call; smp_device_call << "_smp_" << outline_name << "(ol_args);"; // The code generated must not contain calls to runtime. The execution will be serial spawn_source << "{" << struct_arg_type_name << "* ol_args = (" << struct_arg_type_name << "*)0;" << fill_outline_arguments << omp_reduction_argument << loop_information << smp_device_call.str() << "}" ; } else { running_error("%s: error: the code generation without calls to runtime only works in smp devices\n", ctr.get_ast().get_locus().c_str()); } } AST_t spawn_tree = spawn_source.parse_statement(ctr.get_ast(), ctr.get_scope_link()); ctr.get_ast().replace(spawn_tree); }
Symbol Overload::solve( ObjectList<Symbol> candidate_functions, Type implicit_argument_type, ObjectList<Type> argument_types, const std::string filename, int line, bool &valid, ObjectList<Symbol>& viable_functions, ObjectList<Symbol>& argument_conversor) { valid = false; // Try hard to not to do useless work if (candidate_functions.empty()) { return Symbol(NULL); } scope_entry_list_t* first_candidate_list = NULL; // Build the candidates list for (ObjectList<Symbol>::iterator it = candidate_functions.begin(); it != candidate_functions.end(); it++) { Symbol sym(*it); first_candidate_list = entry_list_add(first_candidate_list, sym.get_internal_symbol()); } // Build the type array unsigned int i = argument_types.size(); type_t** argument_types_array = new type_t*[argument_types.size() + 1]; argument_types_array[0] = implicit_argument_type.get_internal_type(); for (i = 0; i < argument_types.size(); i++) { argument_types_array[i+1] = argument_types[i].get_internal_type(); } // Now we need a decl_context_t but we were not given any explicitly, // use the one of the first candidate decl_context_t decl_context = candidate_functions[0].get_scope().get_decl_context(); // Unfold and mix! scope_entry_list_t* candidate_list = NULL; candidate_list = unfold_and_mix_candidate_functions(first_candidate_list, NULL /* builtins */, &argument_types_array[1], argument_types.size(), decl_context, uniquestr(filename.c_str()), line, NULL /* explicit template arguments */); { ObjectList<Symbol> list; Scope::convert_to_vector(candidate_list, list); viable_functions.append(list); } candidate_t* candidate_set = NULL; scope_entry_list_iterator_t* it = NULL; for (it = entry_list_iterator_begin(candidate_list); !entry_list_iterator_end(it); entry_list_iterator_next(it)) { scope_entry_t* entry = entry_list_iterator_current(it); if (entry->entity_specs.is_member) { candidate_set = add_to_candidate_set(candidate_set, entry, argument_types.size() + 1, argument_types_array); } else { candidate_set = add_to_candidate_set(candidate_set, entry, argument_types.size(), argument_types_array + 1); } } entry_list_iterator_free(it); // We also need a scope_entry_t** for holding the conversor argument scope_entry_t** conversor_per_argument = new scope_entry_t*[argument_types.size() + 1]; // Now invoke all the machinery scope_entry_t* entry_result = solve_overload(candidate_set, decl_context, uniquestr(filename.c_str()), line, conversor_per_argument); if (entry_result != NULL) { valid = true; // Store the arguments argument_conversor.clear(); for (i = 0; i < argument_types.size(); i++) { argument_conversor.append(Symbol(conversor_per_argument[i])); } } // Free the conversor per argument delete[] conversor_per_argument; // Free the type array delete[] argument_types_array; // Free the scope entry list free_scope_entry_list(candidate_list); // This one has been allocated above free_scope_entry_list(first_candidate_list); return Symbol(entry_result); }
// Create outline for parallel for AST_t OpenMPTransform::get_outline_parallel_for( PragmaCustomConstruct &construct, FunctionDefinition function_definition, Source outlined_function_name, ForStatement for_statement, Statement /* loop_body */, ReplaceIdExpression replace_references, ObjectList<ParameterInfo> parameter_info_list, ObjectList<Symbol> private_references, ObjectList<Symbol> firstprivate_references, ObjectList<Symbol> lastprivate_references, ObjectList<OpenMP::ReductionSymbol> reduction_references, ObjectList<Symbol> copyin_references, ObjectList<Symbol> copyprivate_references ) { // empty ObjectList<IdExpression> pass_by_value; Source empty; Source outline_parallel_for; Source parallel_for_body; // Get the source of the common parallel X outline outline_parallel_for = get_outline_common( function_definition, parallel_for_body, outlined_function_name, parameter_info_list, construct, /* team_parameter */ true); Source private_declarations = get_privatized_declarations( construct, private_references, firstprivate_references, lastprivate_references, reduction_references, copyin_references, parameter_info_list ); Source loop_distribution = get_loop_distribution_code( for_statement, construct, replace_references, function_definition); Source lastprivate_code; if (!lastprivate_references.empty()) { Source lastprivate_assignments = get_lastprivate_assignments( firstprivate_references, lastprivate_references, copyprivate_references, parameter_info_list); lastprivate_code << "if (intone_last != 0)" << "{" << lastprivate_assignments << "}" ; } // Barrier is already done at parallel level Source loop_finalization = get_loop_finalization(/* do_barrier = */ false); Source reduction_update = get_reduction_update(reduction_references); Source code_before_entering_team, code_after_leaving_team; Source enter_team, leave_team; code_before_entering_team << "nth_player_t nth_player;" << "nth_init_player(&nth_player);" ; enter_team << "nth_enter_team(nth_current_team, &nth_player, 0);" ; leave_team << "nth_leave_team(1);" ; code_after_leaving_team << "nth_end_player(&nth_player);" ; Source destructor_calls; invoke_destructors(parameter_info_list, destructor_calls); parallel_for_body << private_declarations << comment("Entering team") << code_before_entering_team << enter_team << comment("Construct code") << loop_distribution << loop_finalization << reduction_update << lastprivate_code << destructor_calls << comment("Leaving team") << leave_team << code_after_leaving_team ; return finish_outline(function_definition, outline_parallel_for, parameter_info_list, /* team_parameter */ true); }
// Create outline for parallel for AST_t OpenMPTransform::get_outline_parallel_for( OpenMP::Construct &construct, FunctionDefinition function_definition, Source outlined_function_name, ForStatement for_statement, Statement /* loop_body */, ReplaceIdExpression replace_references, ObjectList<ParameterInfo> parameter_info_list, ObjectList<Symbol> private_references, ObjectList<Symbol> firstprivate_references, ObjectList<Symbol> lastprivate_references, ObjectList<OpenMP::ReductionSymbol> reduction_references, ObjectList<Symbol> copyin_references, ObjectList<Symbol> copyprivate_references, OpenMP::Directive directive ) { // empty ObjectList<IdExpression> pass_by_value; Source empty; Source outline_parallel_for; Source parallel_for_body; // Get the source of the common parallel X outline outline_parallel_for = get_outline_common( function_definition, parallel_for_body, outlined_function_name, parameter_info_list); Source private_declarations = get_privatized_declarations( construct, private_references, firstprivate_references, lastprivate_references, reduction_references, copyin_references, parameter_info_list ); Source loop_distribution = get_loop_distribution_code(for_statement, replace_references, function_definition, directive); Source lastprivate_code; if (!lastprivate_references.empty()) { Source lastprivate_assignments = get_lastprivate_assignments( lastprivate_references, copyprivate_references, parameter_info_list); lastprivate_code << "if (intone_last != 0)" << "{" << lastprivate_assignments << "}" ; } // Barrier is already done at parallel level Source loop_finalization = get_loop_finalization(/* do_barrier = */ false); Source reduction_update = get_reduction_update(reduction_references); Source task_block_code; parallel_for_body << private_declarations << loop_distribution << lastprivate_code << reduction_update << loop_finalization << task_block_code ; task_block_code = get_task_block_code(); return finish_outline(function_definition, outline_parallel_for, parameter_info_list); }