mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Reorganization directory structure [2/n]
Change-Id: I47962d17d755e80dcd9476e1ed75560f433f6115
This commit is contained in:
committed by
Jaroslaw Chodor
parent
d015d3633f
commit
e8852a68c4
114
opencl/test/unit_test/api/cl_function_pointers_tests.inl
Normal file
114
opencl/test/unit_test/api/cl_function_pointers_tests.inl
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cl_api_tests.h"
|
||||
#include "mocks/mock_program.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using clGetDeviceGlobalVariablePointer = api_tests;
|
||||
using clGetDeviceFunctionPointer = api_tests;
|
||||
|
||||
TEST_F(clGetDeviceGlobalVariablePointer, GivenNullMandatoryArgumentsThenReturnInvalidArgError) {
|
||||
this->pProgram->symbols["A"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["A"].symbol.size = 64U;
|
||||
this->pProgram->symbols["A"].symbol.segment = NEO::SegmentType::GlobalVariables;
|
||||
|
||||
void *globalRet = 0;
|
||||
auto ret = clGetDeviceGlobalVariablePointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", nullptr, &globalRet);
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
EXPECT_EQ(7U, reinterpret_cast<uintptr_t>(globalRet));
|
||||
|
||||
ret = clGetDeviceGlobalVariablePointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", nullptr, nullptr);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
|
||||
ret = clGetDeviceGlobalVariablePointerINTEL(this->pContext->getDevice(0), nullptr, "A", nullptr, &globalRet);
|
||||
EXPECT_EQ(CL_INVALID_PROGRAM, ret);
|
||||
|
||||
ret = clGetDeviceGlobalVariablePointerINTEL(nullptr, this->pProgram, "A", nullptr, &globalRet);
|
||||
EXPECT_EQ(CL_INVALID_DEVICE, ret);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceGlobalVariablePointer, GivenValidSymbolNameThenReturnProperAddressAndSize) {
|
||||
this->pProgram->symbols["A"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["A"].symbol.size = 64U;
|
||||
this->pProgram->symbols["A"].symbol.segment = NEO::SegmentType::GlobalVariables;
|
||||
|
||||
void *globalRet = 0;
|
||||
size_t sizeRet = 0;
|
||||
auto ret = clGetDeviceGlobalVariablePointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", &sizeRet, &globalRet);
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
EXPECT_EQ(7U, reinterpret_cast<uintptr_t>(globalRet));
|
||||
EXPECT_EQ(64U, sizeRet);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceGlobalVariablePointer, GivenFunctionSymbolNameThenReturnInvalidArgError) {
|
||||
this->pProgram->symbols["A"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["A"].symbol.size = 64U;
|
||||
this->pProgram->symbols["A"].symbol.segment = NEO::SegmentType::Instructions;
|
||||
|
||||
void *globalRet = 0;
|
||||
auto ret = clGetDeviceGlobalVariablePointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", nullptr, &globalRet);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceGlobalVariablePointer, GivenUnknownSymbolNameThenReturnInvalidArgError) {
|
||||
void *globalRet = 0;
|
||||
auto ret = clGetDeviceGlobalVariablePointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", nullptr, &globalRet);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceFunctionPointer, GivenNullMandatoryArgumentsThenReturnInvalidArgError) {
|
||||
this->pProgram->symbols["A"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["A"].symbol.size = 64U;
|
||||
this->pProgram->symbols["A"].symbol.segment = NEO::SegmentType::Instructions;
|
||||
|
||||
cl_ulong fptrRet = 0;
|
||||
auto ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", &fptrRet);
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
EXPECT_EQ(7U, fptrRet);
|
||||
|
||||
ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", nullptr);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
|
||||
ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), nullptr, "A", &fptrRet);
|
||||
EXPECT_EQ(CL_INVALID_PROGRAM, ret);
|
||||
|
||||
ret = clGetDeviceFunctionPointerINTEL(nullptr, this->pProgram, "A", &fptrRet);
|
||||
EXPECT_EQ(CL_INVALID_DEVICE, ret);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceFunctionPointer, GivenValidSymbolNameThenReturnProperAddress) {
|
||||
this->pProgram->symbols["A"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["A"].symbol.size = 64U;
|
||||
this->pProgram->symbols["A"].symbol.segment = NEO::SegmentType::Instructions;
|
||||
|
||||
cl_ulong fptrRet = 0;
|
||||
auto ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", &fptrRet);
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
EXPECT_EQ(7U, fptrRet);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceFunctionPointer, GivenGlobalSymbolNameThenReturnInvalidArgError) {
|
||||
this->pProgram->symbols["A"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["A"].symbol.size = 64U;
|
||||
this->pProgram->symbols["A"].symbol.segment = NEO::SegmentType::GlobalVariables;
|
||||
this->pProgram->symbols["B"].gpuAddress = 7U;
|
||||
this->pProgram->symbols["B"].symbol.size = 64U;
|
||||
this->pProgram->symbols["B"].symbol.segment = NEO::SegmentType::GlobalConstants;
|
||||
|
||||
cl_ulong fptrRet = 0;
|
||||
auto ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", &fptrRet);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), this->pProgram, "B", &fptrRet);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
}
|
||||
TEST_F(clGetDeviceFunctionPointer, GivenUnknownSymbolNameThenReturnInvalidArgError) {
|
||||
cl_ulong fptrRet = 0;
|
||||
auto ret = clGetDeviceFunctionPointerINTEL(this->pContext->getDevice(0), this->pProgram, "A", &fptrRet);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, ret);
|
||||
}
|
||||
Reference in New Issue
Block a user