Skip to content

Commit 92584d8

Browse files
Minor cleanup.
Change-Id: I0f345c4fbf49f6464dce7bafd8b8d59347ff2d77 Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
1 parent 148774e commit 92584d8

File tree

11 files changed

+37
-57
lines changed

11 files changed

+37
-57
lines changed

runtime/command_queue/gpgpu_walker.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,13 @@ class GpgpuWalkerHelper {
181181
uint32_t registerAddress);
182182

183183
static void dispatchPerfCountersGeneralPurposeCounterCommands(
184-
CommandQueue &commandQueue,
185-
TagNode<HwPerfCounter> &hwPerfCounter,
186184
LinearStream *commandStream,
187-
bool start);
185+
uint64_t baseAddress);
188186

189187
static void dispatchPerfCountersUserCounterCommands(
190188
CommandQueue &commandQueue,
191-
TagNode<HwPerfCounter> &hwPerfCounter,
192189
LinearStream *commandStream,
193-
bool start);
190+
uint64_t baseAddress);
194191

195192
static void dispatchPerfCountersOABufferStateCommands(
196193
TagNode<HwPerfCounter> &hwPerfCounter,

runtime/command_queue/gpgpu_walker.inl

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,8 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchStoreRegisterCommand(
165165

166166
template <typename GfxFamily>
167167
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(
168-
CommandQueue &commandQueue,
169-
TagNode<HwPerfCounter> &hwPerfCounter,
170168
LinearStream *commandStream,
171-
bool start) {
172-
173-
uint64_t baseAddress = hwPerfCounter.getGpuAddress();
174-
baseAddress += start ? offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportBegin.Gp)
175-
: offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportEnd.Gp);
169+
uint64_t baseAddress) {
176170

177171
// Read General Purpose counters
178172
for (auto i = 0u; i < NEO::INSTR_GENERAL_PURPOSE_COUNTERS_COUNT; i++) {
@@ -186,19 +180,15 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterComm
186180
template <typename GfxFamily>
187181
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(
188182
CommandQueue &commandQueue,
189-
TagNode<HwPerfCounter> &hwPerfCounter,
190183
LinearStream *commandStream,
191-
bool start) {
184+
uint64_t baseAddress) {
192185

193-
uint64_t baseAddr = hwPerfCounter.getGpuAddress();
194-
baseAddr += start ? offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportBegin.User)
195-
: offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportEnd.User);
196186
auto userRegs = &commandQueue.getPerfCountersConfigData()->ReadRegs;
197187

198188
for (uint32_t i = 0; i < userRegs->RegsCount; i++) {
199189
uint32_t regAddr = userRegs->Reg[i].Offset;
200190
//offset between base (low) registers is cl_ulong wide
201-
uint64_t address = baseAddr + i * sizeof(cl_ulong);
191+
uint64_t address = baseAddress + i * sizeof(cl_ulong);
202192
dispatchStoreRegisterCommand(commandStream, address, regAddr);
203193

204194
if (userRegs->Reg[i].BitSize > 32) {
@@ -240,7 +230,7 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsStart(
240230
//Read Core Frequency
241231
GpgpuWalkerHelper<GfxFamily>::dispatchStoreRegisterCommand(commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.CoreFreqBegin), INSTR_MMIO_RPSTAT1);
242232

243-
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(commandQueue, hwPerfCounter, commandStream, true);
233+
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportBegin.Gp));
244234

245235
auto pReportPerfCount = commandStream->getSpaceForCmd<MI_REPORT_PERF_COUNT>();
246236
*pReportPerfCount = GfxFamily::cmdInitReportPerfCount;
@@ -252,7 +242,7 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsStart(
252242

253243
PipeControlHelper<GfxFamily>::obtainPipeControlAndProgramPostSyncOperation(commandStream, PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP, address, 0llu, false);
254244

255-
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(commandQueue, hwPerfCounter, commandStream, true);
245+
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(commandQueue, commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportBegin.User));
256246

257247
commandQueue.sendPerfCountersConfig();
258248
}
@@ -286,15 +276,15 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsEnd(
286276
address = hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportEnd.Oa);
287277
pReportPerfCount->setMemoryAddress(address);
288278

