MCPcopy Create free account
hub / github.com/Kitware/CMake / AllocateResources

Method AllocateResources

Source/CTest/cmCTestMultiProcessHandler.cxx:334–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334bool cmCTestMultiProcessHandler::AllocateResources(int index)
335{
336 if (!this->UseResourceSpec) {
337 return true;
338 }
339
340 // If the test needs unavailable resources then do not allocate anything
341 // because it will never run. We will issue the recorded errors instead.
342 if (!this->ResourceAvailabilityErrors[index].empty()) {
343 return true;
344 }
345
346 std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
347 if (!this->TryAllocateResources(index, allocations)) {
348 return false;
349 }
350
351 auto& allocatedResources = this->AllocatedResources[index];
352 allocatedResources.resize(this->Properties[index]->ResourceGroups.size());
353 for (auto const& it : allocations) {
354 for (auto const& alloc : it.second) {
355 bool result = this->ResourceAllocator.AllocateResource(
356 it.first, alloc.Id, alloc.SlotsNeeded);
357 (void)result;
358 assert(result);
359 allocatedResources[alloc.ProcessIndex][it.first].push_back(
360 { alloc.Id, static_cast<unsigned int>(alloc.SlotsNeeded) });
361 }
362 }
363
364 return true;
365}
366
367bool cmCTestMultiProcessHandler::TryAllocateResources(
368 int index,

Callers 1

StartNextTestsMethod · 0.95

Calls 6

TryAllocateResourcesMethod · 0.95
AllocateResourceMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected