mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Block SVMAllocsManager creation in Context when SVM is not supported
- skip SVM tests when SVM is not supported Related-To: NEO-3157 Change-Id: Ie5d5ef4778749f60537084fc7f388714954a4873 Signed-off-by: Hoppe, Mateusz <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
9217b80b42
commit
d15174d7c5
@@ -3621,6 +3621,12 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto svmManager = pKernel->getContext().getSVMAllocsManager();
|
||||||
|
if (!svmManager) {
|
||||||
|
retVal = CL_INVALID_ARG_VALUE;
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
cl_int kernelArgAddressQualifier = pKernel->getKernelArgAddressQualifier(argIndex);
|
cl_int kernelArgAddressQualifier = pKernel->getKernelArgAddressQualifier(argIndex);
|
||||||
if ((kernelArgAddressQualifier != CL_KERNEL_ARG_ADDRESS_GLOBAL) &&
|
if ((kernelArgAddressQualifier != CL_KERNEL_ARG_ADDRESS_GLOBAL) &&
|
||||||
(kernelArgAddressQualifier != CL_KERNEL_ARG_ADDRESS_CONSTANT)) {
|
(kernelArgAddressQualifier != CL_KERNEL_ARG_ADDRESS_CONSTANT)) {
|
||||||
@@ -3630,7 +3636,7 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
|
|||||||
|
|
||||||
GraphicsAllocation *pSvmAlloc = nullptr;
|
GraphicsAllocation *pSvmAlloc = nullptr;
|
||||||
if (argValue != nullptr) {
|
if (argValue != nullptr) {
|
||||||
auto svmData = pKernel->getContext().getSVMAllocsManager()->getSVMAlloc(argValue);
|
auto svmData = svmManager->getSVMAlloc(argValue);
|
||||||
if (svmData == nullptr) {
|
if (svmData == nullptr) {
|
||||||
retVal = CL_INVALID_ARG_VALUE;
|
retVal = CL_INVALID_ARG_VALUE;
|
||||||
return retVal;
|
return retVal;
|
||||||
@@ -3668,6 +3674,10 @@ cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel,
|
|||||||
size_t numPointers = paramValueSize / sizeof(void *);
|
size_t numPointers = paramValueSize / sizeof(void *);
|
||||||
size_t *pSvmPtrList = (size_t *)paramValue;
|
size_t *pSvmPtrList = (size_t *)paramValue;
|
||||||
|
|
||||||
|
if (pKernel->getContext().getSVMAllocsManager() == nullptr) {
|
||||||
|
return CL_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
pKernel->clearKernelExecInfo();
|
pKernel->clearKernelExecInfo();
|
||||||
for (uint32_t i = 0; i < numPointers; i++) {
|
for (uint32_t i = 0; i < numPointers; i++) {
|
||||||
auto svmData = pKernel->getContext().getSVMAllocsManager()->getSVMAlloc((const void *)pSvmPtrList[i]);
|
auto svmData = pKernel->getContext().getSVMAllocsManager()->getSVMAlloc((const void *)pSvmPtrList[i]);
|
||||||
@@ -4145,9 +4155,14 @@ cl_int CL_API_CALL clEnqueueSVMMigrateMem(cl_command_queue commandQueue,
|
|||||||
retVal = CL_INVALID_VALUE;
|
retVal = CL_INVALID_VALUE;
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
auto pSvmAllocMgr = pCommandQueue->getContext().getSVMAllocsManager();
|
||||||
|
|
||||||
|
if (pSvmAllocMgr == nullptr) {
|
||||||
|
retVal = CL_INVALID_VALUE;
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numSvmPointers; i++) {
|
for (uint32_t i = 0; i < numSvmPointers; i++) {
|
||||||
SVMAllocsManager *pSvmAllocMgr = pCommandQueue->getContext().getSVMAllocsManager();
|
|
||||||
auto svmData = pSvmAllocMgr->getSVMAlloc(svmPointers[i]);
|
auto svmData = pSvmAllocMgr->getSVMAlloc(svmPointers[i]);
|
||||||
if (svmData == nullptr) {
|
if (svmData == nullptr) {
|
||||||
retVal = CL_INVALID_VALUE;
|
retVal = CL_INVALID_VALUE;
|
||||||
|
|||||||
@@ -166,7 +166,9 @@ bool Context::createImpl(const cl_context_properties *properties,
|
|||||||
if (devices.size() > 0) {
|
if (devices.size() > 0) {
|
||||||
auto device = this->getDevice(0);
|
auto device = this->getDevice(0);
|
||||||
this->memoryManager = device->getMemoryManager();
|
this->memoryManager = device->getMemoryManager();
|
||||||
|
if (device->getHardwareInfo().capabilityTable.ftrSvm) {
|
||||||
this->svmAllocsManager = new SVMAllocsManager(this->memoryManager);
|
this->svmAllocsManager = new SVMAllocsManager(this->memoryManager);
|
||||||
|
}
|
||||||
if (memoryManager->isAsyncDeleterEnabled()) {
|
if (memoryManager->isAsyncDeleterEnabled()) {
|
||||||
memoryManager->getDeferredDeleter()->addClient();
|
memoryManager->getDeferredDeleter()->addClient();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,9 @@ Buffer *Buffer::create(Context *context,
|
|||||||
allocateMemory = true;
|
allocateMemory = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto svmData = context->getSVMAllocsManager()->getSVMAlloc(hostPtr);
|
auto svmManager = context->getSVMAllocsManager();
|
||||||
|
if (svmManager) {
|
||||||
|
auto svmData = svmManager->getSVMAlloc(hostPtr);
|
||||||
if (svmData) {
|
if (svmData) {
|
||||||
memory = svmData->gpuAllocation;
|
memory = svmData->gpuAllocation;
|
||||||
allocationType = memory->getAllocationType();
|
allocationType = memory->getAllocationType();
|
||||||
@@ -186,6 +188,7 @@ Buffer *Buffer::create(Context *context,
|
|||||||
mapAllocation = svmData->cpuAllocation;
|
mapAllocation = svmData->cpuAllocation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (context->isSharedContext) {
|
if (context->isSharedContext) {
|
||||||
zeroCopyAllowed = true;
|
zeroCopyAllowed = true;
|
||||||
|
|||||||
@@ -42,8 +42,12 @@ void api_fixture::SetUp() {
|
|||||||
void api_fixture::TearDown() {
|
void api_fixture::TearDown() {
|
||||||
delete pKernel;
|
delete pKernel;
|
||||||
delete pCommandQueue;
|
delete pCommandQueue;
|
||||||
|
if (pContext) {
|
||||||
pContext->release();
|
pContext->release();
|
||||||
|
}
|
||||||
|
if (pProgram) {
|
||||||
pProgram->release();
|
pProgram->release();
|
||||||
|
}
|
||||||
|
|
||||||
PlatformFixture::TearDown();
|
PlatformFixture::TearDown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointer_invalidArgValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointerWithNullArgValue_success) {
|
TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointerWithNullArgValue_success) {
|
||||||
|
const DeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||||
|
if (devInfo.svmCapabilities != 0) {
|
||||||
auto retVal = clSetKernelArgSVMPointer(
|
auto retVal = clSetKernelArgSVMPointer(
|
||||||
pMockKernel, // cl_kernel kernel
|
pMockKernel, // cl_kernel kernel
|
||||||
0, // cl_uint arg_index
|
0, // cl_uint arg_index
|
||||||
@@ -120,6 +122,7 @@ TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointerWithNullArgValue_success
|
|||||||
);
|
);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointer_success) {
|
TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointer_success) {
|
||||||
const DeviceInfo &devInfo = pDevice->getDeviceInfo();
|
const DeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ class clSVMAllocTemplateTests : public api_fixture,
|
|||||||
public:
|
public:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
api_fixture::SetUp();
|
api_fixture::SetUp();
|
||||||
|
if (!pPlatform->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm) {
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
|
|||||||
@@ -299,6 +299,21 @@ TEST_F(ContextTest, givenContextWhenSharingTableIsNotEmptyThenReturnsSharingFunc
|
|||||||
EXPECT_EQ(sharingF, sharingFunctions);
|
EXPECT_EQ(sharingF, sharingFunctions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Context, givenFtrSvmFalseWhenContextIsCreatedThenSVMAllocsManagerIsNotCreated) {
|
||||||
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||||
|
auto hwInfo = executionEnvironment->getMutableHardwareInfo();
|
||||||
|
hwInfo->capabilityTable.ftrSvm = false;
|
||||||
|
|
||||||
|
std::unique_ptr<MockDevice> device(MockDevice::createWithExecutionEnvironment<MockDevice>(hwInfo, executionEnvironment, 0));
|
||||||
|
|
||||||
|
cl_device_id clDevice = device.get();
|
||||||
|
cl_int retVal = CL_SUCCESS;
|
||||||
|
auto context = std::unique_ptr<MockContext>(Context::create<MockContext>(nullptr, DeviceVector(&clDevice, 1), nullptr, nullptr, retVal));
|
||||||
|
ASSERT_NE(nullptr, context);
|
||||||
|
auto svmManager = context->getSVMAllocsManager();
|
||||||
|
EXPECT_EQ(nullptr, svmManager);
|
||||||
|
}
|
||||||
|
|
||||||
class ContextWithAsyncDeleterTest : public ::testing::WithParamInterface<bool>,
|
class ContextWithAsyncDeleterTest : public ::testing::WithParamInterface<bool>,
|
||||||
public ::testing::Test {
|
public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -661,7 +661,9 @@ TEST_P(PerformanceHintEnqueueMapTest, GivenZeroCopyFlagWhenEnqueueUnmapIsCalling
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PerformanceHintEnqueueTest, GivenSVMPointerWhenEnqueueSVMMapIsCallingThenContextProvidesProperHint) {
|
TEST_F(PerformanceHintEnqueueTest, GivenSVMPointerWhenEnqueueSVMMapIsCallingThenContextProvidesProperHint) {
|
||||||
|
if (!pPlatform->peekExecutionEnvironment()->getHardwareInfo()->capabilityTable.ftrSvm) {
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
void *svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
void *svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||||
|
|
||||||
pCmdQ->enqueueSVMMap(CL_FALSE, 0, svmPtr, 256, 0, nullptr, nullptr);
|
pCmdQ->enqueueSVMMap(CL_FALSE, 0, svmPtr, 256, 0, nullptr, nullptr);
|
||||||
|
|||||||
@@ -509,6 +509,9 @@ TEST_F(CloneKernelTest, cloneKernelWithArgImmediate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CloneKernelTest, cloneKernelWithExecInfo) {
|
TEST_F(CloneKernelTest, cloneKernelWithExecInfo) {
|
||||||
|
if (!pDevice->getHardwareInfo().capabilityTable.ftrSvm) {
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, {});
|
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||||
ASSERT_NE(nullptr, ptrSVM);
|
ASSERT_NE(nullptr, ptrSVM);
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,9 @@ TEST_F(BufferSetArgTest, clSetKernelArgBuffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BufferSetArgTest, clSetKernelArgSVMPointer) {
|
TEST_F(BufferSetArgTest, clSetKernelArgSVMPointer) {
|
||||||
|
if (!pDevice->getHardwareInfo().capabilityTable.ftrSvm) {
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, {});
|
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||||
EXPECT_NE(nullptr, ptrSVM);
|
EXPECT_NE(nullptr, ptrSVM);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user