P4 to Git Change 1205056 by gandryey@gera-w8 on 2015/10/28 17:13:54
SWDEV-78467 - OpenCL LiquidFlash feature
- Add WriteBufferFromFile command
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp#8 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h#21 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#189 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#259 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpusettings.cpp#333 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#72 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#79 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#93 edit
... //depot/stg/opencl/drivers/opencl/runtime/runtimedefs#35 edit
[ROCm/clr commit: 715cbfd662]
Este cometimento está contido em:
@@ -58,6 +58,7 @@ class SvmCopyMemoryCommand;
|
||||
class SvmFillMemoryCommand;
|
||||
class SvmMapMemoryCommand;
|
||||
class SvmUnmapMemoryCommand;
|
||||
class WriteBufferFromFileCommand;
|
||||
class HwDebugManager;
|
||||
class Device;
|
||||
struct KernelParameterDescriptor;
|
||||
@@ -111,6 +112,7 @@ enum OclExtensions {
|
||||
ClKhrMipMapImage,
|
||||
ClKhrMipMapImageWrites,
|
||||
ClKhrIlProgram,
|
||||
ClAMDLiquidFlash,
|
||||
ClExtTotal
|
||||
};
|
||||
|
||||
@@ -153,6 +155,7 @@ OclExtensionsString[] = {
|
||||
"cl_khr_mipmap_image ",
|
||||
"cl_khr_mipmap_image_writes ",
|
||||
"",
|
||||
(IS_MAINLINE || IS_LINUX) ? "" : "cl_amd_liquid_flash ",
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1410,13 +1413,14 @@ public:
|
||||
virtual void submitThreadTraceMemObjects(amd::ThreadTraceMemObjectsCommand& cmd) = 0;
|
||||
virtual void submitThreadTrace(amd::ThreadTraceCommand& cmd) = 0;
|
||||
virtual void flush(amd::Command* list = NULL, bool wait = false) = 0;
|
||||
virtual void submitSignal(amd::SignalCommand & cmd) = 0;
|
||||
virtual void submitMakeBuffersResident(amd::MakeBuffersResidentCommand & cmd) = 0;
|
||||
virtual void submitSvmFreeMemory(amd::SvmFreeMemoryCommand& cmd) = 0;
|
||||
virtual void submitSvmCopyMemory(amd::SvmCopyMemoryCommand& cmd) = 0;
|
||||
virtual void submitSvmFillMemory(amd::SvmFillMemoryCommand& cmd) = 0;
|
||||
virtual void submitSvmMapMemory(amd::SvmMapMemoryCommand& cmd) = 0;
|
||||
virtual void submitSvmUnmapMemory(amd::SvmUnmapMemoryCommand& cmd) = 0;
|
||||
/// Optional extensions
|
||||
virtual void submitSignal(amd::SignalCommand & cmd) = 0;
|
||||
virtual void submitMakeBuffersResident(amd::MakeBuffersResidentCommand & cmd) = 0;
|
||||
|
||||
//! Get the blit manager object
|
||||
device::BlitManager& blitMgr() const { return *blitMgr_; }
|
||||
|
||||
@@ -337,6 +337,10 @@ Settings::create(
|
||||
enableExtension(ClAmdVec3);
|
||||
enableExtension(ClAmdPrintf);
|
||||
enableExtension(ClExtAtomicCounters32);
|
||||
// Enable some platform extensions
|
||||
enableExtension(ClAmdDeviceAttributeQuery);
|
||||
enableExtension(ClKhrSpir);
|
||||
enableExtension(ClAMDLiquidFlash);
|
||||
|
||||
hwLDSSize_ = 32 * Ki;
|
||||
|
||||
@@ -380,11 +384,6 @@ Settings::create(
|
||||
|
||||
svmAtomics_ = (calAttr.svmAtomics || calAttr.isSVMFineGrainSystem) ? true : false;
|
||||
|
||||
// Enable some platform extensions
|
||||
enableExtension(ClAmdDeviceAttributeQuery);
|
||||
|
||||
enableExtension(ClKhrSpir);
|
||||
|
||||
// SVM is not currently supported for DX Interop
|
||||
if (!svmFineGrainSystem_) {
|
||||
#if defined(_WIN32)
|
||||
|
||||
@@ -217,10 +217,6 @@ Command::Command(
|
||||
std::mem_fun(&Command::retain));
|
||||
}
|
||||
|
||||
Command::~Command()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Command::releaseResources()
|
||||
{
|
||||
@@ -577,4 +573,35 @@ ThreadTraceMemObjectsCommand::validateMemory()
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
WriteBufferFromFileCommand::submit(device::VirtualDevice& device)
|
||||
{
|
||||
device::Memory* mem = memory_->getDeviceMemory(queue()->device());
|
||||
void* dstBuffer = mem->cpuMap(device);
|
||||
// Make HD transfer to the host accessible memory
|
||||
if (!file()->readBlock(dstBuffer, fileOffset(), origin()[0], size()[0])) {
|
||||
return;
|
||||
}
|
||||
mem->cpuUnmap(device);
|
||||
}
|
||||
|
||||
bool
|
||||
WriteBufferFromFileCommand::validateMemory()
|
||||
{
|
||||
if (!(memory_->getMemFlags() & (CL_MEM_USE_HOST_PTR |
|
||||
CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_PERSISTENT_MEM_AMD))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (queue()->device().info().type_ & CL_DEVICE_TYPE_GPU) {
|
||||
device::Memory* mem = memory_->getDeviceMemory(queue()->device());
|
||||
if (NULL == mem) {
|
||||
LogPrintfError("Can't allocate memory size - 0x%08X bytes!",
|
||||
memory_->getSize());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
|
||||
@@ -223,9 +223,6 @@ protected:
|
||||
exception_(0), data_(NULL), eventWaitList_(nullWaitList)
|
||||
{ }
|
||||
|
||||
//! Destroy the command object.
|
||||
virtual ~Command();
|
||||
|
||||
bool terminate() {
|
||||
if (Agent::shouldPostEventEvents() && type() != 0) {
|
||||
Agent::postEventFree(as_cl(static_cast<Event*>(this)));
|
||||
@@ -1472,6 +1469,56 @@ public:
|
||||
Memory* getSvmMem() const {return svmMem_;}
|
||||
};
|
||||
|
||||
/*! \brief A generic write memory from file command.
|
||||
*
|
||||
* \details Currently supports buffers only. Buffers
|
||||
* are treated as 1D structures so origin_[0] and size_[0]
|
||||
* are equivalent to offset_ and count_ respectively.
|
||||
*/
|
||||
class WriteBufferFromFileCommand : public OneMemoryArgCommand
|
||||
{
|
||||
private:
|
||||
const Coord3D origin_; //!< Origin of the region to write to
|
||||
const Coord3D size_; //!< Size of the region to write to
|
||||
LiquidFlashFile* file_; //!< The file object for data read
|
||||
size_t fileOffset_; //!< Offset in the file for data read
|
||||
|
||||
public:
|
||||
WriteBufferFromFileCommand(
|
||||
HostQueue& queue,
|
||||
const EventWaitList& eventWaitList,
|
||||
Memory& memory, const Coord3D& origin,
|
||||
const Coord3D& size, LiquidFlashFile* file, size_t fileOffset)
|
||||
: OneMemoryArgCommand(queue, CL_COMMAND_WRITE_BUFFER_FROM_FILE_AMD,
|
||||
eventWaitList, memory)
|
||||
, origin_(origin)
|
||||
, size_(size)
|
||||
, file_(file)
|
||||
, fileOffset_(fileOffset)
|
||||
{
|
||||
// Sanity checks
|
||||
assert(size.c[0] > 0 && "invalid");
|
||||
}
|
||||
|
||||
virtual void submit(device::VirtualDevice& device);
|
||||
|
||||
//! Return the memory object to write to
|
||||
Memory& memory() const { return *memory_; }
|
||||
|
||||
//! Return the host memory to read from
|
||||
LiquidFlashFile* file() const { return file_; }
|
||||
|
||||
//! Returns file offset
|
||||
size_t fileOffset() const { return fileOffset_; }
|
||||
|
||||
//! Return the region origin
|
||||
const Coord3D& origin() const { return origin_; }
|
||||
//! Return the region size
|
||||
const Coord3D& size() const { return size_; }
|
||||
|
||||
bool validateMemory();
|
||||
};
|
||||
|
||||
/*! @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "platform/object.hpp"
|
||||
#include "platform/interop.hpp"
|
||||
#include "device/device.hpp"
|
||||
#include "lf.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <utility>
|
||||
@@ -671,6 +672,34 @@ private:
|
||||
static Monitor AllocatedLock_;
|
||||
};
|
||||
|
||||
//! Liquid flash extension
|
||||
class LiquidFlashFile : public RuntimeObject
|
||||
{
|
||||
private:
|
||||
const wchar_t* name_;
|
||||
cl_file_flags_amd flags_;
|
||||
lf_file handle_;
|
||||
uint32_t blockSize_;
|
||||
|
||||
public:
|
||||
LiquidFlashFile(const wchar_t* name, cl_file_flags_amd flags)
|
||||
: name_(name), flags_(flags), handle_(NULL) { }
|
||||
|
||||
~LiquidFlashFile();
|
||||
|
||||
bool open();
|
||||
void close();
|
||||
|
||||
uint32_t blockSize() const { return blockSize_; };
|
||||
|
||||
bool readBlock(
|
||||
void* dst,
|
||||
uint64_t fileOffset,
|
||||
uint64_t bufferOffset,
|
||||
uint64_t size) const;
|
||||
|
||||
virtual ObjectType objectType() const { return ObjectTypeLiquidFlashFile; }
|
||||
};
|
||||
} // namespace amd
|
||||
|
||||
#endif // MEMORY_H_
|
||||
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador