为什么连续启动调度需要不同的时间
Why Dispatches started consecutively take different time?
我有这个程序:
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 ) {}
第一次迭代仅持续26ms,第二次迭代持续46ms ?
只是以防着色器:
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);
}
}
但我认为不应该每次出发都花不同的时间。
有趣的如果我注释掉"if (I == STEPS/2)"这行会怎么样?
编辑:据我所知,这是由于兑现
最可能的选择(在我看来)是操作系统中线程之间的上下文切换。操作时间越长,操作系统就越有可能在中途暂停。
你的程序在任何时候都不是唯一在进行的事情,有时操作系统会让你暂停,而其他事情会得到一些处理时间。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- 从持续时间构造std::chrono::system_clock::time_point
- 模板元程序查找相似的连续类型名称
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- while循环中while循环的时间复杂度是多少
- 使用简单类型列表实现的指数编译时间.为什么
- 是否可以在编译时初始化数组,以便在运行时不会花费时间?
- 在已经使用Git的情况下减少编译时间
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何将包含epoch时间的十六进制字符串转换为time_t
- 从文本文件中读取时钟时间和事件时间并进行处理
- 具有未知值时的时间复杂性
- 如何减少花费的时间
- 连续光线投射之间的时间延迟
- 持续的时间访问是否在某个时候意味着连续内存
- 如何与时间连续创建对象?C 游戏
- std::list c++是连续的,那么在序列中的任何位置插入和擦除操作都需要恒定的时间
- c ++:TCP服务器"bind"功能失败(errno 98),如果我在两次连续应用程序启动之间没有等待足够的时间
- 为什么连续启动调度需要不同的时间
- 使用libevent读取连续的HTTP流并在随机时间发送数据