Пример #1
0
mfxTraceU32 MFXTraceITT_BeginTask(mfxTraceStaticHandle *static_handle
                                ,const char * //file_name
                                ,mfxTraceU32 //line_num
                                ,const char * //function_name
                                ,mfxTraceChar* //category
                                ,mfxTraceLevel level
                                ,const char * task_name
                                ,mfxTraceTaskHandle *handle
                                ,const void * /*task_params*/)
{
    if (!static_handle || !handle) return 1;

    if (MFX_TRACE_LEVEL_API == level ||
        MFX_TRACE_LEVEL_INTERNAL_VTUNE == level)
    {
        // cache string handle across task instances
        if (NULL == static_handle->itt1.ptr)
        {
            static_handle->itt1.ptr = __itt_string_handle_create(task_name);
        }

        // task is traced
        handle->itt1.uint32 = 1;

        __itt_task_begin(GetDomain(), __itt_null, __itt_null,
            (__itt_string_handle*)static_handle->itt1.ptr);
    }

    return 0;
}
Пример #2
0
void vtuneInit()
{
    domain = __itt_domain_create("x265");
    size_t length = sizeof(stringNames) / sizeof(const char *);
    for (size_t i = 0; i < length; i++)
        taskHandle[i] = __itt_string_handle_create(stringNames[i]);
}
Пример #3
0
static void ITT_init_strings() {
    for ( int i = 0; i < NUM_STRINGS; ++i ) {
#if _WIN32||_WIN64
        strings_for_itt[i].itt_str_handle = __itt_string_handle_createA( strings_for_itt[i].str );
#else
        strings_for_itt[i].itt_str_handle = __itt_string_handle_create( strings_for_itt[i].str );
#endif
    }
}
Пример #4
0
void RunExample() 
{
	__itt_task_begin(pD, __itt_null, __itt_null,  __itt_string_handle_create(L"End of run"));

    for(int i = 0; i < 50; ++i) 
	{
        Example(i);
    }

	__itt_task_end(pD);
}
Пример #5
0
// ITT Metadata are sometimes useful for telling a bunch of tasks apart.
// Here, we have a function that accepts a parameter that, depending on its
// value, will cause the function to run quickly or slowly.
// 
// If we trace this function without a parameter, all we will see is 
// that one of these functions is really long, but won't know why.
//
// The __itt_metadata_add call below adds the actual index value to the trace
// In the GUI, we can then use this captured parameter to decide whether there
// is a correlation between the parameter and the function's duration.
//

__itt_domain* pD = __itt_domain_create(L"gpa_metadata_sample");
__itt_string_handle* pSH1 = __itt_string_handle_createA("Example");
__itt_string_handle* pSH2 = __itt_string_handle_create(L"index");

