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


C++ NodeclBase::is_null方法代码示例

本文整理汇总了C++中nodecl::NodeclBase::is_null方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeclBase::is_null方法的具体用法?C++ NodeclBase::is_null怎么用?C++ NodeclBase::is_null使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nodecl::NodeclBase的用法示例。


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

示例1: 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);
        }
    }
开发者ID:bsc-pm,项目名称:mcxx,代码行数:10,代码来源:tl-vectorizer-visitor-postprocessor.cpp

示例2: 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);
            }
        }
开发者ID:bsc-pm,项目名称:mcxx,代码行数:14,代码来源:tl-vector-legalization-sse.cpp

示例3: 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);
                }
            }
        }
开发者ID:bsc-pm,项目名称:mcxx,代码行数:16,代码来源:tl-vector-backend-neon.cpp

示例4: visit

        void SimdVisitor::visit(const Nodecl::OpenMP::Simd& simd_node)
        {
            Nodecl::NodeclBase for_statement = simd_node.get_statement();

            // Vectorize for
            Nodecl::NodeclBase epilog = 
                    _vectorizer.vectorize(for_statement.as<Nodecl::ForStatement>(), 
                            _device_name, _vector_length, NULL); 

            // Add epilog
            if (!epilog.is_null())
            {
                simd_node.append_sibling(epilog);
            }

            // Remove Simd node
            simd_node.replace(for_statement);
        }
开发者ID:drpicox,项目名称:mcxx,代码行数:18,代码来源:tl-omp-simd.cpp

