0

I have this program :

        for (int i = 0; i < STEPS; ++i)
        {
            context->CSSetShader(computeShader, NULL, 0);

            ID3D11UnorderedAccessView *aUAViews[1] = {bufferOut_UAV};
            context->CSSetUnorderedAccessViews(0, 1, aUAViews, NULL);

            context->Dispatch(32, 32, 1);
            in[i] = t.GetTime();

            if (i == STEPS / 2)
            {
context->End(pEventQuery);
while( context->GetData( pEventQuery, NULL, 0, 0 ) == S_FALSE ) {}
            }
        }

        double out = t.GetTime();

context->End(pEventQuery);
while( context->GetData( pEventQuery, NULL, 0, 0 ) == S_FALSE ) {}

First while iteration last only 26 ms, while second 46 ms?

Just in case the shader:

RWStructuredBuffer<float> Output : register(u0);

[numthreads(GROUP_SIZE_X, GROUP_SIZE_Y, 1)]
void arrayTest(uint3 DTid : SV_DispatchThreadID)
{
    float i = DTid.x * 32 + DTid.y;
    Output[i] = 0;
    for (int k = 0; k < 100; ++k)
    {
        Output[i] += sqrt(i + k);
    }
}

but i don't think it should take different time at every start.

interesting what if I comment out line ''if (i == STEPS / 2)'' both halves take nearly the same time.

EDIT: as far as i can see for now, it is decause of cashing

Yola
  • 18,496
  • 11
  • 65
  • 106

1 Answers1

1

The most likely candidate (in my mind) is context switching between threads in the operating system. An operation that takes longer is more likely to be put on hold by the OS sometime in the middle.

Your program is not the only thing going on at any given moment, and sometimes the OS will put you on hold while other things get some of the processing time.

Silas
  • 406
  • 2
  • 11
  • You're giving time to the millisecond - forever in CPU time - have you measured CPU ticks? That might give you a more accurate idea of the timing. – Silas Apr 15 '13 at 15:48
  • There is also inherent overhead in any threading - there are any number of possibilities that is causing this disparity. – Silas Apr 15 '13 at 15:51
  • Actually i measure it in us and then translate it to ms, but it can't matter so much i think – Yola Apr 15 '13 at 16:05
  • Could you suggest from where any thread can appear to interfere into program? – Yola Apr 15 '13 at 17:09