diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index 4045f09d21..07e3d36c5e 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -2211,10 +2211,23 @@ void VirtualGPU::submitFillMemory(amd::FillMemoryCommand& cmd) { amd::ScopedLock lock(execution()); profilingBegin(cmd); - - if (!fillMemory(cmd.type(), &cmd.memory(), cmd.pattern(), cmd.patternSize(), cmd.origin(), - cmd.size())) { - cmd.setStatus(CL_INVALID_OPERATION); + size_t width = cmd.size().c[0]; + size_t height = cmd.size().c[1]; + size_t depth = cmd.size().c[2]; + size_t pitch = cmd.surface().c[0]; + amd::Coord3D origin = cmd.origin(); + amd::Coord3D region{cmd.surface().c[1], cmd.surface().c[2], depth}; + amd::BufferRect rect; + rect.create(static_cast(origin), static_cast(region), + pitch, 0); + for (size_t slice = 0; slice < depth; slice++) { + for (size_t row = 0; row < height; row++) { + const size_t rowOffset = rect.offset(0, row, slice); + if (!fillMemory(cmd.type(), &cmd.memory(), cmd.pattern(), cmd.patternSize(), + amd::Coord3D{rowOffset, 0, 0}, amd::Coord3D{width, 1, 1})) { + cmd.setStatus(CL_INVALID_OPERATION); + } + } } profilingEnd(cmd); } diff --git a/rocclr/platform/command.hpp b/rocclr/platform/command.hpp index e4ac030009..193b60307e 100644 --- a/rocclr/platform/command.hpp +++ b/rocclr/platform/command.hpp @@ -601,16 +601,18 @@ class FillMemoryCommand : public OneMemoryArgCommand { private: Coord3D origin_; //!< Origin of the region to write to. Coord3D size_; //!< Size of the region to write to. + Coord3D surface_; //!< Total surface char pattern_[MaxFillPatterSize]; //!< The fill pattern size_t patternSize_; //!< Pattern size public: FillMemoryCommand(HostQueue& queue, cl_command_type cmdType, const EventWaitList& eventWaitList, - Memory& memory, const void* pattern, size_t patternSize, Coord3D origin, - Coord3D size) + Memory& memory, const void* pattern, size_t patternSize, const Coord3D& origin, + const Coord3D& size, const Coord3D& surface) : OneMemoryArgCommand(queue, cmdType, eventWaitList, memory), origin_(origin), size_(size), + surface_(surface), patternSize_(patternSize) { // Sanity checks assert(pattern != NULL && "pattern cannot be null"); @@ -632,6 +634,9 @@ class FillMemoryCommand : public OneMemoryArgCommand { //! Return the region size const Coord3D& size() const { return size_; } + //! Return the surface + const Coord3D& surface() const { return surface_; } + //! Return true if the entire memory object is written. bool isEntireMemory() const; };