2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
2018-09-18 15:11:08 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#pragma once
|
2020-02-24 20:10:44 +08:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
|
|
|
|
2020-05-28 20:05:12 +08:00
|
|
|
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/fixtures/context_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/program_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2020-02-22 16:28:27 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <string>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ProgramFromBinaryTest Test Fixture
|
|
|
|
// Used to test the Program class
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2020-12-02 20:43:54 +08:00
|
|
|
struct ProgramFromBinaryFixture : public ClDeviceFixture,
|
|
|
|
public ContextFixture,
|
|
|
|
public ProgramFixture,
|
|
|
|
public testing::Test {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
using ContextFixture::SetUp;
|
|
|
|
|
|
|
|
void SetUp() override {
|
2020-12-02 20:43:54 +08:00
|
|
|
ProgramFromBinaryFixture::SetUp("CopyBuffer_simd32", "CopyBuffer");
|
|
|
|
}
|
|
|
|
void SetUp(const char *binaryFileName, const char *kernelName) {
|
|
|
|
this->binaryFileName = binaryFileName;
|
|
|
|
this->kernelName = kernelName;
|
2020-05-28 20:05:12 +08:00
|
|
|
ClDeviceFixture::SetUp();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
cl_device_id device = pClDevice;
|
2017-12-21 07:45:38 +08:00
|
|
|
ContextFixture::SetUp(1, &device);
|
|
|
|
ProgramFixture::SetUp();
|
|
|
|
|
|
|
|
if (options.size())
|
2020-12-02 20:43:54 +08:00
|
|
|
CreateProgramFromBinary(pContext, pContext->getDevices(), binaryFileName, options);
|
2017-12-21 07:45:38 +08:00
|
|
|
else
|
2020-12-02 20:43:54 +08:00
|
|
|
CreateProgramFromBinary(pContext, pContext->getDevices(), binaryFileName);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2019-08-29 21:10:51 +08:00
|
|
|
knownSource.reset();
|
2017-12-21 07:45:38 +08:00
|
|
|
ProgramFixture::TearDown();
|
|
|
|
ContextFixture::TearDown();
|
2020-05-28 20:05:12 +08:00
|
|
|
ClDeviceFixture::TearDown();
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void setOptions(std::string &optionsIn) {
|
|
|
|
options = optionsIn;
|
|
|
|
}
|
|
|
|
|
2020-12-02 20:43:54 +08:00
|
|
|
const char *binaryFileName = nullptr;
|
2020-12-01 01:38:28 +08:00
|
|
|
const char *kernelName = nullptr;
|
2020-03-13 21:59:00 +08:00
|
|
|
cl_int retVal = CL_SUCCESS;
|
2017-12-21 07:45:38 +08:00
|
|
|
std::string options;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2018-03-16 01:13:52 +08:00
|
|
|
// ProgramSimpleFixture Test Fixture
|
2017-12-21 07:45:38 +08:00
|
|
|
// Used to test the Program class, but not using parameters
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2020-05-28 20:05:12 +08:00
|
|
|
class ProgramSimpleFixture : public ClDeviceFixture,
|
2018-03-16 01:13:52 +08:00
|
|
|
public ContextFixture,
|
|
|
|
public ProgramFixture {
|
2017-12-21 07:45:38 +08:00
|
|
|
using ContextFixture::SetUp;
|
|
|
|
|
2018-03-16 01:13:52 +08:00
|
|
|
public:
|
2017-12-21 07:45:38 +08:00
|
|
|
void SetUp() override {
|
2020-05-28 20:05:12 +08:00
|
|
|
ClDeviceFixture::SetUp();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
cl_device_id device = pClDevice;
|
2017-12-21 07:45:38 +08:00
|
|
|
ContextFixture::SetUp(1, &device);
|
|
|
|
ProgramFixture::SetUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2019-08-29 21:10:51 +08:00
|
|
|
knownSource.reset();
|
2017-12-21 07:45:38 +08:00
|
|
|
ProgramFixture::TearDown();
|
|
|
|
ContextFixture::TearDown();
|
2020-05-28 20:05:12 +08:00
|
|
|
ClDeviceFixture::TearDown();
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-03-16 01:13:52 +08:00
|
|
|
protected:
|
2020-03-13 21:59:00 +08:00
|
|
|
cl_int retVal = CL_SUCCESS;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|