289-
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(commandQueue, hwPerfCounter, commandStream, false);
279+
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportEnd.Gp));
290280

291281
//Store value of NOOPID register
292282
GpgpuWalkerHelper<GfxFamily>::dispatchStoreRegisterCommand(commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.DMAFenceIdEnd), INSTR_MMIO_NOOPID);
293283

294284
//Read Core Frequency
295285
GpgpuWalkerHelper<GfxFamily>::dispatchStoreRegisterCommand(commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.CoreFreqEnd), INSTR_MMIO_RPSTAT1);
296286

297-
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(commandQueue, hwPerfCounter, commandStream, false);
287+
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(commandQueue, commandStream, hwPerfCounter.getGpuAddress() + offsetof(HwPerfCounter, HWPerfCounters.HwPerfReportEnd.User));
298288

299289
perfCounters->setCpuTimestamp();
300290
}

runtime/command_stream/experimental_command_buffer.inl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace NEO {
1616
template <typename GfxFamily>
1717
void ExperimentalCommandBuffer::injectBufferStart(LinearStream &parentStream, size_t cmdBufferOffset) {
1818
using MI_BATCH_BUFFER_START = typename GfxFamily::MI_BATCH_BUFFER_START;
19-
auto pCmd = static_cast<MI_BATCH_BUFFER_START *>(parentStream.getSpace(sizeof(MI_BATCH_BUFFER_START)));
20-
auto commandStreamReceiverHw = reinterpret_cast<CommandStreamReceiverHw<GfxFamily> *>(commandStreamReceiver);
19+
auto pCmd = parentStream.getSpaceForCmd<MI_BATCH_BUFFER_START>();
20+
auto commandStreamReceiverHw = static_cast<CommandStreamReceiverHw<GfxFamily> *>(commandStreamReceiver);
2121
commandStreamReceiverHw->addBatchBufferStart(pCmd, currentStream->getGraphicsAllocation()->getGpuAddress() + cmdBufferOffset, true);
2222
}
2323

@@ -44,7 +44,7 @@ size_t ExperimentalCommandBuffer::programExperimentalCommandBuffer() {
4444
addTimeStampPipeControl<GfxFamily>();
4545

4646
//end
47-
auto pCmd = static_cast<MI_BATCH_BUFFER_END *>(currentStream->getSpace(sizeof(MI_BATCH_BUFFER_END)));
47+
auto pCmd = currentStream->getSpaceForCmd<MI_BATCH_BUFFER_END>();
4848
*pCmd = GfxFamily::cmdInitBatchBufferEnd;
4949

5050
return returnOffset;
@@ -70,7 +70,7 @@ template <typename GfxFamily>
7070
void ExperimentalCommandBuffer::addTimeStampPipeControl() {
7171
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
7272

73-
auto pCmd = static_cast<PIPE_CONTROL *>(currentStream->getSpace(sizeof(PIPE_CONTROL)));
73+
auto pCmd = currentStream->getSpaceForCmd<PIPE_CONTROL>();
7474
*pCmd = GfxFamily::cmdInitPipeControl;
7575
pCmd->setCommandStreamerStallEnable(true);
7676

@@ -88,12 +88,11 @@ template <typename GfxFamily>
8888
void ExperimentalCommandBuffer::addExperimentalCommands() {
8989
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
9090

91-
uintptr_t semaphoreAddr = reinterpret_cast<uintptr_t>(experimentalAllocation->getUnderlyingBuffer()) + experimentalAllocationOffset;
92-
uint32_t *semaphoreData = reinterpret_cast<uint32_t *>(semaphoreAddr);
91+
uint32_t *semaphoreData = reinterpret_cast<uint32_t *>(ptrOffset(experimentalAllocation->getUnderlyingBuffer(), experimentalAllocationOffset));
9392
*semaphoreData = 1;
9493
uint64_t gpuAddr = experimentalAllocation->getGpuAddress() + experimentalAllocationOffset;
9594

96-
auto semaphoreCmd = reinterpret_cast<MI_SEMAPHORE_WAIT *>(currentStream->getSpace(sizeof(MI_SEMAPHORE_WAIT)));
95+
auto semaphoreCmd = currentStream->getSpaceForCmd<MI_SEMAPHORE_WAIT>();
9796
*semaphoreCmd = GfxFamily::cmdInitMiSemaphoreWait;
9897
semaphoreCmd->setCompareOperation(MI_SEMAPHORE_WAIT::COMPARE_OPERATION_SAD_EQUAL_SDD);
9998
semaphoreCmd->setSemaphoreDataDword(*semaphoreData);

runtime/memory_manager/svm_memory_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <mutex>
1212

1313
namespace NEO {
14+
class CommandStreamReceiver;
1415
class Device;
1516
class GraphicsAllocation;
16-
class CommandStreamReceiver;
1717
class MemoryManager;
1818

1919
struct SvmAllocationData {

runtime/os_interface/linux/drm_neo.h

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

2626
class DeviceFactory;
2727
struct HardwareInfo;
28-
struct FeatureTable;
2928

3029
struct DeviceDescriptor {
3130
unsigned short deviceId;

unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
4141
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue) {
4242
CommandStreamReceiver *csr = pCommandStreamReceiver;
4343
if (testMode == TestMode::AubTestsWithTbx) {
44-
csr = reinterpret_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(pCommandStreamReceiver)->aubCSR.get();
44+
csr = static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(pCommandStreamReceiver)->aubCSR.get();
4545
}
4646

4747
if (csr) {
4848
// Write our pseudo-op to the AUB file
49-
auto aubCsr = reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(csr);
49+
auto aubCsr = static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(csr);
5050
aubCsr->expectMMIO(mmioRegister, expectedValue);
5151
}
5252
}
@@ -55,14 +55,14 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
5555
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length) {
5656
CommandStreamReceiver *csr = pCommandStreamReceiver;
5757
if (testMode == TestMode::AubTestsWithTbx) {
58-
auto tbxCsr = reinterpret_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(pCommandStreamReceiver);
58+
auto tbxCsr = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(pCommandStreamReceiver);
5959
tbxCsr->expectMemoryEqual(gfxAddress, srcAddress, length);
6060

61-
csr = reinterpret_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(pCommandStreamReceiver)->aubCSR.get();
61+
csr = static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(pCommandStreamReceiver)->aubCSR.get();
6262
}
6363

6464
if (csr) {
65-
auto aubCsr = reinterpret_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(csr);
65+
auto aubCsr = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(csr);
6666
aubCsr->expectMemoryEqual(gfxAddress, srcAddress, length);
6767
}
6868
}
@@ -71,21 +71,21 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
7171
void expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length) {
7272
CommandStreamReceiver *csr = pCommandStreamReceiver;
7373
if (testMode == TestMode::AubTestsWithTbx) {
74-
auto tbxCsr = reinterpret_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(pCommandStreamReceiver);
74+
auto tbxCsr = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(pCommandStreamReceiver);
7575
tbxCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length);
7676

77-
csr = reinterpret_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(pCommandStreamReceiver)->aubCSR.get();
77+
csr = static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(pCommandStreamReceiver)->aubCSR.get();
7878
}
7979

8080
if (csr) {
81-
auto aubCsr = reinterpret_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(csr);
81+
auto aubCsr = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(csr);
8282
aubCsr->expectMemoryNotEqual(gfxAddress, srcAddress, length);
8383
}
8484
}
8585

8686
template <typename FamilyType>
87-
CommandStreamReceiverSimulatedCommonHw<FamilyType> *getSimulatedCsr() {
88-
return reinterpret_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(pCommandStreamReceiver);
87+
CommandStreamReceiverSimulatedCommonHw<FamilyType> *getSimulatedCsr() const {
88+
return static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(pCommandStreamReceiver);
8989
}
9090

9191
template <typename FamilyType>

unit_tests/aub_tests/fixtures/aub_fixture.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ class AUBFixture : public CommandQueueHwFixture {
5656
GraphicsAllocation *createHostPtrAllocationFromSvmPtr(void *svmPtr, size_t size);
5757

5858
template <typename FamilyType>
59-
CommandStreamReceiverSimulatedCommonHw<FamilyType> *getSimulatedCsr() {
60-
CommandStreamReceiverSimulatedCommonHw<FamilyType> *simulatedCsr = nullptr;
61-
simulatedCsr = reinterpret_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(csr);
62-
return simulatedCsr;
59+
CommandStreamReceiverSimulatedCommonHw<FamilyType> *getSimulatedCsr() const {
60+
return static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(csr);
6361
}
6462

6563
template <typename FamilyType>

unit_tests/event/event_tests.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,13 +1138,8 @@ TEST_F(EventTest, hwTimeStampsMemoryIsPlacedInGraphicsAllocation) {
11381138
void *memoryStorage = allocation->getUnderlyingBuffer();
11391139
size_t graphicsAllocationSize = allocation->getUnderlyingBufferSize();
11401140

1141-
uintptr_t timeStampAddress = reinterpret_cast<uintptr_t>(timeStamps);
1142-
uintptr_t graphicsAllocationStart = reinterpret_cast<uintptr_t>(memoryStorage);
1143-
1144-
if (!((timeStampAddress >= graphicsAllocationStart) &&
1145-
((timeStampAddress + sizeof(HwTimeStamps)) <= (graphicsAllocationStart + graphicsAllocationSize)))) {
1146-
EXPECT_TRUE(false);
1147-
}
1141+
EXPECT_GE(timeStamps, memoryStorage);
1142+
EXPECT_LE(timeStamps + 1, ptrOffset(memoryStorage, graphicsAllocationSize));
11481143
}
11491144

11501145
TEST_F(EventTest, getHwPerfCounterReturnsValidPointer) {

unit_tests/mem_obj/image_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,10 @@ TEST(TestCreateImageUseHostPtr, CheckMemoryAllocationForDifferenHostPtrAlignment
371371
imageDesc.image_slice_pitch = 0;
372372

373373
void *pageAlignedPointer = alignedMalloc(imageDesc.image_row_pitch * height * 1 * 4 + 256, 4096);
374-
void *hostPtr[] = {reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(pageAlignedPointer) + 16), // 16 - byte alignment
375-
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(pageAlignedPointer) + 32), // 32 - byte alignment
376-
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(pageAlignedPointer) + 64), // 64 - byte alignment
377-
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(pageAlignedPointer) + 128)}; // 128 - byte alignment
374+
void *hostPtr[] = {ptrOffset(pageAlignedPointer, 16), // 16 - byte alignment
375+
ptrOffset(pageAlignedPointer, 32), // 32 - byte alignment
376+
ptrOffset(pageAlignedPointer, 64), // 64 - byte alignment
377+
ptrOffset(pageAlignedPointer, 128)}; // 128 - byte alignment
378378

379379
bool result[] = {false,
380380
false,

unit_tests/memory_manager/memory_manager_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,13 +1753,15 @@ TEST_F(MemoryAllocatorTest, whenCommandStreamerIsNotRegisteredThenReturnNullEngi
17531753
auto engineControl = memoryManager->getRegisteredEngineForCsr(dummyCsr);
17541754
EXPECT_EQ(nullptr, engineControl);
17551755
}
1756+
17561757
TEST(MemoryManagerCopyMemoryTest, givenAllocationWithNoStorageWhenCopyMemoryToAllocationThenReturnFalse) {
17571758
MockExecutionEnvironment executionEnvironment(*platformDevices);
17581759
MockMemoryManager memoryManager(false, false, executionEnvironment);
17591760
uint8_t memory = 1;
17601761
MockGraphicsAllocation invalidAllocation{nullptr, 0u};
17611762
EXPECT_FALSE(memoryManager.copyMemoryToAllocation(&invalidAllocation, &memory, sizeof(memory)));
17621763
}
1764+
17631765
TEST(MemoryManagerCopyMemoryTest, givenValidAllocationAndMemoryWhenCopyMemoryToAllocationThenDataIsCopied) {
17641766
MockExecutionEnvironment executionEnvironment(*platformDevices);
17651767
MockMemoryManager memoryManager(false, false, executionEnvironment);

0 commit comments

Comments
 (0)