2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-03-02 05:43:04 +08:00
|
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* 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
|
2018-03-30 23:57:51 +08:00
|
|
|
#include "runtime/command_queue/gpgpu_walker.h"
|
2018-09-07 23:04:18 +08:00
|
|
|
#include "hardware_interface.h"
|
|
|
|
#include "hardware_interface.inl"
|
2018-04-09 22:39:32 +08:00
|
|
|
#include "runtime/command_queue/command_queue.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/command_queue/local_id_gen.h"
|
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
|
|
|
#include "runtime/device/device_info.h"
|
|
|
|
#include "runtime/event/perf_counter.h"
|
|
|
|
#include "runtime/event/user_event.h"
|
|
|
|
#include "runtime/indirect_heap/indirect_heap.h"
|
2018-04-09 22:39:32 +08:00
|
|
|
#include "instrumentation.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/aligned_memory.h"
|
|
|
|
#include "runtime/helpers/debug_helpers.h"
|
|
|
|
#include "runtime/helpers/kernel_commands.h"
|
|
|
|
#include "runtime/helpers/validators.h"
|
|
|
|
#include "runtime/mem_obj/mem_obj.h"
|
|
|
|
#include "runtime/memory_manager/graphics_allocation.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
// Performs ReadModifyWrite operation on value of a register: Register = Register Operation Mask
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::addAluReadModifyWriteRegister(
|
|
|
|
OCLRT::LinearStream *pCommandStream,
|
|
|
|
uint32_t aluRegister,
|
|
|
|
uint32_t operation,
|
|
|
|
uint32_t mask) {
|
|
|
|
// Load "Register" value into CS_GPR_R0
|
|
|
|
typedef typename GfxFamily::MI_LOAD_REGISTER_REG MI_LOAD_REGISTER_REG;
|
|
|
|
typedef typename GfxFamily::MI_MATH MI_MATH;
|
|
|
|
typedef typename GfxFamily::MI_MATH_ALU_INST_INLINE MI_MATH_ALU_INST_INLINE;
|
|
|
|
auto pCmd = reinterpret_cast<MI_LOAD_REGISTER_REG *>(pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_REG)));
|
|
|
|
*pCmd = MI_LOAD_REGISTER_REG::sInit();
|
|
|
|
pCmd->setSourceRegisterAddress(aluRegister);
|
|
|
|
pCmd->setDestinationRegisterAddress(CS_GPR_R0);
|
|
|
|
|
|
|
|
// Load "Mask" into CS_GPR_R1
|
|
|
|
typedef typename GfxFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
|
|
|
auto pCmd2 = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
|
|
|
|
*pCmd2 = MI_LOAD_REGISTER_IMM::sInit();
|
|
|
|
pCmd2->setRegisterOffset(CS_GPR_R1);
|
|
|
|
pCmd2->setDataDword(mask);
|
|
|
|
|
|
|
|
// Add instruction MI_MATH with 4 MI_MATH_ALU_INST_INLINE operands
|
|
|
|
auto pCmd3 = reinterpret_cast<uint32_t *>(pCommandStream->getSpace(sizeof(MI_MATH) + NUM_ALU_INST_FOR_READ_MODIFY_WRITE * sizeof(MI_MATH_ALU_INST_INLINE)));
|
|
|
|
reinterpret_cast<MI_MATH *>(pCmd3)->DW0.Value = 0x0;
|
|
|
|
reinterpret_cast<MI_MATH *>(pCmd3)->DW0.BitField.InstructionType = MI_MATH::COMMAND_TYPE_MI_COMMAND;
|
|
|
|
reinterpret_cast<MI_MATH *>(pCmd3)->DW0.BitField.InstructionOpcode = MI_MATH::MI_COMMAND_OPCODE_MI_MATH;
|
|
|
|
// 0x3 - 5 Dwords length cmd (-2): 1 for MI_MATH, 4 for MI_MATH_ALU_INST_INLINE
|
|
|
|
reinterpret_cast<MI_MATH *>(pCmd3)->DW0.BitField.DwordLength = NUM_ALU_INST_FOR_READ_MODIFY_WRITE - 1;
|
|
|
|
pCmd3++;
|
|
|
|
MI_MATH_ALU_INST_INLINE *pAluParam = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(pCmd3);
|
|
|
|
|
|
|
|
// Setup first operand of MI_MATH - load CS_GPR_R0 into register A
|
|
|
|
pAluParam->DW0.BitField.ALUOpcode = ALU_OPCODE_LOAD;
|
|
|
|
pAluParam->DW0.BitField.Operand1 = ALU_REGISTER_R_SRCA;
|
|
|
|
pAluParam->DW0.BitField.Operand2 = ALU_REGISTER_R_0;
|
|
|
|
pAluParam++;
|
|
|
|
|
|
|
|
// Setup second operand of MI_MATH - load CS_GPR_R1 into register B
|
|
|
|
pAluParam->DW0.BitField.ALUOpcode = ALU_OPCODE_LOAD;
|
|
|
|
pAluParam->DW0.BitField.Operand1 = ALU_REGISTER_R_SRCB;
|
|
|
|
pAluParam->DW0.BitField.Operand2 = ALU_REGISTER_R_1;
|
|
|
|
pAluParam++;
|
|
|
|
|
|
|
|
// Setup third operand of MI_MATH - "Operation" on registers A and B
|
|
|
|
pAluParam->DW0.BitField.ALUOpcode = operation;
|
|
|
|
pAluParam->DW0.BitField.Operand1 = 0;
|
|
|
|
pAluParam->DW0.BitField.Operand2 = 0;
|
|
|
|
pAluParam++;
|
|
|
|
|
|
|
|
// Setup fourth operand of MI_MATH - store result into CS_GPR_R0
|
|
|
|
pAluParam->DW0.BitField.ALUOpcode = ALU_OPCODE_STORE;
|
|
|
|
pAluParam->DW0.BitField.Operand1 = ALU_REGISTER_R_0;
|
|
|
|
pAluParam->DW0.BitField.Operand2 = ALU_REGISTER_R_ACCU;
|
|
|
|
|
|
|
|
// LOAD value of CS_GPR_R0 into "Register"
|
|
|
|
auto pCmd4 = reinterpret_cast<MI_LOAD_REGISTER_REG *>(pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_REG)));
|
|
|
|
*pCmd4 = MI_LOAD_REGISTER_REG::sInit();
|
|
|
|
pCmd4->setSourceRegisterAddress(CS_GPR_R0);
|
|
|
|
pCmd4->setDestinationRegisterAddress(aluRegister);
|
|
|
|
|
|
|
|
// Add PIPE_CONTROL to flush caches
|
|
|
|
auto pCmd5 = reinterpret_cast<PIPE_CONTROL *>(pCommandStream->getSpace(sizeof(PIPE_CONTROL)));
|
|
|
|
*pCmd5 = PIPE_CONTROL::sInit();
|
|
|
|
pCmd5->setCommandStreamerStallEnable(true);
|
|
|
|
pCmd5->setDcFlushEnable(true);
|
|
|
|
pCmd5->setTextureCacheInvalidationEnable(true);
|
|
|
|
pCmd5->setPipeControlFlushEnable(true);
|
|
|
|
pCmd5->setStateCacheInvalidationEnable(true);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
inline size_t GpgpuWalkerHelper<GfxFamily>::setGpgpuWalkerThreadData(
|
2018-04-24 21:55:24 +08:00
|
|
|
WALKER_HANDLE pCmdData,
|
2017-12-21 07:45:38 +08:00
|
|
|
const size_t globalOffsets[3],
|
|
|
|
const size_t startWorkGroups[3],
|
|
|
|
const size_t numWorkGroups[3],
|
|
|
|
const size_t localWorkSizesIn[3],
|
|
|
|
uint32_t simd) {
|
2018-08-24 21:53:33 +08:00
|
|
|
WALKER_TYPE<GfxFamily> *pCmd = static_cast<WALKER_TYPE<GfxFamily> *>(pCmdData);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto localWorkSize = localWorkSizesIn[0] * localWorkSizesIn[1] * localWorkSizesIn[2];
|
|
|
|
|
|
|
|
auto threadsPerWorkGroup = getThreadsPerWG(simd, localWorkSize);
|
2018-08-24 21:53:33 +08:00
|
|
|
pCmd->setThreadWidthCounterMaximum(static_cast<uint32_t>(threadsPerWorkGroup));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-24 21:53:33 +08:00
|
|
|
pCmd->setThreadGroupIdXDimension(static_cast<uint32_t>(numWorkGroups[0]));
|
|
|
|
pCmd->setThreadGroupIdYDimension(static_cast<uint32_t>(numWorkGroups[1]));
|
|
|
|
pCmd->setThreadGroupIdZDimension(static_cast<uint32_t>(numWorkGroups[2]));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-24 21:53:33 +08:00
|
|
|
// compute executionMask - to tell which SIMD lines are active within thread
|
2017-12-21 07:45:38 +08:00
|
|
|
auto remainderSimdLanes = localWorkSize & (simd - 1);
|
|
|
|
uint64_t executionMask = (1ull << remainderSimdLanes) - 1;
|
|
|
|
if (!executionMask)
|
|
|
|
executionMask = ~executionMask;
|
|
|
|
|
2018-08-24 21:53:33 +08:00
|
|
|
using SIMD_SIZE = typename WALKER_TYPE<GfxFamily>::SIMD_SIZE;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-24 21:53:33 +08:00
|
|
|
pCmd->setRightExecutionMask(static_cast<uint32_t>(executionMask));
|
|
|
|
pCmd->setBottomExecutionMask(static_cast<uint32_t>(0xffffffff));
|
|
|
|
pCmd->setSimdSize(static_cast<SIMD_SIZE>(simd >> 4));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-24 21:53:33 +08:00
|
|
|
pCmd->setThreadGroupIdStartingX(static_cast<uint32_t>(startWorkGroups[0]));
|
|
|
|
pCmd->setThreadGroupIdStartingY(static_cast<uint32_t>(startWorkGroups[1]));
|
|
|
|
pCmd->setThreadGroupIdStartingResumeZ(static_cast<uint32_t>(startWorkGroups[2]));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
return localWorkSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsStart(
|
2017-12-21 07:45:38 +08:00
|
|
|
HwTimeStamps &hwTimeStamps,
|
|
|
|
OCLRT::LinearStream *commandStream) {
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
|
|
|
// PIPE_CONTROL for global timestamp
|
|
|
|
uint64_t TimeStampAddress = reinterpret_cast<uint64_t>(&(hwTimeStamps.GlobalStartTS));
|
|
|
|
|
|
|
|
auto pPipeControlCmd = (PIPE_CONTROL *)commandStream->getSpace(sizeof(PIPE_CONTROL));
|
|
|
|
*pPipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
pPipeControlCmd->setPostSyncOperation(PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP);
|
|
|
|
pPipeControlCmd->setAddress(static_cast<uint32_t>(TimeStampAddress & 0x0000FFFFFFFFULL));
|
|
|
|
pPipeControlCmd->setAddressHigh(static_cast<uint32_t>(TimeStampAddress >> 32));
|
|
|
|
|
|
|
|
//MI_STORE_REGISTER_MEM for context local timestamp
|
|
|
|
TimeStampAddress = reinterpret_cast<uint64_t>(&(hwTimeStamps.ContextStartTS));
|
|
|
|
|
|
|
|
//low part
|
|
|
|
auto pMICmdLow = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pMICmdLow = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pMICmdLow->setRegisterAddress(GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW);
|
|
|
|
pMICmdLow->setMemoryAddress(TimeStampAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsEnd(
|
2017-12-21 07:45:38 +08:00
|
|
|
HwTimeStamps &hwTimeStamps,
|
|
|
|
OCLRT::LinearStream *commandStream) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
|
|
|
// PIPE_CONTROL for global timestamp
|
|
|
|
auto pPipeControlCmd = (PIPE_CONTROL *)commandStream->getSpace(sizeof(PIPE_CONTROL));
|
|
|
|
*pPipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
|
|
|
|
//MI_STORE_REGISTER_MEM for context local timestamp
|
|
|
|
uint64_t TimeStampAddress = reinterpret_cast<uint64_t>(&(hwTimeStamps.ContextEndTS));
|
|
|
|
|
|
|
|
//low part
|
|
|
|
auto pMICmdLow = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pMICmdLow = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pMICmdLow->setRegisterAddress(GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW);
|
|
|
|
pMICmdLow->setMemoryAddress(TimeStampAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersNoopidRegisterCommands(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream,
|
|
|
|
bool start) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
2018-02-16 06:05:04 +08:00
|
|
|
uint64_t address = start ? reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.DMAFenceIdBegin))
|
|
|
|
: reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.DMAFenceIdEnd));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto pNoopIdRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pNoopIdRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pNoopIdRegister->setRegisterAddress(OCLRT::INSTR_MMIO_NOOPID);
|
|
|
|
pNoopIdRegister->setMemoryAddress(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersReadFreqRegisterCommands(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream,
|
|
|
|
bool start) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
2018-02-16 06:05:04 +08:00
|
|
|
uint64_t address = start ? reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.CoreFreqBegin))
|
|
|
|
: reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.CoreFreqEnd));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto pCoreFreqRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pCoreFreqRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pCoreFreqRegister->setRegisterAddress(OCLRT::INSTR_MMIO_RPSTAT1);
|
|
|
|
pCoreFreqRegister->setMemoryAddress(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream,
|
|
|
|
bool start) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
uint64_t address = 0;
|
2018-02-16 06:05:04 +08:00
|
|
|
const uint64_t baseAddress = start ? reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.HwPerfReportBegin.Gp))
|
|
|
|
: reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.HwPerfReportEnd.Gp));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
// Read General Purpose counters
|
|
|
|
for (uint16_t i = 0; i < OCLRT::INSTR_GENERAL_PURPOSE_COUNTERS_COUNT; i++) {
|
|
|
|
auto pGeneralPurposeRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pGeneralPurposeRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
uint32_t regAddr = INSTR_GFX_OFFSETS::INSTR_PERF_CNT_1_DW0 + i * sizeof(cl_uint);
|
|
|
|
pGeneralPurposeRegister->setRegisterAddress(regAddr);
|
|
|
|
//Gp field is 2*uint64 wide so it can hold 4 uint32
|
|
|
|
address = baseAddress + i * sizeof(cl_uint);
|
|
|
|
pGeneralPurposeRegister->setMemoryAddress(address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream,
|
|
|
|
bool start) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
|
|
|
uint64_t address = 0;
|
2018-02-16 06:05:04 +08:00
|
|
|
const uint64_t baseAddr = start ? reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.HwPerfReportBegin.User))
|
|
|
|
: reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.HwPerfReportEnd.User));
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t cmdNum = 0;
|
|
|
|
uint32_t regAddr = 0;
|
|
|
|
auto configData = commandQueue.getPerfCountersConfigData();
|
2018-01-05 20:35:03 +08:00
|
|
|
auto userRegs = &configData->ReadRegs;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-05 20:35:03 +08:00
|
|
|
for (uint32_t i = 0; i < userRegs->RegsCount; i++) {
|
2017-12-21 07:45:38 +08:00
|
|
|
auto pRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
|
2018-01-05 20:35:03 +08:00
|
|
|
regAddr = userRegs->Reg[i].Offset;
|
2017-12-21 07:45:38 +08:00
|
|
|
pRegister->setRegisterAddress(regAddr);
|
|
|
|
//offset between base (low) registers is cl_ulong wide
|
|
|
|
address = baseAddr + i * sizeof(cl_ulong);
|
|
|
|
pRegister->setMemoryAddress(address);
|
|
|
|
cmdNum++;
|
|
|
|
|
2018-01-05 20:35:03 +08:00
|
|
|
if (userRegs->Reg[i].BitSize > 32) {
|
2017-12-21 07:45:38 +08:00
|
|
|
pRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
|
|
|
|
regAddr += sizeof(cl_uint);
|
|
|
|
pRegister->setRegisterAddress(regAddr);
|
|
|
|
address += sizeof(cl_uint);
|
|
|
|
pRegister->setMemoryAddress(address);
|
|
|
|
cmdNum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersOABufferStateCommands(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
|
|
|
uint64_t address = 0;
|
|
|
|
//OA Status
|
|
|
|
auto pOaRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pOaRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pOaRegister->setRegisterAddress(INSTR_GFX_OFFSETS::INSTR_OA_STATUS);
|
2018-02-16 06:05:04 +08:00
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.OaStatus));
|
2017-12-21 07:45:38 +08:00
|
|
|
pOaRegister->setMemoryAddress(address);
|
|
|
|
|
|
|
|
//OA Head
|
|
|
|
pOaRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pOaRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pOaRegister->setRegisterAddress(INSTR_GFX_OFFSETS::INSTR_OA_HEAD_PTR);
|
2018-02-16 06:05:04 +08:00
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.OaHead));
|
2017-12-21 07:45:38 +08:00
|
|
|
pOaRegister->setMemoryAddress(address);
|
|
|
|
|
|
|
|
//OA Tail
|
|
|
|
pOaRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
|
|
|
*pOaRegister = MI_STORE_REGISTER_MEM::sInit();
|
|
|
|
pOaRegister->setRegisterAddress(INSTR_GFX_OFFSETS::INSTR_OA_TAIL_PTR);
|
2018-02-16 06:05:04 +08:00
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.OaTail));
|
2017-12-21 07:45:38 +08:00
|
|
|
pOaRegister->setMemoryAddress(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsStart(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
using MI_REPORT_PERF_COUNT = typename GfxFamily::MI_REPORT_PERF_COUNT;
|
|
|
|
|
|
|
|
auto perfCounters = commandQueue.getPerfCounters();
|
|
|
|
|
|
|
|
uint32_t currentReportId = perfCounters->getCurrentReportId();
|
|
|
|
uint64_t address = 0;
|
|
|
|
//flush command streamer
|
|
|
|
auto pPipeControlCmd = (PIPE_CONTROL *)commandStream->getSpace(sizeof(PIPE_CONTROL));
|
|
|
|
*pPipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
|
|
|
|
//Store value of NOOPID register
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersNoopidRegisterCommands(commandQueue, hwPerfCounter, commandStream, true);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
//Read Core Frequency
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersReadFreqRegisterCommands(commandQueue, hwPerfCounter, commandStream, true);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(commandQueue, hwPerfCounter, commandStream, true);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto pReportPerfCount = (MI_REPORT_PERF_COUNT *)commandStream->getSpace(sizeof(MI_REPORT_PERF_COUNT));
|
|
|
|
*pReportPerfCount = MI_REPORT_PERF_COUNT::sInit();
|
|
|
|
pReportPerfCount->setReportId(currentReportId);
|
2018-02-16 06:05:04 +08:00
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.HwPerfReportBegin.Oa));
|
2017-12-21 07:45:38 +08:00
|
|
|
pReportPerfCount->setMemoryAddress(address);
|
|
|
|
|
|
|
|
//Timestamp: Global Start
|
|
|
|
pPipeControlCmd = (PIPE_CONTROL *)commandStream->getSpace(sizeof(PIPE_CONTROL));
|
|
|
|
*pPipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
pPipeControlCmd->setPostSyncOperation(PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP);
|
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWTimeStamp.GlobalStartTS));
|
|
|
|
pPipeControlCmd->setAddress(static_cast<uint32_t>(address & ((uint64_t)UINT32_MAX)));
|
|
|
|
pPipeControlCmd->setAddressHigh(static_cast<uint32_t>(address >> 32));
|
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(commandQueue, hwPerfCounter, commandStream, true);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
commandQueue.sendPerfCountersConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsEnd(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
OCLRT::HwPerfCounter &hwPerfCounter,
|
|
|
|
OCLRT::LinearStream *commandStream) {
|
|
|
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
using MI_REPORT_PERF_COUNT = typename GfxFamily::MI_REPORT_PERF_COUNT;
|
|
|
|
|
|
|
|
auto perfCounters = commandQueue.getPerfCounters();
|
|
|
|
|
|
|
|
uint32_t currentReportId = perfCounters->getCurrentReportId();
|
|
|
|
uint64_t address = 0;
|
|
|
|
|
|
|
|
//flush command streamer
|
|
|
|
auto pPipeControlCmd = (PIPE_CONTROL *)commandStream->getSpace(sizeof(PIPE_CONTROL));
|
|
|
|
*pPipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersOABufferStateCommands(commandQueue, hwPerfCounter, commandStream);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
//Timestamp: Global End
|
|
|
|
pPipeControlCmd = (PIPE_CONTROL *)commandStream->getSpace(sizeof(PIPE_CONTROL));
|
|
|
|
*pPipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
pPipeControlCmd->setPostSyncOperation(PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP);
|
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWTimeStamp.GlobalEndTS));
|
|
|
|
pPipeControlCmd->setAddress(static_cast<uint32_t>(address & ((uint64_t)UINT32_MAX)));
|
|
|
|
pPipeControlCmd->setAddressHigh(static_cast<uint32_t>(address >> 32));
|
|
|
|
|
|
|
|
auto pReportPerfCount = (MI_REPORT_PERF_COUNT *)commandStream->getSpace(sizeof(MI_REPORT_PERF_COUNT));
|
|
|
|
*pReportPerfCount = MI_REPORT_PERF_COUNT::sInit();
|
|
|
|
pReportPerfCount->setReportId(currentReportId);
|
2018-02-16 06:05:04 +08:00
|
|
|
address = reinterpret_cast<uint64_t>(&(hwPerfCounter.HWPerfCounters.HwPerfReportEnd.Oa));
|
2017-12-21 07:45:38 +08:00
|
|
|
pReportPerfCount->setMemoryAddress(address);
|
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersGeneralPurposeCounterCommands(commandQueue, hwPerfCounter, commandStream, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
//Store value of NOOPID register
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersNoopidRegisterCommands(commandQueue, hwPerfCounter, commandStream, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
//Read Core Frequency
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersReadFreqRegisterCommands(commandQueue, hwPerfCounter, commandStream, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersUserCounterCommands(commandQueue, hwPerfCounter, commandStream, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
perfCounters->setCpuTimestamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchWalker(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
const MultiDispatchInfo &multiDispatchInfo,
|
|
|
|
cl_uint numEventsInWaitList,
|
|
|
|
const cl_event *eventWaitList,
|
|
|
|
KernelOperation **blockedCommandsData,
|
|
|
|
HwTimeStamps *hwTimeStamps,
|
|
|
|
OCLRT::HwPerfCounter *hwPerfCounter,
|
2018-09-11 15:43:06 +08:00
|
|
|
TimestampPacket *previousTimestampPacket,
|
|
|
|
TimestampPacket *currentTimestampPacket,
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode,
|
2018-03-30 17:49:36 +08:00
|
|
|
bool blockQueue,
|
2018-04-09 22:39:32 +08:00
|
|
|
uint32_t commandType) {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-07 23:04:18 +08:00
|
|
|
HARDWARE_INTERFACE<GfxFamily> hardwareInterface;
|
|
|
|
hardwareInterface.dispatchWalker(
|
|
|
|
commandQueue,
|
|
|
|
multiDispatchInfo,
|
|
|
|
numEventsInWaitList,
|
|
|
|
eventWaitList,
|
|
|
|
blockedCommandsData,
|
|
|
|
hwTimeStamps,
|
|
|
|
hwPerfCounter,
|
|
|
|
previousTimestampPacket,
|
|
|
|
currentTimestampPacket,
|
|
|
|
preemptionMode,
|
|
|
|
blockQueue,
|
|
|
|
commandType);
|
2018-08-24 21:53:33 +08:00
|
|
|
}
|
2018-01-02 19:10:34 +08:00
|
|
|
|
2018-09-07 15:09:24 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
inline void GpgpuWalkerHelper<GfxFamily>::dispatchOnDeviceWaitlistSemaphores(LinearStream *commandStream, Device ¤tDevice,
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList) {
|
|
|
|
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
|
|
|
|
|
|
|
|
for (cl_uint i = 0; i < numEventsInWaitList; i++) {
|
|
|
|
auto event = castToObjectOrAbort<Event>(eventWaitList[i]);
|
|
|
|
if (event->isUserEvent() || (&event->getCommandQueue()->getDevice() != ¤tDevice)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
auto timestampPacket = event->getTimestampPacket();
|
|
|
|
|
|
|
|
auto compareAddress = timestampPacket->pickAddressForDataWrite(TimestampPacket::DataIndex::ContextEnd);
|
|
|
|
|
2018-09-11 16:15:54 +08:00
|
|
|
KernelCommandsHelper<GfxFamily>::programMiSemaphoreWait(*commandStream, compareAddress, 1);
|
2018-09-07 15:09:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 14:48:59 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::setupTimestampPacket(
|
|
|
|
LinearStream *cmdStream,
|
|
|
|
WALKER_HANDLE walkerHandle,
|
|
|
|
TimestampPacket *timestampPacket,
|
|
|
|
TimestampPacket::WriteOperationType writeOperationType) {
|
|
|
|
|
2018-09-03 15:34:57 +08:00
|
|
|
uint64_t address;
|
|
|
|
if (TimestampPacket::WriteOperationType::BeforeWalker == writeOperationType) {
|
|
|
|
address = timestampPacket->pickAddressForDataWrite(TimestampPacket::DataIndex::Submit);
|
|
|
|
} else {
|
|
|
|
address = timestampPacket->pickAddressForDataWrite(TimestampPacket::DataIndex::ContextEnd);
|
|
|
|
}
|
2018-08-24 14:48:59 +08:00
|
|
|
|
|
|
|
auto pipeControlCmd = cmdStream->getSpaceForCmd<PIPE_CONTROL>();
|
|
|
|
*pipeControlCmd = PIPE_CONTROL::sInit();
|
|
|
|
pipeControlCmd->setCommandStreamerStallEnable(true);
|
|
|
|
pipeControlCmd->setPostSyncOperation(PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA);
|
|
|
|
pipeControlCmd->setAddress(static_cast<uint32_t>(address & 0x0000FFFFFFFFULL));
|
|
|
|
pipeControlCmd->setAddressHigh(static_cast<uint32_t>(address >> 32));
|
|
|
|
pipeControlCmd->setImmediateData(0);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-03-30 23:57:51 +08:00
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchScheduler(
|
2017-12-21 07:45:38 +08:00
|
|
|
CommandQueue &commandQueue,
|
|
|
|
DeviceQueueHw<GfxFamily> &devQueueHw,
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode,
|
2018-04-05 21:12:28 +08:00
|
|
|
SchedulerKernel &scheduler,
|
|
|
|
IndirectHeap *ssh,
|
|
|
|
IndirectHeap *dsh) {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
using INTERFACE_DESCRIPTOR_DATA = typename GfxFamily::INTERFACE_DESCRIPTOR_DATA;
|
|
|
|
using GPGPU_WALKER = typename GfxFamily::GPGPU_WALKER;
|
|
|
|
using MI_BATCH_BUFFER_START = typename GfxFamily::MI_BATCH_BUFFER_START;
|
|
|
|
|
|
|
|
OCLRT::LinearStream *commandStream = nullptr;
|
2018-04-05 21:12:28 +08:00
|
|
|
OCLRT::IndirectHeap *ioh = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
commandStream = &commandQueue.getCS(0);
|
|
|
|
|
|
|
|
bool dcFlush = false;
|
|
|
|
commandQueue.getDevice().getCommandStreamReceiver().addPipeControl(*commandStream, dcFlush);
|
|
|
|
|
|
|
|
uint32_t interfaceDescriptorIndex = devQueueHw.schedulerIDIndex;
|
|
|
|
const size_t offsetInterfaceDescriptorTable = devQueueHw.colorCalcStateSize;
|
|
|
|
const size_t offsetInterfaceDescriptor = offsetInterfaceDescriptorTable;
|
|
|
|
const size_t totalInterfaceDescriptorTableSize = devQueueHw.interfaceDescriptorEntries * sizeof(INTERFACE_DESCRIPTOR_DATA);
|
|
|
|
|
|
|
|
// Program media interface descriptor load
|
|
|
|
KernelCommandsHelper<GfxFamily>::sendMediaInterfaceDescriptorLoad(
|
|
|
|
*commandStream,
|
|
|
|
offsetInterfaceDescriptor,
|
|
|
|
totalInterfaceDescriptorTableSize);
|
|
|
|
|
|
|
|
DEBUG_BREAK_IF(offsetInterfaceDescriptorTable % 64 != 0);
|
|
|
|
|
|
|
|
// Determine SIMD size
|
|
|
|
uint32_t simd = scheduler.getKernelInfo().getMaxSimdSize();
|
|
|
|
DEBUG_BREAK_IF(simd != PARALLEL_SCHEDULER_COMPILATION_SIZE_20);
|
|
|
|
|
|
|
|
// Patch our kernel constants
|
|
|
|
*scheduler.globalWorkOffsetX = 0;
|
|
|
|
*scheduler.globalWorkOffsetY = 0;
|
|
|
|
*scheduler.globalWorkOffsetZ = 0;
|
|
|
|
|
|
|
|
*scheduler.globalWorkSizeX = (uint32_t)scheduler.getGws();
|
|
|
|
*scheduler.globalWorkSizeY = 1;
|
|
|
|
*scheduler.globalWorkSizeZ = 1;
|
|
|
|
|
|
|
|
*scheduler.localWorkSizeX = (uint32_t)scheduler.getLws();
|
|
|
|
*scheduler.localWorkSizeY = 1;
|
|
|
|
*scheduler.localWorkSizeZ = 1;
|
|
|
|
|
|
|
|
*scheduler.localWorkSizeX2 = (uint32_t)scheduler.getLws();
|
|
|
|
*scheduler.localWorkSizeY2 = 1;
|
|
|
|
*scheduler.localWorkSizeZ2 = 1;
|
|
|
|
|
|
|
|
*scheduler.enqueuedLocalWorkSizeX = (uint32_t)scheduler.getLws();
|
|
|
|
*scheduler.enqueuedLocalWorkSizeY = 1;
|
|
|
|
*scheduler.enqueuedLocalWorkSizeZ = 1;
|
|
|
|
|
|
|
|
*scheduler.numWorkGroupsX = (uint32_t)(scheduler.getGws() / scheduler.getLws());
|
|
|
|
*scheduler.numWorkGroupsY = 0;
|
|
|
|
*scheduler.numWorkGroupsZ = 0;
|
|
|
|
|
|
|
|
*scheduler.workDim = 1;
|
|
|
|
|
|
|
|
// Send our indirect object data
|
|
|
|
size_t localWorkSizes[3] = {scheduler.getLws(), 1, 1};
|
|
|
|
|
|
|
|
// Create indirectHeap for IOH that is located at the end of device enqueue DSH
|
|
|
|
size_t curbeOffset = devQueueHw.setSchedulerCrossThreadData(scheduler);
|
2018-03-05 18:03:38 +08:00
|
|
|
IndirectHeap indirectObjectHeap(dsh->getCpuBase(), dsh->getMaxAvailableSpace());
|
2017-12-21 07:45:38 +08:00
|
|
|
indirectObjectHeap.getSpace(curbeOffset);
|
|
|
|
ioh = &indirectObjectHeap;
|
|
|
|
|
|
|
|
auto offsetCrossThreadData = KernelCommandsHelper<GfxFamily>::sendIndirectState(
|
|
|
|
*commandStream,
|
|
|
|
*dsh,
|
|
|
|
*ioh,
|
|
|
|
*ssh,
|
|
|
|
scheduler,
|
|
|
|
simd,
|
|
|
|
localWorkSizes,
|
|
|
|
offsetInterfaceDescriptorTable,
|
2018-03-02 05:43:04 +08:00
|
|
|
interfaceDescriptorIndex,
|
2018-05-11 19:33:16 +08:00
|
|
|
preemptionMode,
|
|
|
|
nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
// Implement enabling special WA DisableLSQCROPERFforOCL if needed
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::applyWADisableLSQCROPERFforOCL(commandStream, scheduler, true);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
// Program the walker. Invokes execution so all state should already be programmed
|
|
|
|
auto pGpGpuWalkerCmd = (GPGPU_WALKER *)commandStream->getSpace(sizeof(GPGPU_WALKER));
|
|
|
|
*pGpGpuWalkerCmd = GfxFamily::cmdInitGpgpuWalker;
|
|
|
|
|
|
|
|
size_t globalOffsets[3] = {0, 0, 0};
|
|
|
|
size_t workGroups[3] = {(scheduler.getGws() / scheduler.getLws()), 1, 1};
|
2018-03-30 23:57:51 +08:00
|
|
|
auto localWorkSize = GpgpuWalkerHelper<GfxFamily>::setGpgpuWalkerThreadData(pGpGpuWalkerCmd, globalOffsets, globalOffsets, workGroups, localWorkSizes, simd);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
pGpGpuWalkerCmd->setIndirectDataStartAddress((uint32_t)offsetCrossThreadData);
|
|
|
|
DEBUG_BREAK_IF(offsetCrossThreadData % 64 != 0);
|
|
|
|
pGpGpuWalkerCmd->setInterfaceDescriptorOffset(interfaceDescriptorIndex);
|
|
|
|
|
|
|
|
auto threadPayload = scheduler.getKernelInfo().patchInfo.threadPayload;
|
|
|
|
DEBUG_BREAK_IF(nullptr == threadPayload);
|
|
|
|
|
|
|
|
auto numChannels = PerThreadDataHelper::getNumLocalIdChannels(*threadPayload);
|
|
|
|
auto localIdSizePerThread = PerThreadDataHelper::getLocalIdSizePerThread(simd, numChannels);
|
|
|
|
localIdSizePerThread = std::max(localIdSizePerThread, sizeof(GRF));
|
|
|
|
|
|
|
|
auto sizePerThreadDataTotal = getThreadsPerWG(simd, localWorkSize) * localIdSizePerThread;
|
|
|
|
DEBUG_BREAK_IF(sizePerThreadDataTotal == 0); // Hardware requires at least 1 GRF of perThreadData for each thread in thread group
|
|
|
|
|
|
|
|
auto sizeCrossThreadData = scheduler.getCrossThreadDataSize();
|
|
|
|
auto IndirectDataLength = alignUp((uint32_t)(sizeCrossThreadData + sizePerThreadDataTotal), GPGPU_WALKER::INDIRECTDATASTARTADDRESS_ALIGN_SIZE);
|
|
|
|
pGpGpuWalkerCmd->setIndirectDataLength(IndirectDataLength);
|
|
|
|
|
|
|
|
// Implement disabling special WA DisableLSQCROPERFforOCL if needed
|
2018-03-30 23:57:51 +08:00
|
|
|
GpgpuWalkerHelper<GfxFamily>::applyWADisableLSQCROPERFforOCL(commandStream, scheduler, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
// Do not put BB_START only when returning in first Scheduler run
|
|
|
|
if (devQueueHw.getSchedulerReturnInstance() != 1) {
|
|
|
|
|
|
|
|
commandQueue.getDevice().getCommandStreamReceiver().addPipeControl(*commandStream, true);
|
|
|
|
|
|
|
|
// Add BB Start Cmd to the SLB in the Primary Batch Buffer
|
|
|
|
auto *bbStart = (MI_BATCH_BUFFER_START *)commandStream->getSpace(sizeof(MI_BATCH_BUFFER_START));
|
|
|
|
*bbStart = MI_BATCH_BUFFER_START::sInit();
|
|
|
|
bbStart->setSecondLevelBatchBuffer(MI_BATCH_BUFFER_START::SECOND_LEVEL_BATCH_BUFFER_FIRST_LEVEL_BATCH);
|
|
|
|
uint64_t slbAddress = devQueueHw.getSlbBuffer()->getGpuAddress();
|
|
|
|
bbStart->setBatchBufferStartAddressGraphicsaddress472(slbAddress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::applyWADisableLSQCROPERFforOCL(OCLRT::LinearStream *pCommandStream, const Kernel &kernel, bool disablePerfMode) {
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-03-30 23:57:51 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t GpgpuWalkerHelper<GfxFamily>::getSizeForWADisableLSQCROPERFforOCL(const Kernel *pKernel) {
|
|
|
|
return (size_t)0;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-04-09 22:39:32 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getTotalSizeRequiredCS(bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue, const MultiDispatchInfo &multiDispatchInfo) {
|
|
|
|
size_t size = KernelCommandsHelper<GfxFamily>::getSizeRequiredCS() +
|
2018-08-24 14:48:59 +08:00
|
|
|
sizeof(PIPE_CONTROL) * (KernelCommandsHelper<GfxFamily>::isPipeControlWArequired() ? 2 : 1);
|
2018-04-09 22:39:32 +08:00
|
|
|
if (reserveProfilingCmdsSpace) {
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL) + 4 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
2018-04-09 22:39:32 +08:00
|
|
|
}
|
|
|
|
if (reservePerfCounters) {
|
|
|
|
//start cmds
|
|
|
|
//P_C: flush CS & TimeStamp BEGIN
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL);
|
2018-04-09 22:39:32 +08:00
|
|
|
//SRM NOOPID & Frequency
|
|
|
|
size += 2 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//gp registers
|
|
|
|
size += OCLRT::INSTR_GENERAL_PURPOSE_COUNTERS_COUNT * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//report perf count
|
|
|
|
size += sizeof(typename GfxFamily::MI_REPORT_PERF_COUNT);
|
|
|
|
//user registers
|
|
|
|
size += commandQueue.getPerfCountersUserRegistersNumber() * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
|
|
|
|
//end cmds
|
|
|
|
//P_C: flush CS & TimeStamp END;
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL);
|
2018-04-09 22:39:32 +08:00
|
|
|
//OA buffer (status head, tail)
|
|
|
|
size += 3 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//report perf count
|
|
|
|
size += sizeof(typename GfxFamily::MI_REPORT_PERF_COUNT);
|
|
|
|
//gp registers
|
|
|
|
size += OCLRT::INSTR_GENERAL_PURPOSE_COUNTERS_COUNT * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//SRM NOOPID & Frequency
|
|
|
|
size += 2 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//user registers
|
|
|
|
size += commandQueue.getPerfCountersUserRegistersNumber() * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
}
|
|
|
|
Device &device = commandQueue.getDevice();
|
|
|
|
for (auto &dispatchInfo : multiDispatchInfo) {
|
|
|
|
auto &kernel = *dispatchInfo.getKernel();
|
|
|
|
size += sizeof(typename GfxFamily::GPGPU_WALKER);
|
|
|
|
size += GpgpuWalkerHelper<GfxFamily>::getSizeForWADisableLSQCROPERFforOCL(&kernel);
|
|
|
|
size += PreemptionHelper::getPreemptionWaCsSize<GfxFamily>(device);
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeRequiredCS(uint32_t cmdType, bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue, const Kernel *pKernel) {
|
|
|
|
switch (cmdType) {
|
|
|
|
case CL_COMMAND_MIGRATE_MEM_OBJECTS:
|
|
|
|
case CL_COMMAND_MARKER:
|
|
|
|
return EnqueueOperation<GfxFamily>::getSizeRequiredCSNonKernel(reserveProfilingCmdsSpace, reservePerfCounters, commandQueue);
|
|
|
|
case CL_COMMAND_NDRANGE_KERNEL:
|
|
|
|
default:
|
|
|
|
return EnqueueOperation<GfxFamily>::getSizeRequiredCSKernel(reserveProfilingCmdsSpace, reservePerfCounters, commandQueue, pKernel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeRequiredCSKernel(bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue, const Kernel *pKernel) {
|
|
|
|
size_t size = sizeof(typename GfxFamily::GPGPU_WALKER) + KernelCommandsHelper<GfxFamily>::getSizeRequiredCS() +
|
2018-08-24 14:48:59 +08:00
|
|
|
sizeof(PIPE_CONTROL) * (KernelCommandsHelper<GfxFamily>::isPipeControlWArequired() ? 2 : 1);
|
2018-04-09 22:39:32 +08:00
|
|
|
size += PreemptionHelper::getPreemptionWaCsSize<GfxFamily>(commandQueue.getDevice());
|
|
|
|
if (reserveProfilingCmdsSpace) {
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL) + 2 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
2018-04-09 22:39:32 +08:00
|
|
|
}
|
|
|
|
if (reservePerfCounters) {
|
|
|
|
//start cmds
|
|
|
|
//P_C: flush CS & TimeStamp BEGIN
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL);
|
2018-04-09 22:39:32 +08:00
|
|
|
//SRM NOOPID & Frequency
|
|
|
|
size += 2 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//gp registers
|
|
|
|
size += OCLRT::INSTR_GENERAL_PURPOSE_COUNTERS_COUNT * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//report perf count
|
|
|
|
size += sizeof(typename GfxFamily::MI_REPORT_PERF_COUNT);
|
|
|
|
//user registers
|
|
|
|
size += commandQueue.getPerfCountersUserRegistersNumber() * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
|
|
|
|
//end cmds
|
|
|
|
//P_C: flush CS & TimeStamp END;
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL);
|
2018-04-09 22:39:32 +08:00
|
|
|
//OA buffer (status head, tail)
|
|
|
|
size += 3 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//report perf count
|
|
|
|
size += sizeof(typename GfxFamily::MI_REPORT_PERF_COUNT);
|
|
|
|
//gp registers
|
|
|
|
size += OCLRT::INSTR_GENERAL_PURPOSE_COUNTERS_COUNT * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//SRM NOOPID & Frequency
|
|
|
|
size += 2 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
//user registers
|
|
|
|
size += commandQueue.getPerfCountersUserRegistersNumber() * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
}
|
|
|
|
size += GpgpuWalkerHelper<GfxFamily>::getSizeForWADisableLSQCROPERFforOCL(pKernel);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeRequiredCSNonKernel(bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue) {
|
|
|
|
size_t size = 0;
|
|
|
|
if (reserveProfilingCmdsSpace) {
|
2018-08-24 14:48:59 +08:00
|
|
|
size += 2 * sizeof(PIPE_CONTROL) + 4 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
2018-04-09 22:39:32 +08:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2018-09-06 16:01:51 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeRequiredForTimestampPacketWrite() {
|
|
|
|
return 2 * sizeof(PIPE_CONTROL);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
} // namespace OCLRT
|