P4 to Git Change 1748674 by cpaquot@cpaquot-ocl-lc-lnx on 2019/02/26 11:31:59

SWDEV-145570 - [HIP] Implemented texture object for ROCm backend
	Needed to implement sampler object and return the getHsaImageObject
	for roc::Image::cpuSrd.

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#118 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#34 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.hpp#15 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#73 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#22 edit


[ROCm/clr commit: 2732ad0300]
Этот коммит содержится в:
foreman
2019-02-26 11:47:55 -05:00
родитель 5aab4688e9
Коммит 1d0572dd0f
5 изменённых файлов: 92 добавлений и 87 удалений
+61
Просмотреть файл
@@ -27,6 +27,7 @@
#ifdef WITH_AMDGPU_PRO
#include "pro/prodriver.hpp"
#endif
#include "platform/sampler.hpp"
#include <cstring>
#include <fstream>
#include <sstream>
@@ -841,6 +842,66 @@ hsa_status_t Device::iterateCpuMemoryPoolCallback(hsa_amd_memory_pool_t pool, vo
return HSA_STATUS_SUCCESS;
}
bool Device::createSampler(const amd::Sampler& owner, device::Sampler** sampler) const {
*sampler = nullptr;
Sampler* gpuSampler = new Sampler(*this);
if ((nullptr == gpuSampler) || !gpuSampler->create(owner)) {
delete gpuSampler;
return false;
}
*sampler = gpuSampler;
return true;
}
void Sampler::fillSampleDescriptor(hsa_ext_sampler_descriptor_t& samplerDescriptor,
const amd::Sampler& sampler) const {
samplerDescriptor.filter_mode = sampler.filterMode() == CL_FILTER_NEAREST
? HSA_EXT_SAMPLER_FILTER_MODE_NEAREST
: HSA_EXT_SAMPLER_FILTER_MODE_LINEAR;
samplerDescriptor.coordinate_mode = sampler.normalizedCoords()
? HSA_EXT_SAMPLER_COORDINATE_MODE_NORMALIZED
: HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED;
switch (sampler.addressingMode()) {
case CL_ADDRESS_CLAMP_TO_EDGE:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE;
break;
case CL_ADDRESS_REPEAT:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT;
break;
case CL_ADDRESS_CLAMP:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER;
break;
case CL_ADDRESS_MIRRORED_REPEAT:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT;
break;
case CL_ADDRESS_NONE:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED;
break;
default:
return;
}
}
bool Sampler::create(const amd::Sampler& owner) {
hsa_ext_sampler_descriptor_t samplerDescriptor;
fillSampleDescriptor(samplerDescriptor, owner);
hsa_status_t status = hsa_ext_sampler_create(dev_.getBackendDevice(), &samplerDescriptor, &hsa_sampler);
if (HSA_STATUS_SUCCESS != status) {
return false;
}
hwSrd_ = reinterpret_cast<uint64_t>(hsa_sampler.handle);
hwState_ = reinterpret_cast<address>(hsa_sampler.handle);
return true;
}
Sampler::~Sampler() {
hsa_ext_sampler_destroy(dev_.getBackendDevice(), hsa_sampler);
}
bool Device::populateOCLDeviceConstants() {
info_.available_ = true;
+26 -10
Просмотреть файл
@@ -59,6 +59,31 @@ class VirtualDevice;
class PrintfDbg;
class IProDevice;
class Sampler : public device::Sampler {
public:
//! Constructor
Sampler(const Device& dev) : dev_(dev) {}
//! Default destructor for the device memory object
virtual ~Sampler();
//! Creates a device sampler from the OCL sampler state
bool create(const amd::Sampler& owner //!< AMD sampler object
);
private:
void fillSampleDescriptor(hsa_ext_sampler_descriptor_t& samplerDescriptor,
const amd::Sampler& sampler) const;
Sampler& operator=(const Sampler&);
//! Disable operator=
Sampler(const Sampler&);
const Device& dev_; //!< Device object associated with the sampler
hsa_ext_sampler_t hsa_sampler;
};
// A NULL Device type used only for offline compilation
// Only functions that are used for compilation will be in this device
class NullDevice : public amd::Device {
@@ -283,16 +308,7 @@ class Device : public NullDevice {
//! Sampler object allocation
virtual bool createSampler(const amd::Sampler& owner, //!< abstraction layer sampler object
device::Sampler** sampler //!< device sampler object
) const {
//! \todo HSA team has to implement sampler allocation.
//! Currently allocate the base device class
*sampler = new device::Sampler();
if (*sampler == nullptr) {
return false;
}
return true;
}
) const;
//! Just returns nullptr for the dummy device
virtual device::Memory* createView(
+3 -3
Просмотреть файл
@@ -78,8 +78,6 @@ class Memory : public device::Memory {
virtual uint64_t virtualAddress() const override { return reinterpret_cast<uint64_t>(getDeviceMemory()); }
virtual const address cpuSrd() const override { return reinterpret_cast<const address>(getDeviceMemory()); }
// Accessors for indirect map memory object
amd::Memory* mapMemory() const { return mapMemory_; }
@@ -176,9 +174,11 @@ class Image : public roc::Memory {
size_t getDeviceDataSize() { return deviceImageInfo_.size; }
size_t getDeviceDataAlignment() { return deviceImageInfo_.alignment; }
hsa_ext_image_t getHsaImageObject() { return hsaImageObject_; }
hsa_ext_image_t getHsaImageObject() const { return hsaImageObject_; }
const hsa_ext_image_descriptor_t& getHsaImageDescriptor() const { return imageDescriptor_; }
virtual const address cpuSrd() const { return reinterpret_cast<const address>(getHsaImageObject().handle); }
private:
//! Disable copy constructor
Image(const Buffer&);
+2 -68
Просмотреть файл
@@ -186,35 +186,6 @@ void VirtualGPU::MemoryDependency::clear(bool all) {
}
}
static void fillSampleDescriptor(hsa_ext_sampler_descriptor_t& samplerDescriptor,
const amd::Sampler& sampler) {
samplerDescriptor.filter_mode = sampler.filterMode() == CL_FILTER_NEAREST
? HSA_EXT_SAMPLER_FILTER_MODE_NEAREST
: HSA_EXT_SAMPLER_FILTER_MODE_LINEAR;
samplerDescriptor.coordinate_mode = sampler.normalizedCoords()
? HSA_EXT_SAMPLER_COORDINATE_MODE_NORMALIZED
: HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED;
switch (sampler.addressingMode()) {
case CL_ADDRESS_CLAMP_TO_EDGE:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE;
break;
case CL_ADDRESS_REPEAT:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT;
break;
case CL_ADDRESS_CLAMP:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER;
break;
case CL_ADDRESS_MIRRORED_REPEAT:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT;
break;
case CL_ADDRESS_NONE:
samplerDescriptor.address_mode = HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED;
break;
default:
return;
}
}
bool VirtualGPU::processMemObjects(const amd::Kernel& kernel, const_address params, size_t& ldsAddress) {
Kernel& hsaKernel = const_cast<Kernel&>(static_cast<const Kernel&>(*(kernel.getDeviceKernel(dev()))));
const amd::KernelSignature& signature = kernel.signature();
@@ -395,36 +366,10 @@ bool VirtualGPU::processMemObjects(const amd::Kernel& kernel, const_address para
const amd::Sampler* sampler = reinterpret_cast<amd::Sampler* const*>(params +
kernelParams.samplerObjOffset())[index];
hsa_ext_sampler_descriptor_t samplerDescriptor;
fillSampleDescriptor(samplerDescriptor, *sampler);
device::Sampler* devSampler = sampler->getDeviceSampler(dev());
hsa_ext_sampler_t hsa_sampler;
hsa_status_t status =
hsa_ext_sampler_create(dev().getBackendDevice(), &samplerDescriptor, &hsa_sampler);
if (status != HSA_STATUS_SUCCESS) {
// Wait on a kernel if one is outstanding
releaseGpuMemoryFence();
// Release the sampler handles allocated for the various
// on one or more kernel submissions
for (const auto& it: samplerList_) {
if (hsa_ext_sampler_destroy(gpu_device_, it) != HSA_STATUS_SUCCESS) {
LogWarning("Error destroying device sampler object!");
}
}
samplerList_.clear();
status = hsa_ext_sampler_create(dev().getBackendDevice(), &samplerDescriptor, &hsa_sampler);
if (status != HSA_STATUS_SUCCESS) {
LogError("Error creating device sampler object!");
return false;
}
}
uint64_t sampler_srd = hsa_sampler.handle;
uint64_t sampler_srd = devSampler->hwSrd();
WriteAqlArgAt(const_cast<address>(params), &sampler_srd, sizeof(sampler_srd), desc.offset_);
samplerList_.push_back(hsa_sampler);
// TODO: destroy sampler.
}
}
@@ -896,17 +841,6 @@ void VirtualGPU::updateCommandsState(amd::Command* list) {
current->release();
current = next;
}
// Release the sampler handles allocated for the various
// on one or more kernel submissions
for (const auto& it: samplerList_) {
if (hsa_ext_sampler_destroy(gpu_device_, it) != HSA_STATUS_SUCCESS) {
LogWarning("Error destroying device sampler object!");
}
}
samplerList_.clear();
return;
}
void VirtualGPU::submitReadMemory(amd::ReadMemoryCommand& cmd) {
-6
Просмотреть файл
@@ -291,12 +291,6 @@ class VirtualGPU : public device::VirtualDevice {
std::vector<Memory*> xferWriteBuffers_; //!< Stage write buffers
std::vector<amd::Memory*> pinnedMems_; //!< Pinned memory list
/**
* @brief Maintains the list of sampler allocated for one or more kernel
* submissions.
*/
std::vector<hsa_ext_sampler_t> samplerList_;
/**
* @brief Indicates if a kernel dispatch is outstanding. This flag is
* used to synchronized on kernel outputs.