Handle program's callbacks on API level

Related-To: NEO-5001
Change-Id: Ic73601f874a972c9c3fe6cc1a04edd5d7915f16e
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-10-27 12:43:48 +01:00
committed by sys_ocldev
parent e3ef10d57e
commit 4be05409a3
30 changed files with 489 additions and 277 deletions

View File

@@ -1511,10 +1511,13 @@ cl_int CL_API_CALL clBuildProgram(cl_program program,
cl_int retVal = CL_INVALID_PROGRAM;
API_ENTER(&retVal);
DBG_LOG_INPUTS("clProgram", program, "numDevices", numDevices, "cl_device_id", deviceList, "options", (options != nullptr) ? options : "", "funcNotify", funcNotify, "userData", userData);
auto pProgram = castToObject<Program>(program);
Program *pProgram = nullptr;
if (pProgram) {
retVal = pProgram->build(numDevices, deviceList, options, funcNotify, userData, clCacheEnabled);
retVal = validateObjects(WithCastToInternal(program, &pProgram), Program::isValidCallback(funcNotify, userData));
if (CL_SUCCESS == retVal) {
retVal = pProgram->build(numDevices, deviceList, options, clCacheEnabled);
pProgram->invokeCallback(funcNotify, userData);
}
TRACING_EXIT(clBuildProgram, &retVal);
@@ -1534,12 +1537,15 @@ cl_int CL_API_CALL clCompileProgram(cl_program program,
cl_int retVal = CL_INVALID_PROGRAM;
API_ENTER(&retVal);
DBG_LOG_INPUTS("clProgram", program, "numDevices", numDevices, "cl_device_id", deviceList, "options", (options != nullptr) ? options : "", "numInputHeaders", numInputHeaders);
auto pProgram = castToObject<Program>(program);
if (pProgram != nullptr) {
Program *pProgram = nullptr;
retVal = validateObjects(WithCastToInternal(program, &pProgram), Program::isValidCallback(funcNotify, userData));
if (CL_SUCCESS == retVal) {
retVal = pProgram->compile(numDevices, deviceList, options,
numInputHeaders, inputHeaders, headerIncludeNames,
funcNotify, userData);
numInputHeaders, inputHeaders, headerIncludeNames);
pProgram->invokeCallback(funcNotify, userData);
}
TRACING_EXIT(clCompileProgram, &retVal);
@@ -1564,18 +1570,15 @@ cl_program CL_API_CALL clLinkProgram(cl_context context,
Context *pContext = nullptr;
Program *program = nullptr;
retVal = validateObject(context);
retVal = validateObjects(WithCastToInternal(context, &pContext), Program::isValidCallback(funcNotify, userData));
if (CL_SUCCESS == retVal) {
pContext = castToObject<Context>(context);
}
if (pContext != nullptr) {
ClDeviceVector deviceVector;
deviceVector.push_back(pContext->getDevice(0));
program = new Program(pContext, false, deviceVector);
retVal = program->link(numDevices, deviceList, options,
numInputPrograms, inputPrograms,
funcNotify, userData);
numInputPrograms, inputPrograms);
program->invokeCallback(funcNotify, userData);
}
err.set(retVal);

View File

@@ -14,7 +14,7 @@ void BuiltinDispatchInfoBuilder::populate(ClDevice &device, EBuiltInOps::Type op
ClDeviceVector deviceVector;
deviceVector.push_back(&device);
prog.reset(BuiltinDispatchInfoBuilder::createProgramFromCode(src, deviceVector).release());
prog->build(0, nullptr, options.data(), nullptr, nullptr, kernelsLib.isCacheingEnabled());
prog->build(0, nullptr, options.data(), kernelsLib.isCacheingEnabled());
grabKernels(std::forward<KernelsDescArgsT>(desc)...);
}
} // namespace NEO

View File

@@ -138,6 +138,10 @@ cl_int validateObject(const PatternSize &ps) {
return CL_INVALID_VALUE;
}
cl_int validateObject(bool isValid) {
return isValid ? CL_SUCCESS : CL_INVALID_VALUE;
}
cl_int validateYuvOperation(const size_t *origin, const size_t *region) {
if (!origin || !region)
return CL_INVALID_VALUE;

View File

@@ -52,6 +52,7 @@ cl_int validateObject(const DeviceList &deviceList);
cl_int validateObject(const MemObjList &memObjList);
cl_int validateObject(const NonZeroBufferSize &nzbs);
cl_int validateObject(const PatternSize &ps);
cl_int validateObject(bool isValid);
// This is the sentinel for the follow variadic template definition.
inline cl_int validateObjects() {

View File

@@ -33,8 +33,6 @@ cl_int Program::build(
cl_uint numDevices,
const cl_device_id *deviceList,
const char *buildOptions,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData,
bool enableCaching) {
cl_int retVal = CL_SUCCESS;
@@ -47,12 +45,6 @@ cl_int Program::build(
break;
}
if ((funcNotify == nullptr) &&
(userData != nullptr)) {
retVal = CL_INVALID_VALUE;
break;
}
// if a device_list is specified, make sure it points to our device
// NOTE: a null device_list is ok - it means "all devices"
if (deviceList && validateObject(*deviceList) != CL_SUCCESS) {
@@ -183,10 +175,6 @@ cl_int Program::build(
programBinaryType = CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
}
if (funcNotify != nullptr) {
(*funcNotify)(this, userData);
}
return retVal;
}
@@ -216,7 +204,7 @@ void Program::notifyDebuggerWithSourceCode(std::string &filename) {
cl_int Program::build(const Device *pDevice, const char *buildOptions, bool enableCaching,
std::unordered_map<std::string, BuiltinDispatchInfoBuilder *> &builtinsMap) {
cl_device_id deviceId = pDevice->getSpecializedDevice<ClDevice>();
auto ret = this->build(1, &deviceId, buildOptions, nullptr, nullptr, enableCaching);
auto ret = this->build(1, &deviceId, buildOptions, enableCaching);
if (ret != CL_SUCCESS) {
return ret;
}

View File

@@ -31,9 +31,7 @@ cl_int Program::compile(
const char *buildOptions,
cl_uint numInputHeaders,
const cl_program *inputHeaders,
const char **headerIncludeNames,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData) {
const char **headerIncludeNames) {
cl_int retVal = CL_SUCCESS;
auto clDevice = this->pDevice->getSpecializedDevice<ClDevice>();
@@ -57,12 +55,6 @@ cl_int Program::compile(
}
}
if ((funcNotify == nullptr) &&
(userData != nullptr)) {
retVal = CL_INVALID_VALUE;
break;
}
// if a device_list is specified, make sure it points to our device
// NOTE: a null device_list is ok - it means "all devices"
if ((deviceList != nullptr) && validateObject(*deviceList) != CL_SUCCESS) {
@@ -183,10 +175,6 @@ cl_int Program::compile(
internalOptions.clear();
if (funcNotify != nullptr) {
(*funcNotify)(this, userData);
}
return retVal;
}
} // namespace NEO

View File

@@ -32,9 +32,7 @@ cl_int Program::link(
const cl_device_id *deviceList,
const char *buildOptions,
cl_uint numInputPrograms,
const cl_program *inputPrograms,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData) {
const cl_program *inputPrograms) {
cl_int retVal = CL_SUCCESS;
bool isCreateLibrary;
@@ -52,12 +50,6 @@ cl_int Program::link(
break;
}
if ((funcNotify == nullptr) &&
(userData != nullptr)) {
retVal = CL_INVALID_VALUE;
break;
}
if ((deviceList != nullptr) && validateObject(*deviceList) != CL_SUCCESS) {
retVal = CL_INVALID_DEVICE;
break;
@@ -209,10 +201,6 @@ cl_int Program::link(
internalOptions.clear();
if (funcNotify != nullptr) {
(*funcNotify)(this, userData);
}
return retVal;
}
} // namespace NEO

View File

@@ -489,4 +489,14 @@ void Program::setBuildStatus(cl_build_status status) {
}
}
bool Program::isValidCallback(void(CL_CALLBACK *funcNotify)(cl_program program, void *userData), void *userData) {
return funcNotify != nullptr || userData == nullptr;
}
void Program::invokeCallback(void(CL_CALLBACK *funcNotify)(cl_program program, void *userData), void *userData) {
if (funcNotify != nullptr) {
(*funcNotify)(this, userData);
}
}
} // namespace NEO

View File

@@ -127,8 +127,7 @@ class Program : public BaseObject<_cl_program> {
Program &operator=(const Program &) = delete;
cl_int build(cl_uint numDevices, const cl_device_id *deviceList, const char *buildOptions,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData, bool enableCaching);
bool enableCaching);
cl_int build(const Device *pDevice, const char *buildOptions, bool enableCaching,
std::unordered_map<std::string, BuiltinDispatchInfoBuilder *> &builtinsMap);
@@ -137,14 +136,10 @@ class Program : public BaseObject<_cl_program> {
MOCKABLE_VIRTUAL cl_int processProgramInfo(ProgramInfo &dst);
cl_int compile(cl_uint numDevices, const cl_device_id *deviceList, const char *buildOptions,
cl_uint numInputHeaders, const cl_program *inputHeaders, const char **headerIncludeNames,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData);
cl_uint numInputHeaders, const cl_program *inputHeaders, const char **headerIncludeNames);
cl_int link(cl_uint numDevices, const cl_device_id *deviceList, const char *buildOptions,
cl_uint numInputPrograms, const cl_program *inputPrograms,
void(CL_CALLBACK *funcNotify)(cl_program program, void *userData),
void *userData);
cl_uint numInputPrograms, const cl_program *inputPrograms);
cl_int setProgramSpecializationConstant(cl_uint specId, size_t specSize, const void *specValue);
MOCKABLE_VIRTUAL cl_int updateSpecializationConstant(cl_uint specId, size_t specSize, const void *specValue);
@@ -265,6 +260,9 @@ class Program : public BaseObject<_cl_program> {
MOCKABLE_VIRTUAL void replaceDeviceBinary(std::unique_ptr<char[]> newBinary, size_t newBinarySize, uint32_t rootDeviceIndex);
static bool isValidCallback(void(CL_CALLBACK *funcNotify)(cl_program program, void *userData), void *userData);
void invokeCallback(void(CL_CALLBACK *funcNotify)(cl_program program, void *userData), void *userData);
protected:
MOCKABLE_VIRTUAL cl_int createProgramFromBinary(const void *pBinary, size_t binarySize, uint32_t rootDeviceIndex);

View File

@@ -14,7 +14,11 @@
#include "opencl/test/unit_test/mocks/mock_context.h"
namespace NEO {
void CL_CALLBACK notifyFuncProgram(
cl_program program,
void *userData) {
*((char *)userData) = 'a';
}
void api_fixture_using_aligned_memory_manager::SetUp() {
retVal = CL_SUCCESS;
retSize = 0;

View File

@@ -107,4 +107,7 @@ struct api_fixture_using_aligned_memory_manager {
using api_test_using_aligned_memory_manager = Test<api_fixture_using_aligned_memory_manager>;
void CL_CALLBACK notifyFuncProgram(
cl_program program,
void *userData);
} // namespace NEO

View File

@@ -224,4 +224,89 @@ TEST_F(clBuildProgramTests, GivenNullAsInputWhenCreatingProgramThenInvalidProgra
nullptr);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
}
TEST_F(clBuildProgramTests, GivenInvalidCallbackInputWhenBuildProgramThenInvalidValueErrorIsReturned) {
cl_program pProgram = nullptr;
cl_int binaryStatus = CL_SUCCESS;
size_t binarySize = 0;
std::string testFile;
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd16_", ".bin");
auto pBinary = loadDataFromFile(
testFile.c_str(),
binarySize);
ASSERT_NE(0u, binarySize);
ASSERT_NE(nullptr, pBinary);
const unsigned char *binaries[1] = {reinterpret_cast<const unsigned char *>(pBinary.get())};
pProgram = clCreateProgramWithBinary(
pContext,
1,
&testedClDevice,
&binarySize,
binaries,
&binaryStatus,
&retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, pProgram);
retVal = clBuildProgram(
pProgram,
1,
&testedClDevice,
nullptr,
nullptr,
&retVal);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
}
TEST_F(clBuildProgramTests, GivenValidCallbackInputWhenBuildProgramThenCallbackIsInvoked) {
cl_program pProgram = nullptr;
cl_int binaryStatus = CL_SUCCESS;
size_t binarySize = 0;
std::string testFile;
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd16_", ".bin");
auto pBinary = loadDataFromFile(
testFile.c_str(),
binarySize);
ASSERT_NE(0u, binarySize);
ASSERT_NE(nullptr, pBinary);
const unsigned char *binaries[1] = {reinterpret_cast<const unsigned char *>(pBinary.get())};
pProgram = clCreateProgramWithBinary(
pContext,
1,
&testedClDevice,
&binarySize,
binaries,
&binaryStatus,
&retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, pProgram);
char userData = 0;
retVal = clBuildProgram(
pProgram,
1,
&testedClDevice,
nullptr,
notifyFuncProgram,
&userData);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ('a', userData);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
}
} // namespace ULT

View File

@@ -146,4 +146,93 @@ TEST_F(clCompileProgramTests, GivenNullProgramWhenCompilingProgramThenInvalidPro
nullptr);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
}
TEST_F(clCompileProgramTests, GivenInvalidCallbackInputWhenCompileProgramThenInvalidValueErrorIsReturned) {
cl_program pProgram = nullptr;
size_t sourceSize = 0;
std::string testFile;
testFile.append(clFiles);
testFile.append("copybuffer.cl");
auto pSource = loadDataFromFile(
testFile.c_str(),
sourceSize);
ASSERT_NE(0u, sourceSize);
ASSERT_NE(nullptr, pSource);
const char *sources[1] = {pSource.get()};
pProgram = clCreateProgramWithSource(
pContext,
1,
sources,
&sourceSize,
&retVal);
EXPECT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
retVal = clCompileProgram(
pProgram,
1,
&testedClDevice,
nullptr,
0,
nullptr,
nullptr,
nullptr,
&retVal);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
}
TEST_F(clCompileProgramTests, GivenValidCallbackInputWhenLinkProgramThenCallbackIsInvoked) {
cl_program pProgram = nullptr;
size_t sourceSize = 0;
std::string testFile;
testFile.append(clFiles);
testFile.append("copybuffer.cl");
auto pSource = loadDataFromFile(
testFile.c_str(),
sourceSize);
ASSERT_NE(0u, sourceSize);
ASSERT_NE(nullptr, pSource);
const char *sources[1] = {pSource.get()};
pProgram = clCreateProgramWithSource(
pContext,
1,
sources,
&sourceSize,
&retVal);
EXPECT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
char userData = 0;
retVal = clCompileProgram(
pProgram,
1,
&testedClDevice,
nullptr,
0,
nullptr,
nullptr,
notifyFuncProgram,
&userData);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ('a', userData);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
}
} // namespace ULT

View File

@@ -206,7 +206,7 @@ TEST_F(clLinkProgramTests, GivenProgramsWithSpecConstantsThenSpecConstantsAreEmb
MockCompilerDebugVars igcDebugVars;
igcDebugVars.receivedInput = &receivedInput;
gEnvironment->igcPushDebugVars(igcDebugVars);
progDst->link(0U, nullptr, "", 3, inputPrograms, nullptr, nullptr);
progDst->link(0U, nullptr, "", 3, inputPrograms);
gEnvironment->igcPopDebugVars();
std::string elfDecodeError;
@@ -253,4 +253,125 @@ TEST_F(clLinkProgramTests, GivenProgramsWithSpecConstantsThenSpecConstantsAreEmb
EXPECT_EQ(0, memcmp(ir3, elf.sectionHeaders[7].data.begin(), sizeof(ir3)));
}
TEST_F(clLinkProgramTests, GivenInvalidCallbackInputWhenLinkProgramThenInvalidValueErrorIsReturned) {
cl_program pProgram = nullptr;
size_t sourceSize = 0;
std::string testFile;
testFile.append(clFiles);
testFile.append("copybuffer.cl");
auto pSource = loadDataFromFile(
testFile.c_str(),
sourceSize);
ASSERT_NE(0u, sourceSize);
ASSERT_NE(nullptr, pSource);
const char *sources[1] = {pSource.get()};
pProgram = clCreateProgramWithSource(
pContext,
1,
sources,
&sourceSize,
&retVal);
EXPECT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
retVal = clCompileProgram(
pProgram,
1,
&testedClDevice,
nullptr,
0,
nullptr,
nullptr,
nullptr,
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
cl_program program = pProgram;
cl_program oprog;
oprog = clLinkProgram(
pContext,
1,
&testedClDevice,
CompilerOptions::createLibrary.data(),
1,
&program,
nullptr,
&retVal,
&retVal);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
EXPECT_EQ(nullptr, oprog);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
}
TEST_F(clLinkProgramTests, GivenValidCallbackInputWhenLinkProgramThenCallbackIsInvoked) {
cl_program pProgram = nullptr;
size_t sourceSize = 0;
std::string testFile;
testFile.append(clFiles);
testFile.append("copybuffer.cl");
auto pSource = loadDataFromFile(
testFile.c_str(),
sourceSize);
ASSERT_NE(0u, sourceSize);
ASSERT_NE(nullptr, pSource);
const char *sources[1] = {pSource.get()};
pProgram = clCreateProgramWithSource(
pContext,
1,
sources,
&sourceSize,
&retVal);
EXPECT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
retVal = clCompileProgram(
pProgram,
1,
&testedClDevice,
nullptr,
0,
nullptr,
nullptr,
nullptr,
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
cl_program program = pProgram;
cl_program oprog;
char userData = 0;
oprog = clLinkProgram(
pContext,
1,
&testedClDevice,
CompilerOptions::createLibrary.data(),
1,
&program,
notifyFuncProgram,
&userData,
&retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ('a', userData);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clReleaseProgram(oprog);
EXPECT_EQ(CL_SUCCESS, retVal);
}
} // namespace ULT

View File

@@ -47,8 +47,6 @@ SKLTEST_F(AUBRunKernelIntegrateTest, ooqExecution) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -275,8 +273,6 @@ SKLTEST_F(AUBRunKernelIntegrateTest, deviceSideVme) {
1,
&device,
"",
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);

View File

@@ -48,7 +48,7 @@ class EnqueueDebugKernelTest : public ProgramSimpleFixture,
"copybuffer.cl");
pProgram->enableKernelDebug();
cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
cl_int retVal = pProgram->build(1, &device, nullptr, false);
ASSERT_EQ(CL_SUCCESS, retVal);
// create a kernel

View File

@@ -738,7 +738,7 @@ TEST_F(EnqueueSvmTest, GivenSvmAllocationWhenEnqueingKernelThenSuccessIsReturned
std::unique_ptr<Program> program(Program::createBuiltInFromSource("FillBufferBytes", context, context->getDevices(), &retVal));
cl_device_id device = pClDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
program->build(1, &device, nullptr, false);
std::unique_ptr<MockKernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
kernel->setSvmKernelExecInfo(pSvmAlloc);
@@ -767,7 +767,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur
auto program = clUniquePtr(Program::createBuiltInFromSource("FillBufferBytes", context, context->getDevices(), &retVal));
cl_device_id device = pClDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
program->build(1, &device, nullptr, false);
auto kernel = clUniquePtr(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
std::vector<Surface *> allSurfaces;

View File

@@ -117,7 +117,7 @@ HWTEST_F(GetSizeRequiredImageTest, WhenCopyingReadWriteImageThenHeapsAndCommandB
std::unique_ptr<Program> program(Program::createBuiltInFromSource("CopyImageToImage3d", context, context->getDevices(), nullptr));
cl_device_id device = pClDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
program->build(1, &device, nullptr, false);
std::unique_ptr<Kernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("CopyImageToImage3d"), nullptr));
EXPECT_NE(nullptr, kernel);

View File

@@ -223,7 +223,7 @@ struct PerformanceHintEnqueueKernelTest : public PerformanceHintEnqueueTest,
PerformanceHintEnqueueTest::SetUp();
CreateProgramFromBinary(context, context->getDevices(), "CopyBuffer_simd32");
cl_device_id device = context->getDevice(0);
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, &device, nullptr, false);
ASSERT_EQ(CL_SUCCESS, retVal);
kernel = Kernel::create<MockKernel>(pProgram, *pProgram->getKernelInfo("CopyBuffer"), &retVal);
@@ -259,7 +259,7 @@ struct PerformanceHintEnqueueKernelPrintfTest : public PerformanceHintEnqueueTes
PerformanceHintEnqueueTest::SetUp();
cl_device_id device = pPlatform->getClDevice(0);
CreateProgramFromBinary(context, context->getDevices(), "printf");
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, &device, nullptr, false);
ASSERT_EQ(CL_SUCCESS, retVal);
kernel = Kernel::create(pProgram, *pProgram->getKernelInfo("test"), &retVal);

View File

@@ -36,8 +36,6 @@ class ExecutionModelKernelFixture : public ProgramFromBinaryTest,
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);

View File

@@ -74,8 +74,6 @@ struct HelloWorldKernelFixture : public ProgramFixture {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);

View File

@@ -106,8 +106,6 @@ class SimpleArgKernelFixture : public ProgramFixture {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -158,8 +156,6 @@ class SimpleArgNonUniformKernelFixture : public ProgramFixture {
1,
&deviceId,
"-cl-std=CL2.0",
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -204,8 +200,6 @@ class SimpleKernelFixture : public ProgramFixture {
1,
&deviceId,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -261,8 +255,6 @@ class SimpleKernelStatelessFixture : public ProgramFixture {
1,
&deviceId,
CompilerOptions::greaterThan4gbBuffersRequired.data(),
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -308,8 +300,6 @@ class BindlessKernelFixture : public ProgramFixture {
1,
&deviceId,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);

View File

@@ -167,6 +167,12 @@ TEST(Platform, GivenValidPlatformWhenValidatingThenSuccessIsReturned) {
EXPECT_EQ(CL_SUCCESS, validateObjects(clPlatformId));
}
TEST(ValidatorBool, GivenBoolFlagWhenValidatingObjectThenCorrectValueIsReturned) {
EXPECT_EQ(CL_INVALID_VALUE, validateObject(false));
EXPECT_EQ(CL_INVALID_VALUE, validateObjects(false, true));
EXPECT_EQ(CL_SUCCESS, validateObject(true));
}
typedef ::testing::TestWithParam<size_t> PatternSizeValid;
TEST_P(PatternSizeValid, GivenValidPatternSizeWhenValidatingThenSuccessIsReturned) {

View File

@@ -36,8 +36,6 @@ class KernelArgInfoTest : public ProgramFromSourceTest {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);

View File

@@ -23,7 +23,7 @@ class PatchedKernelTest : public ::testing::Test {
program.reset(Program::createBuiltInFromSource("FillBufferBytes", context.get(), context->getDevices(), &retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
cl_device_id clDevice = device.get();
program->build(1, &clDevice, nullptr, nullptr, nullptr, false);
program->build(1, &clDevice, nullptr, false);
kernel.reset(Kernel::create(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
}

View File

@@ -63,8 +63,6 @@ class KernelTest : public ProgramFromBinaryTest {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -354,8 +352,6 @@ TEST_F(KernelFromBinaryTests, GivenKernelNumArgsWhenGettingInfoThenNumberOfKerne
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -397,8 +393,6 @@ TEST_F(KernelFromBinaryTests, WhenRegularKernelIsCreatedThenItIsNotBuiltIn) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -432,8 +426,6 @@ TEST_F(KernelFromBinaryTests, givenArgumentDeclaredAsConstantWhenKernelIsCreated
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);

View File

@@ -193,8 +193,6 @@ TEST_F(ProgramNonUniformTest, GivenCl21WhenExecutingKernelWithNonUniformThenEnqu
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -235,8 +233,6 @@ TEST_F(ProgramNonUniformTest, GivenCl20WhenExecutingKernelWithNonUniformThenEnqu
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -275,8 +271,6 @@ TEST_F(ProgramNonUniformTest, GivenCl12WhenExecutingKernelWithNonUniformThenInva
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);

View File

@@ -69,12 +69,6 @@ void ProgramTests::TearDown() {
ClDeviceFixture::TearDown();
}
void CL_CALLBACK notifyFunc(
cl_program program,
void *userData) {
*((char *)userData) = 'a';
}
std::vector<const char *> BinaryFileNames{
"CopyBuffer_simd32",
};
@@ -120,8 +114,6 @@ TEST_P(ProgramFromBinaryTest, WhenBuildingProgramThenSuccessIsReturned) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -234,8 +226,6 @@ TEST_P(ProgramFromBinaryTest, GivenProgramWithOneKernelWhenGettingNumKernelsThen
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -276,8 +266,6 @@ TEST_P(ProgramFromBinaryTest, WhenGettingKernelNamesThenCorrectNameIsReturned) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -637,7 +625,7 @@ TEST_P(ProgramFromBinaryTest, GivenGlobalVariableTotalSizeSetWhenGettingBuildGlo
TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphicsAllocationInKernelInfo) {
cl_device_id device = pClDevice;
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
pProgram->build(1, &device, nullptr, true);
auto kernelInfo = pProgram->getKernelInfo(size_t(0));
auto graphicsAllocation = kernelInfo->getGraphicsAllocation();
@@ -654,7 +642,7 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi
TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffersAreFreed) {
cl_device_id device = pClDevice;
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
pProgram->build(1, &device, nullptr, true);
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface);
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface);
@@ -671,7 +659,7 @@ TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffers
TEST_P(ProgramFromBinaryTest, givenProgramWhenCleanKernelInfoIsCalledThenKernelAllocationIsFreed) {
cl_device_id device = pClDevice;
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
pProgram->build(1, &device, nullptr, true);
EXPECT_EQ(1u, pProgram->getNumKernels());
pProgram->cleanCurrentKernelInfo();
EXPECT_EQ(0u, pProgram->getNumKernels());
@@ -681,7 +669,7 @@ HWTEST_P(ProgramFromBinaryTest, givenProgramWhenCleanCurrentKernelInfoIsCalledBu
cl_device_id device = pClDevice;
auto &csr = pDevice->getGpgpuCommandStreamReceiver();
EXPECT_TRUE(csr.getTemporaryAllocations().peekIsEmpty());
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
pProgram->build(1, &device, nullptr, true);
auto kernelAllocation = pProgram->getKernelInfo(size_t(0))->getGraphicsAllocation();
kernelAllocation->updateTaskCount(100, csr.getOsContext().getContextId());
*csr.getTagAddress() = 0;
@@ -697,7 +685,7 @@ HWTEST_P(ProgramFromBinaryTest, givenIsaAllocationUsedByMultipleCsrsWhenItIsDele
cl_device_id device = pClDevice;
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
pProgram->build(1, &device, nullptr, true);
auto kernelAllocation = pProgram->getKernelInfo(size_t(0))->getGraphicsAllocation();
@@ -723,7 +711,6 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSucc
auto device = pPlatform->getClDevice(0);
cl_device_id deviceList = {0};
char data[4] = {0};
cl_device_id usedDevice = pPlatform->getClDevice(0);
@@ -738,23 +725,19 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSucc
auto pMockProgram = pProgram;
// invalid build parameters: combinations of numDevices & deviceList
retVal = pProgram->build(1, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, nullptr, nullptr, false);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = pProgram->build(0, &deviceList, nullptr, nullptr, nullptr, false);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid build parameters: combinations of funcNotify & userData
retVal = pProgram->build(0, nullptr, nullptr, nullptr, &data[0], false);
retVal = pProgram->build(0, &deviceList, nullptr, false);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid build parameters: invalid content of deviceList
retVal = pProgram->build(1, &deviceList, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, &deviceList, nullptr, false);
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
// fail build - another build is already in progress
pMockProgram->setBuildStatus(CL_BUILD_IN_PROGRESS);
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
pMockProgram->setBuildStatus(CL_BUILD_NONE);
@@ -764,13 +747,13 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSucc
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
auto p2 = std::make_unique<MockProgram>(toClDeviceVector(*device));
retVal = p2->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = p2->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
p2.reset(nullptr);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
// fail build - any build error (here caused by specifying unrecognized option)
retVal = pProgram->build(0, nullptr, "-invalid-option", nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, "-invalid-option", false);
EXPECT_EQ(CL_BUILD_PROGRAM_FAILURE, retVal);
// fail build - linked code is corrupted and cannot be postprocessed
@@ -784,13 +767,13 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSucc
EXPECT_NE(nullptr, pSourceBuffer);
p3->sourceCode = pSourceBuffer.get();
p3->createdFrom = Program::CreatedFrom::SOURCE;
retVal = p3->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = p3->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_INVALID_BINARY, retVal);
p3.reset(nullptr);
// build successfully without notifyFunc - build kernel and write it to Kernel Cache
// build successfully - build kernel and write it to Kernel Cache
pMockProgram->clearOptions();
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(CompilerOptions::contains(pProgram->getInternalOptions(), pPlatform->getClDevice(0)->peekCompilerExtensions())) << pProgram->getInternalOptions();
@@ -816,18 +799,13 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSucc
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(param_value_size_ret, 0u);
// build successfully without notifyFunc - build kernel but do not write it to Kernel Cache (kernel is already in the Cache)
// build successfully - build kernel but do not write it to Kernel Cache (kernel is already in the Cache)
pMockProgram->setBuildStatus(CL_BUILD_NONE);
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
// build successfully with notifyFunc - duplicate build (kernel already built), do not build and just take it
retVal = pProgram->build(0, nullptr, nullptr, notifyFunc, &data[0], false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ('a', data[0]);
// build successfully without notifyFunc - kernel is already in Kernel Cache, do not build and take it from Cache
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, true);
// build successfully - kernel is already in Kernel Cache, do not build and take it from Cache
retVal = pProgram->build(0, nullptr, nullptr, true);
EXPECT_EQ(CL_SUCCESS, retVal);
// fail build - code to be build does not exist
@@ -835,26 +813,26 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSucc
pMockProgram->createdFrom = Program::CreatedFrom::SOURCE;
pMockProgram->setBuildStatus(CL_BUILD_NONE);
pMockProgram->setCreatedFromBinary(false);
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
}
TEST_P(ProgramFromSourceTest, CreateWithSource_Build_Options_Duplicate) {
KernelBinaryHelper kbHelper(BinaryFileName, false);
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = pProgram->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), false);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = pProgram->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), false);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = pProgram->build(0, nullptr, CompilerOptions::finiteMathOnly.data(), nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, CompilerOptions::finiteMathOnly.data(), false);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
}
@@ -862,7 +840,7 @@ TEST_P(ProgramFromSourceTest, WhenBuildingProgramThenFeaturesOptionIsNotAdded) {
auto featuresOption = static_cast<ClDevice *>(devices[0])->peekCompilerFeatures();
EXPECT_THAT(pProgram->getInternalOptions(), testing::Not(testing::HasSubstr(featuresOption)));
retVal = pProgram->build(1, devices, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, devices, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getInternalOptions(), testing::Not(testing::HasSubstr(featuresOption)));
}
@@ -878,7 +856,7 @@ TEST_P(ProgramFromSourceTest, WhenBuildingProgramWithOpenClC30ThenFeaturesOption
pProgram->sourceCode = "__kernel mock() {}";
pProgram->createdFrom = Program::CreatedFrom::SOURCE;
retVal = pProgram->build(1, devices, "-cl-std=CL3.0", nullptr, nullptr, false);
retVal = pProgram->build(1, devices, "-cl-std=CL3.0", false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getInternalOptions(), testing::HasSubstr(featuresOption));
}
@@ -891,9 +869,9 @@ TEST_P(ProgramFromSourceTest, WhenBuildingProgramWithOpenClC30ThenFeaturesOption
pProgram->sourceCode = "__kernel mock() {}";
pProgram->createdFrom = Program::CreatedFrom::SOURCE;
retVal = pProgram->build(0, nullptr, "-cl-std=CL3.0", nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, "-cl-std=CL3.0", false);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = pProgram->build(0, nullptr, "-cl-std=CL3.0", nullptr, nullptr, false);
retVal = pProgram->build(0, nullptr, "-cl-std=CL3.0", false);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedFeaturesOption = static_cast<ClDevice *>(devices[0])->peekCompilerFeatures();
@@ -912,7 +890,7 @@ TEST_P(ProgramFromSourceTest, WhenCompilingProgramThenFeaturesOptionIsNotAdded)
auto featuresOption = pClDevice->peekCompilerFeatures();
EXPECT_THAT(pCompilerInterface->buildInternalOptions, testing::Not(testing::HasSubstr(featuresOption)));
retVal = pProgram->compile(1, devices, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, devices, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pCompilerInterface->buildInternalOptions, testing::Not(testing::HasSubstr(featuresOption)));
}
@@ -928,7 +906,7 @@ TEST_P(ProgramFromSourceTest, WhenCompilingProgramWithOpenClC30ThenFeaturesOptio
auto featuresOption = pClDevice->peekCompilerFeatures();
EXPECT_THAT(pCompilerInterface->buildInternalOptions, testing::Not(testing::HasSubstr(featuresOption)));
retVal = pProgram->compile(1, devices, "-cl-std=CL3.0", 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, devices, "-cl-std=CL3.0", 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pCompilerInterface->buildInternalOptions, testing::HasSubstr(featuresOption));
}
@@ -972,14 +950,14 @@ TEST_P(ProgramFromSourceTest, GivenDifferentCommpilerOptionsWhenBuildingProgramT
Callback callback;
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, true);
retVal = pProgram->build(0, nullptr, nullptr, true);
EXPECT_EQ(CL_SUCCESS, retVal);
auto hash1 = pProgram->getCachedFileName();
auto kernel1 = pProgram->getKernelInfo("CopyBuffer");
Callback::watch(kernel1);
EXPECT_NE(nullptr, kernel1);
retVal = pProgram->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), nullptr, nullptr, true);
retVal = pProgram->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), true);
EXPECT_EQ(CL_SUCCESS, retVal);
auto hash2 = pProgram->getCachedFileName();
auto kernel2 = pProgram->getKernelInfo("CopyBuffer");
@@ -988,7 +966,7 @@ TEST_P(ProgramFromSourceTest, GivenDifferentCommpilerOptionsWhenBuildingProgramT
Callback::unwatch(kernel1);
Callback::watch(kernel2);
retVal = pProgram->build(0, nullptr, CompilerOptions::finiteMathOnly.data(), nullptr, nullptr, true);
retVal = pProgram->build(0, nullptr, CompilerOptions::finiteMathOnly.data(), true);
EXPECT_EQ(CL_SUCCESS, retVal);
auto hash3 = pProgram->getCachedFileName();
auto kernel3 = pProgram->getKernelInfo("CopyBuffer");
@@ -1001,7 +979,7 @@ TEST_P(ProgramFromSourceTest, GivenDifferentCommpilerOptionsWhenBuildingProgramT
pProgram->createdFrom = NEO::Program::CreatedFrom::BINARY;
pProgram->setIrBinary(new char[16], true);
pProgram->setIrBinarySize(16, true);
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, true);
retVal = pProgram->build(0, nullptr, nullptr, true);
EXPECT_EQ(CL_SUCCESS, retVal);
auto hash4 = pProgram->getCachedFileName();
auto kernel4 = pProgram->getKernelInfo("CopyBuffer");
@@ -1011,7 +989,7 @@ TEST_P(ProgramFromSourceTest, GivenDifferentCommpilerOptionsWhenBuildingProgramT
Callback::watch(kernel4);
pProgram->createdFrom = NEO::Program::CreatedFrom::SOURCE;
retVal = pProgram->build(0, nullptr, nullptr, nullptr, nullptr, true);
retVal = pProgram->build(0, nullptr, nullptr, true);
EXPECT_EQ(CL_SUCCESS, retVal);
auto hash5 = pProgram->getCachedFileName();
auto kernel5 = pProgram->getKernelInfo("CopyBuffer");
@@ -1042,52 +1020,47 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenCompilingProgramThenSuc
const char *headerIncludeNames = "";
cl_program nullprogram = nullptr;
cl_program invprogram = (cl_program)pContext;
char data[4];
// Order of following microtests is important - do not change.
// Add new microtests at end.
// invalid compile parameters: combinations of numDevices & deviceList
retVal = pProgram->compile(1, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = pProgram->compile(0, &deviceList, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, &deviceList, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid compile parameters: combinations of numInputHeaders==0 & inputHeaders & headerIncludeNames
retVal = pProgram->compile(0, nullptr, nullptr, 0, &inputHeaders, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 0, &inputHeaders, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, &headerIncludeNames, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, &headerIncludeNames);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid compile parameters: combinations of numInputHeaders!=0 & inputHeaders & headerIncludeNames
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = pProgram->compile(0, nullptr, nullptr, 1, nullptr, &headerIncludeNames, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid compile parameters: combinations of funcNotify & userData with valid numInputHeaders!=0 & inputHeaders & headerIncludeNames
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, &headerIncludeNames, nullptr, &data[0]);
retVal = pProgram->compile(0, nullptr, nullptr, 1, nullptr, &headerIncludeNames);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid compile parameters: invalid content of deviceList
retVal = pProgram->compile(1, &deviceList, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, &deviceList, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
// fail compilation - another compilation is already in progress
p->setBuildStatus(CL_BUILD_IN_PROGRESS);
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
p->setBuildStatus(CL_BUILD_NONE);
// invalid compile parameters: invalid header Program object==nullptr
retVal = pProgram->compile(0, nullptr, nullptr, 1, &nullprogram, &headerIncludeNames, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 1, &nullprogram, &headerIncludeNames);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
// invalid compile parameters: invalid header Program object==non Program object
retVal = pProgram->compile(0, nullptr, nullptr, 1, &invprogram, &headerIncludeNames, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 1, &invprogram, &headerIncludeNames);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
// compile successfully kernel with header
@@ -1104,13 +1077,13 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenCompilingProgramThenSuc
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, p3);
inputHeaders = p3;
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, &headerIncludeNames, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, &headerIncludeNames);
EXPECT_EQ(CL_SUCCESS, retVal);
// fail compilation of kernel with header - header is invalid
p = (MockProgram *)p3;
p->sourceCode = ""; // set header source code as non-existent (invalid)
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, &headerIncludeNames, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 1, &inputHeaders, &headerIncludeNames);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
delete p3;
@@ -1120,24 +1093,18 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenCompilingProgramThenSuc
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment = std::make_unique<NoCompilerInterfaceRootDeviceEnvironment>(*executionEnvironment);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
auto p2 = std::make_unique<MockProgram>(toClDeviceVector(*device));
retVal = p2->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = p2->compile(0, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
p2.reset(nullptr);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
// fail compilation - any compilation error (here caused by specifying unrecognized option)
retVal = pProgram->compile(0, nullptr, "-invalid-option", 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, "-invalid-option", 0, nullptr, nullptr);
EXPECT_EQ(CL_COMPILE_PROGRAM_FAILURE, retVal);
// compile successfully without notifyFunc
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
// compile successfully
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
// compile successfully with notifyFunc
data[0] = 0;
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr, notifyFunc, &data[0]);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ('a', data[0]);
}
TEST_P(ProgramFromSourceTest, GivenFlagsWhenCompilingProgramThenBuildOptionsHaveBeenApplied) {
@@ -1148,7 +1115,7 @@ TEST_P(ProgramFromSourceTest, GivenFlagsWhenCompilingProgramThenBuildOptionsHave
program->sourceCode = "__kernel mock() {}";
// Ask to build created program without NEO::CompilerOptions::gtpinRera and NEO::CompilerOptions::greaterThan4gbBuffersRequired flags.
cl_int retVal = program->compile(0, nullptr, CompilerOptions::fastRelaxedMath.data(), 0, nullptr, nullptr, nullptr, nullptr);
cl_int retVal = program->compile(0, nullptr, CompilerOptions::fastRelaxedMath.data(), 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
// Check build options that were applied
@@ -1164,7 +1131,7 @@ TEST_P(ProgramFromSourceTest, GivenFlagsWhenCompilingProgramThenBuildOptionsHave
cip->buildInternalOptions.clear();
auto options = CompilerOptions::concatenate(CompilerOptions::greaterThan4gbBuffersRequired, CompilerOptions::gtpinRera, CompilerOptions::finiteMathOnly);
retVal = program->compile(0, nullptr, options.c_str(),
0, nullptr, nullptr, nullptr, nullptr);
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
// Check build options that were applied
@@ -1184,7 +1151,7 @@ TEST_F(ProgramTests, GivenFlagsWhenLinkingProgramThenBuildOptionsHaveBeenApplied
cl_program program = pProgram.get();
// compile successfully a kernel to be linked later
cl_int retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
cl_int retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
// Ask to link created program with NEO::CompilerOptions::gtpinRera and NEO::CompilerOptions::greaterThan4gbBuffersRequired flags.
@@ -1192,7 +1159,7 @@ TEST_F(ProgramTests, GivenFlagsWhenLinkingProgramThenBuildOptionsHaveBeenApplied
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
retVal = pProgram->link(0, nullptr, options.c_str(), 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, options.c_str(), 1, &program);
EXPECT_EQ(CL_SUCCESS, retVal);
// Check build options that were applied
@@ -1262,7 +1229,6 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenLinkingProgramThenSucce
SourceFileName);
cl_device_id deviceList = {0};
char data[4];
cl_program program = pProgram;
cl_program nullprogram = nullptr;
cl_program invprogram = (cl_program)pContext;
@@ -1271,43 +1237,39 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenLinkingProgramThenSucce
// Add new microtests at end.
// invalid link parameters: combinations of numDevices & deviceList
retVal = pProgram->link(1, nullptr, nullptr, 1, &program, nullptr, nullptr);
retVal = pProgram->link(1, nullptr, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = pProgram->link(0, &deviceList, nullptr, 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, &deviceList, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid link parameters: combinations of numInputPrograms & inputPrograms
retVal = pProgram->link(0, nullptr, nullptr, 0, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, nullptr, 0, &program);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
retVal = pProgram->link(0, nullptr, nullptr, 1, nullptr, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid link parameters: combinations of funcNotify & userData with valid numInputPrograms & inputPrograms
retVal = pProgram->link(0, nullptr, nullptr, 1, &program, nullptr, &data[0]);
retVal = pProgram->link(0, nullptr, nullptr, 1, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
// invalid link parameters: invalid content of deviceList
retVal = pProgram->link(1, &deviceList, nullptr, 1, &program, nullptr, nullptr);
retVal = pProgram->link(1, &deviceList, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
// fail linking - another linking is already in progress
pProgram->setBuildStatus(CL_BUILD_IN_PROGRESS);
retVal = pProgram->link(0, nullptr, nullptr, 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
pProgram->setBuildStatus(CL_BUILD_NONE);
// invalid link parameters: invalid Program object==nullptr
retVal = pProgram->link(0, nullptr, nullptr, 1, &nullprogram, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, nullptr, 1, &nullprogram);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
// invalid link parameters: invalid Program object==non Program object
retVal = pProgram->link(0, nullptr, nullptr, 1, &invprogram, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, nullptr, 1, &invprogram);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
// compile successfully a kernel to be linked later
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
// fail linking - code to be linked does not exist
@@ -1316,36 +1278,30 @@ TEST_P(ProgramFromSourceTest, GivenSpecificParamatersWhenLinkingProgramThenSucce
pProgram->irBinary.release();
size_t irBinSize = pProgram->irBinarySize;
pProgram->setIrBinary(nullptr, false);
retVal = pProgram->link(0, nullptr, nullptr, 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
pProgram->setIrBinary(pIrBin, isSpirvTmp);
// fail linking - size of code to be linked is == 0
pProgram->setIrBinarySize(0, isSpirvTmp);
retVal = pProgram->link(0, nullptr, nullptr, 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_PROGRAM, retVal);
pProgram->setIrBinarySize(irBinSize, isSpirvTmp);
// fail linking - any link error (here caused by specifying unrecognized option)
retVal = pProgram->link(0, nullptr, "-invalid-option", 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, "-invalid-option", 1, &program);
EXPECT_EQ(CL_LINK_PROGRAM_FAILURE, retVal);
// fail linking - linked code is corrupted and cannot be postprocessed
auto device = static_cast<ClDevice *>(usedDevice);
auto p2 = std::make_unique<FailingGenBinaryProgram>(toClDeviceVector(*device));
retVal = p2->link(0, nullptr, nullptr, 1, &program, nullptr, nullptr);
retVal = p2->link(0, nullptr, nullptr, 1, &program);
EXPECT_EQ(CL_INVALID_BINARY, retVal);
p2.reset(nullptr);
// link successfully without notifyFunc
retVal = pProgram->link(0, nullptr, nullptr, 1, &program, nullptr, nullptr);
// link successfully
retVal = pProgram->link(0, nullptr, nullptr, 1, &program);
EXPECT_EQ(CL_SUCCESS, retVal);
// link successfully with notifyFunc
data[0] = 0;
retVal = pProgram->link(0, nullptr, "", 1, &program, notifyFunc, &data[0]);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ('a', data[0]);
}
TEST_P(ProgramFromSourceTest, GivenInvalidOptionsWhenCreatingLibraryThenCorrectErrorIsReturned) {
@@ -1355,15 +1311,15 @@ TEST_P(ProgramFromSourceTest, GivenInvalidOptionsWhenCreatingLibraryThenCorrectE
// Add new microtests at end.
// compile successfully a kernel to be later used to create library
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(0, nullptr, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
// create library successfully
retVal = pProgram->link(0, nullptr, CompilerOptions::createLibrary.data(), 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, CompilerOptions::createLibrary.data(), 1, &program);
EXPECT_EQ(CL_SUCCESS, retVal);
// fail library creation - any link error (here caused by specifying unrecognized option)
retVal = pProgram->link(0, nullptr, CompilerOptions::concatenate(CompilerOptions::createLibrary, "-invalid-option").c_str(), 1, &program, nullptr, nullptr);
retVal = pProgram->link(0, nullptr, CompilerOptions::concatenate(CompilerOptions::createLibrary, "-invalid-option").c_str(), 1, &program);
EXPECT_EQ(CL_LINK_PROGRAM_FAILURE, retVal);
auto device = pContext->getDevice(0);
@@ -1373,7 +1329,7 @@ TEST_P(ProgramFromSourceTest, GivenInvalidOptionsWhenCreatingLibraryThenCorrectE
auto failingProgram = std::make_unique<MockProgram>(toClDeviceVector(*device));
// fail library creation - CompilerInterface cannot be obtained
retVal = failingProgram->link(0, nullptr, CompilerOptions::createLibrary.data(), 1, &program, nullptr, nullptr);
retVal = failingProgram->link(0, nullptr, CompilerOptions::createLibrary.data(), 1, &program);
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
std::swap(rootDeviceEnvironment, executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]);
}
@@ -1418,8 +1374,6 @@ HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResident
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -1487,8 +1441,6 @@ TEST_F(PatchTokenTests, WhenBuildingProgramThenGwsIsSet) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -1511,8 +1463,6 @@ TEST_F(PatchTokenTests, WhenBuildingProgramThenLwsIsSet) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
ASSERT_EQ(CL_SUCCESS, retVal);
@@ -1546,8 +1496,6 @@ TEST_F(PatchTokenTests, WhenBuildingProgramThenConstantKernelArgsAreAvailable) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -1589,8 +1537,6 @@ TEST_F(PatchTokenTests, GivenVmeKernelWhenBuildingKernelThenArgAvailable) {
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -1706,8 +1652,6 @@ TEST_F(ProgramWithDebugSymbolsTests, GivenProgramCreatedWithDashGOptionWhenGetti
1,
&device,
"-g",
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -2081,7 +2025,7 @@ TEST_F(ProgramTests, GivenGtpinReraFlagWhenBuildingProgramThenCorrectOptionsAreS
program->createdFrom = Program::CreatedFrom::SOURCE;
// Ask to build created program without NEO::CompilerOptions::gtpinRera flag.
cl_int retVal = program->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), nullptr, nullptr, false);
cl_int retVal = program->build(0, nullptr, CompilerOptions::fastRelaxedMath.data(), false);
EXPECT_EQ(CL_SUCCESS, retVal);
// Check build options that were applied
@@ -2091,7 +2035,7 @@ TEST_F(ProgramTests, GivenGtpinReraFlagWhenBuildingProgramThenCorrectOptionsAreS
// Ask to build created program with NEO::CompilerOptions::gtpinRera flag.
cip->buildOptions.clear();
cip->buildInternalOptions.clear();
retVal = program->build(0, nullptr, CompilerOptions::concatenate(CompilerOptions::gtpinRera, CompilerOptions::finiteMathOnly).c_str(), nullptr, nullptr, false);
retVal = program->build(0, nullptr, CompilerOptions::concatenate(CompilerOptions::gtpinRera, CompilerOptions::finiteMathOnly).c_str(), false);
EXPECT_EQ(CL_SUCCESS, retVal);
// Check build options that were applied
@@ -2324,7 +2268,7 @@ TEST_F(ProgramTests, givenProgramCreatedFromILWhenCompileIsCalledThenReuseTheILI
auto debugVars = NEO::getIgcDebugVars();
debugVars.forceBuildFailure = true;
gEnvironment->fclPushDebugVars(debugVars);
auto compilerErr = prog->compile(1, &deviceId, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
auto compilerErr = prog->compile(1, &deviceId, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, compilerErr);
gEnvironment->fclPopDebugVars();
prog->release();
@@ -2341,7 +2285,7 @@ TEST_F(ProgramTests, givenProgramCreatedFromIntermediateBinaryRepresentationWhen
auto debugVars = NEO::getIgcDebugVars();
debugVars.forceBuildFailure = true;
gEnvironment->fclPushDebugVars(debugVars);
auto compilerErr = prog->compile(1, &deviceId, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
auto compilerErr = prog->compile(1, &deviceId, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, compilerErr);
gEnvironment->fclPopDebugVars();
prog->release();
@@ -2440,7 +2384,7 @@ TEST_F(ProgramTests, WhenLinkingTwoValidSpirvProgramsThenValidProgramIsReturned)
EXPECT_EQ(CL_SUCCESS, errCode);
cl_program linkNodes[] = {node1, node2};
errCode = prog->link(0, nullptr, nullptr, 2, linkNodes, nullptr, nullptr);
errCode = prog->link(0, nullptr, nullptr, 2, linkNodes);
EXPECT_EQ(CL_SUCCESS, errCode);
prog->release();
@@ -2719,7 +2663,7 @@ TEST_F(ProgramTests, givenProgramWhenBuiltThenAdditionalOptionsAreApplied) {
AdditionalOptionsMockProgram program(toClDeviceVector(*pClDevice));
cl_device_id device = pClDevice;
program.build(1, &device, nullptr, nullptr, nullptr, false);
program.build(1, &device, nullptr, false);
EXPECT_EQ(1u, program.applyAdditionalOptionsCalled);
}
@@ -2900,8 +2844,6 @@ TEST_F(ProgramBinTest, givenPrintProgramBinaryProcessingTimeSetWhenBuildProgramT
1,
&device,
nullptr,
nullptr,
nullptr,
false);
auto output = testing::internal::GetCapturedStdout();
@@ -2945,7 +2887,7 @@ TEST_F(ProgramBinTest, GivenBuildWithDebugDataThenBuildDataAvailableViaGetInfo)
&sourceCode,
&knownSourceSize,
retVal);
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
// Verify
@@ -3002,11 +2944,11 @@ TEST_F(ProgramBinTest, GivenDebugDataAvailableWhenLinkingProgramThenDebugDataIsS
&knownSourceSize,
retVal);
retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
cl_program programToLink = pProgram;
retVal = pProgram->link(1, &device, nullptr, 1, &programToLink, nullptr, nullptr);
retVal = pProgram->link(1, &device, nullptr, 1, &programToLink);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, pProgram->getDebugData());
@@ -3084,12 +3026,12 @@ TEST_F(ProgramBinTest, GivenSourceKernelWhenLinkingProgramThenGtpinInitInfoIsPas
retVal);
std::unique_ptr<MockCompilerInterfaceWithGtpinParam> mockCompilerInterface(new MockCompilerInterfaceWithGtpinParam);
retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(mockCompilerInterface.get());
cl_program programToLink = pProgram;
retVal = pProgram->link(1, &device, nullptr, 1, &programToLink, nullptr, nullptr);
retVal = pProgram->link(1, &device, nullptr, 1, &programToLink);
EXPECT_EQ(pIgcInitPtr, mockCompilerInterface->gtpinInfoPassed);
mockCompilerInterface.release();
@@ -3110,3 +3052,31 @@ TEST(ProgramReplaceDeviceBinary, GivenBinaryZebinThenUseAsBothPackedAndUnpackedB
EXPECT_EQ(0, memcmp(program.buildInfos[rootDeviceIndex].packedDeviceBinary.get(), zebin.storage.data(), program.buildInfos[rootDeviceIndex].packedDeviceBinarySize));
EXPECT_EQ(0, memcmp(program.buildInfos[rootDeviceIndex].unpackedDeviceBinary.get(), zebin.storage.data(), program.buildInfos[rootDeviceIndex].unpackedDeviceBinarySize));
}
TEST(ProgramCallbackTest, whenFunctionIsNullptrThenUserDataNeedsToBeNullptr) {
void *userData = nullptr;
EXPECT_TRUE(Program::isValidCallback(nullptr, nullptr));
EXPECT_FALSE(Program::isValidCallback(nullptr, &userData));
}
void CL_CALLBACK callbackFuncProgram(
cl_program program,
void *userData) {
*reinterpret_cast<bool *>(userData) = true;
}
TEST(ProgramCallbackTest, whenFunctionIsNotNullptrThenUserDataDoesntMatter) {
void *userData = nullptr;
EXPECT_TRUE(Program::isValidCallback(callbackFuncProgram, nullptr));
EXPECT_TRUE(Program::isValidCallback(callbackFuncProgram, &userData));
}
TEST(ProgramCallbackTest, whenInvokeCallbackIsCalledThenFunctionIsProperlyInvoked) {
bool functionCalled = false;
MockContext context;
MockProgram program{&context, false, context.getDevices()};
program.invokeCallback(callbackFuncProgram, &functionCalled);
EXPECT_TRUE(functionCalled);
program.invokeCallback(nullptr, nullptr);
}

View File

@@ -60,8 +60,6 @@ TEST_F(ProgramWithBlockKernelsTest, GivenKernelWithBlockKernelsWhenProgramIsBuil
1,
&device,
nullptr,
nullptr,
nullptr,
false);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -102,11 +100,11 @@ TEST_F(ProgramWithBlockKernelsTest, GivenKernelWithBlockKernelsWhenProgramIsLink
Program *programLinked = new Program(pContext, false, pContext->getDevices());
cl_program program = pProgram;
retVal = pProgram->compile(1, &device, buildOptions, 0, nullptr, nullptr, nullptr, nullptr);
retVal = pProgram->compile(1, &device, buildOptions, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = programLinked->link(1, &device, buildOptions, 1, &program, nullptr, nullptr);
retVal = programLinked->link(1, &device, buildOptions, 1, &program);
EXPECT_EQ(CL_SUCCESS, retVal);
BlockKernelManager *blockManager = programLinked->getBlockKernelManager();

View File

@@ -95,9 +95,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompi
gEnvironment->fclPushDebugVars(debugVars);
cl_int retVal = pProgram->compile(1, &device, nullptr,
0, nullptr, nullptr,
nullptr,
nullptr);
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(CompilerOptions::contains(receivedInternalOptions, CompilerOptions::debugKernelEnable)) << receivedInternalOptions;
@@ -106,9 +104,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompi
TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompiledThenInternalOptionsIncludeDashGFlag) {
cl_int retVal = pProgram->compile(1, &device, nullptr,
0, nullptr, nullptr,
nullptr,
nullptr);
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getOptions(), ::testing::HasSubstr("-g"));
@@ -120,9 +116,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugAndOptDisabledWhen
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->compile(1, &device, nullptr,
0, nullptr, nullptr,
nullptr,
nullptr);
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getOptions(), ::testing::HasSubstr(CompilerOptions::optDisable.data()));
}
@@ -133,9 +127,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompi
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->compile(1, &device, nullptr,
0, nullptr, nullptr,
nullptr,
nullptr);
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getOptions(), ::testing::StartsWith("-s debugFileName"));
}
@@ -147,7 +139,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuilt
debugVars.receivedInternalOptionsOutput = &receivedInternalOptions;
gEnvironment->fclPushDebugVars(debugVars);
cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
cl_int retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(CompilerOptions::contains(receivedInternalOptions, CompilerOptions::debugKernelEnable)) << receivedInternalOptions;
@@ -155,7 +147,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuilt
}
TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuiltThenOptionsIncludeDashGFlag) {
cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
cl_int retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getOptions(), ::testing::HasSubstr("-g"));
}
@@ -165,7 +157,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugAndOptDisabledWhen
sourceLevelDebugger->isOptDisabled = true;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
cl_int retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getOptions(), ::testing::HasSubstr(CompilerOptions::optDisable.data()));
}
@@ -175,7 +167,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuilt
sourceLevelDebugger->sourceCodeFilename = "debugFileName";
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
cl_int retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(pProgram->getOptions(), ::testing::StartsWith("-s debugFileName"));
}
@@ -184,7 +176,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinke
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, nullptr, nullptr);
cl_int retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto program = std::unique_ptr<GMockProgram>(new GMockProgram(pContext, false, toClDeviceVector(*pClDevice)));
@@ -193,7 +185,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinke
EXPECT_CALL(*program, appendKernelDebugOptions()).Times(1);
cl_program clProgramToLink = pProgram;
retVal = program->link(1, &device, nullptr, 1, &clProgramToLink, nullptr, nullptr);
retVal = program->link(1, &device, nullptr, 1, &clProgramToLink);
EXPECT_EQ(CL_SUCCESS, retVal);
}
@@ -209,7 +201,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuilt
sourceLevelDebugger->setActive(true);
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
cl_int retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
}
@@ -226,19 +218,17 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinke
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = pProgram->compile(1, &device, nullptr,
0, nullptr, nullptr,
nullptr,
nullptr);
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
cl_program program = pProgram;
retVal = pProgram->link(1, &device, nullptr,
1, &program, nullptr, nullptr);
1, &program);
EXPECT_EQ(CL_SUCCESS, retVal);
}
TEST_F(ProgramWithKernelDebuggingTest, givenProgramWithKernelDebugEnabledWhenBuiltThenPatchTokenAllocateSipSurfaceHasSizeGreaterThanZero) {
retVal = pProgram->build(1, &device, CompilerOptions::debugKernelEnable.data(), nullptr, nullptr, false);
retVal = pProgram->build(1, &device, CompilerOptions::debugKernelEnable.data(), false);
EXPECT_EQ(CL_SUCCESS, retVal);
auto kernelInfo = pProgram->getKernelInfo("CopyBuffer");
@@ -246,7 +236,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenProgramWithKernelDebugEnabledWhenBui
}
TEST_F(ProgramWithKernelDebuggingTest, givenKernelDebugEnabledWhenProgramIsBuiltThenDebugDataIsStored) {
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, &device, nullptr, false);
auto debugData = mockProgram->getDebugData();
EXPECT_NE(nullptr, debugData);
@@ -254,7 +244,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenKernelDebugEnabledWhenProgramIsBuilt
}
TEST_F(ProgramWithKernelDebuggingTest, givenProgramWithKernelDebugEnabledWhenProcessDebugDataIsCalledThenKernelInfosAreFilledWithDebugData) {
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
retVal = pProgram->build(1, &device, nullptr, false);
EXPECT_EQ(CL_SUCCESS, retVal);
pProgram->processDebugData();