Fix issue with moving CUDA memory to host and multiple devices.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 9 Jan 2018 17:37:46 +0000 (18:37 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 10 Jan 2018 23:00:48 +0000 (00:00 +0100)
This is not expected to fix all issues. Also adds some more details
to error reporting to investigate failures.

intern/cycles/device/device_cuda.cpp

index 51d9994ee261d5b2699a7b4cbf304617afff9f24..116f4e2a452e421526b9d454e07b3d15387d9ad5 100644 (file)
@@ -829,18 +829,26 @@ public:
                                status = " in host memory";
 
                                /* Replace host pointer with our host allocation. Only works if
-                                * CUDA memory layout is the same and has no pitch padding. */
-                               if(pitch_padding == 0 && mem.host_pointer && mem.host_pointer != mem.shared_pointer) {
+                                * CUDA memory layout is the same and has no pitch padding. Also
+                                * does not work if we move textures to host during a render,
+                                * since other devices might be using the memory. */
+                               if(!move_texture_to_host && pitch_padding == 0 &&
+                                  mem.host_pointer && mem.host_pointer != mem.shared_pointer) {
                                        memcpy(mem.shared_pointer, mem.host_pointer, size);
                                        mem.host_free();
                                        mem.host_pointer = mem.shared_pointer;
                                }
                        }
+                       else {
+                               status = " failed, out of host memory";
+                       }
+               }
+               else if(mem_alloc_result != CUDA_SUCCESS) {
+                       status = " failed, out of device and host memory";
                }
 
                if(mem_alloc_result != CUDA_SUCCESS) {
                        cuda_assert(mem_alloc_result);
-                       status = " failed, out of memory";
                }
 
                if(mem.name) {