Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Robert Maynard
CMake
Commits
c544cb66
Commit
c544cb66
authored
Nov 05, 2019
by
Craig Scott
Committed by
Brad King
Nov 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CTest: Rename hardware -> resources for source code
parent
6ce27d3a
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
257 additions
and
252 deletions
+257
-252
Source/CMakeLists.txt
Source/CMakeLists.txt
+2
-2
Source/CTest/cmCTestBinPacker.cxx
Source/CTest/cmCTestBinPacker.cxx
+67
-65
Source/CTest/cmCTestBinPacker.h
Source/CTest/cmCTestBinPacker.h
+5
-5
Source/CTest/cmCTestMultiProcessHandler.cxx
Source/CTest/cmCTestMultiProcessHandler.cxx
+35
-35
Source/CTest/cmCTestMultiProcessHandler.h
Source/CTest/cmCTestMultiProcessHandler.h
+14
-14
Source/CTest/cmCTestResourceAllocator.cxx
Source/CTest/cmCTestResourceAllocator.cxx
+10
-10
Source/CTest/cmCTestResourceAllocator.h
Source/CTest/cmCTestResourceAllocator.h
+5
-5
Source/CTest/cmCTestResourceSpec.cxx
Source/CTest/cmCTestResourceSpec.cxx
+14
-14
Source/CTest/cmCTestResourceSpec.h
Source/CTest/cmCTestResourceSpec.h
+5
-5
Source/CTest/cmCTestRunTest.cxx
Source/CTest/cmCTestRunTest.cxx
+5
-5
Source/CTest/cmCTestRunTest.h
Source/CTest/cmCTestRunTest.h
+12
-9
Source/CTest/cmCTestTestCommand.cxx
Source/CTest/cmCTestTestCommand.cxx
+3
-3
Source/CTest/cmCTestTestCommand.h
Source/CTest/cmCTestTestCommand.h
+1
-1
Source/CTest/cmCTestTestHandler.cxx
Source/CTest/cmCTestTestHandler.cxx
+6
-6
Source/CTest/cmCTestTestHandler.h
Source/CTest/cmCTestTestHandler.h
+3
-3
Tests/CMakeLib/CMakeLists.txt
Tests/CMakeLib/CMakeLists.txt
+3
-3
Tests/CMakeLib/testCTestBinPacker.cxx
Tests/CMakeLib/testCTestBinPacker.cxx
+9
-9
Tests/CMakeLib/testCTestResourceAllocator.cxx
Tests/CMakeLib/testCTestResourceAllocator.cxx
+33
-33
Tests/CMakeLib/testCTestResourceSpec.cxx
Tests/CMakeLib/testCTestResourceSpec.cxx
+8
-8
Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec12.json
Tests/CMakeLib/testCTestResourceSpec_data/spec12.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec13.json
Tests/CMakeLib/testCTestResourceSpec_data/spec13.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
+0
-0
Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
+0
-0
Tests/RunCMake/CTestHardwareAllocation/cthwalloc.cxx
Tests/RunCMake/CTestHardwareAllocation/cthwalloc.cxx
+17
-17
No files found.
Source/CMakeLists.txt
View file @
c544cb66
...
...
@@ -919,8 +919,8 @@ set(CTEST_SRCS cmCTest.cxx
CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
CTest/cmCTestGenericHandler.cxx
CTest/cmCTestHandlerCommand.cxx
CTest/cmCTest
Hardwar
eAllocator.cxx
CTest/cmCTest
Hardwar
eSpec.cxx
CTest/cmCTest
Resourc
eAllocator.cxx
CTest/cmCTest
Resourc
eSpec.cxx
CTest/cmCTestLaunch.cxx
CTest/cmCTestMemCheckCommand.cxx
CTest/cmCTestMemCheckHandler.cxx
...
...
Source/CTest/cmCTestBinPacker.cxx
View file @
c544cb66
...
...
@@ -23,7 +23,7 @@ namespace {
/*
* The following algorithm is used to do two things:
*
* 1) Determine if a test's
hardwar
e requirements can fit within the
hardware
* 1) Determine if a test's
resourc
e requirements can fit within the
resources
* present on the system, and
* 2) Do the actual allocation
*
...
...
@@ -34,46 +34,46 @@ namespace {
* more combinations can be tried.
*/
template
<
typename
AllocationStrategy
>
static
bool
AllocateCTest
Hardware
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
const
std
::
vector
<
std
::
string
>&
hardware
Sorted
,
std
::
size_t
currentIndex
,
static
bool
AllocateCTest
Resources
(
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
const
std
::
vector
<
std
::
string
>&
resources
Sorted
,
std
::
size_t
currentIndex
,
std
::
vector
<
cmCTestBinPackerAllocation
*>&
allocations
)
{
// Iterate through all large enough resources until we find a solution
std
::
size_t
hardwar
eIndex
=
0
;
while
(
hardwar
eIndex
<
hardware
Sorted
.
size
())
{
auto
const
&
resource
=
hardware
.
at
(
hardwareSorted
[
hardwar
eIndex
]);
std
::
size_t
resourc
eIndex
=
0
;
while
(
resourc
eIndex
<
resources
Sorted
.
size
())
{
auto
const
&
resource
=
resources
.
at
(
resourcesSorted
[
resourc
eIndex
]);
if
(
resource
.
Free
()
>=
static_cast
<
unsigned
int
>
(
allocations
[
currentIndex
]
->
SlotsNeeded
))
{
// Preemptively allocate the resource
allocations
[
currentIndex
]
->
Id
=
hardwareSorted
[
hardwar
eIndex
];
allocations
[
currentIndex
]
->
Id
=
resourcesSorted
[
resourc
eIndex
];
if
(
currentIndex
+
1
>=
allocations
.
size
())
{
// We have a solution
return
true
;
}
// Move the resource up the list until it is sorted again
auto
hardware2
=
hardware
;
auto
hardware
Sorted2
=
hardware
Sorted
;
hardware2
[
hardware
Sorted2
[
hardwar
eIndex
]].
Locked
+=
auto
resources2
=
resources
;
auto
resources
Sorted2
=
resources
Sorted
;
resources2
[
resources
Sorted2
[
resourc
eIndex
]].
Locked
+=
allocations
[
currentIndex
]
->
SlotsNeeded
;
AllocationStrategy
::
IncrementalSort
(
hardware2
,
hardware
Sorted2
,
hardwar
eIndex
);
AllocationStrategy
::
IncrementalSort
(
resources2
,
resources
Sorted2
,
resourc
eIndex
);
// Recurse one level deeper
if
(
AllocateCTest
Hardware
<
AllocationStrategy
>
(
hardware2
,
hardware
Sorted2
,
currentIndex
+
1
,
allocations
))
{
if
(
AllocateCTest
Resources
<
AllocationStrategy
>
(
resources2
,
resources
Sorted2
,
currentIndex
+
1
,
allocations
))
{
return
true
;
}
}
// No solution found here, deallocate the resource and try the next one
allocations
[
currentIndex
]
->
Id
.
clear
();
auto
freeSlots
=
hardware
.
at
(
hardware
Sorted
.
at
(
hardwar
eIndex
)).
Free
();
auto
freeSlots
=
resources
.
at
(
resources
Sorted
.
at
(
resourc
eIndex
)).
Free
();
do
{
++
hardwar
eIndex
;
}
while
(
hardwar
eIndex
<
hardware
Sorted
.
size
()
&&
hardware
.
at
(
hardware
Sorted
.
at
(
hardwar
eIndex
)).
Free
()
==
++
resourc
eIndex
;
}
while
(
resourc
eIndex
<
resources
Sorted
.
size
()
&&
resources
.
at
(
resources
Sorted
.
at
(
resourc
eIndex
)).
Free
()
==
freeSlots
);
}
...
...
@@ -82,8 +82,8 @@ static bool AllocateCTestHardware(
}
template
<
typename
AllocationStrategy
>
static
bool
AllocateCTest
Hardware
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
static
bool
AllocateCTest
Resources
(
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
cmCTestBinPackerAllocation
>&
allocations
)
{
// Sort the resource requirements in descending order by slots needed
...
...
@@ -99,103 +99,105 @@ static bool AllocateCTestHardware(
});
// Sort the resources according to sort strategy
std
::
vector
<
std
::
string
>
hardware
Sorted
;
hardware
Sorted
.
reserve
(
hardware
.
size
());
for
(
auto
const
&
hw
:
hardware
)
{
hardware
Sorted
.
push_back
(
hw
.
first
);
std
::
vector
<
std
::
string
>
resources
Sorted
;
resources
Sorted
.
reserve
(
resources
.
size
());
for
(
auto
const
&
res
:
resources
)
{
resources
Sorted
.
push_back
(
res
.
first
);
}
AllocationStrategy
::
InitialSort
(
hardware
,
hardware
Sorted
);
AllocationStrategy
::
InitialSort
(
resources
,
resources
Sorted
);
// Do the actual allocation
return
AllocateCTest
Hardware
<
AllocationStrategy
>
(
hardware
,
hardware
Sorted
,
std
::
size_t
(
0
),
allocationsPtr
);
return
AllocateCTest
Resources
<
AllocationStrategy
>
(
resources
,
resources
Sorted
,
std
::
size_t
(
0
),
allocationsPtr
);
}
class
RoundRobinAllocationStrategy
{
public:
static
void
InitialSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
);
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
);
static
void
IncrementalSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
,
std
::
size_t
lastAllocatedIndex
);
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
,
std
::
size_t
lastAllocatedIndex
);
};
void
RoundRobinAllocationStrategy
::
InitialSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
)
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
)
{
std
::
stable_sort
(
hardware
Sorted
.
rbegin
(),
hardware
Sorted
.
rend
(),
[
&
hardware
](
const
std
::
string
&
id1
,
const
std
::
string
&
id2
)
{
return
hardware
.
at
(
id1
).
Free
()
<
hardware
.
at
(
id2
).
Free
();
resources
Sorted
.
rbegin
(),
resources
Sorted
.
rend
(),
[
&
resources
](
const
std
::
string
&
id1
,
const
std
::
string
&
id2
)
{
return
resources
.
at
(
id1
).
Free
()
<
resources
.
at
(
id2
).
Free
();
});
}
void
RoundRobinAllocationStrategy
::
IncrementalSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
,
std
::
size_t
lastAllocatedIndex
)
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
,
std
::
size_t
lastAllocatedIndex
)
{
auto
tmp
=
hardware
Sorted
[
lastAllocatedIndex
];
auto
tmp
=
resources
Sorted
[
lastAllocatedIndex
];
std
::
size_t
i
=
lastAllocatedIndex
;
while
(
i
<
hardwareSorted
.
size
()
-
1
&&
hardware
.
at
(
hardwareSorted
[
i
+
1
]).
Free
()
>
hardware
.
at
(
tmp
).
Free
())
{
hardwareSorted
[
i
]
=
hardwareSorted
[
i
+
1
];
while
(
i
<
resourcesSorted
.
size
()
-
1
&&
resources
.
at
(
resourcesSorted
[
i
+
1
]).
Free
()
>
resources
.
at
(
tmp
).
Free
())
{
resourcesSorted
[
i
]
=
resourcesSorted
[
i
+
1
];
++
i
;
}
hardware
Sorted
[
i
]
=
tmp
;
resources
Sorted
[
i
]
=
tmp
;
}
class
BlockAllocationStrategy
{
public:
static
void
InitialSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
);
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
);
static
void
IncrementalSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
,
std
::
size_t
lastAllocatedIndex
);
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
,
std
::
size_t
lastAllocatedIndex
);
};
void
BlockAllocationStrategy
::
InitialSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
)
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
std
::
string
>&
resources
Sorted
)
{
std
::
stable_sort
(
hardware
Sorted
.
rbegin
(),
hardware
Sorted
.
rend
(),
[
&
hardware
](
const
std
::
string
&
id1
,
const
std
::
string
&
id2
)
{
return
hardware
.
at
(
id1
).
Free
()
<
hardware
.
at
(
id2
).
Free
();
resources
Sorted
.
rbegin
(),
resources
Sorted
.
rend
(),
[
&
resources
](
const
std
::
string
&
id1
,
const
std
::
string
&
id2
)
{
return
resources
.
at
(
id1
).
Free
()
<
resources
.
at
(
id2
).
Free
();
});
}
void
BlockAllocationStrategy
::
IncrementalSort
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
,
std
::
vector
<
std
::
string
>&
hardware
Sorted
,
std
::
size_t
lastAllocatedIndex
)
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
,
std
::
vector
<
std
::
string
>&
resources
Sorted
,
std
::
size_t
lastAllocatedIndex
)
{
auto
tmp
=
hardware
Sorted
[
lastAllocatedIndex
];
auto
tmp
=
resources
Sorted
[
lastAllocatedIndex
];
std
::
size_t
i
=
lastAllocatedIndex
;
while
(
i
>
0
)
{
hardware
Sorted
[
i
]
=
hardware
Sorted
[
i
-
1
];
resources
Sorted
[
i
]
=
resources
Sorted
[
i
-
1
];
--
i
;
}
hardware
Sorted
[
i
]
=
tmp
;
resources
Sorted
[
i
]
=
tmp
;
}
}
bool
cmAllocateCTest
Hardware
RoundRobin
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
bool
cmAllocateCTest
Resources
RoundRobin
(
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
cmCTestBinPackerAllocation
>&
allocations
)
{
return
AllocateCTest
Hardware
<
RoundRobinAllocationStrategy
>
(
hardware
,
allocations
);
return
AllocateCTest
Resources
<
RoundRobinAllocationStrategy
>
(
resources
,
allocations
);
}
bool
cmAllocateCTest
Hardware
Block
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
bool
cmAllocateCTest
Resources
Block
(
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
cmCTestBinPackerAllocation
>&
allocations
)
{
return
AllocateCTestHardware
<
BlockAllocationStrategy
>
(
hardware
,
allocations
);
return
AllocateCTestResources
<
BlockAllocationStrategy
>
(
resources
,
allocations
);
}
Source/CTest/cmCTestBinPacker.h
View file @
c544cb66
...
...
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
#include "cmCTest
Hardwar
eAllocator.h"
#include "cmCTest
Resourc
eAllocator.h"
struct
cmCTestBinPackerAllocation
{
...
...
@@ -20,12 +20,12 @@ struct cmCTestBinPackerAllocation
bool
operator
!=
(
const
cmCTestBinPackerAllocation
&
other
)
const
;
};
bool
cmAllocateCTest
Hardware
RoundRobin
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
bool
cmAllocateCTest
Resources
RoundRobin
(
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
cmCTestBinPackerAllocation
>&
allocations
);
bool
cmAllocateCTest
Hardware
Block
(
const
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>&
hardware
,
bool
cmAllocateCTest
Resources
Block
(
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>&
resources
,
std
::
vector
<
cmCTestBinPackerAllocation
>&
allocations
);
#endif
Source/CTest/cmCTestMultiProcessHandler.cxx
View file @
c544cb66
...
...
@@ -140,7 +140,7 @@ void cmCTestMultiProcessHandler::RunTests()
assert
(
this
->
Completed
==
this
->
Total
);
assert
(
this
->
Tests
.
empty
());
}
assert
(
this
->
All
Hardware
Available
());
assert
(
this
->
All
Resources
Available
());
this
->
MarkFinished
();
this
->
UpdateCostData
();
...
...
@@ -177,9 +177,9 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
}
testRun
->
SetIndex
(
test
);
testRun
->
SetTestProperties
(
this
->
Properties
[
test
]);
if
(
this
->
TestHandler
->
Use
Hardwar
eSpec
)
{
testRun
->
SetUseAllocated
Hardware
(
true
);
testRun
->
SetAllocated
Hardware
(
this
->
Allocated
Hardware
[
test
]);
if
(
this
->
TestHandler
->
Use
Resourc
eSpec
)
{
testRun
->
SetUseAllocated
Resources
(
true
);
testRun
->
SetAllocated
Resources
(
this
->
Allocated
Resources
[
test
]);
}
// Find any failed dependencies for this test. We assume the more common
...
...
@@ -194,7 +194,7 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
// working directory because FinishTestProcess() will try to unlock them
this
->
LockResources
(
test
);
if
(
!
this
->
TestsHaveSufficient
Hardware
[
test
])
{
if
(
!
this
->
TestsHaveSufficient
Resources
[
test
])
{
testRun
->
StartFailure
(
"Insufficient resources"
);
this
->
FinishTestProcess
(
testRun
,
false
);
return
false
;
...
...
@@ -218,26 +218,26 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
return
false
;
}
bool
cmCTestMultiProcessHandler
::
Allocate
Hardware
(
int
index
)
bool
cmCTestMultiProcessHandler
::
Allocate
Resources
(
int
index
)
{
if
(
!
this
->
TestHandler
->
Use
Hardwar
eSpec
)
{
if
(
!
this
->
TestHandler
->
Use
Resourc
eSpec
)
{
return
true
;
}
std
::
map
<
std
::
string
,
std
::
vector
<
cmCTestBinPackerAllocation
>>
allocations
;
if
(
!
this
->
TryAllocate
Hardware
(
index
,
allocations
))
{
if
(
!
this
->
TryAllocate
Resources
(
index
,
allocations
))
{
return
false
;
}
auto
&
allocated
Hardware
=
this
->
Allocated
Hardware
[
index
];
allocated
Hardware
.
resize
(
this
->
Properties
[
index
]
->
ResourceGroups
.
size
());
auto
&
allocated
Resources
=
this
->
Allocated
Resources
[
index
];
allocated
Resources
.
resize
(
this
->
Properties
[
index
]
->
ResourceGroups
.
size
());
for
(
auto
const
&
it
:
allocations
)
{
for
(
auto
const
&
alloc
:
it
.
second
)
{
bool
result
=
this
->
Hardwar
eAllocator
.
AllocateResource
(
bool
result
=
this
->
Resourc
eAllocator
.
AllocateResource
(
it
.
first
,
alloc
.
Id
,
alloc
.
SlotsNeeded
);
(
void
)
result
;
assert
(
result
);
allocated
Hardware
[
alloc
.
ProcessIndex
][
it
.
first
].
push_back
(
allocated
Resources
[
alloc
.
ProcessIndex
][
it
.
first
].
push_back
(
{
alloc
.
Id
,
static_cast
<
unsigned
int
>
(
alloc
.
SlotsNeeded
)
});
}
}
...
...
@@ -245,7 +245,7 @@ bool cmCTestMultiProcessHandler::AllocateHardware(int index)
return
true
;
}
bool
cmCTestMultiProcessHandler
::
TryAllocate
Hardware
(
bool
cmCTestMultiProcessHandler
::
TryAllocate
Resources
(
int
index
,
std
::
map
<
std
::
string
,
std
::
vector
<
cmCTestBinPackerAllocation
>>&
allocations
)
{
...
...
@@ -262,13 +262,13 @@ bool cmCTestMultiProcessHandler::TryAllocateHardware(
++
processIndex
;
}
auto
const
&
available
Hardware
=
this
->
Hardwar
eAllocator
.
GetResources
();
auto
const
&
available
Resources
=
this
->
Resourc
eAllocator
.
GetResources
();
for
(
auto
&
it
:
allocations
)
{
if
(
!
available
Hardware
.
count
(
it
.
first
))
{
if
(
!
available
Resources
.
count
(
it
.
first
))
{
return
false
;
}
if
(
!
cmAllocateCTest
Hardware
RoundRobin
(
available
Hardware
.
at
(
it
.
first
),
it
.
second
))
{
if
(
!
cmAllocateCTest
Resources
RoundRobin
(
available
Resources
.
at
(
it
.
first
),
it
.
second
))
{
return
false
;
}
}
...
...
@@ -276,19 +276,19 @@ bool cmCTestMultiProcessHandler::TryAllocateHardware(
return
true
;
}
void
cmCTestMultiProcessHandler
::
Deallocate
Hardware
(
int
index
)
void
cmCTestMultiProcessHandler
::
Deallocate
Resources
(
int
index
)
{
if
(
!
this
->
TestHandler
->
Use
Hardwar
eSpec
)
{
if
(
!
this
->
TestHandler
->
Use
Resourc
eSpec
)
{
return
;
}
{
auto
&
allocated
Hardware
=
this
->
Allocated
Hardware
[
index
];
for
(
auto
const
&
processAlloc
:
allocated
Hardware
)
{
auto
&
allocated
Resources
=
this
->
Allocated
Resources
[
index
];
for
(
auto
const
&
processAlloc
:
allocated
Resources
)
{
for
(
auto
const
&
it
:
processAlloc
)
{
auto
resourceType
=
it
.
first
;
for
(
auto
const
&
it2
:
it
.
second
)
{
bool
success
=
this
->
Hardwar
eAllocator
.
DeallocateResource
(
bool
success
=
this
->
Resourc
eAllocator
.
DeallocateResource
(
resourceType
,
it2
.
Id
,
it2
.
Slots
);
(
void
)
success
;
assert
(
success
);
...
...
@@ -296,12 +296,12 @@ void cmCTestMultiProcessHandler::DeallocateHardware(int index)
}
}
}
this
->
Allocated
Hardware
.
erase
(
index
);
this
->
Allocated
Resources
.
erase
(
index
);
}
bool
cmCTestMultiProcessHandler
::
All
Hardware
Available
()
bool
cmCTestMultiProcessHandler
::
All
Resources
Available
()
{
for
(
auto
const
&
it
:
this
->
Hardwar
eAllocator
.
GetResources
())
{
for
(
auto
const
&
it
:
this
->
Resourc
eAllocator
.
GetResources
())
{
for
(
auto
const
&
it2
:
it
.
second
)
{
if
(
it2
.
second
.
Locked
!=
0
)
{
return
false
;
...
...
@@ -312,13 +312,13 @@ bool cmCTestMultiProcessHandler::AllHardwareAvailable()
return
true
;
}
void
cmCTestMultiProcessHandler
::
Check
Hardware
Available
()
void
cmCTestMultiProcessHandler
::
Check
Resources
Available
()
{
for
(
auto
test
:
this
->
SortedTests
)
{
std
::
map
<
std
::
string
,
std
::
vector
<
cmCTestBinPackerAllocation
>>
allocations
;
this
->
TestsHaveSufficient
Hardware
[
test
]
=
!
this
->
TestHandler
->
Use
Hardwar
eSpec
||
this
->
TryAllocate
Hardware
(
test
,
allocations
);
this
->
TestsHaveSufficient
Resources
[
test
]
=
!
this
->
TestHandler
->
Use
Resourc
eSpec
||
this
->
TryAllocate
Resources
(
test
,
allocations
);
}
}
...
...
@@ -404,10 +404,10 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
}
}
// Allocate
hardware
if
(
this
->
TestsHaveSufficient
Hardware
[
test
]
&&
!
this
->
Allocate
Hardware
(
test
))
{
this
->
Deallocate
Hardware
(
test
);
// Allocate
resources
if
(
this
->
TestsHaveSufficient
Resources
[
test
]
&&
!
this
->
Allocate
Resources
(
test
))
{
this
->
Deallocate
Resources
(
test
);
return
false
;
}
...
...
@@ -417,7 +417,7 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
}
// This test was not able to start because it is waiting
// on depends to run
this
->
Deallocate
Hardware
(
test
);
this
->
Deallocate
Resources
(
test
);
return
false
;
}
...
...
@@ -602,7 +602,7 @@ void cmCTestMultiProcessHandler::FinishTestProcess(cmCTestRunTest* runner,
this
->
TestFinishMap
[
test
]
=
true
;
this
->
TestRunningMap
[
test
]
=
false
;
this
->
WriteCheckpoint
(
test
);
this
->
Deallocate
Hardware
(
test
);
this
->
Deallocate
Resources
(
test
);
this
->
UnlockResources
(
test
);
this
->
RunningCount
-=
GetProcessorsUsed
(
test
);
...
...
Source/CTest/cmCTestMultiProcessHandler.h
View file @
c544cb66
...
...
@@ -14,13 +14,13 @@
#include "cm_uv.h"
#include "cmCTest
Hardwar
eAllocator.h"
#include "cmCTest
Resourc
eAllocator.h"
#include "cmCTestTestHandler.h"
#include "cmUVHandlePtr.h"
class
cmCTest
;
struct
cmCTestBinPackerAllocation
;
class
cmCTest
Hardwar
eSpec
;
class
cmCTest
Resourc
eSpec
;
class
cmCTestRunTest
;
/** \class cmCTestMultiProcessHandler
...
...
@@ -47,7 +47,7 @@ public:
:
public
std
::
map
<
int
,
cmCTestTestHandler
::
cmCTestTestProperties
*>
{
};
struct
Hardwar
eAllocation
struct
Resourc
eAllocation
{
std
::
string
Id
;
unsigned
int
Slots
;
...
...
@@ -87,12 +87,12 @@ public:
void
SetQuiet
(
bool
b
)
{
this
->
Quiet
=
b
;
}
void
Init
Hardwar
eAllocator
(
const
cmCTest
Hardwar
eSpec
&
spec
)
void
Init
Resourc
eAllocator
(
const
cmCTest
Resourc
eSpec
&
spec
)
{
this
->
Hardwar
eAllocator
.
InitializeFrom
Hardwar
eSpec
(
spec
);
this
->
Resourc
eAllocator
.
InitializeFrom
Resourc
eSpec
(
spec
);
}
void
Check
Hardware
Available
();
void
Check
Resources
Available
();
protected:
// Start the next test or tests as many as are allowed by
...
...
@@ -137,13 +137,13 @@ protected:
void
LockResources
(
int
index
);
void
UnlockResources
(
int
index
);
bool
Allocate
Hardware
(
int
index
);
bool
TryAllocate
Hardware
(
bool
Allocate
Resources
(
int
index
);
bool
TryAllocate
Resources
(
int
index
,
std
::
map
<
std
::
string
,
std
::
vector
<
cmCTestBinPackerAllocation
>>&
allocations
);
void
Deallocate
Hardware
(
int
index
);
bool
All
Hardware
Available
();
void
Deallocate
Resources
(
int
index
);
bool
All
Resources
Available
();
// map from test number to set of depend tests
TestMap
Tests
;
...
...
@@ -166,10 +166,10 @@ protected:
std
::
vector
<
std
::
string
>
LastTestsFailed
;
std
::
set
<
std
::
string
>
LockedResources
;
std
::
map
<
int
,
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
vector
<
Hardwar
eAllocation
>>>>
Allocated
Hardware
;
std
::
map
<
int
,
bool
>
TestsHaveSufficient
Hardware
;
cmCTest
Hardwar
eAllocator
Hardwar
eAllocator
;
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
vector
<
Resourc
eAllocation
>>>>
Allocated
Resources
;
std
::
map
<
int
,
bool
>
TestsHaveSufficient
Resources
;
cmCTest
Resourc
eAllocator
Resourc
eAllocator
;
std
::
vector
<
cmCTestTestHandler
::
cmCTestTestResult
>*
TestResults
;
size_t
ParallelLevel
;
// max number of process that can be run at once
unsigned
long
TestLoad
;
...
...
Source/CTest/cmCTest
Hardwar
eAllocator.cxx
→
Source/CTest/cmCTest
Resourc
eAllocator.cxx
View file @
c544cb66
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTest
Hardwar
eAllocator.h"
#include "cmCTest
Resourc
eAllocator.h"
#include <utility>
#include <vector>
#include "cmCTest
Hardwar
eSpec.h"
#include "cmCTest
Resourc
eSpec.h"
void
cmCTest
Hardwar
eAllocator
::
InitializeFrom
Hardwar
eSpec
(
const
cmCTest
Hardwar
eSpec
&
spec
)
void
cmCTest
Resourc
eAllocator
::
InitializeFrom
Resourc
eSpec
(
const
cmCTest
Resourc
eSpec
&
spec
)
{
this
->
Resources
.
clear
();
...
...
@@ -23,13 +23,13 @@ void cmCTestHardwareAllocator::InitializeFromHardwareSpec(
}
const
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
cmCTest
Hardwar
eAllocator
::
Resource
>>&
cmCTest
Hardwar
eAllocator
::
GetResources
()
const
std
::
map
<
std
::
string
,
cmCTest
Resourc
eAllocator
::
Resource
>>&
cmCTest
Resourc
eAllocator
::
GetResources
()
const
{
return
this
->
Resources
;
}
bool
cmCTest
Hardwar
eAllocator
::
AllocateResource
(
const
std
::
string
&
name
,
bool
cmCTest
Resourc
eAllocator
::
AllocateResource
(
const
std
::
string
&
name
,
const
std
::
string
&
id
,
unsigned
int
slots
)
{
...
...
@@ -51,7 +51,7 @@ bool cmCTestHardwareAllocator::AllocateResource(const std::string& name,
return
true
;
}
bool
cmCTest
Hardwar
eAllocator
::
DeallocateResource
(
const
std
::
string
&
name
,
bool
cmCTest
Resourc
eAllocator
::
DeallocateResource
(
const
std
::
string
&
name
,
const
std
::
string
&
id
,
unsigned
int
slots
)
{
...
...
@@ -73,13 +73,13 @@ bool cmCTestHardwareAllocator::DeallocateResource(const std::string& name,
return
true
;
}
bool
cmCTest
Hardwar
eAllocator
::
Resource
::
operator
==
(
bool
cmCTest
Resourc
eAllocator
::
Resource
::
operator
==
(
const
Resource
&
other
)
const
{
return
this
->
Total
==
other
.
Total
&&
this
->
Locked
==
other
.
Locked
;
}
bool
cmCTest
Hardwar
eAllocator
::
Resource
::
operator
!=
(