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


C++ Universe::InitializeUniverse方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
    try {
        tbb::tick_count mainStartTime = tbb::tick_count::now();
        RunOptions options = ParseCommandLine(argc,argv);
        SeismicVideo video(u,options.numberOfFrames,options.threads.last,options.parallel);

        // video layer init
        if(video.init_window(u.UniverseWidth, u.UniverseHeight)) {
            video.calc_fps = true;
            video.threaded = options.threads.first > 0;
            // video is ok, init Universe
            u.InitializeUniverse(video);
            // main loop
            video.main_loop();
        }
        else if(video.init_console()) {
            // do console mode
            for(int p = options.threads.first;  p <= options.threads.last; ++p ) {
                tbb::tick_count xwayParallelismStartTime = tbb::tick_count::now();
                u.InitializeUniverse(video);
                int numberOfFrames = options.numberOfFrames;
#if __TBB_MIC
                drawing_memory dmem = video.get_drawing_memory();
                char *pMem = dmem.get_address();
                size_t memSize = dmem.get_size();

#pragma offload target(mic) in(u, numberOfFrames, p, dmem), out(pMem:length(memSize))
                {
                    // It is necessary to update the pointer on mic
                    // since the address spaces on host and on target are different
                    dmem.set_address(pMem);
                    u.SetDrawingMemory(dmem);
#endif // __TBB_MIC
                    if (p==0) {
                        //run a serial version
                        for( int i=0; i<numberOfFrames; ++i ) {
                            u.SerialUpdateUniverse();
                        }
                    } else {
                        tbb::task_scheduler_init init(p);
                        for( int i=0; i<numberOfFrames; ++i ) {
                            u.ParallelUpdateUniverse();
                        }
                    }
#if __TBB_MIC
                }
#endif // __TBB_MIC

                if (!options.silent) {
                    double fps =  options.numberOfFrames/((tbb::tick_count::now()-xwayParallelismStartTime).seconds());
                    std::cout<<fps<<" frame per sec with ";
                    if (p==0) {
                        std::cout<<"serial code\n";
                    } else {
                        std::cout<<p<<" way parallelism\n";
                    }
                }
            }
        }
        video.terminate();
        utility::report_elapsed_time((tbb::tick_count::now() - mainStartTime).seconds());
        return 0;
    } catch(std::exception& e) {
        std::cerr<<"error occurred. error text is :\"" <<e.what()<<"\"\n";
        return 1;
    }
}
开发者ID:yyzreal,项目名称:tbb,代码行数:68,代码来源:main.cpp


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