Refactor ult's for preemption enabling part 2
Change-Id: If8e335e87f3a78d35cab12a17880fb1922d479f5
This commit is contained in:
parent
541735d932
commit
2bc2869fe1
|
@ -45,8 +45,9 @@ set(RUNTIME_SRCS_DLL_BASE
|
|||
)
|
||||
|
||||
set(RUNTIME_SRCS_DLL_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/options.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/allocator_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/drm_neo_create.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/options.cpp
|
||||
)
|
||||
|
||||
set(RUNTIME_SRCS_DLL_WINDOWS
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
size_t getSizeToMap() {
|
||||
return static_cast<size_t>(alignUp(4 * GB - 8096, 4096));
|
||||
}
|
||||
} // namespace OCLRT
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
set(RUNTIME_SRCS_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/d3d_sharing_functions.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
|
||||
namespace OCLRT {
|
||||
size_t getSizeToMap();
|
||||
} // namespace OCLRT
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include "runtime/os_interface/32bit_memory.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
|
@ -105,7 +106,7 @@ OCLRT::Allocator32bit::Allocator32bit() : Allocator32bit(new OsInternals) {
|
|||
OCLRT::Allocator32bit::Allocator32bit(Allocator32bit::OsInternals *osInternalsIn) : osInternals(osInternalsIn) {
|
||||
|
||||
if (DebugManager.flags.UseNewHeapAllocator.get()) {
|
||||
size_t sizeToMap = alignUp(4 * GB - 8096, 4096);
|
||||
size_t sizeToMap = getSizeToMap();
|
||||
void *ptr = MAP_FAILED;
|
||||
|
||||
ptr = this->osInternals->mmapFunction(nullptr, sizeToMap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
|
||||
|
|
|
@ -1042,7 +1042,7 @@ HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeWhenEnqueueK
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
auto ret = pCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
|
@ -1106,7 +1106,6 @@ HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeAndBatchedKe
|
|||
EXPECT_TRUE(mockedSubmissionsAggregator->peekCmdBufferList().peekIsEmpty());
|
||||
EXPECT_EQ(1, mockCsrmockCsr->flushCalledCount);
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeWhenKernelIsEnqueuedTwiceThenTwoSubmissionsAreRecorded) {
|
||||
auto mockCsrmockCsr = new MockCsrHw2<FamilyType>(pDevice->getHardwareInfo());
|
||||
mockCsrmockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
|
||||
|
@ -1115,7 +1114,7 @@ HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeWhenKernelIs
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsrmockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
//make sure csr emits something
|
||||
mockCsrmockCsr->overrideMediaVFEStateDirty(true);
|
||||
|
@ -1357,7 +1356,7 @@ HWTEST_F(EnqueueKernelTest, givenOutOfOrderCommandQueueWhenEnqueueKernelIsMadeTh
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
clEnqueueNDRangeKernel(ooq, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
|
@ -1379,7 +1378,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelIsMadeThenP
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
clEnqueueNDRangeKernel(inOrderQueue, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
|
@ -1401,7 +1400,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelThatHasShar
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
mockKernel.mockKernel->setUsingSharedArgs(true);
|
||||
clEnqueueNDRangeKernel(inOrderQueue, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
|
@ -1419,7 +1418,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelThatHasShar
|
|||
mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
|
||||
pDevice->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
mockKernel.mockKernel->setUsingSharedArgs(true);
|
||||
clEnqueueNDRangeKernel(this->pCmdQ, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
|
@ -1438,7 +1437,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelReturningEv
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
cl_event event;
|
||||
|
||||
|
@ -1465,7 +1464,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelReturningEv
|
|||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
cl_event event;
|
||||
|
||||
|
@ -1491,7 +1490,7 @@ HWTEST_F(EnqueueKernelTest, givenOutOfOrderCommandQueueWhenEnqueueKernelReturnin
|
|||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0};
|
||||
auto inOrderQueue = clCreateCommandQueueWithProperties(context, pDevice, props, nullptr);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice);
|
||||
MockKernelWithInternals mockKernel(*pDevice, context);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
cl_event event;
|
||||
|
||||
|
@ -1575,6 +1574,7 @@ TEST_F(EnqueueKernelTest, givenKernelWhenAllArgsAreNotAndEventExistSetThenClEnqu
|
|||
retVal = clEnqueueNDRangeKernel(pCmdQ2, kernel.get(), 1, nullptr, globalWorkSize, localWorkSize, 0, nullptr, &event);
|
||||
EXPECT_EQ(CL_INVALID_KERNEL_ARGS, retVal);
|
||||
|
||||
clFlush(pCmdQ2);
|
||||
clReleaseCommandQueue(pCmdQ2);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@
|
|||
|
||||
using namespace OCLRT;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::_;
|
||||
|
||||
HWTEST_F(UltCommandStreamReceiverTest, givenThreadArbitrationPolicyNotChangedWhenEstimatingPreambleCmdSizeThenReturnItsValue) {
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
|
@ -1817,6 +1817,10 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEnabledPreemptionWhenFlushTas
|
|||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithPCWhenPreambleSentAndL3ConfigChanged) {
|
||||
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
|
||||
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
|
||||
typedef typename FamilyType::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
|
||||
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
typedef typename FamilyType::MEDIA_VFE_STATE MEDIA_VFE_STATE;
|
||||
CsrSizeRequestFlags csrSizeRequest = {};
|
||||
|
||||
commandStream.getSpace(sizeof(PIPE_CONTROL));
|
||||
|
@ -1829,13 +1833,18 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithPCWhenPreambleSentAnd
|
|||
commandStreamReceiver.isPreambleSent = true;
|
||||
commandStreamReceiver.lastPreemptionMode = pDevice->getPreemptionMode();
|
||||
commandStreamReceiver.lastMediaSamplerConfig = 0;
|
||||
commandStreamReceiver.lastSentCoherencyRequest = false;
|
||||
commandStreamReceiver.lastSentThreadArbitrationPolicy = commandStreamReceiver.requiredThreadArbitrationPolicy;
|
||||
csrSizeRequest.l3ConfigChanged = true;
|
||||
commandStreamReceiver.overrideCsrSizeReqFlags(csrSizeRequest);
|
||||
|
||||
auto &csrCS = commandStreamReceiver.getCS();
|
||||
size_t sizeNeeded = commandStreamReceiver.getRequiredCmdStreamSizeAligned(flushTaskFlags);
|
||||
size_t sizeNeeded = 2 * sizeof(PIPE_CONTROL) + sizeof(MI_LOAD_REGISTER_IMM) + sizeof(MEDIA_VFE_STATE) +
|
||||
sizeof(MI_BATCH_BUFFER_START) + sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL) +
|
||||
commandStreamReceiver.getRequiredPipeControlSize();
|
||||
|
||||
auto expectedUsed = csrCS.getUsed() + sizeNeeded;
|
||||
expectedUsed = alignUp(expectedUsed, MemoryConstants::cacheLineSize);
|
||||
|
||||
commandStreamReceiver.flushTask(commandStream, 0, dsh, ioh, ssh, taskLevel, flushTaskFlags);
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ TEST_F(CompilerInterfaceTest, BuildWithDebugData) {
|
|||
retVal = pProgram->getInfo(CL_PROGRAM_DEBUG_INFO_INTEL, debugDataSize, nullptr, &retData);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(numDevices * sizeof(debugData), retData);
|
||||
cip->shutdown();
|
||||
|
||||
delete[] debugData;
|
||||
delete cip;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
namespace OCLRT {
|
||||
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
|
||||
CompilerInterface::getInstance();
|
||||
std::unique_ptr<MockCompilerInterface> mockCompilerInterface(new MockCompilerInterface());
|
||||
mockCompilerInterface->overrideGlobalCompilerInterface();
|
||||
mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary();
|
||||
|
|
|
@ -120,6 +120,7 @@ set(IGDRCL_SRCS_LIB_ULT_ENV_WINDOWS
|
|||
|
||||
set(IGDRCL_SRCS_LIB_ULT_ENV_LINUX
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/allocator_helper.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
set(IGDRCL_SRCS_linux_tests
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main_linux.cpp
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/allocator_helper.cpp
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp
|
||||
)
|
||||
|
||||
|
@ -30,6 +31,7 @@ set(IGDRCL_SRCS_linux_dll_tests
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_layer.h
|
||||
${IGDRCL_SOURCE_DIR}/runtime/os_interface/debug_settings_manager.cpp
|
||||
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/allocator_helper.cpp
|
||||
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/drm_neo_create.cpp
|
||||
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/options.cpp
|
||||
)
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "mock_os_layer.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
#include "unit_tests/custom_event_listener.h"
|
||||
#include "test.h"
|
||||
|
||||
|
@ -289,6 +292,10 @@ TEST_F(DrmTests, failOnInvalidDeviceName) {
|
|||
EXPECT_EQ(ptr, nullptr);
|
||||
}
|
||||
|
||||
TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedValueReturned) {
|
||||
EXPECT_EQ((alignUp(4 * GB - 8096, 4096)), OCLRT::getSizeToMap());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
bool useDefaultListener = false;
|
||||
|
||||
|
|
|
@ -170,9 +170,6 @@ std::string getRunPath(char *argv0) {
|
|||
return res;
|
||||
}
|
||||
|
||||
extern int preemptionModeFromDebugManager;
|
||||
int preemptionModeFromDebugManager = -2;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int retVal = 0;
|
||||
bool useDefaultListener = false;
|
||||
|
@ -365,10 +362,6 @@ int main(int argc, char **argv) {
|
|||
gEnvironment->setMockFileNames(fclDebugVars.fileName, igcDebugVars.fileName);
|
||||
gEnvironment->setDefaultDebugVars(fclDebugVars, igcDebugVars, device);
|
||||
|
||||
// globally override-disable preemption to speed-up test execution
|
||||
preemptionModeFromDebugManager = OCLRT::DebugManager.flags.ForcePreemptionMode.get();
|
||||
OCLRT::DebugManager.flags.ForcePreemptionMode.set(static_cast<int>(PreemptionMode::Disabled));
|
||||
|
||||
#if defined(__linux__)
|
||||
//ULTs timeout
|
||||
if (enable_alarm) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -191,9 +191,7 @@ struct MockFclOclDeviceCtx : MockCIF<IGC::FclOclDeviceCtxTagOCL> {
|
|||
class MockCompilerInterface : public CompilerInterface {
|
||||
public:
|
||||
~MockCompilerInterface() {
|
||||
if (originalGlobalCompilerInterface != nullptr) {
|
||||
CompilerInterface::pInstance = originalGlobalCompilerInterface;
|
||||
}
|
||||
CompilerInterface::pInstance = originalGlobalCompilerInterface;
|
||||
}
|
||||
|
||||
bool isCompilerAvailable() const {
|
||||
|
@ -318,4 +316,4 @@ template <>
|
|||
inline std::map<const Device *, MockCompilerInterface::fclDevCtxUptr> &MockCompilerInterface::getDeviceContexts<IGC::FclOclDeviceCtxTagOCL>() {
|
||||
return getFclDeviceContexts();
|
||||
}
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -63,8 +63,6 @@ MockContext::~MockContext() {
|
|||
delete specialQueue;
|
||||
specialQueue = nullptr;
|
||||
}
|
||||
CompilerInterface::shutdown();
|
||||
BuiltIns::shutDown();
|
||||
if (memoryManager->isAsyncDeleterEnabled()) {
|
||||
memoryManager->getDeferredDeleter()->removeClient();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,20 @@ class MockDevice : public Device {
|
|||
void setSourceLevelDebuggerActive(bool active) {
|
||||
this->deviceInfo.sourceLevelDebuggerActive = active;
|
||||
}
|
||||
template <typename T>
|
||||
static T *createWithMemoryManager(const HardwareInfo *pHwInfo,
|
||||
MemoryManager *memManager) {
|
||||
pHwInfo = getDeviceInitHwInfo(pHwInfo);
|
||||
T *device = new T(*pHwInfo);
|
||||
if (memManager) {
|
||||
device->setMemoryManager(memManager);
|
||||
}
|
||||
if (false == createDeviceImpl(pHwInfo, true, *device)) {
|
||||
delete device;
|
||||
return nullptr;
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
private:
|
||||
bool forceWhitelistedRegs = false;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
set(IGDRCL_SRCS_tests_os_interface_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.cpp
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
size_t getSizeToMap() {
|
||||
return static_cast<size_t>(1 * 1024 * 1024u);
|
||||
}
|
||||
} // namespace OCLRT
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
|
||||
TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedValueReturned) {
|
||||
EXPECT_EQ(1 * 1024 * 1024u, OCLRT::getSizeToMap());
|
||||
}
|
|
@ -705,6 +705,7 @@ class DrmCommandStreamEnhancedFixture
|
|||
DrmMockCustom *mock;
|
||||
DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr = nullptr;
|
||||
DrmMemoryManager *mm = nullptr;
|
||||
MockDevice *device = nullptr;
|
||||
DebugManagerStateRestore *dbgState;
|
||||
|
||||
void SetUp() {
|
||||
|
@ -719,12 +720,15 @@ class DrmCommandStreamEnhancedFixture
|
|||
ASSERT_NE(nullptr, csr);
|
||||
mm = reinterpret_cast<DrmMemoryManager *>(csr->createMemoryManager(false));
|
||||
ASSERT_NE(nullptr, mm);
|
||||
device = MockDevice::createWithMemoryManager<MockDevice>(platformDevices[0], mm);
|
||||
ASSERT_NE(nullptr, device);
|
||||
mm->device = device;
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
//And close at destruction
|
||||
delete csr;
|
||||
delete mm;
|
||||
delete device;
|
||||
delete mock;
|
||||
delete dbgState;
|
||||
}
|
||||
|
@ -942,19 +946,13 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenDrmCsrCreatedWithInactiveGemCloseWor
|
|||
class DrmCommandStreamBatchingTests : public Test<DrmCommandStreamEnhancedFixture> {
|
||||
public:
|
||||
DrmAllocation *tagAllocation;
|
||||
DrmAllocation *preemptionAllocation = nullptr;
|
||||
DrmAllocation *preemptionAllocation;
|
||||
void SetUp() override {
|
||||
DrmCommandStreamEnhancedFixture::SetUp();
|
||||
tagAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
if (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) {
|
||||
preemptionAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
}
|
||||
tagAllocation = static_cast<DrmAllocation *>(device->getTagAllocation());
|
||||
preemptionAllocation = static_cast<DrmAllocation *>(device->getPreemptionAllocation());
|
||||
}
|
||||
void TearDown() override {
|
||||
if (preemptionAllocation) {
|
||||
mm->freeGraphicsMemory(preemptionAllocation);
|
||||
}
|
||||
mm->freeGraphicsMemory(tagAllocation);
|
||||
DrmCommandStreamEnhancedFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
@ -974,10 +972,10 @@ TEST_F(DrmCommandStreamBatchingTests, givenCSRWhenFlushIsCalledThenProperFlagsAr
|
|||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
|
||||
|
||||
//preemption allocation in Mid Thread preemption mode
|
||||
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 1 : 0;
|
||||
//preemption allocation + Sip Kernel
|
||||
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 2 : 0;
|
||||
|
||||
EXPECT_EQ(5 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
|
||||
EXPECT_EQ(6 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
|
||||
uint64_t flags = I915_EXEC_RENDER | I915_EXEC_NO_RELOC;
|
||||
EXPECT_EQ(flags, this->mock->execBuffer.flags);
|
||||
|
||||
|
@ -1007,6 +1005,7 @@ TEST_F(DrmCommandStreamBatchingTests, givenCsrWhenDispatchPolicyIsSetToBatchingT
|
|||
tCsr->setTagAllocation(tagAllocation);
|
||||
tCsr->setPreemptionCsrAllocation(preemptionAllocation);
|
||||
DispatchFlags dispatchFlags;
|
||||
dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(device->getHardwareInfo());
|
||||
tCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags);
|
||||
|
||||
//make sure command buffer is recorded
|
||||
|
@ -1015,10 +1014,10 @@ TEST_F(DrmCommandStreamBatchingTests, givenCsrWhenDispatchPolicyIsSetToBatchingT
|
|||
EXPECT_NE(nullptr, cmdBuffers.peekHead());
|
||||
|
||||
//preemption allocation
|
||||
size_t csrSurfaceCount = (tCsr->getMemoryManager()->device->getPreemptionMode() == PreemptionMode::MidThread) ? 1 : 0;
|
||||
size_t csrSurfaceCount = (tCsr->getMemoryManager()->device->getPreemptionMode() == PreemptionMode::MidThread) ? 2 : 0;
|
||||
|
||||
//preemption allocation in Mid Thread preemption mode
|
||||
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 1 : 0;
|
||||
//preemption allocation + sipKernel
|
||||
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 2 : 0;
|
||||
|
||||
auto recordedCmdBuffer = cmdBuffers.peekHead();
|
||||
EXPECT_EQ(3u + csrSurfaceCount, recordedCmdBuffer->surfaces.size());
|
||||
|
@ -1035,7 +1034,7 @@ TEST_F(DrmCommandStreamBatchingTests, givenCsrWhenDispatchPolicyIsSetToBatchingT
|
|||
|
||||
EXPECT_EQ(tCsr->commandStream.getGraphicsAllocation(), recordedCmdBuffer->batchBuffer.commandBufferAllocation);
|
||||
|
||||
EXPECT_EQ(5 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
|
||||
EXPECT_EQ(6 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
|
||||
|
||||
EXPECT_EQ(0u, this->mock->execBuffer.flags);
|
||||
|
||||
|
@ -1066,6 +1065,7 @@ TEST_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhenItIsSubmitte
|
|||
|
||||
DispatchFlags dispatchFlags;
|
||||
dispatchFlags.guardCommandBufferWithPipeControl = true;
|
||||
dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(device->getHardwareInfo());
|
||||
tCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags);
|
||||
|
||||
auto &cmdBuffers = mockedSubmissionsAggregator->peekCommandBuffers();
|
||||
|
@ -1082,10 +1082,10 @@ TEST_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhenItIsSubmitte
|
|||
EXPECT_FALSE(commandBufferGraphicsAllocation->isResident());
|
||||
|
||||
//preemption allocation
|
||||
size_t csrSurfaceCount = (tCsr->getMemoryManager()->device->getPreemptionMode() == PreemptionMode::MidThread) ? 1 : 0;
|
||||
size_t csrSurfaceCount = (tCsr->getMemoryManager()->device->getPreemptionMode() == PreemptionMode::MidThread) ? 2 : 0;
|
||||
|
||||
//preemption allocation in Mid Thread preemption mode
|
||||
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 1 : 0;
|
||||
//preemption allocation +sip Kernel
|
||||
int ioctlExtraCnt = (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) ? 2 : 0;
|
||||
|
||||
//validate that submited command buffer has what we want
|
||||
EXPECT_EQ(3u + csrSurfaceCount, this->mock->execBuffer.buffer_count);
|
||||
|
@ -1107,7 +1107,7 @@ TEST_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhenItIsSubmitte
|
|||
EXPECT_TRUE(handleFound);
|
||||
}
|
||||
|
||||
EXPECT_EQ(6 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
|
||||
EXPECT_EQ(7 + ioctlExtraCnt, this->mock->ioctl_cnt.total);
|
||||
|
||||
mm->freeGraphicsMemory(dummyAllocation);
|
||||
mm->freeGraphicsMemory(commandBuffer);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "runtime/mem_obj/image.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
#include "runtime/os_interface/linux/drm_allocation.h"
|
||||
#include "runtime/os_interface/linux/drm_buffer_object.h"
|
||||
#include "runtime/os_interface/linux/drm_command_stream.h"
|
||||
|
@ -1129,7 +1130,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs
|
|||
memoryManager->device = pDevice.get();
|
||||
|
||||
auto allocator = memoryManager->getDrmInternal32BitAllocator();
|
||||
size_t size = 4 * GB - 4096;
|
||||
size_t size = getSizeToMap();
|
||||
auto alloc = allocator->allocate(size);
|
||||
EXPECT_NE(0llu, alloc);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "runtime/command_stream/device_command_stream.h"
|
||||
#include "runtime/command_stream/linear_stream.h"
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/helpers/built_ins_helper.h"
|
||||
#include "runtime/gen_common/hw_cmds.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/helpers/translationtable_callbacks.h"
|
||||
|
@ -35,6 +36,7 @@
|
|||
#include "runtime/os_interface/windows/wddm_memory_manager.h"
|
||||
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/mocks/mock_builtins.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
|
@ -109,10 +111,9 @@ class WddmCommandStreamWithMockGdiFixture {
|
|||
memManager = csr->createMemoryManager(false);
|
||||
ASSERT_NE(nullptr, memManager);
|
||||
|
||||
device = MockDevice::create<MockDevice>(platformDevices[0]);
|
||||
device = MockDevice::createWithMemoryManager<MockDevice>(platformDevices[0], memManager);
|
||||
ASSERT_NE(nullptr, device);
|
||||
memManager->device = device;
|
||||
|
||||
tagAllocation = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
preemptionAllocation = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
|
@ -128,7 +129,6 @@ class WddmCommandStreamWithMockGdiFixture {
|
|||
}
|
||||
delete csr->getTagAddress();
|
||||
delete csr;
|
||||
delete memManager;
|
||||
wddm = nullptr;
|
||||
delete device;
|
||||
}
|
||||
|
@ -687,6 +687,7 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
|||
DispatchFlags dispatchFlags;
|
||||
dispatchFlags.guardCommandBufferWithPipeControl = true;
|
||||
dispatchFlags.requiresCoherency = true;
|
||||
dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(device->getHardwareInfo());
|
||||
mockCsr->flushTask(cs, 0u, dsh, ioh, ssh, 0u, dispatchFlags);
|
||||
|
||||
auto &cmdBuffers = mockedSubmissionsAggregator->peekCommandBuffers();
|
||||
|
@ -699,8 +700,8 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
|||
|
||||
EXPECT_TRUE(cmdBuffers.peekIsEmpty());
|
||||
|
||||
//preemption allocation
|
||||
size_t csrSurfaceCount = (device->getPreemptionMode() == PreemptionMode::MidThread) ? 1 : 0;
|
||||
//preemption allocation + sip Kernel
|
||||
size_t csrSurfaceCount = (device->getPreemptionMode() == PreemptionMode::MidThread) ? 2 : 0;
|
||||
|
||||
EXPECT_EQ(1u, wddm->submitResult.called);
|
||||
auto csrCommandStream = mockCsr->commandStream.getGraphicsAllocation();
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
|
||||
using namespace OCLRT;
|
||||
|
||||
extern int preemptionModeFromDebugManager;
|
||||
|
||||
class ThreadGroupPreemptionTests : public DevicePreemptionTests {
|
||||
void SetUp() override {
|
||||
dbgRestore.reset(new DebugManagerStateRestore());
|
||||
|
@ -309,10 +307,6 @@ TEST_F(DevicePreemptionTests, setDefaultDisabledPreemptionNoMidBatchSupport) {
|
|||
EXPECT_EQ(PreemptionMode::Disabled, devCapabilities.defaultPreemptionMode);
|
||||
}
|
||||
|
||||
TEST(PreemptionTest, defaultMode) {
|
||||
EXPECT_EQ(-1, preemptionModeFromDebugManager);
|
||||
}
|
||||
|
||||
struct PreemptionHwTest : ::testing::Test, ::testing::WithParamInterface<PreemptionMode> {
|
||||
};
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ if(WIN32)
|
|||
)
|
||||
else()
|
||||
target_sources(igdrcl_tbx_tests PRIVATE
|
||||
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/allocator_helper.cpp
|
||||
${IGDRCL_SOURCE_DIR}/runtime/dll/linux/options.cpp
|
||||
)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue