Correct handling unique_ptr in functions

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski 2021-10-21 12:37:31 +00:00 committed by Compute-Runtime-Automation
parent f305e38b32
commit 28b37aea72
30 changed files with 37 additions and 37 deletions

View File

@ -49,7 +49,7 @@ struct BuiltinFunctionsLibImpl::BuiltinData {
module.reset();
}
BuiltinData() = default;
BuiltinData(std::unique_ptr<L0::Module> mod, std::unique_ptr<L0::Kernel> ker) {
BuiltinData(std::unique_ptr<L0::Module> &&mod, std::unique_ptr<L0::Kernel> &&ker) {
module = std::move(mod);
func = std::move(ker);
}

View File

@ -60,7 +60,7 @@ class TestBuiltinFunctionsLibImpl : public DeviceFixture, public testing::Test {
struct MockBuiltinData : BuiltinFunctionsLibImpl::BuiltinData {
using BuiltinFunctionsLibImpl::BuiltinData::func;
using BuiltinFunctionsLibImpl::BuiltinData::module;
MockBuiltinData(std::unique_ptr<L0::Module> mod, std::unique_ptr<L0::Kernel> ker) {
MockBuiltinData(std::unique_ptr<L0::Module> &&mod, std::unique_ptr<L0::Kernel> &&ker) {
module = std::move(mod);
func = std::move(ker);
}

View File

@ -398,7 +398,7 @@ class CommandQueueHw : public CommandQueue {
const EnqueueProperties &enqueueProperties,
EventsRequest &eventsRequest,
EventBuilder &externalEventBuilder,
std::unique_ptr<PrintfHandler> printfHandler,
std::unique_ptr<PrintfHandler> &&printfHandler,
CommandStreamReceiver *bcsCsr);
CompletionStamp enqueueCommandWithoutKernel(Surface **surfaces,

View File

@ -944,7 +944,7 @@ void CommandQueueHw<GfxFamily>::enqueueBlocked(
const EnqueueProperties &enqueueProperties,
EventsRequest &eventsRequest,
EventBuilder &externalEventBuilder,
std::unique_ptr<PrintfHandler> printfHandler,
std::unique_ptr<PrintfHandler> &&printfHandler,
CommandStreamReceiver *bcsCsr) {
TakeOwnershipWrapper<CommandQueueHw<GfxFamily>> queueOwnership(*this);

View File

@ -31,7 +31,7 @@ const DeviceDescriptor deviceDescriptorTable[] = {
#undef NAMEDDEVICE
{0, nullptr, nullptr, GTTYPE_UNDEFINED}};
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
std::unique_ptr<Drm> drmObject;
if (DebugManager.flags.EnableNullHardware.get() == true) {
drmObject.reset(new DrmNullDevice(std::move(hwDeviceId), rootDeviceEnvironment));

View File

@ -112,7 +112,7 @@ CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) {
}
CommandComputeKernel::CommandComputeKernel(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> &kernelOperation, std::vector<Surface *> &surfaces,
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> printfHandler,
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> &&printfHandler,
PreemptionMode preemptionMode, Kernel *kernel, uint32_t kernelCount)
: Command(commandQueue, kernelOperation), flushDC(flushDC), slmUsed(usesSLM),
NDRangeKernel(ndRangeKernel), printfHandler(std::move(printfHandler)), kernel(kernel),

View File

@ -130,7 +130,7 @@ class CommandMapUnmap : public Command {
class CommandComputeKernel : public Command {
public:
CommandComputeKernel(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> &kernelOperation, std::vector<Surface *> &surfaces,
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> printfHandler,
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> &&printfHandler,
PreemptionMode preemptionMode, Kernel *kernel, uint32_t kernelCount);
~CommandComputeKernel() override;

View File

@ -127,7 +127,7 @@ T *Program::createBuiltInFromGenBinary(
program = new T(context, true, deviceVector);
for (const auto &device : deviceVector) {
if (program->buildInfos[device->getRootDeviceIndex()].packedDeviceBinarySize == 0) {
program->replaceDeviceBinary(makeCopy(binary, size), size, device->getRootDeviceIndex());
program->replaceDeviceBinary(std::move(makeCopy(binary, size)), size, device->getRootDeviceIndex());
}
}
program->setBuildStatusSuccess(deviceVector, CL_PROGRAM_BINARY_TYPE_EXECUTABLE);

View File

@ -424,7 +424,7 @@ void Program::updateNonUniformFlag(const Program **inputPrograms, size_t numInpu
this->allowNonUniform = allowNonUniform;
}
void Program::replaceDeviceBinary(std::unique_ptr<char[]> newBinary, size_t newBinarySize, uint32_t rootDeviceIndex) {
void Program::replaceDeviceBinary(std::unique_ptr<char[]> &&newBinary, size_t newBinarySize, uint32_t rootDeviceIndex) {
if (isAnyPackedDeviceBinaryFormat(ArrayRef<const uint8_t>(reinterpret_cast<uint8_t *>(newBinary.get()), newBinarySize))) {
this->buildInfos[rootDeviceIndex].packedDeviceBinary = std::move(newBinary);
this->buildInfos[rootDeviceIndex].packedDeviceBinarySize = newBinarySize;

View File

@ -250,7 +250,7 @@ class Program : public BaseObject<_cl_program> {
buildInfos[rootDeviceIndex].linkerInput = std::move(linkerInput);
}
MOCKABLE_VIRTUAL void replaceDeviceBinary(std::unique_ptr<char[]> newBinary, size_t newBinarySize, uint32_t rootDeviceIndex);
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);

View File

@ -148,7 +148,7 @@ class MockProgram : public Program {
return this->build(getDevices(), this->options.c_str(), false, builtins);
}
void replaceDeviceBinary(std::unique_ptr<char[]> newBinary, size_t newBinarySize, uint32_t rootDeviceIndex) override {
void replaceDeviceBinary(std::unique_ptr<char[]> &&newBinary, size_t newBinarySize, uint32_t rootDeviceIndex) override {
if (replaceDeviceBinaryCalledPerRootDevice.find(rootDeviceIndex) == replaceDeviceBinaryCalledPerRootDevice.end()) {
replaceDeviceBinaryCalledPerRootDevice.insert({rootDeviceIndex, 1});
} else {

View File

@ -30,7 +30,7 @@ class DrmMockDefault : public DrmMock {
Drm **pDrmToReturnFromCreateFunc = nullptr;
bool disableBindDefaultInTests = true;
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
rootDeviceEnvironment.setHwInfo(defaultHwInfo.get());
if (pDrmToReturnFromCreateFunc) {
return *pDrmToReturnFromCreateFunc;

View File

@ -100,7 +100,7 @@ TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMapp
TEST(WddmDiscoverDevices, WhenNoHwDeviceIdIsProvidedToWddmThenWddmIsNotCreated) {
struct MockWddm : public Wddm {
MockWddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceIdIn), rootDeviceEnvironment) {}
MockWddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceIdIn), rootDeviceEnvironment) {}
};
MockExecutionEnvironment executionEnvironment;

View File

@ -8,7 +8,7 @@
#include "shared/test/common/mocks/mock_wddm.h"
namespace NEO {
Wddm *Wddm::createWddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
Wddm *Wddm::createWddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
return new WddmMock(rootDeviceEnvironment);
}
} // namespace NEO

View File

@ -20,7 +20,7 @@ static void show_usage(std::string name) {
<< "\t -p, --platform\t\tOPTIONAL - Family name with type\n"
<< "\t -a, --array\t\tName of an uin32_t type array containing parsed input file" << std::endl;
}
std::string parseToCharArray(std::unique_ptr<uint8_t[]> binary, size_t size, std::string &builtinName, std::string &platform, std::string revisionId, bool isSpirV) {
std::string parseToCharArray(std::unique_ptr<uint8_t[]> &binary, size_t size, std::string &builtinName, std::string &platform, std::string revisionId, bool isSpirV) {
std::ostringstream out;
out << "#include <cstddef>\n";
@ -113,7 +113,7 @@ int main(int argc, char *argv[]) {
inputFile.read(reinterpret_cast<char *>(memblock.get()), size);
inputFile.close();
isSpirV = fileName.find(".spv") != std::string::npos;
std::string cpp = parseToCharArray(move(memblock), size, arrayName, platform, revisionId, isSpirV);
std::string cpp = parseToCharArray(memblock, size, arrayName, platform, revisionId, isSpirV);
std::fstream(cppOutputName.c_str(), std::ios::out | std::ios::binary).write(cpp.c_str(), cpp.size());
} else {
std::cerr << "File cannot be opened!" << std::endl;

View File

@ -354,7 +354,7 @@ bool CompilerInterface::loadIgc() {
return NEO::loadCompiler<IGC::IgcOclDeviceCtx>(Os::igcDllName, igcLib, igcMain);
}
bool CompilerInterface::initialize(std::unique_ptr<CompilerCache> cache, bool requireFcl) {
bool CompilerInterface::initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl) {
bool fclAvailable = requireFcl ? this->loadFcl() : false;
bool igcAvailable = this->loadIgc();

View File

@ -105,7 +105,7 @@ class CompilerInterface {
virtual ~CompilerInterface();
template <typename CompilerInterfaceT = CompilerInterface>
static CompilerInterfaceT *createInstance(std::unique_ptr<CompilerCache> cache, bool requireFcl) {
static CompilerInterfaceT *createInstance(std::unique_ptr<CompilerCache> &&cache, bool requireFcl) {
auto instance = new CompilerInterfaceT();
if (!instance->initialize(std::move(cache), requireFcl)) {
delete instance;
@ -137,7 +137,7 @@ class CompilerInterface {
std::vector<char> &stateSaveAreaHeader);
protected:
MOCKABLE_VIRTUAL bool initialize(std::unique_ptr<CompilerCache> cache, bool requireFcl);
MOCKABLE_VIRTUAL bool initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl);
MOCKABLE_VIRTUAL bool loadFcl();
MOCKABLE_VIRTUAL bool loadIgc();

View File

@ -18,7 +18,7 @@ InternalAllocationStorage::InternalAllocationStorage(CommandStreamReceiver &comm
temporaryAllocations(TEMPORARY_ALLOCATION),
allocationsForReuse(REUSABLE_ALLOCATION){};
void InternalAllocationStorage::storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage) {
void InternalAllocationStorage::storeAllocation(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage) {
uint32_t taskCount = gfxAllocation->getTaskCount(commandStreamReceiver.getOsContext().getContextId());
if (allocationUsage == REUSABLE_ALLOCATION) {
@ -27,7 +27,7 @@ void InternalAllocationStorage::storeAllocation(std::unique_ptr<GraphicsAllocati
storeAllocationWithTaskCount(std::move(gfxAllocation), allocationUsage, taskCount);
}
void InternalAllocationStorage::storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage, uint32_t taskCount) {
void InternalAllocationStorage::storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage, uint32_t taskCount) {
if (allocationUsage == REUSABLE_ALLOCATION) {
if (DebugManager.flags.DisableResourceRecycling.get()) {
commandStreamReceiver.getMemoryManager()->freeGraphicsMemory(gfxAllocation.release());

View File

@ -16,8 +16,8 @@ class InternalAllocationStorage {
MOCKABLE_VIRTUAL ~InternalAllocationStorage() = default;
InternalAllocationStorage(CommandStreamReceiver &commandStreamReceiver);
MOCKABLE_VIRTUAL void cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage);
void storeAllocation(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage);
void storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation> gfxAllocation, uint32_t allocationUsage, uint32_t taskCount);
void storeAllocation(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage);
void storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage, uint32_t taskCount);
std::unique_ptr<GraphicsAllocation> obtainReusableAllocation(size_t requiredSize, GraphicsAllocation::AllocationType allocationType);
std::unique_ptr<GraphicsAllocation> obtainTemporaryAllocationWithPtr(size_t requiredSize, const void *requiredPtr, GraphicsAllocation::AllocationType allocationType);
AllocationsList &getTemporaryAllocations() { return temporaryAllocations; }

View File

@ -191,7 +191,7 @@ std::string getIoctlString(unsigned long request) {
} // namespace IoctlHelper
Drm::Drm(std::unique_ptr<HwDeviceIdDrm> hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment)
Drm::Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment)
: DriverModel(DriverModelType::DRM),
hwDeviceId(std::move(hwDeviceIdIn)), rootDeviceEnvironment(rootDeviceEnvironment) {
pagingFence.fill(0u);

View File

@ -206,7 +206,7 @@ class Drm : public DriverModel {
static bool isi915Version(int fd);
static Drm *create(std::unique_ptr<HwDeviceIdDrm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
static Drm *create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
static void overrideBindSupport(bool &useVmBind);
std::string getPciPath() {
return hwDeviceId->getPciPath();
@ -243,7 +243,7 @@ class Drm : public DriverModel {
}
protected:
Drm(std::unique_ptr<HwDeviceIdDrm> hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
uint32_t createDrmContextExt(drm_i915_gem_context_create_ext &gcc, uint32_t drmVmId, bool isSpecialContextRequested);
int getQueueSliceCount(drm_i915_gem_context_param_sseu *sseu);

View File

@ -38,7 +38,7 @@ class DrmNullDevice : public Drm {
}
}
DrmNullDevice(std::unique_ptr<HwDeviceIdDrm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::move(hwDeviceId), rootDeviceEnvironment), gpuTimestamp(0){};
DrmNullDevice(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::move(hwDeviceId), rootDeviceEnvironment), gpuTimestamp(0){};
protected:
uint64_t gpuTimestamp;

View File

@ -52,7 +52,7 @@ Wddm::DXCoreCreateAdapterFactoryFcn Wddm::dXCoreCreateAdapterFactory = getDXCore
Wddm::CreateDXGIFactoryFcn Wddm::createDxgiFactory = getCreateDxgiFactory();
Wddm::GetSystemInfoFcn Wddm::getSystemInfo = getGetSystemInfo();
Wddm::Wddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment)
Wddm::Wddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment)
: DriverModel(DriverModelType::WDDM), hwDeviceId(std::move(hwDeviceIdIn)), rootDeviceEnvironment(rootDeviceEnvironment) {
UNRECOVERABLE_IF(!hwDeviceId);
featureTable.reset(new FeatureTable());

View File

@ -63,7 +63,7 @@ class Wddm : public DriverModel {
virtual ~Wddm();
static Wddm *createWddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
static Wddm *createWddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
bool init();
MOCKABLE_VIRTUAL bool evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
@ -226,7 +226,7 @@ class Wddm : public DriverModel {
std::unique_ptr<GmmMemory> gmmMemory;
uintptr_t minAddress = 0;
Wddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
Wddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
MOCKABLE_VIRTUAL bool waitOnGPU(D3DKMT_HANDLE context);
bool createDevice(PreemptionMode preemptionMode);
bool createPagingQueue();

View File

@ -8,7 +8,7 @@
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
Wddm *Wddm::createWddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
Wddm *Wddm::createWddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
return new Wddm(std::move(hwDeviceId), rootDeviceEnvironment);
}
} // namespace NEO

View File

@ -53,7 +53,7 @@ void PerfProfiler::destroyAll() {
gPerfProfiler = nullptr;
}
PerfProfiler::PerfProfiler(int id, std::unique_ptr<std::ostream> logOut, std::unique_ptr<std::ostream> sysLogOut) : totalSystemTime(0) {
PerfProfiler::PerfProfiler(int id, std::unique_ptr<std::ostream> &&logOut, std::unique_ptr<std::ostream> &&sysLogOut) : totalSystemTime(0) {
ApiTimer.setFreq();
systemLogs.reserve(20);

View File

@ -36,8 +36,8 @@ class PerfProfiler {
static void readAndVerify(std::istream &stream, const std::string &token);
PerfProfiler(int id, std::unique_ptr<std::ostream> logOut = {nullptr},
std::unique_ptr<std::ostream> sysLogOut = {nullptr});
PerfProfiler(int id, std::unique_ptr<std::ostream> &&logOut = {nullptr},
std::unique_ptr<std::ostream> &&sysLogOut = {nullptr});
~PerfProfiler();
void apiEnter() {

View File

@ -48,7 +48,7 @@ class WddmMock : public Wddm {
using Wddm::timestampFrequency;
using Wddm::wddmInterface;
WddmMock(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceId), rootDeviceEnvironment) {}
WddmMock(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceId), rootDeviceEnvironment) {}
WddmMock(RootDeviceEnvironment &rootDeviceEnvironment);
~WddmMock();

View File

@ -139,7 +139,7 @@ TEST(CompilerInterface, WhenInitializeIsCalledThenFailIfOneOfRequiredCompilersIs
TEST(CompilerInterfaceCreateInstance, WhenInitializeFailedThenReturnNull) {
struct FailInitializeCompilerInterface : CompilerInterface {
bool initialize(std::unique_ptr<CompilerCache> cache, bool requireFcl) override {
bool initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl) override {
return false;
}
};

View File

@ -17,7 +17,7 @@ using namespace NEO;
class WddmSharedAllocationsMock : public WddmMock {
public:
WddmSharedAllocationsMock(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
WddmSharedAllocationsMock(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(std::move(hwDeviceId), rootDeviceEnvironment) {}
WddmSharedAllocationsMock(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(std::move(hwDeviceId), rootDeviceEnvironment) {}
NTSTATUS createNTHandle(const D3DKMT_HANDLE *resourceHandle, HANDLE *ntHandle) override {
return static_cast<NTSTATUS>(0xfff);
}