Changeset 855

Show
Ignore:
Timestamp:
01/22/08 19:45:49
Author:
robert
Message:

Added support for generating tasks sets based on two split levels

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vpb/DataSet.cpp

    r854 r855  
    23112311bool DataSet::generateTasks(TaskManager* taskManager) 
    23122312{ 
     2313    if (!getLogFileName().empty()) 
     2314    { 
     2315        if (!getBuildLog()) setBuildLog(new BuildLog()); 
     2316     
     2317        getBuildLog()->openLogFile(getLogFileName()); 
     2318    } 
     2319 
     2320    if (getBuildLog()) 
     2321    { 
     2322        pushOperationLog(getBuildLog()); 
     2323    } 
     2324 
     2325    bool result = false; 
    23132326    if (getBuildOptionsString().find("tm")!=std::string::npos) 
    23142327    { 
    2315         return generateTasks_new(taskManager); 
     2328        result = generateTasks_new(taskManager); 
    23162329    } 
    23172330    else 
    23182331    { 
    2319         return generateTasks_old(taskManager); 
    2320     } 
     2332        result = generateTasks_old(taskManager); 
     2333    } 
     2334 
     2335    if (getBuildLog()) 
     2336    { 
     2337        popOperationLog(); 
     2338    } 
     2339     
     2340    return result; 
     2341 
    23212342} 
    23222343 
     
    24012422{ 
    24022423    log(osg::NOTICE,"DataSet::generateTasks_new"); 
    2403     if (!getLogFileName().empty()) 
    2404     { 
    2405         if (!getBuildLog()) setBuildLog(new BuildLog()); 
    2406      
    2407         getBuildLog()->openLogFile(getLogFileName()); 
    2408     } 
    2409  
    2410     if (getBuildLog()) 
    2411     { 
    2412         pushOperationLog(getBuildLog()); 
    2413     } 
    2414      
     2424 
    24152425    loadSources(); 
    24162426 
     
    24222432     
    24232433    if (getDistributedBuildSplitLevel()==0) return false; 
    2424  
    2425     log(osg::NOTICE,"Then generate the root task"); 
    2426     log(osg::NOTICE,"Then generate the intermediate tasks if any"); 
    2427     log(osg::NOTICE,"Then generate the leaf tasks if any"); 
    2428  
    2429     if (getBuildLog()) 
    2430     { 
    2431         popOperationLog(); 
     2434     
     2435    int bottomDistributedBuildLevel = getDistributedBuildSecondarySplitLevel()==0 ?  
     2436                                        getDistributedBuildSplitLevel() : 
     2437                                        getDistributedBuildSecondarySplitLevel(); 
     2438 
     2439    computeDestinationGraphFromSources(bottomDistributedBuildLevel+1); 
     2440 
     2441    if (!_destinationGraph.valid()) return false; 
     2442 
     2443 
     2444    // initialize various tasks related settings 
     2445    std::string sourceFile = taskManager->getSourceFileName(); 
     2446    std::string basename = taskManager->getBuildName(); 
     2447    std::string taskDirectory = getTaskDirectory(); 
     2448    if (!taskDirectory.empty()) taskDirectory += "/"; 
     2449 
     2450    std::string fileCacheName; 
     2451    if (System::instance()->getFileCache()) fileCacheName = System::instance()->getFileCache()->getFileName();  
     2452 
     2453    bool logging = getNotifyLevel() > ALWAYS; 
     2454 
     2455     
     2456    // create root task 
     2457    { 
     2458        std::ostringstream taskfile; 
     2459        taskfile<<taskDirectory<<basename<<"_root_L0_X0_Y0.task"; 
     2460 
     2461        std::ostringstream app; 
     2462        app<<"osgdem --run-path "<<taskManager->getRunPath()<<" -s "<<sourceFile<<" --record-subtile-on-leaf-tiles -l "<<getDistributedBuildSplitLevel()<<" --task "<<taskfile.str(); 
     2463 
     2464        if (!fileCacheName.empty()) 
     2465        { 
     2466            app<<" --cache "<<fileCacheName; 
     2467        } 
     2468 
     2469        if (logging) 
     2470        { 
     2471            std::ostringstream logfile; 
     2472            logfile<<taskDirectory<<basename<<"_root_L0_X0_Y0.log"; 
     2473            app<<" --log "<<logfile.str(); 
     2474        } 
     2475#if 0             
     2476        else 
     2477        { 
     2478            app<<" > /dev/null"; 
     2479        } 
     2480#endif             
     2481 
     2482        taskManager->addTask(taskfile.str(), app.str(), sourceFile); 
     2483    } 
     2484     
     2485     
     2486    // need to create an intermediate level if required. 
     2487    if (getDistributedBuildSecondarySplitLevel()!=0) 
     2488    { 
     2489        CollectSubtiles cs(getDistributedBuildSplitLevel()-1); 
     2490        _destinationGraph->accept(cs); 
     2491 
     2492        for(CollectSubtiles::SubtileList::iterator itr = cs._subtileList.begin(); 
     2493            itr != cs._subtileList.end(); 
     2494            ++itr) 
     2495        { 
     2496            CompositeDestination* cd = itr->get(); 
     2497 
     2498            std::ostringstream taskfile; 
     2499            taskfile<<taskDirectory<<basename<<"_subtile_L"<<cd->_level<<"_X"<<cd->_tileX<<"_Y"<<cd->_tileY<<".task"; 
     2500 
     2501 
     2502            std::ostringstream app; 
     2503            app<<"osgdem --run-path "<<taskManager->getRunPath()<<" -s "<<sourceFile<<" --record-subtile-on-leaf-tiles -l "<<getDistributedBuildSecondarySplitLevel()<<" --subtile "<<cd->_level<<" "<<cd->_tileX<<" "<<cd->_tileY<<" --task "<<taskfile.str(); 
     2504 
     2505 
     2506            if (!fileCacheName.empty()) 
     2507            { 
     2508                app<<" --cache "<<fileCacheName; 
     2509            } 
     2510 
     2511            if (logging) 
     2512            { 
     2513                std::ostringstream logfile; 
     2514 
     2515                logfile<<taskDirectory<<basename<<"_subtile_L"<<cd->_level<<"_X"<<cd->_tileX<<"_Y"<<cd->_tileY<<".log"; 
     2516                app<<" --log "<<logfile.str(); 
     2517            } 
     2518    #if 0 
     2519            else 
     2520            { 
     2521                app<<" > /dev/null"; 
     2522            } 
     2523    #endif 
     2524            taskManager->addTask(taskfile.str(), app.str(), sourceFile); 
     2525        } 
     2526    } 
     2527     
     2528    // create the bottom level split 
     2529    {     
     2530        // bottom set of tasks 
     2531        CollectSubtiles cs(bottomDistributedBuildLevel-1); 
     2532        _destinationGraph->accept(cs); 
     2533 
     2534        for(CollectSubtiles::SubtileList::iterator itr = cs._subtileList.begin(); 
     2535            itr != cs._subtileList.end(); 
     2536            ++itr) 
     2537        { 
     2538            CompositeDestination* cd = itr->get(); 
     2539 
     2540            std::ostringstream taskfile; 
     2541            taskfile<<taskDirectory<<basename<<"_subtile_L"<<cd->_level<<"_X"<<cd->_tileX<<"_Y"<<cd->_tileY<<".task"; 
     2542 
     2543 
     2544            std::ostringstream app; 
     2545            app<<"osgdem --run-path "<<taskManager->getRunPath()<<" -s "<<sourceFile<<" --subtile "<<cd->_level<<" "<<cd->_tileX<<" "<<cd->_tileY<<" --task "<<taskfile.str(); 
     2546 
     2547            if (!fileCacheName.empty()) 
     2548            { 
     2549                app<<" --cache "<<fileCacheName; 
     2550            } 
     2551 
     2552            if (logging) 
     2553            { 
     2554                std::ostringstream logfile; 
     2555 
     2556                logfile<<taskDirectory<<basename<<"_subtile_L"<<cd->_level<<"_X"<<cd->_tileX<<"_Y"<<cd->_tileY<<".log"; 
     2557                app<<" --log "<<logfile.str(); 
     2558            } 
     2559    #if 0 
     2560            else 
     2561            { 
     2562                app<<" > /dev/null"; 
     2563            } 
     2564    #endif 
     2565            taskManager->addTask(taskfile.str(), app.str(), sourceFile); 
     2566        } 
    24322567    } 
    24332568 
     
    24372572bool DataSet::generateTasks_old(TaskManager* taskManager) 
    24382573{ 
    2439     if (!getLogFileName().empty()) 
    2440     { 
    2441         if (!getBuildLog()) setBuildLog(new BuildLog()); 
    2442      
    2443         getBuildLog()->openLogFile(getLogFileName()); 
    2444     } 
    2445  
    2446     if (getBuildLog()) 
    2447     { 
    2448         pushOperationLog(getBuildLog()); 
    2449     } 
    2450      
    24512574    loadSources(); 
    24522575 
     
    25422665        } 
    25432666 
    2544     } 
    2545  
    2546     if (getBuildLog()) 
    2547     { 
    2548         popOperationLog(); 
    25492667    } 
    25502668