void Example(int index)
{
	__itt_task_begin(pD, __itt_null, __itt_null, pSH1);

	__itt_metadata_add(pD, __itt_null, pSH2, __itt_metadata_s32, 1, (void*)&index);

	__itt_metadata_str_add(pD, __itt_null, pSH1, L"Example is running", 0);

    if(index == 10) 
	{
        Sleep(30);
    } 
	else 
	{
Пример #6
0
namespace livre
{

#ifdef _ITT_DEBUG_
#include "ittnotify.h"
__itt_domain* ittTextureLoadDomain = __itt_domain_create("Texture Loading");
__itt_string_handle* ittTextureComputationTask =
        __itt_string_handle_create("Texture loading computation");
__itt_string_handle* ittTextureLoadTask = __itt_string_handle_create("Texture loading task");
#endif // _ITT_DEBUG_


// Dont forget to apply cache policy after each traversal
class TextureLoaderVisitor : public RenderNodeVisitor
{
public:
    TextureLoaderVisitor( DashTreePtr dashTree,
                          TextureCache& textureCache,
                          ProcessorInputPtr processorInput,
                          ProcessorOutputPtr processorOutput,
                          bool& needRedraw )
        : RenderNodeVisitor( dashTree )
        , _cache( textureCache )
        , _input( processorInput )
        , _output( processorOutput )
        , _allLoaded( true ) // be optimistic; will be set to false on first
                             // non-loaded data during visit
        , _synchronous( false )
        , _needRedraw( needRedraw )
    {}

    void visit( DashRenderNode& renderNode, VisitState& state ) final;

    bool isAllDataLoaded() const { return _allLoaded; }

    bool isSynchronous() const { return _synchronous; }
    void setSynchronous( const bool synchronous ) { _synchronous = synchronous;}

private:
    TextureCache& _cache;
    ProcessorInputPtr _input;
    ProcessorOutputPtr _output;
    bool _allLoaded;
    bool _synchronous;
    bool& _needRedraw;
};

class CollectVisiblesVisitor : public RenderNodeVisitor
{
public:
    CollectVisiblesVisitor( DashTreePtr dashTree,
                            CacheIdSet& currentVisibleSet )
     : RenderNodeVisitor( dashTree ),
       currentVisibleSet_( currentVisibleSet ) {}

    void visit( DashRenderNode& renderNode, VisitState& state ) final
    {
        const LODNode& lodNode = renderNode.getLODNode();

        if( !renderNode.isInFrustum( ))
             state.setVisitChild( false );

        if( renderNode.isLODVisible( ))
        {
            currentVisibleSet_.insert( lodNode.getNodeId().getId( ));
            state.setVisitChild( false );
        }
    }

private:
    CacheIdSet& currentVisibleSet_;
};

TextureUploadProcessor::TextureUploadProcessor( DashTreePtr dashTree,
                                                GLContextPtr shareContext,
                                                GLContextPtr context,
                                                ConstVolumeRendererParametersPtr vrParameters )
    : GLContextTrait( context )
    , _dashTree( dashTree )
    , _shareContext( shareContext )
    , _textureCache( GL_LUMINANCE8 )
    , _currentFrameID( 0 )
    , _threadOp( TO_NONE )
    , _vrParameters( vrParameters )
    , _allDataLoaded( false )
    , _needRedraw( false )
{
    setDashContext( dashTree->createContext());
}

const TextureCache& TextureUploadProcessor::getTextureCache() const
{
    return _textureCache;
}

bool TextureUploadProcessor::initializeThreadRun_()
{
    setName( "TexUp" );
    _textureCache.setMaximumMemory( _vrParameters->maxGPUCacheMemoryMB * LB_1MB );
    LBASSERT( getGLContext( ));
    _shareContext->shareContext( getGLContext( ));
    return DashProcessor::initializeThreadRun_();
}

bool TextureUploadProcessor::onPreCommit_( const uint32_t outputConnection LB_UNUSED )
{
    const bool ret = _allDataLoaded;

    _allDataLoaded = false;
    return ret;
}

void TextureUploadProcessor::onPostCommit_( const uint32_t,
                                            const CommitState state )
{
    if( state != CS_NOCHANGE )
        glFinish();
}

void TextureUploadProcessor::_loadData()
{
    TextureLoaderVisitor loadVisitor( _dashTree, _textureCache,
                                      processorInputPtr_, processorOutputPtr_,
                                      _needRedraw );

    loadVisitor.setSynchronous( _vrParameters->synchronousMode );

    DFSTraversal traverser;
    const RootNode& rootNode = _dashTree->getDataSource()->getVolumeInformation().rootNode;
    traverser.traverse( rootNode, loadVisitor, _currentFrameID );

    if( _vrParameters->synchronousMode )
        _allDataLoaded = loadVisitor.isAllDataLoaded();
    else
        _allDataLoaded = true;
}

void TextureUploadProcessor::runLoop_()
{
    _needRedraw = false;
    if( GLContext::getCurrent() != getGLContext().get( ))
        getGLContext()->makeCurrent();

    processorInputPtr_->applyAll( CONNECTION_ID );
    _checkThreadOperation();

#ifdef _ITT_DEBUG_
    __itt_task_begin ( ittTextureLoadDomain, __itt_null, __itt_null, ittTextureComputationTask );
#endif //_ITT_DEBUG_

    const DashRenderStatus& renderStatus = _dashTree->getRenderStatus();
    if( renderStatus.getFrameID() != _currentFrameID )
    {
        _protectUnloading.clear();
        CollectVisiblesVisitor collectVisibles( _dashTree,
                                                _protectUnloading );
        DFSTraversal traverser;
        const RootNode& rootNode =
                _dashTree->getDataSource()->getVolumeInformation().rootNode;
        traverser.traverse( rootNode, collectVisibles, renderStatus.getFrameID( ));
        _textureCache.setProtectList( _protectUnloading );
        _currentFrameID = renderStatus.getFrameID();
    }
    _loadData();
    processorOutputPtr_->commit( CONNECTION_ID );

#ifdef _ITT_DEBUG_
    __itt_task_end( ittTextureLoadDomain );
#endif //_ITT_DEBUG_
}

void TextureUploadProcessor::_checkThreadOperation()
{
    DashRenderStatus& renderStatus = _dashTree->getRenderStatus();
    ThreadOperation op = renderStatus.getThreadOp();
    if( op != _threadOp )
    {
        _threadOp = op;
        renderStatus.setThreadOp( op );
        processorOutputPtr_->commit( CONNECTION_ID );
    }

    if( _threadOp == TO_EXIT )
        exit();
}

void TextureLoaderVisitor::visit( DashRenderNode& renderNode, VisitState& state )
{
    const LODNode& lodNode = renderNode.getLODNode();
    if( !lodNode.isValid( ))
        return;

    if( !renderNode.isInFrustum( ))
    {
        state.setVisitChild( false );
        return;
    }

    if( !renderNode.isLODVisible( ))
        return;

    state.setVisitChild( false );

    const ConstCacheObjectPtr texPtr = renderNode.getTextureObject();
    if( texPtr->isLoaded( ))
        return;

    TextureObject& texture = _cache.getNodeTexture( lodNode.getNodeId().getId( ));
    if( texture.isLoaded() )
    {
        renderNode.setTextureObject( &texture );
        _output->commit( CONNECTION_ID );
        return;
    }
    else
    {
        const ConstCacheObjectPtr textureData = renderNode.getTextureDataObject();
        if( textureData->isLoaded( ))
        {
#ifdef _ITT_DEBUG_
            __itt_task_begin ( ittTextureLoadDomain, __itt_null, __itt_null,
                               ittTextureLoadTask );
#endif //_ITT_DEBUG_
            TextureObject& lodTexture = _cache.getNodeTexture( lodNode.getNodeId().getId( ));
            lodTexture.setTextureDataObject(
                            static_cast< const TextureDataObject * >( textureData.get() ) );
            lodTexture.cacheLoad();

#ifdef _ITT_DEBUG_
            __itt_task_end( ittTextureLoadDomain );
#endif //_ITT_DEBUG_
            renderNode.setTextureObject( &lodTexture );

            renderNode.setTextureDataObject( TextureDataObject::getEmptyPtr() );
            _output->commit( CONNECTION_ID );
            _needRedraw = true;
        }
        else
        {
            _allLoaded = false;
            LBVERB << "Texture data not loaded:" << lodNode.getNodeId() << std::endl;
        }
    }

    if( !isSynchronous( ))
        // only in asynchronous mode
        state.setBreakTraversal( _input->dataWaitingOnInput( CONNECTION_ID ));
}

}
Пример #7
0
Task *task(std::string Name) { return __itt_string_handle_create(Name.c_str()); }
Пример #8
0
#include "Module.h"
#include "Globals.h"

#include "HWInterface.h"
#include "HardwareConfig.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define ARDUINO_SIO_BUF_LEN		 128

__itt_string_handle* pshPicThreadReadLoop = __itt_string_handle_create("Read Loop");
__itt_string_handle* pshPicThreadWriteLoop = __itt_string_handle_create("Write Loop");

__itt_string_handle* pshReadError = __itt_string_handle_create("Read Error");
__itt_string_handle* pshPicError = __itt_string_handle_create("Arduino Reported Error");
__itt_string_handle* pshHandleArduinoMessage = __itt_string_handle_create("Handle Arduino Msg");
__itt_string_handle* pshWaitForMoreData = __itt_string_handle_create("Wait for More Data");

__itt_string_handle* pshVersionRequest = __itt_string_handle_create("VersionRequest");
__itt_string_handle* pshPicWriteFile = __itt_string_handle_create("WriteFile");
__itt_string_handle* pshWriteIndex = __itt_string_handle_create("WriteIndex = ");
__itt_string_handle* pshReadIndex = __itt_string_handle_create("ReadIndex = ");


/**