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