mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-04 15:00:36 +01:00
swr: [rasterizer] Add rdtsc buckets support for shaders
Pass pointer to core buckets mgr back to sim layer. Add support for RDTSC_START/RDTSC_STOP macros in the builder. Each unique shader now has a unique bucket associated with it, enabling more detailed reporting at the shader level. Currently due to some llvm issue with thread local storage, 64bit runs require single threaded mode.
This commit is contained in:
parent
abd4aa68cc
commit
bfb954189e
6 changed files with 75 additions and 3 deletions
|
|
@ -64,8 +64,10 @@ void BucketManager::RegisterThread(const std::string& name)
|
|||
|
||||
UINT BucketManager::RegisterBucket(const BUCKET_DESC& desc)
|
||||
{
|
||||
mThreadMutex.lock();
|
||||
size_t id = mBuckets.size();
|
||||
mBuckets.push_back(desc);
|
||||
mThreadMutex.unlock();
|
||||
return (UINT)id;
|
||||
}
|
||||
|
||||
|
|
@ -186,3 +188,13 @@ void BucketManager::PrintReport(const std::string& filename)
|
|||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
void BucketManager_StartBucket(BucketManager* pBucketMgr, uint32_t id)
|
||||
{
|
||||
pBucketMgr->StartBucket(id);
|
||||
}
|
||||
|
||||
void BucketManager_StopBucket(BucketManager* pBucketMgr, uint32_t id)
|
||||
{
|
||||
pBucketMgr->StopBucket(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ public:
|
|||
// removes all registered buckets
|
||||
void ClearBuckets()
|
||||
{
|
||||
mThreadMutex.lock();
|
||||
mBuckets.clear();
|
||||
mThreadMutex.unlock();
|
||||
}
|
||||
|
||||
/// Registers a new thread with the manager.
|
||||
|
|
@ -227,3 +229,8 @@ private:
|
|||
bool mThreadViz{ false };
|
||||
std::string mThreadVizDir;
|
||||
};
|
||||
|
||||
|
||||
// C helpers for jitter
|
||||
void BucketManager_StartBucket(BucketManager* pBucketMgr, uint32_t id);
|
||||
void BucketManager_StopBucket(BucketManager* pBucketMgr, uint32_t id);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void SetupDefaultState(SWR_CONTEXT *pContext);
|
|||
/// @brief Create SWR Context.
|
||||
/// @param pCreateInfo - pointer to creation info.
|
||||
HANDLE SwrCreateContext(
|
||||
const SWR_CREATECONTEXT_INFO* pCreateInfo)
|
||||
SWR_CREATECONTEXT_INFO* pCreateInfo)
|
||||
{
|
||||
RDTSC_RESET();
|
||||
RDTSC_INIT(0);
|
||||
|
|
@ -118,6 +118,11 @@ HANDLE SwrCreateContext(
|
|||
pContext->pfnStoreTile = pCreateInfo->pfnStoreTile;
|
||||
pContext->pfnClearTile = pCreateInfo->pfnClearTile;
|
||||
|
||||
// pass pointer to bucket manager back to caller
|
||||
#ifdef KNOB_ENABLE_RDTSC
|
||||
pCreateInfo->pBucketMgr = &gBucketMgr;
|
||||
#endif
|
||||
|
||||
return (HANDLE)pContext;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ typedef void(SWR_API *PFN_CLEAR_TILE)(HANDLE hPrivateContext,
|
|||
SWR_RENDERTARGET_ATTACHMENT rtIndex,
|
||||
uint32_t x, uint32_t y, const float* pClearColor);
|
||||
|
||||
class BucketManager;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// SWR_CREATECONTEXT_INFO
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -91,10 +93,14 @@ struct SWR_CREATECONTEXT_INFO
|
|||
// Each SWR context can have multiple sets of active state
|
||||
uint32_t maxSubContexts;
|
||||
|
||||
// tile manipulation functions
|
||||
// Tile manipulation functions
|
||||
PFN_LOAD_TILE pfnLoadTile;
|
||||
PFN_STORE_TILE pfnStoreTile;
|
||||
PFN_CLEAR_TILE pfnClearTile;
|
||||
|
||||
// Pointer to rdtsc buckets mgr returned to the caller.
|
||||
// Only populated when KNOB_ENABLE_RDTSC is set
|
||||
BucketManager* pBucketMgr;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -112,7 +118,7 @@ struct SWR_RECT
|
|||
/// @brief Create SWR Context.
|
||||
/// @param pCreateInfo - pointer to creation info.
|
||||
HANDLE SWR_API SwrCreateContext(
|
||||
const SWR_CREATECONTEXT_INFO* pCreateInfo);
|
||||
SWR_CREATECONTEXT_INFO* pCreateInfo);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Destroys SWR Context.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
*
|
||||
******************************************************************************/
|
||||
#include "builder.h"
|
||||
#include "common/rdtsc_buckets.h"
|
||||
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
|
||||
void __cdecl CallPrint(const char* fmt, ...);
|
||||
|
|
@ -1447,3 +1449,39 @@ Value *Builder::VINSERTI128(Value* a, Value* b, Constant* imm8)
|
|||
return VSHUFFLE(a, inter, ConstantVector::get(idx2));
|
||||
#endif
|
||||
}
|
||||
|
||||
// rdtsc buckets macros
|
||||
void Builder::RDTSC_START(Value* pBucketMgr, Value* pId)
|
||||
{
|
||||
std::vector<Type*> args{
|
||||
PointerType::get(mInt32Ty, 0), // pBucketMgr
|
||||
mInt32Ty // id
|
||||
};
|
||||
|
||||
FunctionType* pFuncTy = FunctionType::get(Type::getVoidTy(JM()->mContext), args, false);
|
||||
Function* pFunc = cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("BucketManager_StartBucket", pFuncTy));
|
||||
if (sys::DynamicLibrary::SearchForAddressOfSymbol("BucketManager_StartBucket") == nullptr)
|
||||
{
|
||||
sys::DynamicLibrary::AddSymbol("BucketManager_StartBucket", (void*)&BucketManager_StartBucket);
|
||||
}
|
||||
|
||||
CALL(pFunc, { pBucketMgr, pId });
|
||||
}
|
||||
|
||||
void Builder::RDTSC_STOP(Value* pBucketMgr, Value* pId)
|
||||
{
|
||||
std::vector<Type*> args{
|
||||
PointerType::get(mInt32Ty, 0), // pBucketMgr
|
||||
mInt32Ty // id
|
||||
};
|
||||
|
||||
FunctionType* pFuncTy = FunctionType::get(Type::getVoidTy(JM()->mContext), args, false);
|
||||
Function* pFunc = cast<Function>(JM()->mpCurrentModule->getOrInsertFunction("BucketManager_StopBucket", pFuncTy));
|
||||
if (sys::DynamicLibrary::SearchForAddressOfSymbol("BucketManager_StopBucket") == nullptr)
|
||||
{
|
||||
sys::DynamicLibrary::AddSymbol("BucketManager_StopBucket", (void*)&BucketManager_StopBucket);
|
||||
}
|
||||
|
||||
CALL(pFunc, { pBucketMgr, pId });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,3 +147,7 @@ Value* INT3() { return INTERRUPT(C((uint8_t)3)); }
|
|||
|
||||
Value *VEXTRACTI128(Value* a, Constant* imm8);
|
||||
Value *VINSERTI128(Value* a, Value* b, Constant* imm8);
|
||||
|
||||
// rdtsc buckets macros
|
||||
void RDTSC_START(Value* pBucketMgr, Value* pId);
|
||||
void RDTSC_STOP(Value* pBucketMgr, Value* pId);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue