mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
-Wire in host allocations API. Related-To: NEO-3148 Change-Id: If7213a7c90a35aebb530e2b4d14413138cd84297 Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
84 lines
3.4 KiB
C++
84 lines
3.4 KiB
C++
/*
|
|
* Copyright (C) 2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/api/api.h"
|
|
#include "runtime/memory_manager/svm_memory_manager.h"
|
|
#include "unit_tests/mocks/mock_context.h"
|
|
|
|
using namespace NEO;
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClHostMemAllocINTELisCalledWithoutContextThenInvalidContextIsReturned) {
|
|
cl_int retVal = CL_SUCCESS;
|
|
auto ptr = clHostMemAllocINTEL(0, nullptr, 0, 0, &retVal);
|
|
EXPECT_EQ(nullptr, ptr);
|
|
EXPECT_EQ(CL_INVALID_CONTEXT, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClHostMemAllocIntelIsCalledThenItAllocatesHostUnifiedMemoryAllocation) {
|
|
MockContext mockContext;
|
|
cl_int retVal = CL_SUCCESS;
|
|
auto unifiedMemoryHostAllocation = clHostMemAllocINTEL(&mockContext, nullptr, 4, 0, &retVal);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
ASSERT_NE(nullptr, unifiedMemoryHostAllocation);
|
|
|
|
auto allocationsManager = mockContext.getSVMAllocsManager();
|
|
EXPECT_EQ(1u, allocationsManager->getNumAllocs());
|
|
auto graphicsAllocation = allocationsManager->getSVMAlloc(unifiedMemoryHostAllocation);
|
|
EXPECT_EQ(graphicsAllocation->size, 4u);
|
|
EXPECT_EQ(graphicsAllocation->memoryType, InternalMemoryType::HOST_UNIFIED_MEMORY);
|
|
EXPECT_EQ(graphicsAllocation->gpuAllocation->getGpuAddress(), castToUint64(unifiedMemoryHostAllocation));
|
|
|
|
allocationsManager->freeSVMAlloc(unifiedMemoryHostAllocation);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClDeviceMemAllocINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
cl_int retVal = CL_SUCCESS;
|
|
clDeviceMemAllocINTEL(0, 0, nullptr, 0, 0, &retVal);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClSharedMemAllocINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
cl_int retVal = CL_SUCCESS;
|
|
clSharedMemAllocINTEL(0, 0, nullptr, 0, 0, &retVal);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClMemFreeINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clMemFreeINTEL(0, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clGetMemAllocInfoINTEL(0, nullptr, 0, 0, nullptr, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClSetKernelArgMemPointerINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clSetKernelArgMemPointerINTEL(0, 0, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemsetINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clEnqueueMemsetINTEL(0, nullptr, 0, 0, 0, nullptr, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemcpyINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clEnqueueMemcpyINTEL(0, 0, nullptr, nullptr, 0, 0, nullptr, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClEnqueueMigrateMemINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clEnqueueMigrateMemINTEL(0, nullptr, 0, 0, 0, nullptr, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|
|
|
|
TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemAdviseINTELisCalledThenOutOfHostMemoryErrorIsReturned) {
|
|
auto retVal = clEnqueueMemAdviseINTEL(0, nullptr, 0, 0, 0, nullptr, nullptr);
|
|
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
|
|
}
|