mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Gmm Memory: initialize client context in constructor
Change-Id: Iaaa40f5485faceb022e018be7930777e14575b46
This commit is contained in:

committed by
sys_ocldev

parent
d80334a534
commit
ab7920ba14
@ -25,10 +25,8 @@
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
void GmmMemoryBase::ensureClientContext() {
|
||||
if (!clientContext) {
|
||||
clientContext = GmmHelper::gmmClientContext->getHandle();
|
||||
}
|
||||
GmmMemoryBase::GmmMemoryBase() {
|
||||
clientContext = GmmHelper::gmmClientContext->getHandle();
|
||||
}
|
||||
bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
|
||||
GMM_ESCAPE_HANDLE hDevice,
|
||||
@ -39,7 +37,6 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
|
||||
BOOLEAN BDWL3Coherency,
|
||||
GMM_GFX_SIZE_T SizeOverride,
|
||||
GMM_GFX_SIZE_T SlmGfxSpaceReserve) {
|
||||
ensureClientContext();
|
||||
return clientContext->ConfigureDeviceAddressSpace(
|
||||
{hAdapter},
|
||||
{hDevice},
|
||||
|
@ -40,8 +40,7 @@ class GmmMemoryBase {
|
||||
GMM_GFX_SIZE_T SlmGfxSpaceReserve);
|
||||
|
||||
protected:
|
||||
GmmMemoryBase() = default;
|
||||
void ensureClientContext();
|
||||
GmmMemoryBase();
|
||||
GMM_CLIENT_CONTEXT *clientContext = nullptr;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -30,25 +30,11 @@ using namespace OCLRT;
|
||||
class PublicGmmMemory : public GmmMemory {
|
||||
public:
|
||||
using GmmMemory::clientContext;
|
||||
using GmmMemory::ensureClientContext;
|
||||
};
|
||||
|
||||
TEST(GmmMemoryTest, givenGmmMemoryWithoutSetClientContextWhenEnsureClientContextThenSetClientContext) {
|
||||
PublicGmmMemory gmmMemory;
|
||||
TEST(GmmMemoryTest, givenGmmHelperWhenCreateGmmMemoryThenItHasClientContextFromGmmHelper) {
|
||||
GmmHelper gmmHelper(*platformDevices);
|
||||
EXPECT_EQ(nullptr, gmmMemory.clientContext);
|
||||
gmmMemory.ensureClientContext();
|
||||
EXPECT_NE(nullptr, gmmMemory.clientContext);
|
||||
ASSERT_NE(nullptr, GmmHelper::gmmClientContext);
|
||||
PublicGmmMemory gmmMemory;
|
||||
EXPECT_EQ(gmmMemory.clientContext, GmmHelper::gmmClientContext->getHandle());
|
||||
}
|
||||
|
||||
TEST(GmmMemoryTest, givenGmmMemoryWithSetClientContextWhenEnsureClientContextThenDontOverrideClientContext) {
|
||||
PublicGmmMemory gmmMemory;
|
||||
GmmHelper gmmHelper(*platformDevices);
|
||||
auto dummyPtr = reinterpret_cast<GMM_CLIENT_CONTEXT *>(0x123);
|
||||
gmmMemory.clientContext = dummyPtr;
|
||||
EXPECT_EQ(dummyPtr, gmmMemory.clientContext);
|
||||
EXPECT_NE(dummyPtr, GmmHelper::gmmClientContext->getHandle());
|
||||
gmmMemory.ensureClientContext();
|
||||
EXPECT_EQ(dummyPtr, gmmMemory.clientContext);
|
||||
}
|
||||
|
Reference in New Issue
Block a user