示例5: visit

    void KNCVectorLegalization::visit(const Nodecl::VectorLoad& n)
    {
        const Nodecl::NodeclBase rhs = n.get_rhs();
        const Nodecl::NodeclBase mask = n.get_mask();
        const Nodecl::List flags = n.get_flags().as<Nodecl::List>();

        walk(rhs);
        walk(mask);
        walk(flags);

        bool explicitly_aligned = !flags.find_first<Nodecl::AlignedFlag>().is_null();

        // Turn unaligned load into gather
        if (!explicitly_aligned
                && (_prefer_gather_scatter ||
                    (_prefer_mask_gather_scatter && !mask.is_null())))
        {
            VECTORIZATION_DEBUG()
            {
                fprintf(stderr, "KNC Legalization: Turn unaligned load '%s' into "\
                        "adjacent gather\n", rhs.prettyprint().c_str());
            }
开发者ID:bsc-pm,项目名称:mcxx,代码行数:22,代码来源:tl-vector-legalization-knc.cpp

示例6: as_expression

 std::string as_expression(const Nodecl::NodeclBase& n)
 {
     ERROR_CONDITION (n.is_null(), "Cannot create a literal expression from a null node", 0);
     return nodecl_expr_to_source(n.get_internal_nodecl());
 }
开发者ID:bsc-pm,项目名称:mcxx,代码行数:5,代码来源:tl-source.cpp

示例7: 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
//.........这里部分代码省略.........
开发者ID:bsc-pm,项目名称:mcxx,代码行数:101,代码来源:tl-loop-spawn-worksharing.cpp

示例8: perform_partial_reduction

    void LoweringVisitor::perform_partial_reduction(OutlineInfo& outline_info, Nodecl::NodeclBase ref_tree)
    {
        ERROR_CONDITION(ref_tree.is_null(), "Invalid tree", 0);

        Source reduction_code;

        TL::ObjectList<OutlineDataItem*> reduction_items = outline_info.get_data_items().filter(
                predicate(lift_pointer(functor(&OutlineDataItem::is_reduction))));
        if (!reduction_items.empty())
        {
            for (TL::ObjectList<OutlineDataItem*>::iterator it = reduction_items.begin();
                    it != reduction_items.end();
                    it++)
            {
                if (IS_C_LANGUAGE || IS_CXX_LANGUAGE)
                {
                    if ((*it)->get_private_type().is_array())
                    {
                        reduction_code
                            << "__builtin_memcpy(rdv_" << (*it)->get_field_name() << "[nanos_omp_get_thread_num()],"
                            << "rdp_" << (*it)->get_symbol().get_name() << ","
                            << " sizeof(" << as_type((*it)->get_private_type()) << "));"
                            ;
                    }
                    else
                    {
                        reduction_code
                            << "rdv_" << (*it)->get_field_name() << "[nanos_omp_get_thread_num()] "
                            << "= rdp_" << (*it)->get_symbol().get_name() << ";"
                            ;
                    }
                }
                else if (IS_FORTRAN_LANGUAGE)
                {
                    Source extra_dims;
                    {
                        TL::Type t = (*it)->get_symbol().get_type().no_ref();
                        int rank = 0;
                        if (t.is_fortran_array())
                        {
                            rank = t.fortran_rank();
                        }

                        int i;
                        for (i = 0; i < rank; i++)
                        {
                            extra_dims << ":,";
                        }
                    }

                    reduction_code
                        << "rdv_" << (*it)->get_field_name() << "( " << extra_dims << "nanos_omp_get_thread_num() ) = rdp_" << (*it)->get_symbol().get_name() << "\n"
                        ;
                }
                else
                {
                    internal_error("Code unreachable", 0);
                }
            }
        }

        ref_tree.replace(reduction_code.parse_statement(ref_tree));
    }
开发者ID:,项目名称:,代码行数:63,代码来源:

示例9: reduction_initialization_code

    void LoweringVisitor::reduction_initialization_code(
            OutlineInfo& outline_info,
            Nodecl::NodeclBase ref_tree,
            Nodecl::NodeclBase construct)
    {
        ERROR_CONDITION(ref_tree.is_null(), "Invalid tree", 0);

        if (!Nanos::Version::interface_is_at_least("master", 5023))
        {
            running_error("%s: error: a newer version of Nanos++ (>=5023) is required for reductions support\n",
                    construct.get_locus_str().c_str());
        }

        TL::ObjectList<OutlineDataItem*> reduction_items = outline_info.get_data_items().filter(
                predicate(lift_pointer(functor(&OutlineDataItem::is_reduction))));
        ERROR_CONDITION (reduction_items.empty(), "No reductions to process", 0);

        Source result;

        Source reduction_declaration,
               thread_initializing_reduction_info,
               thread_fetching_reduction_info;

        result
            << reduction_declaration
            << "{"
            << as_type(get_bool_type()) << " red_single_guard;"
            << "nanos_err_t err;"
            << "err = nanos_enter_sync_init(&red_single_guard);"
            << "if (err != NANOS_OK)"
            <<     "nanos_handle_error(err);"
            << "if (red_single_guard)"
            << "{"
            <<    "int nanos_num_threads = nanos_omp_get_num_threads();"
            <<    thread_initializing_reduction_info
            <<    "err = nanos_release_sync_init();"
            <<    "if (err != NANOS_OK)"
            <<        "nanos_handle_error(err);"
            << "}"
            << "else"
            << "{"
            <<    "err = nanos_wait_sync_init();"
            <<    "if (err != NANOS_OK)"
            <<        "nanos_handle_error(err);"
            <<    thread_fetching_reduction_info
            << "}"
            << "}"
            ;

        for (TL::ObjectList<OutlineDataItem*>::iterator it = reduction_items.begin();
                it != reduction_items.end();
                it++)
        {
            std::string nanos_red_name = "nanos_red_" + (*it)->get_symbol().get_name();

            std::pair<OpenMP::Reduction*, TL::Type> reduction_info = (*it)->get_reduction_info();
            OpenMP::Reduction* reduction = reduction_info.first;
            TL::Type reduction_type = reduction_info.second;

            if (reduction_type.is_any_reference())
                reduction_type = reduction_type.references_to();

            TL::Type reduction_element_type = reduction_type;
            if (IS_FORTRAN_LANGUAGE)
            {
                while (reduction_element_type.is_fortran_array())
                    reduction_element_type = reduction_element_type.array_element();
            }
            else
            {
                while (reduction_element_type.is_array())
                    reduction_element_type = reduction_element_type.array_element();
            }

            Source element_size;
            if (IS_FORTRAN_LANGUAGE)
            {
                if (reduction_type.is_fortran_array())
                {
                    // We need to parse this bit in Fortran
                    Source number_of_bytes;
                    number_of_bytes << "SIZE(" << (*it)->get_symbol().get_name() << ") * " << reduction_element_type.get_size();

                    element_size << as_expression(number_of_bytes.parse_expression(construct));
                }
                else
                {
                    element_size << "sizeof(" << as_type(reduction_type) << ")";
                }
            }
            else
            {
                element_size << "sizeof(" << as_type(reduction_type) << ")";
            }

            reduction_declaration
                << "nanos_reduction_t* " << nanos_red_name << ";"
                ;

            Source allocate_private_buffer, cleanup_code;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: perform_partial_reduction_slicer

    void LoweringVisitor::perform_partial_reduction_slicer(OutlineInfo& outline_info,
            Nodecl::NodeclBase ref_tree,
            Nodecl::Utils::SimpleSymbolMap*& symbol_map)
    {
        ERROR_CONDITION(ref_tree.is_null(), "Invalid tree", 0);

        TL::ObjectList<OutlineDataItem*> reduction_items = outline_info.get_data_items().filter(
               lift_pointer<bool, OutlineDataItem>(&OutlineDataItem::is_reduction));
        if (!reduction_items.empty())
        {
            TL::ObjectList<Nodecl::NodeclBase> reduction_stmts;

            Nodecl::Utils::SimpleSymbolMap* simple_symbol_map = new Nodecl::Utils::SimpleSymbolMap(symbol_map);
            symbol_map = simple_symbol_map;

            for (TL::ObjectList<OutlineDataItem*>::iterator it = reduction_items.begin();
                    it != reduction_items.end();
                    it++)
            {
                scope_entry_t* shared_symbol = (*it)->get_symbol().get_internal_symbol();

                // We need this to avoid the original symbol be replaced
                // incorrectly
                scope_entry_t* shared_symbol_proxy = NEW0(scope_entry_t);
                shared_symbol_proxy->symbol_name = UNIQUESTR_LITERAL("<<reduction-variable>>"); // Crude way to ensure it is replaced
                shared_symbol_proxy->kind = shared_symbol->kind;
                symbol_entity_specs_copy_from(shared_symbol_proxy, shared_symbol);
                shared_symbol_proxy->decl_context = shared_symbol->decl_context;
                shared_symbol_proxy->type_information = shared_symbol->type_information;
                shared_symbol_proxy->locus = shared_symbol->locus;

                simple_symbol_map->add_map( shared_symbol_proxy,
                        (*it)->reduction_get_shared_symbol_in_outline() );

                Source reduction_code;
                Nodecl::NodeclBase partial_reduction_code;
                reduction_code
                    << "{"
                    << "nanos_lock_t* red_lock;"
                    << "nanos_err_t nanos_err;"
                    << "nanos_err = nanos_get_lock_address("
                    <<       ((*it)->get_private_type().is_array() ? "" : "&")
                    <<             as_symbol( shared_symbol_proxy ) << ", &red_lock);"
                    << "if (nanos_err != NANOS_OK) nanos_handle_error(nanos_err);"

                    << "nanos_err = nanos_set_lock(red_lock);"
                    << "if (nanos_err != NANOS_OK) nanos_handle_error(nanos_err);"
                    << statement_placeholder(partial_reduction_code)
                    << "nanos_err = nanos_unset_lock(red_lock);"
                    << "if (nanos_err != NANOS_OK) nanos_handle_error(nanos_err);"
                    << "}"
                    ;

                FORTRAN_LANGUAGE()
                {
                    Source::source_language = SourceLanguage::C;
                }
                Nodecl::NodeclBase statement = reduction_code.parse_statement(ref_tree);
                FORTRAN_LANGUAGE()
                {
                    Source::source_language = SourceLanguage::Current;
                }

                ERROR_CONDITION(!statement.is<Nodecl::List>(), "Expecting a list", 0);
                reduction_stmts.append(statement.as<Nodecl::List>()[0]);

                TL::Type elemental_type = (*it)->get_private_type();
                while (elemental_type.is_array())
                    elemental_type = elemental_type.array_element();

                Source partial_reduction_code_src;
                if (IS_C_LANGUAGE || IS_CXX_LANGUAGE)
                {
                    partial_reduction_code_src
                        << as_symbol( (*it)->reduction_get_basic_function() ) << "("
                        // This will be the reduction shared
                        <<       ((*it)->get_private_type().is_array() ? "" : "&")
                        <<       as_symbol( shared_symbol_proxy ) << ", "
                        // This will be the reduction private var
                        <<       ((*it)->get_private_type().is_array() ? "" : "&")
                        <<       as_symbol( (*it)->get_symbol() ) << ", "
                        <<    ((*it)->get_private_type().is_array() ?
                               (
                                  "sizeof(" + as_type( (*it)->get_private_type()) + ")"
                                   "/ sizeof(" + as_type(elemental_type) + ")"
                                )
                                : "1")
                        << ");"
                        ;

                }
                else if (IS_FORTRAN_LANGUAGE)
                {
                    // We use an ELEMENTAL call here
                    partial_reduction_code_src
                        << "CALL " << as_symbol ( (*it)->reduction_get_basic_function() ) << "("
                        // This will be the reduction shared
                        <<    as_symbol( shared_symbol_proxy ) << ", "
                        // This will be the reduction private var
                        <<    as_symbol( (*it)->get_symbol() )
//.........这里部分代码省略.........
开发者ID:bsc-pm,项目名称:mcxx,代码行数:101,代码来源:tl-reduction-ompss.cpp


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