Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/cuda/device_cuda_impl.cpp
| Show First 20 Lines • Show All 848 Lines • ▼ Show 20 Lines | if (mem_alloc_result == CUDA_SUCCESS) { | ||||
| status = " in device memory"; | status = " in device memory"; | ||||
| } | } | ||||
| } | } | ||||
| /* Fall back to mapped host memory if needed and possible. */ | /* Fall back to mapped host memory if needed and possible. */ | ||||
| void *shared_pointer = 0; | void *shared_pointer = 0; | ||||
| if (mem_alloc_result != CUDA_SUCCESS && can_map_host) { | if (mem_alloc_result != CUDA_SUCCESS && can_map_host && mem.type != MEM_DEVICE_ONLY) { | ||||
| if (mem.shared_pointer) { | if (mem.shared_pointer) { | ||||
| /* Another device already allocated host memory. */ | /* Another device already allocated host memory. */ | ||||
| mem_alloc_result = CUDA_SUCCESS; | mem_alloc_result = CUDA_SUCCESS; | ||||
| shared_pointer = mem.shared_pointer; | shared_pointer = mem.shared_pointer; | ||||
| } | } | ||||
| else if (map_host_used + size < map_host_limit) { | else if (map_host_used + size < map_host_limit) { | ||||
| /* Allocate host memory ourselves. */ | /* Allocate host memory ourselves. */ | ||||
| mem_alloc_result = cuMemHostAlloc( | mem_alloc_result = cuMemHostAlloc( | ||||
| &shared_pointer, size, CU_MEMHOSTALLOC_DEVICEMAP | CU_MEMHOSTALLOC_WRITECOMBINED); | &shared_pointer, size, CU_MEMHOSTALLOC_DEVICEMAP | CU_MEMHOSTALLOC_WRITECOMBINED); | ||||
| assert((mem_alloc_result == CUDA_SUCCESS && shared_pointer != 0) || | assert((mem_alloc_result == CUDA_SUCCESS && shared_pointer != 0) || | ||||
| (mem_alloc_result != CUDA_SUCCESS && shared_pointer == 0)); | (mem_alloc_result != CUDA_SUCCESS && shared_pointer == 0)); | ||||
| } | } | ||||
| if (mem_alloc_result == CUDA_SUCCESS) { | if (mem_alloc_result == CUDA_SUCCESS) { | ||||
| cuda_assert(cuMemHostGetDevicePointer_v2(&device_pointer, shared_pointer, 0)); | cuda_assert(cuMemHostGetDevicePointer_v2(&device_pointer, shared_pointer, 0)); | ||||
| map_host_used += size; | map_host_used += size; | ||||
| status = " in host memory"; | status = " in host memory"; | ||||
| } | } | ||||
| } | } | ||||
| if (mem_alloc_result != CUDA_SUCCESS) { | if (mem_alloc_result != CUDA_SUCCESS) { | ||||
| if (mem.type == MEM_DEVICE_ONLY) { | |||||
| status = " failed, out of device memory"; | |||||
| set_error("System is out of GPU memory"); | |||||
| } | |||||
| else { | |||||
| status = " failed, out of device and host memory"; | status = " failed, out of device and host memory"; | ||||
| set_error("System is out of GPU and shared host memory"); | set_error("System is out of GPU and shared host memory"); | ||||
| } | } | ||||
| } | |||||
| if (mem.name) { | if (mem.name) { | ||||
| VLOG(1) << "Buffer allocate: " << mem.name << ", " | VLOG(1) << "Buffer allocate: " << mem.name << ", " | ||||
| << string_human_readable_number(mem.memory_size()) << " bytes. (" | << string_human_readable_number(mem.memory_size()) << " bytes. (" | ||||
| << string_human_readable_size(mem.memory_size()) << ")" << status; | << string_human_readable_size(mem.memory_size()) << ")" << status; | ||||
| } | } | ||||
| mem.device_pointer = (device_ptr)device_pointer; | mem.device_pointer = (device_ptr)device_pointer; | ||||
| ▲ Show 20 Lines • Show All 1,820 Lines • Show Last 20 Lines | |||||