mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix threading issue in mt_tests
Resolves: NEO-5165 Change-Id: I1258cff22541c395c74c999fc7dd45be5e430dd1 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
80076a808c
commit
e34c44b425
@ -49,20 +49,23 @@ TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFro
|
||||
GraphicsAllocation *createdAllocations[maxThreads];
|
||||
std::thread threads[maxThreads];
|
||||
std::atomic<size_t> index(0);
|
||||
std::atomic<size_t> allocateCount(0);
|
||||
|
||||
auto createFunction = [&]() {
|
||||
size_t indexFree = index++;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, {});
|
||||
createdAllocations[indexFree] = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
EXPECT_NE(nullptr, createdAllocations[indexFree]);
|
||||
EXPECT_GE(1u, memoryManager->peekSharedBosSize());
|
||||
allocateCount++;
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < maxThreads; i++) {
|
||||
threads[i] = std::thread(createFunction);
|
||||
}
|
||||
|
||||
while (index < maxThreads) {
|
||||
EXPECT_GE(1u, memoryManager->sharingBufferObjects.size());
|
||||
while (allocateCount < maxThreads) {
|
||||
EXPECT_GE(1u, memoryManager->peekSharedBosSize());
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < maxThreads; i++) {
|
||||
|
Reference in New Issue
Block a user