Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device_multi.cpp
| Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | foreach(SubDevice& sub, devices) { | ||||
| if(sub.device == sub_device) | if(sub.device == sub_device) | ||||
| return i; | return i; | ||||
| i++; | i++; | ||||
| } | } | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| void map_neighbor_tiles(Device * sub_device, RenderTile * tiles) | |||||
brecht: Style: `Device *sub_device, RenderTile *tiles`. | |||||
| { | |||||
| for(int i = 0; i < 9; i++) { | |||||
| if(!tiles[i].buffers) { | |||||
| continue; | |||||
| } | |||||
| /* If the tile isn't already allocated on the current device, | |||||
| * allocate and copy it now. | |||||
| * Note that this temporarily modifies the RenderBuffers, | |||||
| * so this function is not threadsafe. */ | |||||
brechtUnsubmitted Done Inline ActionsIt took me a while to understand what's going on here, this comment would have been more clear for me: /* If the tile was rendered on another device, copy its memory to * to the current device now, for the duration of the denoising task. * Note that this temporarily modifies the RenderBuffers and calls * the device, so this function is not thread safe. */ brecht: It took me a while to understand what's going on here, this comment would have been more clear… | |||||
| if(tiles[i].buffers->device != sub_device) { | |||||
| device_vector<float> &mem = tiles[i].buffers->buffer; | |||||
brechtUnsubmitted Not Done Inline ActionsCould this allocate a new device_vector<float> mem rather than referencing the global tiles[i].buffers->buffer and doing the original_ptr swapping? Not that this solves the thread safety entirely, but seems a bit unnecessary to access the global buffers here. brecht: Could this allocate a new `device_vector<float> mem` rather than referencing the global `tiles… | |||||
| tiles[i].buffers->copy_from_device(); | |||||
| device_ptr original_ptr = mem.device_pointer; | |||||
| mem.device_pointer = 0; | |||||
| sub_device->mem_alloc("Temporary memory for neighboring tile", mem, MEM_READ_WRITE); | |||||
| sub_device->mem_copy_to(mem); | |||||
| tiles[i].buffer = mem.device_pointer; | |||||
| mem.device_pointer = original_ptr; | |||||
| } | |||||
| } | |||||
| } | |||||
| void unmap_neighbor_tiles(Device * sub_device, RenderTile * tiles) | |||||
| { | |||||
| for(int i = 0; i < 9; i++) { | |||||
| if(!tiles[i].buffers) { | |||||
| continue; | |||||
| } | |||||
| if(tiles[i].buffers->device != sub_device) { | |||||
| device_vector<float> &mem = tiles[i].buffers->buffer; | |||||
brechtUnsubmitted Not Done Inline ActionsSimilar comment as above, not sure this access to global buffers is needed. brecht: Similar comment as above, not sure this access to global buffers is needed. | |||||
| device_ptr original_ptr = mem.device_pointer; | |||||
| mem.device_pointer = tiles[i].buffer; | |||||
| /* Copy denoised tile to the host device. */ | |||||
| if(i == 4) { | |||||
| tiles[i].buffers->copy_from_device(sub_device); | |||||
| } | |||||
| size_t mem_size = mem.device_size; | |||||
| sub_device->mem_free(mem); | |||||
| mem.device_pointer = original_ptr; | |||||
| mem.device_size = mem_size; | |||||
| /* Copy denoised tile to the original device. */ | |||||
| if(i == 4) { | |||||
| tiles[i].buffers->device->mem_copy_to(mem); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| int get_split_task_count(DeviceTask& task) | int get_split_task_count(DeviceTask& task) | ||||
| { | { | ||||
| int total_tasks = 0; | int total_tasks = 0; | ||||
| list<DeviceTask> tasks; | list<DeviceTask> tasks; | ||||
| task.split(tasks, devices.size()); | task.split(tasks, devices.size()); | ||||
| foreach(SubDevice& sub, devices) { | foreach(SubDevice& sub, devices) { | ||||
| if(!tasks.empty()) { | if(!tasks.empty()) { | ||||
| DeviceTask subtask = tasks.front(); | DeviceTask subtask = tasks.front(); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||
Style: Device *sub_device, RenderTile *tiles.