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

@@ -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);
}