| 47 | } |
| 48 | |
| 49 | bool TGpuOneDeviceWorker::RunIteration() { |
| 50 | bool shouldStop = false; |
| 51 | try { |
| 52 | const bool hasRunning = CheckRunningTasks(); |
| 53 | const bool isEmpty = InputTaskQueue.IsEmpty(); |
| 54 | |
| 55 | while (TempMemoryAllocatedObjects.size()) { |
| 56 | ObjectsToFree.push_back(std::move(TempMemoryAllocatedObjects.back())); |
| 57 | TempMemoryAllocatedObjects.pop_back(); |
| 58 | } |
| 59 | |
| 60 | if (!hasRunning && isEmpty) { |
| 61 | InputTaskQueue.Wait(TDuration::Max()); |
| 62 | } else if (!isEmpty) { |
| 63 | THolder<ICommand> task = InputTaskQueue.Dequeue(); |
| 64 | |
| 65 | if (task->GetCommandType() == ECommandType::SerializedCommand) { |
| 66 | task = reinterpret_cast<TSerializedCommand*>(task.Get())->Deserialize(); |
| 67 | } |
| 68 | |
| 69 | switch (task->GetCommandType()) { |
| 70 | case ECommandType::Reset: { |
| 71 | TResetCommand* init = dynamic_cast<TResetCommand*>(task.Get()); |
| 72 | WaitSubmitAndSync(); |
| 73 | Reset(*init); |
| 74 | break; |
| 75 | } |
| 76 | //could be run async |
| 77 | case ECommandType::StreamKernel: { |
| 78 | THolder<IGpuKernelTask> kernelTask(reinterpret_cast<IGpuKernelTask*>(task.Release())); |
| 79 | const ui32 streamId = kernelTask->GetStreamId(); |
| 80 | if (streamId == 0) { |
| 81 | WaitAllTaskToSubmit(); |
| 82 | SyncActiveStreams(true); |
| 83 | if (ObjectsToFree.size()) { |
| 84 | DeleteObjects(); |
| 85 | SyncStream(0); |
| 86 | } |
| 87 | } |
| 88 | auto& stream = *Streams[streamId]; |
| 89 | THolder<NKernel::IKernelContext> data; |
| 90 | data = kernelTask->PrepareExec(TempMemoryManager); |
| 91 | |
| 92 | stream.AddTask(std::move(kernelTask), std::move(data)); |
| 93 | break; |
| 94 | } |
| 95 | //synchronized on memory defragmentation |
| 96 | case ECommandType::MemoryAllocation: { |
| 97 | IAllocateMemoryTask* memoryTask = reinterpret_cast<IAllocateMemoryTask*>(task.Get()); |
| 98 | AllocateMemory(*memoryTask); |
| 99 | break; |
| 100 | } |
| 101 | case ECommandType::MemoryDeallocation: { |
| 102 | THolder<IFreeMemoryTask> freeMemoryTask(reinterpret_cast<IFreeMemoryTask*>(task.Release())); |
| 103 | ObjectsToFree.push_back(std::move(freeMemoryTask)); |
| 104 | WaitSubmitAndSync(); |
| 105 | break; |
| 106 | } |
nothing calls this directly
no test coverage detected