Skip to content

Commit 2bc2869

Browse files
Refactor ult's for preemption enabling part 2
Change-Id: If8e335e87f3a78d35cab12a17880fb1922d479f5
1 parent 541735d commit 2bc2869

24 files changed

+203
-64
lines changed

runtime/dll/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ set(RUNTIME_SRCS_DLL_BASE
4545
)
4646

4747
set(RUNTIME_SRCS_DLL_LINUX
48-
${CMAKE_CURRENT_SOURCE_DIR}/linux/options.cpp
48+
${CMAKE_CURRENT_SOURCE_DIR}/linux/allocator_helper.cpp
4949
${CMAKE_CURRENT_SOURCE_DIR}/linux/drm_neo_create.cpp
50+
${CMAKE_CURRENT_SOURCE_DIR}/linux/options.cpp
5051
)
5152

5253
set(RUNTIME_SRCS_DLL_WINDOWS
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#include "runtime/helpers/aligned_memory.h"
24+
#include "runtime/helpers/basic_math.h"
25+
#include "runtime/os_interface/linux/allocator_helper.h"
26+
27+
namespace OCLRT {
28+
size_t getSizeToMap() {
29+
return static_cast<size_t>(alignUp(4 * GB - 8096, 4096));
30+
}
31+
} // namespace OCLRT

runtime/os_interface/linux/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
set(RUNTIME_SRCS_OS_INTERFACE_LINUX
2222
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
23+
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper.h
2324
${CMAKE_CURRENT_SOURCE_DIR}/api.cpp
2425
${CMAKE_CURRENT_SOURCE_DIR}/d3d_sharing_functions.h
2526
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#pragma once
24+
#include <cstddef>
25+
26+
namespace OCLRT {
27+
size_t getSizeToMap();
28+
} // namespace OCLRT

runtime/os_interface/linux/drm_32bit_memory.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,6 +22,7 @@
2222

2323
#include <memory>
2424
#include "runtime/os_interface/32bit_memory.h"
25+
#include "runtime/os_interface/linux/allocator_helper.h"
2526
#include "runtime/helpers/aligned_memory.h"
2627
#include "runtime/helpers/ptr_math.h"
2728
#include "runtime/helpers/basic_math.h"
@@ -105,7 +106,7 @@ OCLRT::Allocator32bit::Allocator32bit() : Allocator32bit(new OsInternals) {
105106
OCLRT::Allocator32bit::Allocator32bit(Allocator32bit::OsInternals *osInternalsIn) : osInternals(osInternalsIn) {
106107

107108
if (DebugManager.flags.UseNewHeapAllocator.get()) {
108-
size_t sizeToMap = alignUp(4 * GB - 8096, 4096);
109+
size_t sizeToMap = getSizeToMap();
109110
void *ptr = MAP_FAILED;
110111

111112
ptr = this->osInternals->mmapFunction(nullptr, sizeToMap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);

unit_tests/command_queue/enqueue_kernel_tests.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeWhenEnqueueK
10421042
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
10431043
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
10441044

1045-
MockKernelWithInternals mockKernel(*pDevice);
1045+
MockKernelWithInternals mockKernel(*pDevice, context);
10461046
size_t gws[3] = {1, 0, 0};
10471047
auto ret = pCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
10481048
EXPECT_EQ(CL_SUCCESS, ret);
@@ -1106,7 +1106,6 @@ HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeAndBatchedKe
11061106
EXPECT_TRUE(mockedSubmissionsAggregator->peekCmdBufferList().peekIsEmpty());
11071107
EXPECT_EQ(1, mockCsrmockCsr->flushCalledCount);
11081108
}
1109-
11101109
HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeWhenKernelIsEnqueuedTwiceThenTwoSubmissionsAreRecorded) {
11111110
auto mockCsrmockCsr = new MockCsrHw2<FamilyType>(pDevice->getHardwareInfo());
11121111
mockCsrmockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
@@ -1115,7 +1114,7 @@ HWTEST_F(EnqueueKernelTest, givenCommandStreamReceiverInBatchingModeWhenKernelIs
11151114
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
11161115
mockCsrmockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
11171116

1118-
MockKernelWithInternals mockKernel(*pDevice);
1117+
MockKernelWithInternals mockKernel(*pDevice, context);
11191118
size_t gws[3] = {1, 0, 0};
11201119
//make sure csr emits something
11211120
mockCsrmockCsr->overrideMediaVFEStateDirty(true);
@@ -1357,7 +1356,7 @@ HWTEST_F(EnqueueKernelTest, givenOutOfOrderCommandQueueWhenEnqueueKernelIsMadeTh
13571356
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
13581357
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
13591358

1360-
MockKernelWithInternals mockKernel(*pDevice);
1359+
MockKernelWithInternals mockKernel(*pDevice, context);
13611360
size_t gws[3] = {1, 0, 0};
13621361
clEnqueueNDRangeKernel(ooq, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
13631362

@@ -1379,7 +1378,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelIsMadeThenP
13791378
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
13801379
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
13811380

1382-
MockKernelWithInternals mockKernel(*pDevice);
1381+
MockKernelWithInternals mockKernel(*pDevice, context);
13831382
size_t gws[3] = {1, 0, 0};
13841383
clEnqueueNDRangeKernel(inOrderQueue, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
13851384

@@ -1401,7 +1400,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelThatHasShar
14011400
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
14021401
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
14031402

1404-
MockKernelWithInternals mockKernel(*pDevice);
1403+
MockKernelWithInternals mockKernel(*pDevice, context);
14051404
size_t gws[3] = {1, 0, 0};
14061405
mockKernel.mockKernel->setUsingSharedArgs(true);
14071406
clEnqueueNDRangeKernel(inOrderQueue, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
@@ -1419,7 +1418,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelThatHasShar
14191418
mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
14201419
pDevice->resetCommandStreamReceiver(mockCsr);
14211420

1422-
MockKernelWithInternals mockKernel(*pDevice);
1421+
MockKernelWithInternals mockKernel(*pDevice, context);
14231422
size_t gws[3] = {1, 0, 0};
14241423
mockKernel.mockKernel->setUsingSharedArgs(true);
14251424
clEnqueueNDRangeKernel(this->pCmdQ, mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
@@ -1438,7 +1437,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelReturningEv
14381437
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
14391438
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
14401439

1441-
MockKernelWithInternals mockKernel(*pDevice);
1440+
MockKernelWithInternals mockKernel(*pDevice, context);
14421441
size_t gws[3] = {1, 0, 0};
14431442
cl_event event;
14441443

@@ -1465,7 +1464,7 @@ HWTEST_F(EnqueueKernelTest, givenInOrderCommandQueueWhenEnqueueKernelReturningEv
14651464
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
14661465
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
14671466

1468-
MockKernelWithInternals mockKernel(*pDevice);
1467+
MockKernelWithInternals mockKernel(*pDevice, context);
14691468
size_t gws[3] = {1, 0, 0};
14701469
cl_event event;
14711470

@@ -1491,7 +1490,7 @@ HWTEST_F(EnqueueKernelTest, givenOutOfOrderCommandQueueWhenEnqueueKernelReturnin
14911490
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0};
14921491
auto inOrderQueue = clCreateCommandQueueWithProperties(context, pDevice, props, nullptr);
14931492

1494-
MockKernelWithInternals mockKernel(*pDevice);
1493+
MockKernelWithInternals mockKernel(*pDevice, context);
14951494
size_t gws[3] = {1, 0, 0};
14961495
cl_event event;
14971496

@@ -1575,6 +1574,7 @@ TEST_F(EnqueueKernelTest, givenKernelWhenAllArgsAreNotAndEventExistSetThenClEnqu
15751574
retVal = clEnqueueNDRangeKernel(pCmdQ2, kernel.get(), 1, nullptr, globalWorkSize, localWorkSize, 0, nullptr, &event);
15761575
EXPECT_EQ(CL_INVALID_KERNEL_ARGS, retVal);
15771576

1577+
clFlush(pCmdQ2);
15781578
clReleaseCommandQueue(pCmdQ2);
15791579
}
15801580

unit_tests/command_stream/command_stream_receiver_hw_tests.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757

5858
using namespace OCLRT;
5959

60-
using ::testing::_;
6160
using ::testing::Invoke;
61+
using ::testing::_;
6262

6363
HWTEST_F(UltCommandStreamReceiverTest, givenThreadArbitrationPolicyNotChangedWhenEstimatingPreambleCmdSizeThenReturnItsValue) {
6464
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
@@ -1817,6 +1817,10 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenEnabledPreemptionWhenFlushTas
18171817

18181818
HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithPCWhenPreambleSentAndL3ConfigChanged) {
18191819
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
1820+
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
1821+
typedef typename FamilyType::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
1822+
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
1823+
typedef typename FamilyType::MEDIA_VFE_STATE MEDIA_VFE_STATE;
18201824
CsrSizeRequestFlags csrSizeRequest = {};
18211825

18221826
commandStream.getSpace(sizeof(PIPE_CONTROL));
@@ -1829,13 +1833,18 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithPCWhenPreambleSentAnd
18291833
commandStreamReceiver.isPreambleSent = true;
18301834
commandStreamReceiver.lastPreemptionMode = pDevice->getPreemptionMode();
18311835
commandStreamReceiver.lastMediaSamplerConfig = 0;
1836+
commandStreamReceiver.lastSentCoherencyRequest = false;
18321837
commandStreamReceiver.lastSentThreadArbitrationPolicy = commandStreamReceiver.requiredThreadArbitrationPolicy;
18331838
csrSizeRequest.l3ConfigChanged = true;
18341839
commandStreamReceiver.overrideCsrSizeReqFlags(csrSizeRequest);
18351840

18361841
auto &csrCS = commandStreamReceiver.getCS();
1837-
size_t sizeNeeded = commandStreamReceiver.getRequiredCmdStreamSizeAligned(flushTaskFlags);
1842+
size_t sizeNeeded = 2 * sizeof(PIPE_CONTROL) + sizeof(MI_LOAD_REGISTER_IMM) + sizeof(MEDIA_VFE_STATE) +
1843+
sizeof(MI_BATCH_BUFFER_START) + sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL) +
1844+
commandStreamReceiver.getRequiredPipeControlSize();
1845+
18381846
auto expectedUsed = csrCS.getUsed() + sizeNeeded;
1847+
expectedUsed = alignUp(expectedUsed, MemoryConstants::cacheLineSize);
18391848

18401849
commandStreamReceiver.flushTask(commandStream, 0, dsh, ioh, ssh, taskLevel, flushTaskFlags);
18411850

unit_tests/compiler_interface/compiler_interface_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ TEST_F(CompilerInterfaceTest, BuildWithDebugData) {
201201
retVal = pProgram->getInfo(CL_PROGRAM_DEBUG_INFO_INTEL, debugDataSize, nullptr, &retData);
202202
EXPECT_EQ(CL_SUCCESS, retVal);
203203
EXPECT_EQ(numDevices * sizeof(debugData), retData);
204+
cip->shutdown();
204205

205206
delete[] debugData;
206207
delete cip;

unit_tests/helpers/built_ins_helper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
namespace OCLRT {
2727
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
28-
CompilerInterface::getInstance();
2928
std::unique_ptr<MockCompilerInterface> mockCompilerInterface(new MockCompilerInterface());
3029
mockCompilerInterface->overrideGlobalCompilerInterface();
3130
mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary();

unit_tests/libult/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ set(IGDRCL_SRCS_LIB_ULT_ENV_WINDOWS
120120

121121
set(IGDRCL_SRCS_LIB_ULT_ENV_LINUX
122122
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp
123+
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/allocator_helper.cpp
123124
)
124125

125126
if(WIN32)

0 commit comments

Comments
 (0)