P4 to Git Change 1257532 by gandryey@gera-ocl on 2016/04/13 13:18:22

SWDEV-92049 - Forum [2712399]: clEnqueueMapBuffer in parallel
	- Handle multiple unmapInfo structures of multiple simultaneous maps of the same buffer
	- The change didn't affect images path, since it requires extra handling

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#79 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#194 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#271 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#126 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#399 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.cpp#25 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.hpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.cpp#64 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#82 edit
This commit is contained in:
foreman
2016-04-13 13:27:37 -04:00
parent 91e212bebe
commit b0631f7ab9
6 changed files with 178 additions and 106 deletions
+32 -29
View File
@@ -1084,7 +1084,7 @@ VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd)
gpu::Memory* memory = dev().getGpuMemory(&vcmd.memory());
// Save map info for unmap operation
memory->saveMapInfo(vcmd.origin(), vcmd.size(),
memory->saveMapInfo(vcmd.mapPtr(), vcmd.origin(), vcmd.size(),
vcmd.mapFlags(), vcmd.isEntireMemory());
// If we have host memory, use it
@@ -1111,7 +1111,7 @@ VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd)
amd::Coord3D dstOrigin(0, 0, 0);
if (memory->cal()->buffer_) {
if (!blitMgr().copyBuffer(*memory,
*memory->mapMemory(), vcmd.origin(), dstOrigin,
*memory->mapMemory(), vcmd.origin(), vcmd.origin(),
vcmd.size(), vcmd.isEntireMemory())) {
LogError("submitMapMemory() - copy failed");
vcmd.setStatus(CL_MAP_FAILURE);
@@ -1151,7 +1151,7 @@ VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd)
amd::Image* amdImage = vcmd.memory().parent()->asImage();
if ((amdImage != NULL) && (amdImage->getMipLevels() > 1)) {
// Save map write info in the parent object
dev().getGpuMemory(amdImage)->saveMapInfo(
dev().getGpuMemory(amdImage)->saveMapInfo(vcmd.mapPtr(),
vcmd.origin(), vcmd.size(),
vcmd.mapFlags(), vcmd.isEntireMemory(),
vcmd.memory().asImage());
@@ -1183,22 +1183,24 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
gpu::Memory* memory = dev().getGpuMemory(&vcmd.memory());
amd::Memory* owner = memory->owner();
bool unmapMip = false;
const device::Memory::WriteMapInfo* writeMapInfo =
memory->writeMapInfo(vcmd.mapPtr());
// Check if image is a mipmap and assign a saved view
amd::Image* amdImage = owner->asImage();
if ((amdImage != NULL) && (amdImage->getMipLevels() > 1) &&
(memory->writeMapInfo()->baseMip_ != NULL)) {
(writeMapInfo->baseMip_ != NULL)) {
// Clear unmap flags from the parent image
memory->clearUnmapFlags();
memory->clearUnmapInfo(vcmd.mapPtr());
// Assign mip level view
amdImage = memory->writeMapInfo()->baseMip_;
amdImage = writeMapInfo->baseMip_;
memory = dev().getGpuMemory(amdImage);
unmapMip = true;
}
// We used host memory
if ((owner->getHostMem() != NULL) && memory->isDirectMap()) {
if (memory->isUnmapWrite() && !owner->usesSvmPointer()) {
if (writeMapInfo->isUnmapWrite() && !owner->usesSvmPointer()) {
// Target is the backing store, so sync
owner->signalWrite(NULL);
memory->syncCacheFromHost(*this);
@@ -1212,17 +1214,17 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
memory->unmap(this);
}
else if (memory->mapMemory() != NULL) {
if (memory->isUnmapWrite()) {
if (writeMapInfo->isUnmapWrite()) {
amd::Coord3D srcOrigin(0, 0, 0);
// Target is a remote resource, so copy
assert(memory->mapMemory() != NULL);
if (memory->cal()->buffer_) {
if (!blitMgr().copyBuffer(
*memory->mapMemory(), *memory,
srcOrigin,
memory->writeMapInfo()->origin_,
memory->writeMapInfo()->region_,
memory->writeMapInfo()->entire_)) {
writeMapInfo->origin_,
writeMapInfo->origin_,
writeMapInfo->region_,
writeMapInfo->isEntire())) {
LogError("submitUnmapMemory() - copy failed");
vcmd.setStatus(CL_OUT_OF_RESOURCES);
}
@@ -1230,8 +1232,8 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
else if ((vcmd.memory().getType() == CL_MEM_OBJECT_IMAGE1D_BUFFER)) {
amd::Memory* bufferFromImage = NULL;
Memory* memoryBuf = memory;
amd::Coord3D origin(memory->writeMapInfo()->origin_[0]);
amd::Coord3D size(memory->writeMapInfo()->region_[0]);
amd::Coord3D origin(writeMapInfo->origin_[0]);
amd::Coord3D size(writeMapInfo->region_[0]);
size_t elemSize =
vcmd.memory().asImage()->getImageFormat().getElementSize();
origin.c[0] *= elemSize;
@@ -1248,7 +1250,7 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
if (!blitMgr().copyBuffer(
*memory->mapMemory(), *memoryBuf,
srcOrigin, origin, size,
memory->writeMapInfo()->entire_)) {
writeMapInfo->isEntire())) {
LogError("submitUnmapMemory() - copy failed");
vcmd.setStatus(CL_OUT_OF_RESOURCES);
}
@@ -1260,9 +1262,9 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
if (!blitMgr().copyBufferToImage(
*memory->mapMemory(), *memory,
srcOrigin,
memory->writeMapInfo()->origin_,
memory->writeMapInfo()->region_,
memory->writeMapInfo()->entire_)) {
writeMapInfo->origin_,
writeMapInfo->region_,
writeMapInfo->isEntire())) {
LogError("submitUnmapMemory() - copy failed");
vcmd.setStatus(CL_OUT_OF_RESOURCES);
}
@@ -1275,7 +1277,7 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd)
}
// Clear unmap flags
memory->clearUnmapFlags();
memory->clearUnmapInfo(vcmd.mapPtr());
// Release a view for a mipmap map
if (unmapMip) {
@@ -1385,16 +1387,15 @@ VirtualGPU::submitSvmMapMemory(amd::SvmMapMemoryCommand& vcmd)
if (!dev().isFineGrainedSystem()) {
// Make sure we have memory for the command execution
gpu::Memory* memory = dev().getGpuMemory(vcmd.getSvmMem());
memory->saveMapInfo(vcmd.origin(), vcmd.size(),
memory->saveMapInfo(vcmd.svmPtr(), vcmd.origin(), vcmd.size(),
vcmd.mapFlags(), vcmd.isEntireMemory());
if (memory->mapMemory() != NULL) {
if (vcmd.mapFlags() & (CL_MAP_READ | CL_MAP_WRITE)) {
amd::Coord3D dstOrigin(0, 0, 0);
assert(memory->cal()->buffer_ && "SVM memory can't be an image");
if (!blitMgr().copyBuffer(*memory, *memory->mapMemory(),
vcmd.origin(), dstOrigin, vcmd.size(), vcmd.isEntireMemory())) {
vcmd.origin(), vcmd.origin(), vcmd.size(),
vcmd.isEntireMemory())) {
LogError("submitSVMMapMemory() - copy failed");
vcmd.setStatus(CL_MAP_FAILURE);
}
@@ -1417,21 +1418,23 @@ VirtualGPU::submitSvmUnmapMemory(amd::SvmUnmapMemoryCommand& vcmd)
//no op for FGS supported device
if (!dev().isFineGrainedSystem()) {
gpu::Memory* memory = dev().getGpuMemory(vcmd.getSvmMem());
const device::Memory::WriteMapInfo* writeMapInfo =
memory->writeMapInfo(vcmd.svmPtr());
if (memory->mapMemory() != NULL) {
if (memory->isUnmapWrite()) {
amd::Coord3D srcOrigin(0, 0, 0);
if (writeMapInfo->isUnmapWrite()) {
// Target is a remote resource, so copy
assert(memory->cal()->buffer_ && "SVM memory can't be an image");
if (!blitMgr().copyBuffer(*memory->mapMemory(), *memory, srcOrigin,
memory->writeMapInfo()->origin_, memory->writeMapInfo()->region_,
memory->writeMapInfo()->entire_)) {
if (!blitMgr().copyBuffer(*memory->mapMemory(), *memory,
writeMapInfo->origin_, writeMapInfo->origin_,
writeMapInfo->region_, writeMapInfo->isEntire())) {
LogError("submitSvmUnmapMemory() - copy failed");
vcmd.setStatus(CL_OUT_OF_RESOURCES);
}
}
}
memory->clearUnmapInfo(vcmd.svmPtr());
}
profilingEnd(vcmd);