Alternative Upload geometry data in parallel to multiple GPUs using the "Multi-Device" #107552

Open
William Leeson wants to merge 137 commits from leesonw/blender-cluster:upload_changed into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

137 Commits

Author SHA1 Message Date
William Leeson cfe2aeb0e3 Merge branch 'upstream_main' into upload_changed 2023-05-29 10:19:00 +02:00
William Leeson c53727e061 Merge branch 'upstream_main' into upload_changed 2023-05-22 10:50:43 +02:00
William Leeson 5084744e8d Merge branch 'upstream_main' into upload_changed 2023-05-19 08:51:35 +02:00
William Leeson 21d9481a76 FIX: Adds missing device import for MacOS bvh.mm 2023-05-17 10:54:47 +02:00
William Leeson 3e561157fe Merge branch 'upstream_main' into upload_changed 2023-05-16 10:11:33 +02:00
William Leeson 4e0a06e08e Merge branch 'upstream_main' into upload_changed 2023-05-15 16:14:39 +02:00
William Leeson 4557b85b38 Merge branch 'upstream_main' into upload_changed 2023-05-12 10:17:01 +02:00
William Leeson b26ba314bc Merge branch 'upstream_main' into upload_changed 2023-05-10 15:34:43 +02:00
William Leeson 9622bcbac1 Merge branch 'upstream_main' into upload_changed 2023-05-09 11:51:37 +02:00
William Leeson f80ef452a1 Merge branch 'remove_parallel_for' into upload_changed
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-09 11:11:19 +02:00
William Leeson b7a80ba6ef FIX: Enable local intersection testing on BVH
The scen bvh layout was set to NONE which disabled the local
intersection testing used for he bevel effect. This removes that
line and also refactors the code to make it cleaner.
2023-05-09 11:09:12 +02:00
William Leeson 72be875f3c FIX: BVH layout determination is the same across all devices. 2023-05-08 17:35:31 +02:00
William Leeson ed1b971948 FIX: Use memory_size and upload_changed in the correct places 2023-05-08 16:55:06 +02:00
William Leeson df7d92a33e FIX: Size used should be the data_size 2023-05-08 11:19:17 +02:00
William Leeson 565bc75769 FIX: get_device_bvh returns the MultiBVH if the device is the MultiDevice
If the device was the MultiDevice it previously returned the first
BVH. This was incorrect it should return the MultiBVH. Also, if
it cannot find the device then it should return NULL.
2023-05-08 09:42:26 +02:00
William Leeson a4b3b8e1fe Add missed changes to select the correct layout. 2023-05-08 09:31:00 +02:00
William Leeson ab21849d86 Remove the parallel_for over devices
The parallel_for for is replaced by many parallel_for's one for
the upload, one for each Object BVH and one for the scene BVH.
2023-05-05 15:54:38 +02:00
William Leeson b1be09d449 Move the BVH layout determination into a method for reuse
This code was duplicated in MultiDevice and geometry_bvh.cpp so
this removed that duplication.
2023-05-05 15:53:14 +02:00
William Leeson e04384f20d FIX: get_device_bvh returns the MultiBVH if the device is the MultiDevice
If the device was the MultiDevice it previously returned the first
BVH. This was incorrect it should return the MultiBVH. Also, if
it cannot find the device then it should return NULL.
2023-05-05 13:43:34 +02:00
William Leeson 8f50b28fa8 Move device_memory list into DeviceScene 2023-05-05 13:12:07 +02:00
William Leeson 9f146557f6 Move copy to device outside parallel_for 2023-05-05 12:22:22 +02:00
William Leeson 3cec5c199e Move buffer list to Scene 2023-05-04 16:56:31 +02:00
William Leeson d536ad206a Merge branch 'upstream_main' into wip_branch 2023-05-04 14:37:41 +02:00
William Leeson df0fba0d7d FIX: Upload buffer if data_size is not zero
This was incorrectly set to be device_size which is not set until
it is allocated on the device.
2023-05-04 10:09:09 +02:00
William Leeson a87d9843d7 FIX: Reinstate lock and context for build_optix_bvh 2023-05-04 10:07:31 +02:00
William Leeson c9b8ee956d FIX: Don't upload buffers with 0 size 2023-05-04 09:32:03 +02:00
William Leeson d01c68f4b0 FIX: program_name should be name only broken on window 2023-05-03 14:16:38 +02:00
William Leeson 66080891f2 FIX: CPU device needs to register globals. 2023-05-03 14:16:01 +02:00
William Leeson 6f458619a4 Change upload_changed to take a vector of buffers to upload 2023-05-03 14:56:10 +02:00
William Leeson d756933965 Create upload_changed to upload all changed buffers 2023-05-02 16:22:31 +02:00
William Leeson de58c2ab8e Merge branch 'upstream_main' into geometry_update
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-01 09:42:38 +02:00
William Leeson 429f953d6c Move CUDA context into a smaller scope
buildbot/vexp-code-patch-coordinator Build done. Details
2023-04-28 15:28:57 +02:00
William Leeson 2485460fb6 Merge branch 'upstream_main' into geometry_update 2023-04-28 13:40:20 +02:00
William Leeson df62806c94 Use task pool for object BVH build also fixes stats recording
Re-instates the task pool used to build the BVHs for the objects.
Also the displacement timing was being reported twice and this is
fixed.
2023-04-28 10:31:38 +02:00
William Leeson e5250ab494 FIX: Remove this from lambda capture for parallel_for 2023-04-28 10:23:44 +02:00
William Leeson 70f531fc2e Merge branch 'upstream_main' into geometry_update 2023-04-27 14:36:36 +02:00
William Leeson a916e34033 Move scene DeviceScene to use unique_ptr
To reduce the amount of code and manage the life cycles of the
DeviceScenes they are now stored as unique_ptrs
2023-04-27 11:14:53 +02:00
William Leeson 58cddaeefe FIX: Upload textures to all devices
For the displacement and shadow texture generation the textures
were originally only uploaded to 1 device. However, this resulted
in some textures that were needed across all devices not being
uploaded. This fixes that by uploading them to all devices.
2023-04-27 10:57:04 +02:00
William Leeson 0af6a3efbe FIX:Add correct parameters to the OneAPI build_bvh method 2023-04-26 16:15:17 +02:00
William Leeson aa24f3dd06 Merge branch 'upstream_main' into geometry_update 2023-04-26 14:38:09 +02:00
William Leeson 8ba98b8138 Move displacement image upload out of geometry loop 2023-04-26 12:22:50 +02:00
William Leeson 1560ec66c9 FIX: Create CUDA context earlier and remove lock
Some CUDA commands were used before the context was setup. Also
since the BVHs are build in order there is not need for the lock
to prevent 2 being build at tehe same time to save memory.
2023-04-26 10:02:39 +02:00
William Leeson d949741a33 FIX: Clear the device buffers after hair transparency calculations 2023-04-26 09:50:00 +02:00
William Leeson 4ca1060431 Rename DeviceScene method device_free to device_free_geometry 2023-04-25 12:43:42 +02:00
William Leeson ee8d450adc Merge branch 'upstream_main' into geometry_update 2023-04-24 10:02:37 +02:00
William Leeson 0669acc5c5 Remove geometry_additions.cpp 2023-04-21 17:29:22 +02:00
William Leeson a126bf3b53 Revert progress related changes 2023-04-21 15:56:04 +02:00
William Leeson 89f11dedda Manage sub-BVHs life cycles using unique_ptr 2023-04-21 15:37:05 +02:00
William Leeson d96fd9b08f Handle the bvh root index correctly for the device specific DeviceScene
Uses the unique_ptr to decallocate the BVH2 structure in the
BVH postprocess and assignes the bvh root indices in the device
specific areas also.
2023-04-21 13:39:58 +02:00
William Leeson 168366b89d Merge branch 'upstream_main' into geometry_update 2023-04-20 17:55:32 +02:00
William Leeson b850a5d4b1 Merge branch 'upstream_main' into geometry_update 2023-04-20 11:00:17 +02:00
William Leeson ce91384a2a Rearrange methods to match the main_reorg PR 2023-04-19 15:35:10 +02:00
William Leeson 215f1267ca Allow BVH2 building to handle multiple sessions correctly 2023-04-19 13:45:50 +02:00
William Leeson dea1a464ef Merge branch 'unbroken_main' into geometry_update 2023-04-19 13:43:39 +02:00
William Leeson 5d0c87c1e4 Use info in device_memory to check to determine what data to upload 2023-04-18 09:04:05 +02:00
William Leeson 5f0678a81b Restore get_estimated_remaining_time methods constness 2023-04-17 16:46:13 +02:00
William Leeson f89abb02c2 Initialise built variable in class definition. 2023-04-17 16:43:12 +02:00
William Leeson 7ffb958444 Remove only grow allocation for HIP devices 2023-04-17 14:16:43 +02:00
William Leeson e69abe1659 Merge branch 'upstream_main' into geometry_update 2023-04-17 10:36:59 +02:00
William Leeson b407dba398 FIX: Use new memory copy method that replaced the old one
Forgot to add the file for the previous change to the memory copy
methods, which resulted in the OneAPI build failing.
2023-04-14 15:52:09 +02:00
William Leeson 064724d14e Merge branch 'geometry_update' of projects.blender.org:leesonw/blender-cluster into geometry_update
buildbot/vexp-code-patch-coordinator Build done. Details
2023-04-14 14:58:05 +02:00
William Leeson d7cd4a4951 FIX: Add device type definitions
Moving DeviceScene from scene.h caused the device definitions to be
no longer present in various files. This add them back in by
including device.h in the required files.
2023-04-14 14:52:07 +02:00
William Leeson f63c508b40 Move BVH2 device update to DeviceScene
As the device_update_bvh2 method just involves transferring data
to the device it was moved to DeviceScene.
2023-04-14 14:06:40 +02:00
William Leeson b1dd204d42 Moves DeviceScene related methods to the DeviceScene class
Refactored the GeometryManager methods so that those relating to
the DeviceScene are now methods in the DeviceScene.
2023-04-14 13:40:20 +02:00
William Leeson bbbf76c4db GeometrySizes and AttributeSizes are stored in Scene
Moved GeometrySizes and AttributeSizes to be stored in scene. This
resulted in them being removed as parameters where a Scene was
already passed in.
2023-04-14 10:55:18 +02:00
William Leeson 99f6183d84 Merge branch 'upstream_main' into geometry_update 2023-04-14 10:00:39 +02:00
William Leeson 29396f6227 Remove unused data elements. 2023-04-14 08:51:28 +02:00
William Leeson 63bb671388 Restore cancel checks 2023-04-13 16:24:51 +02:00
William Leeson 4ba4f7bf65 Remove commented out code 2023-04-13 16:24:18 +02:00
William Leeson b1fa18f6f8 Restore const methods and clean up code. 2023-04-13 16:22:03 +02:00
William Leeson 5c9b27b374 Switch to use Cycles CUDA error checking. 2023-04-13 16:20:26 +02:00
William Leeson d8dcfcb89b Merge branch 'upstream_main' into geometry_update 2023-04-13 15:28:37 +02:00
William Leeson 4920afae04 Merge branch 'geometry_update' of projects.blender.org:leesonw/blender-cluster into geometry_update 2023-04-12 10:37:25 +02:00
William Leeson fe548c872d Merge branch 'upstream_main' into geometry_update 2023-04-12 10:14:26 +02:00
William Leeson bb2e9cc75f FIX: Size needs to be explicit as default params have been removed. 2023-04-11 18:49:54 +02:00
William Leeson 66a6a7a0af Clean up code
1. remove camelCase method names.
2. fix up white space changes.
3. remove some unnecessary changes.
2023-04-11 16:56:36 +02:00
William Leeson cddd2bfdf0 Replae upload and building times arrays with a vector struct
Arrays of dougle values are replaced by a vector<> of a struct
scene_times.
2023-04-11 14:55:08 +02:00
William Leeson 506106b3a8 Remove custom spin lock and replace with that from utils/thread.h 2023-04-11 14:38:36 +02:00
William Leeson 06b43213b7 Don't use background to disable progress update. 2023-04-11 14:37:57 +02:00
William Leeson 6e904ef6b2 Rename progressErrorCheck check_cancel_update 2023-04-11 13:52:22 +02:00
William Leeson 8731ee9761 Change swop to swap. 2023-04-11 13:51:56 +02:00
William Leeson 511d878921 Use unique_ptr to handle the SubDevice and Device pointers 2023-04-11 13:41:45 +02:00
William Leeson 32c44f9f43 Remove only grow memory allocation. 2023-04-11 11:42:44 +02:00
William Leeson 0f1e29912c Remove unused constructor 2023-04-11 11:20:56 +02:00
William Leeson bd08b280a4 Replace include with forward declaration of DeviceScene. 2023-04-11 10:50:15 +02:00
William Leeson e3068b23b7 Remove only allocating memory if it needs to be enlarged. 2023-04-11 10:49:46 +02:00
William Leeson 3c81e479a6 Switch off using pinned memory on CUDA devices
Pinned memory was used for all device_memory. However, due to
that it may cause memory pressure this was removed and can be
enabled by passing USE_DEVICE_PINNED_MEMORY.
2023-04-11 09:38:26 +02:00
William Leeson 674721194e FIX: Adds case where no CPU is selected in MultiDevice
Forgot to push the code which skips swopping if the is no CPU in
the MultiDevice set.
2023-04-11 09:36:58 +02:00
William Leeson ac67371fa4 Makes sure the CPU is the last device just once at the end.
Previously after every device was added the CPU device was swopped
to the end of the list. Now the position it was added at is saved
and it is swopped with the last device at the end.
2023-04-10 19:37:48 +02:00
William Leeson 57d7deec2a Merge branch 'geometry_update' into geometry_update_refactor 2023-04-10 17:36:01 +02:00
William Leeson 3186d8d725 Merge branch 'upstream_main' into geometry_update 2023-04-10 17:11:55 +02:00
William Leeson 9b3b180d23 FIX: Enable OneAPI build and fix compile issues
Needed to add the memory copy methods the have offset and size.
2023-04-06 17:51:22 +02:00
William Leeson 5409cc2011 Refactor memory copy methods to remove duplication 2023-04-06 16:47:28 +02:00
William Leeson a27247e28f Refactor geometry.cpp and geometry_additions.cpp
This breaks up the geometry.cpp and geometry_additions.cpp into
the following files:
- geometry.cpp
- geometry_mesh.cpp
- geometry_attributes.cpp
- geometry_bvh.cpp
so as to organise the code into more manageable pieces.
2023-04-06 11:07:20 +02:00
William Leeson fc30231f88 Merge branch 'upstream_main' into geometry_update 2023-04-05 17:49:13 +02:00
William Leeson b9840e7640 Merge branch 'upstream_main' into geometry_update 2023-04-04 14:41:09 +02:00
William Leeson 04475876d3 Merge branch 'upstream_main' into geometry_update 2023-03-29 17:55:21 +02:00
William Leeson b75f6ad788 FIX: Make sure top level BVH is built after all other BVHs
The top level BVH can only be built once all the other (bottom
level) BVHs are completed.
2023-03-29 10:09:35 +02:00
William Leeson d59a30b4a0 FIX: Lock mutex before using condition variable waiting on BVH build
Mutex needs to be locked before using the condition variable can
be used. This adds a scoped lock to ensure it is locked before
waiting on the condition_variable.
2023-03-28 14:52:12 +02:00
William Leeson b0345701a0 FIX:Use the headless flag to switch on/off progress updates
Don't do progress updates when in headless mode. Previously
the background flag was used but this is also used for F12 render.
Which needs the updates.
2023-03-28 14:43:17 +02:00
William Leeson 3a566ccee4 FIX: Using the Optix BVH for the NVidia device
Optix device was using the multi-bvh as the Optix BVH which was
causing the device to have the wrong handles for the objects.
2023-03-28 13:23:31 +02:00
William Leeson c952e5d159 FIX: Fix memory leak when using more than 1 device
The mult-device set the device pointer for the device_memory as it
iterated through the devices. However, it did not restore the
original pointer to the device if the device_ptr (pointer to the
memory buffer) was 0 which it always is after a mem_free.
2023-03-28 10:19:04 +02:00
William Leeson 92a3b720bf Merge branch 'upstream_main' into geometry_update 2023-03-28 10:04:10 +02:00
William Leeson 9f149ee682 Merge branch 'upstream_main' into geometry_update 2023-03-28 08:51:24 +02:00
William Leeson 6618d31e12 Merge branch 'upstream_main' into geometry_update 2023-03-24 12:07:26 +01:00
William Leeson 6e0875b729 Only build a BVH2 BVH once
Basically checks if the BVH2 BVH has been built or is being built.
Then when building the top level BVH2 BVH all devices that use it
wait for the one that is building it to finish before continuing.
2023-03-23 16:00:32 +01:00
William Leeson 6795ee2f71 Only wait on condition_variable if mutex is locked. 2023-03-22 12:34:21 +01:00
William Leeson 4e1469b8bb Only build the BVH2 BVH once
Ensures that only 1 BVH2 BVH is built for each object or scene.
This is done using lock to aquire the BVH2 and other threads
can skip the building if it is for an object. However, for the
top level BVH all threads wait on the TLAS to be finished.
2023-03-22 11:15:24 +01:00
William Leeson 01e96490f1 Change params for host_mem_alloc to host_mem_alloc(size_t size, int aligment)
The parameters for host_mem_alloc were changed to
`host_mem_alloc(size_t size, int aligment) from
host_mem_alloc(size_t size, int aligment, void **p_mem)
2023-03-22 09:28:28 +01:00
William Leeson 7bf80f2b77 Clean up code and simplify
1. Switch to use auto for DeviceScene
2. use parallel_for instead of tbb::parallel_for
3. rename n_scenes num_scenes
2023-03-21 15:56:17 +01:00
William Leeson fcb3bd5854 Adds comment to describe the find_matching_mem method 2023-03-21 15:54:22 +01:00
William Leeson 042bf24409 Remove cuew changes. 2023-03-21 15:53:22 +01:00
William Leeson ccf7384458 Merge branch 'upstream_main' into geometry_update 2023-03-21 10:26:44 +01:00
William Leeson ef84fe9e5d Merge branch 'upstream_main' into geometry_update
buildbot/vexp-code-patch-coordinator Build done. Details
2023-03-20 12:41:36 +01:00
William Leeson 717b7a9b6f Remove profiling interval markers from geometry update 2023-03-17 16:01:14 +01:00
William Leeson 0bd30b175a Merge branch 'upstream_main' into geometry_update 2023-03-17 12:35:40 +01:00
William Leeson a875bc9e45 Remove comments from cuew 2023-03-16 15:59:16 +01:00
William Leeson b5e12fa1cc Remove some more comments 2023-03-16 15:55:56 +01:00
William Leeson 20bd8ad907 Merge branch 'upstream_main' into geometry_update 2023-03-16 09:16:19 +01:00
William Leeson 74a7a2df77 Merge branch 'upstream_main' into geometry_update 2023-03-15 13:01:57 +01:00
William Leeson 3fb101d2ba Clean up code comments 2023-03-14 16:24:32 +01:00
William Leeson 532479e569 Move BVH2 device data update inside parallel_for 2023-03-14 15:01:04 +01:00
William Leeson 665a0e84b2 Move scne BVH upload into deviceDataXferAndBVHUpdate
To simplify the code and make it easier to read this moves the
scene BVH upload into the deviceDataXferAndBVHUpdate method.
2023-03-14 13:30:43 +01:00
William Leeson cba4d732e2 Remove stats params from deviceDataXferAndBVHUpdate
The stats parameters are now contained in the Scene class and
no longer need to be passed as a parameter.
2023-03-14 12:57:20 +01:00
William Leeson 5c56f518eb FIX: Preallocate timer arrays in scene
The Windows build failed as the timers were using
a dynamic array. This has been changed to use an
heap array which is allocated with the scene
instead.
2023-03-14 12:20:38 +01:00
William Leeson 2183d70e9d Move scene BVH update into parallel_for
The scen BVH update was outside the parallel for this moves it
inside the parallel_for so it can be performed in parallel also.
2023-03-14 12:00:33 +01:00
William Leeson 59ddc1be9e Merge branch 'upstream_main' into geometry_update 2023-03-14 09:53:22 +01:00
William Leeson 8f0b239036 Merge branch 'upstream_main' into geometry_update 2023-03-10 12:13:59 +01:00
William Leeson 858195e683 Merge branch 'upstream_main' into geometry_update 2023-03-08 13:34:39 +01:00
William Leeson fdd1c856e4 Add file that was forgotten 2023-03-07 09:05:23 +01:00
William Leeson 0f5e6ed93e Refactor geometry update allow for easier parallel updates 2023-03-03 14:59:10 +01:00
William Leeson e45b7f3a00 Merge branch 'upstream_main' into progress_update 2023-03-03 10:02:38 +01:00
William Leeson 72b918a9e2 Adds scoped event markers
Add scoped event markers to highlight code regions of interest.
2023-03-03 09:34:57 +01:00
William Leeson bbce8a0aae Add macro to switch from std::mutex to SpinLock
Simplified the code to be more similar to the original by
implementing it as a spin lock. Then added a macro to be able to
switch back and forth between std::mutex and the SpinLock.
2023-03-03 08:55:29 +01:00
William Leeson a5efd8b582 Update the update lock with a lockless update 2023-03-01 14:10:32 +01:00
William Leeson 31bda3d613 Create function to update progress values locklessly 2023-03-01 13:44:14 +01:00
William Leeson 598c7c151d Remove some locks from progress update
Removes mutex locks when updating pixel counts etc. Also, when
in background mode text status updates are removed.
2023-03-01 09:32:37 +01:00