mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Append LRI params for Translation Table callbacks
Change-Id: I8f0f81f9c49edf83f76b38cf886143ac018ec400
This commit is contained in:

committed by
sys_ocldev

parent
26c2768ebb
commit
dbe3bdb8a3
@ -37,6 +37,7 @@ ENABLE_WUD()
|
||||
if(WIN32)
|
||||
set(GEN_OS_SRC
|
||||
windows/command_stream_receiver.cpp
|
||||
windows/translationtable_callbacks.cpp
|
||||
windows/wddm_engine_mapper.cpp
|
||||
windows/wddm.cpp
|
||||
)
|
||||
|
29
runtime/gen8/windows/translationtable_callbacks.cpp
Normal file
29
runtime/gen8/windows/translationtable_callbacks.cpp
Normal file
@ -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 "hw_cmds.h"
|
||||
#include "runtime/helpers/translationtable_callbacks.h"
|
||||
#include "runtime/helpers/translationtable_callbacks.inl"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
template struct TTCallbacks<BDWFamily>;
|
29
runtime/gen9/windows/translationtable_callbacks.cpp
Normal file
29
runtime/gen9/windows/translationtable_callbacks.cpp
Normal file
@ -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 "hw_cmds.h"
|
||||
#include "runtime/helpers/translationtable_callbacks.h"
|
||||
#include "runtime/helpers/translationtable_callbacks.inl"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
template struct TTCallbacks<SKLFamily>;
|
@ -83,5 +83,6 @@ set(RUNTIME_SRCS_HELPERS_BASE
|
||||
)
|
||||
set(RUNTIME_SRCS_HELPERS_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks.inl
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
@ -101,12 +101,14 @@ struct DwordBuilder {
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct LriHelper {
|
||||
static void program(LinearStream *cmdStream, uint32_t address, uint32_t value) {
|
||||
typedef typename GfxFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
static MI_LOAD_REGISTER_IMM *program(LinearStream *cmdStream, uint32_t address, uint32_t value) {
|
||||
auto lri = (MI_LOAD_REGISTER_IMM *)cmdStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM));
|
||||
*lri = MI_LOAD_REGISTER_IMM::sInit();
|
||||
lri->setRegisterOffset(address);
|
||||
lri->setDataDword(value);
|
||||
return lri;
|
||||
}
|
||||
};
|
||||
} // 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"),
|
||||
@ -21,29 +21,16 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_stream/linear_stream.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct TTCallbacks {
|
||||
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
static int __stdcall writeL3Address(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset) {
|
||||
typedef typename GfxFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
|
||||
auto cmdStream = reinterpret_cast<LinearStream *>(queueHandle);
|
||||
|
||||
LriHelper<GfxFamily>::program(cmdStream,
|
||||
static_cast<uint32_t>(regOffset & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(l3GfxAddress & 0xFFFFFFFF));
|
||||
|
||||
LriHelper<GfxFamily>::program(cmdStream,
|
||||
static_cast<uint32_t>(regOffset >> 32),
|
||||
static_cast<uint32_t>(l3GfxAddress >> 32));
|
||||
|
||||
return 1;
|
||||
};
|
||||
static int __stdcall writeL3Address(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset);
|
||||
static void appendLriParams(MI_LOAD_REGISTER_IMM *lri);
|
||||
};
|
||||
|
||||
} // namespace OCLRT
|
||||
|
49
runtime/helpers/translationtable_callbacks.inl
Normal file
49
runtime/helpers/translationtable_callbacks.inl
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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/translationtable_callbacks.h"
|
||||
#include "runtime/command_stream/linear_stream.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace OCLRT {
|
||||
template <typename GfxFamily>
|
||||
int __stdcall TTCallbacks<GfxFamily>::writeL3Address(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset) {
|
||||
|
||||
auto cmdStream = reinterpret_cast<LinearStream *>(queueHandle);
|
||||
|
||||
auto lri1 = LriHelper<GfxFamily>::program(cmdStream,
|
||||
static_cast<uint32_t>(regOffset & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(l3GfxAddress & 0xFFFFFFFF));
|
||||
appendLriParams(lri1);
|
||||
|
||||
auto lri2 = LriHelper<GfxFamily>::program(cmdStream,
|
||||
static_cast<uint32_t>(regOffset >> 32),
|
||||
static_cast<uint32_t>(l3GfxAddress >> 32));
|
||||
appendLriParams(lri2);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
void TTCallbacks<GfxFamily>::appendLriParams(MI_LOAD_REGISTER_IMM *lri) {}
|
||||
} // namespace OCLRT
|
@ -53,6 +53,7 @@ endif(NOT MSVC)
|
||||
if(MSVC)
|
||||
set(IGDRCL_SRCS_tests_gen8_windows
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_mapper_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/translationtable_callbacks_tests.cpp"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
else()
|
||||
|
39
unit_tests/gen8/windows/translationtable_callbacks_tests.cpp
Normal file
39
unit_tests/gen8/windows/translationtable_callbacks_tests.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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/translationtable_callbacks.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
typedef ::testing::Test Gen8TTCallbacksTests;
|
||||
|
||||
GEN8TEST_F(Gen8TTCallbacksTests, givenLriWhenAppendCalledThenDoNothing) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
auto lri = MI_LOAD_REGISTER_IMM::sInit();
|
||||
auto lriBefore = lri;
|
||||
TTCallbacks<FamilyType>::appendLriParams(&lri);
|
||||
|
||||
EXPECT_TRUE(memcmp(&lri, &lriBefore, sizeof(MI_LOAD_REGISTER_IMM)) == 0);
|
||||
}
|
@ -134,6 +134,7 @@ if(MSVC)
|
||||
set(IGDRCL_SRCS_tests_gen9_windows
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_mapper_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/os_interface_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/translationtable_callbacks_tests.cpp"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
else()
|
||||
|
39
unit_tests/gen9/windows/translationtable_callbacks_tests.cpp
Normal file
39
unit_tests/gen9/windows/translationtable_callbacks_tests.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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/translationtable_callbacks.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
typedef ::testing::Test Gen9TTCallbacksTests;
|
||||
|
||||
GEN9TEST_F(Gen9TTCallbacksTests, givenLriWhenAppendCalledThenDoNothing) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
auto lri = MI_LOAD_REGISTER_IMM::sInit();
|
||||
auto lriBefore = lri;
|
||||
TTCallbacks<FamilyType>::appendLriParams(&lri);
|
||||
|
||||
EXPECT_TRUE(memcmp(&lri, &lriBefore, sizeof(MI_LOAD_REGISTER_IMM)) == 0);
|
||||
}
|
@ -165,3 +165,24 @@ TEST(DwordBuilderTest, setMaskedBitsWithDifferentBitValue) {
|
||||
dword = DwordBuilder::build(3, true, true, 0);
|
||||
EXPECT_EQ(expectedDword, dword);
|
||||
}
|
||||
|
||||
using LriHelperTests = ::testing::Test;
|
||||
|
||||
HWTEST_F(LriHelperTests, givenAddressAndOffsetWhenHelperIsUsedThenProgramCmdStream) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
std::unique_ptr<uint8_t> buffer(new uint8_t[128]);
|
||||
|
||||
LinearStream stream(buffer.get(), 128);
|
||||
uint32_t address = 0x8888;
|
||||
uint32_t data = 0x1234;
|
||||
|
||||
auto expectedLri = MI_LOAD_REGISTER_IMM::sInit();
|
||||
expectedLri.setRegisterOffset(address);
|
||||
expectedLri.setDataDword(data);
|
||||
|
||||
auto lri = LriHelper<FamilyType>::program(&stream, address, data);
|
||||
|
||||
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM), stream.getUsed());
|
||||
EXPECT_EQ(lri, stream.getBase());
|
||||
EXPECT_TRUE(memcmp(lri, &expectedLri, sizeof(MI_LOAD_REGISTER_IMM)) == 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user