1
我一直在開發一個看不見的(讀:不會產生任何視覺輸出)stressor來測試我的圖形卡的功能(以及作爲一般的DirectCompute的探索,我很新) 。我有下面的代碼的權利,現在我很得意:使用HLSL無形的壓力圖形卡 - 如何強調內存?
RWStructuredBuffer<uint> BufferOut : register(u0);
[numthreads(1, 1, 1)]
void CSMain(uint3 DTid : SV_DispatchThreadID)
{
uint total = 0;
float p = 0;
while(p++ < 40.0){
float s= 4.0;
float M= pow(2.0,p) - 1.0;
for(uint i=0; i <= p - 2; i++)
{
s=((s*s) - 2) % M;
}
if(s < 1.0) total++;
}
BufferOut[DTid.x] = total;
}
這將運行Lucas Lehmer Test的兩個前40個大國。當我在定時循環中調度此代碼並使用GPU-Z查看我的圖形卡統計信息時,我的GPU負載在此持續時間內達到99%。我對此非常滿意,但我也注意到,從滿載GPU中產生的熱量實際上是非常小的(我得到的溫度大約是5到10攝氏度,遠遠低於我在跑步時獲得的熱量跳躍,說,無主之地2)。我的想法是,我的大部分熱量來自內存訪問,所以我需要在整個運行過程中包含一致的內存訪問。我最初的代碼是這樣的:
RWStructuredBuffer<uint> BufferOut : register(u0);
groupshared float4 memory_buffer[1024];
[numthreads(1, 1, 1)]
void CSMain(uint3 DTid : SV_DispatchThreadID)
{
uint total = 0;
float p = 0;
while(p++ < 40.0){
[fastop] // to lower compile times - Code efficiency is strangely not what Im looking for right now.
for(uint i = 0; i < 1024; ++i)
float s= 4.0;
float M= pow(2.0,p) - 1.0;
for(uint i=0; i <= p - 2; i++)
{
s=((s*s) - 2) % M;
}
if(s < 1.0) total++;
}
BufferOut[DTid.x] = total;
}