Fix: Cycles: Avoid unnecessary move to host with multi-device
If one of the devices already used host happed memory but another not, it would previously realloc both. Thanks to Jorn Visser for investigating and finding this problem. Pull Request: https://projects.blender.org/blender/blender/pulls/132912
This commit is contained in:
@@ -601,6 +601,14 @@ void CUDADevice::mem_copy_to(device_memory &mem)
|
||||
|
||||
void CUDADevice::mem_move_to_host(device_memory &mem)
|
||||
{
|
||||
{
|
||||
/* If already host mapped, nothing to do. */
|
||||
thread_scoped_lock lock(device_mem_map_mutex);
|
||||
if (device_mem_map[&mem].use_mapped_host) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mem.type == MEM_GLOBAL) {
|
||||
global_free(mem);
|
||||
global_alloc(mem);
|
||||
|
||||
@@ -563,6 +563,14 @@ void HIPDevice::mem_copy_to(device_memory &mem)
|
||||
|
||||
void HIPDevice::mem_move_to_host(device_memory &mem)
|
||||
{
|
||||
{
|
||||
/* If already host mapped, nothing to do. */
|
||||
thread_scoped_lock lock(device_mem_map_mutex);
|
||||
if (device_mem_map[&mem].use_mapped_host) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mem.type == MEM_GLOBAL) {
|
||||
global_free(mem);
|
||||
global_alloc(mem);
|
||||
|
||||
@@ -444,6 +444,14 @@ void OneapiDevice::mem_move_to_host(device_memory &mem)
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
/* If already host mapped, nothing to do. */
|
||||
thread_scoped_lock lock(device_mem_map_mutex);
|
||||
if (device_mem_map[&mem].use_mapped_host) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mem.type == MEM_GLOBAL) {
|
||||
global_free(mem);
|
||||
global_alloc(mem);
|
||||
|
||||
Reference in New Issue
Block a user