Blender V5.3
device/multi/device.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
6#include "device/device.h"
7#include "device/queue.h"
8
9#include <atomic>
10#include <cstdlib>
11#include <functional>
12#include <shared_mutex>
13#include <span>
14
15#include "bvh/multi.h"
16
17#include "scene/geometry.h"
18
19#include "util/list.h"
20#include "util/map.h"
21#include "util/types_image.h"
22
24
25class MultiDevice : public Device {
26 public:
27 struct SubDevice {
30 map<device_ptr, device_ptr> ptr_map;
32 };
33 using Island = std::span<SubDevice *const>;
34
35 list<SubDevice> devices;
36 std::atomic<device_ptr> unique_key = 1;
38
39 /* Different memory might be allocated/freed in different threads across
40 * multiple devices, so the ptr_map needs to be mutex protected. */
41 mutable std::shared_mutex ptr_map_mutex;
42
43 device_ptr ptr_map_find(const SubDevice &sub, const device_ptr key) const
44 {
45 const std::shared_lock lock(ptr_map_mutex);
46 auto it = sub.ptr_map.find(key);
47 return (it != sub.ptr_map.end()) ? it->second : device_ptr(0);
48 }
49
50 bool ptr_map_contains(const SubDevice &sub, const device_ptr key) const
51 {
52 const std::shared_lock lock(ptr_map_mutex);
53 return sub.ptr_map.contains(key);
54 }
55
56 void ptr_map_set(SubDevice &sub, const device_ptr key, const device_ptr ptr)
57 {
58 const std::unique_lock lock(ptr_map_mutex);
59 sub.ptr_map[key] = ptr;
60 }
61
62 void ptr_map_erase(SubDevice &sub, const device_ptr key)
63 {
64 const std::unique_lock lock(ptr_map_mutex);
65 sub.ptr_map.erase(key);
66 }
67
69 : Device(info_, stats, profiler, headless)
70 {
72
73 for (const DeviceInfo &subinfo : this->info.multi_devices) {
74 /* Always add CPU devices at the back since GPU devices can change
75 * host memory pointers, which CPU uses as device pointer. */
76 SubDevice *sub;
77 if (subinfo.type == DEVICE_CPU) {
78 devices.emplace_back();
79 sub = &devices.back();
80 }
81 else {
82 devices.emplace_front();
83 sub = &devices.front();
84 }
85
86 /* The pointer to 'sub->stats' will stay valid even after new devices
87 * are added, since 'devices' is a linked list. */
88 sub->device = Device::create(subinfo, sub->stats, profiler, headless);
89 }
90
91 /* Build a list of peer islands for the available render devices */
92 for (SubDevice &sub : devices) {
93 /* First ensure that every device is in at least once peer island */
94 if (sub.peer_island_index < 0) {
95 peer_islands.emplace_back();
96 sub.peer_island_index = (int)peer_islands.size() - 1;
97 peer_islands[sub.peer_island_index].push_back(&sub);
98 }
99
100 if (!info.has_peer_memory) {
101 continue;
102 }
103
104 /* Second check peer access between devices and fill up the islands accordingly */
105 for (SubDevice &peer_sub : devices) {
106 if (peer_sub.peer_island_index < 0 &&
107 peer_sub.device->info.type == sub.device->info.type &&
108 peer_sub.device->check_peer_access(sub.device.get()))
109 {
110 peer_sub.peer_island_index = sub.peer_island_index;
111 peer_islands[sub.peer_island_index].push_back(&peer_sub);
112 }
113 }
114 }
115 }
116
118 {
119 /* Determine if we can use hardware ray-tracing. It is only supported if all selected
120 * GPU devices support it. Both the backends and scene update code do not support mixed
121 * BVH2 and hardware raytracing. The CPU device will ignore this setting. */
122 bool have_disabled_hardware_rt = false;
123 bool have_enabled_hardware_rt = false;
124
125 for (const DeviceInfo &subinfo : info.multi_devices) {
126 if (subinfo.type != DEVICE_CPU) {
127 if (subinfo.use_hardware_raytracing) {
128 have_enabled_hardware_rt = true;
129 }
130 else {
131 have_disabled_hardware_rt = true;
132 }
133 }
134 }
135
136 info.use_hardware_raytracing = have_enabled_hardware_rt && !have_disabled_hardware_rt;
137
138 for (DeviceInfo &subinfo : info.multi_devices) {
139 if (subinfo.type != DEVICE_CPU) {
141 }
142 }
143 }
144
145 const string &error_message() override
146 {
147 error_msg.clear();
148
149 for (SubDevice &sub : devices) {
150 error_msg += sub.device->error_message();
151 }
152
153 return error_msg;
154 }
155
156 BVHLayoutMask get_bvh_layout_mask(const uint64_t kernel_features) const override
157 {
158 BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL;
159 BVHLayoutMask bvh_layout_mask_all = BVH_LAYOUT_NONE;
160 for (const SubDevice &sub_device : devices) {
161 BVHLayoutMask device_bvh_layout_mask = sub_device.device->get_bvh_layout_mask(
162 kernel_features);
163 bvh_layout_mask &= device_bvh_layout_mask;
164 bvh_layout_mask_all |= device_bvh_layout_mask;
165 }
166
167 /* With multiple OptiX devices, every device needs its own acceleration structure */
168 if (bvh_layout_mask == BVH_LAYOUT_OPTIX) {
170 }
171
172 /* With multiple Metal devices, every device needs its own acceleration structure */
173 if (bvh_layout_mask == BVH_LAYOUT_METAL) {
175 }
176
177 if (bvh_layout_mask == BVH_LAYOUT_HIPRT) {
179 }
180
181 /* With multiple oneAPI devices, every device needs its own acceleration structure */
182 if (bvh_layout_mask == BVH_LAYOUT_EMBREEGPU) {
184 }
185
186 /* When devices do not share a common BVH layout, fall back to creating one for each */
187 const BVHLayoutMask BVH_LAYOUT_OPTIX_EMBREE = (BVH_LAYOUT_OPTIX | BVH_LAYOUT_EMBREE);
188 if ((bvh_layout_mask_all & BVH_LAYOUT_OPTIX_EMBREE) == BVH_LAYOUT_OPTIX_EMBREE) {
190 }
191 const BVHLayoutMask BVH_LAYOUT_METAL_EMBREE = (BVH_LAYOUT_METAL | BVH_LAYOUT_EMBREE);
192 if ((bvh_layout_mask_all & BVH_LAYOUT_METAL_EMBREE) == BVH_LAYOUT_METAL_EMBREE) {
194 }
195 const BVHLayoutMask BVH_LAYOUT_EMBREEGPU_EMBREE = (BVH_LAYOUT_EMBREEGPU | BVH_LAYOUT_EMBREE);
196 if ((bvh_layout_mask_all & BVH_LAYOUT_EMBREEGPU_EMBREE) == BVH_LAYOUT_EMBREEGPU_EMBREE) {
198 }
199
200 const BVHLayoutMask BVH_LAYOUT_HIPRT_EMBREE = (BVH_LAYOUT_HIPRT | BVH_LAYOUT_EMBREE);
201 if ((bvh_layout_mask_all & BVH_LAYOUT_HIPRT_EMBREE) == BVH_LAYOUT_HIPRT_EMBREE) {
203 }
204
205 return bvh_layout_mask;
206 }
207
208 bool load_kernels(const uint64_t kernel_features) override
209 {
210 for (SubDevice &sub : devices) {
211 if (!sub.device->load_kernels(kernel_features)) {
212 return false;
213 }
214 }
215
216 return true;
217 }
218
219 bool load_osl_kernels() override
220 {
221 for (SubDevice &sub : devices) {
222 if (!sub.device->load_osl_kernels()) {
223 return false;
224 }
225 }
226
227 return true;
228 }
229
230 void build_bvh(BVH *bvh, Progress &progress, bool refit) override
231 {
232 /* Try to build and share a single acceleration structure, if possible */
234 devices.back().device->build_bvh(bvh, progress, refit);
235 return;
236 }
237
246
247 BVHMulti *const bvh_multi = static_cast<BVHMulti *>(bvh);
248 bvh_multi->sub_bvhs.resize(devices.size());
249
250 /* Temporarily move ownership of BVH on geometry to this vector, to swap
251 * it for each sub device. Need to find a better way to handle this. */
252 vector<unique_ptr<BVH>> geom_bvhs;
253 geom_bvhs.reserve(bvh->geometry.size());
254 for (Geometry *geom : bvh->geometry) {
255 geom_bvhs.push_back(std::move(geom->bvh));
256 }
257
258 /* Broadcast acceleration structure build to all render devices */
259 size_t i = 0;
260 for (SubDevice &sub : devices) {
261 /* Change geometry BVH pointers to the sub BVH */
262 for (size_t k = 0; k < bvh->geometry.size(); ++k) {
263 bvh->geometry[k]->bvh.release(); // NOLINT: was not actually the owner
264 bvh->geometry[k]->bvh.reset(
265 static_cast<BVHMulti *>(geom_bvhs[k].get())->sub_bvhs[i].get());
266 }
267
268 if (!bvh_multi->sub_bvhs[i]) {
269 BVHParams params = bvh->params;
272 }
273 else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) {
275 }
276 else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_HIPRT) {
278 }
281 }
283 params.bvh_layout = sub.device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX :
285 }
287 params.bvh_layout = sub.device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL :
289 }
291 params.bvh_layout = sub.device->info.type == DEVICE_HIP ? BVH_LAYOUT_HIPRT :
293 }
295 params.bvh_layout = sub.device->info.type == DEVICE_ONEAPI ? BVH_LAYOUT_EMBREEGPU :
297 }
298 /* Skip building a bottom level acceleration structure for non-instanced geometry on Embree
299 * (since they are put into the top level directly, see bvh_embree.cpp) */
300 if (!params.top_level && params.bvh_layout == BVH_LAYOUT_EMBREE &&
301 !bvh->geometry[0]->is_instanced())
302 {
303 i++;
304 continue;
305 }
306
307 bvh_multi->sub_bvhs[i] = BVH::create(
308 params, bvh->geometry, bvh->objects, sub.device.get());
309 }
310
311 sub.device->build_bvh(bvh_multi->sub_bvhs[i].get(), progress, refit);
312 i++;
313 }
314
315 /* Change BVH ownership back to Geometry. */
316 for (size_t k = 0; k < bvh->geometry.size(); ++k) {
317 bvh->geometry[k]->bvh.release(); // NOLINT: was not actually the owner
318 bvh->geometry[k]->bvh = std::move(geom_bvhs[k]);
319 }
320 }
321
322 OSLGlobals *get_cpu_osl_memory() override
323 {
324 /* Always return the OSL memory of the CPU device (this works since the constructor above
325 * guarantees that CPU devices are always added to the back). */
326 if (devices.size() > 1 && devices.back().device->info.type != DEVICE_CPU) {
327 return nullptr;
328 }
329 return devices.back().device->get_cpu_osl_memory();
330 }
331
332 device_ptr mem_device_ptr(const device_memory &mem, Device *sub_device) override
333 {
334 if (mem.device == sub_device) {
335 return mem.device_pointer;
336 }
337
338 device_ptr key = mem.device_pointer;
339 if (key == 0) {
340 return device_ptr(0);
341 }
342
343 for (SubDevice &sub : devices) {
344 if (sub.device.get() == sub_device) {
345 /* Memory may be owned by a peer device when distributing memory across devices. */
346 SubDevice *owner_sub = find_matching_mem_device(key, sub);
347 return ptr_map_find(*owner_sub, key);
348 }
349 }
350
351 assert(!"MultiDevice::mem_device_ptr could not find sub_device");
352 return device_ptr(0);
353 }
354
357 {
358 for (SubDevice &sub : devices) {
359 sub.device->set_image_cache_func(image_load_requested_cpu, image_load_requested_gpu);
360 }
361 }
362
363 bool is_resident(device_ptr key, Device *sub_device) override
364 {
365 for (SubDevice &sub : devices) {
366 if (sub.device.get() == sub_device) {
367 return find_matching_mem_device(key, sub)->device.get() == sub_device;
368 }
369 }
370 return false;
371 }
372
374 {
375 assert(key != 0 && (sub.peer_island_index >= 0 || ptr_map_contains(sub, key)));
376
377 /* Get the memory owner of this key (first try current device, then peer devices) */
378 SubDevice *owner_sub = &sub;
379 if (!ptr_map_contains(*owner_sub, key)) {
380 for (SubDevice *island_sub : peer_islands[sub.peer_island_index]) {
381 if (island_sub != owner_sub && ptr_map_contains(*island_sub, key)) {
382 owner_sub = island_sub;
383 }
384 }
385 }
386 return owner_sub;
387 }
388
390 {
391 assert(!island.empty());
392
393 /* Get the memory owner of this key or the device with the lowest memory usage when new */
394 SubDevice *owner_sub = island.front();
395 for (SubDevice *island_sub : island) {
396 if (key ? ptr_map_contains(*island_sub, key) :
397 (island_sub->device->stats.mem_used < owner_sub->device->stats.mem_used))
398 {
399 owner_sub = island_sub;
400 }
401 }
402 return owner_sub;
403 }
404
406 {
407 return ptr_map_find(*find_matching_mem_device(key, sub), key);
408 }
409
410 /* Islands to allocate memory in, with one allocation per island. */
412 {
413 vector<Island> islands;
414 for (const vector<SubDevice *> &peer_island : peer_islands) {
415 if (!(mem.flags & MEM_FLAG_PER_DEVICE)) {
416 islands.emplace_back(peer_island);
417 continue;
418 }
419
420 for (SubDevice *const &sub : peer_island) {
421 islands.emplace_back(&sub, 1);
422 }
423 }
424 return islands;
425 }
426
427 void *host_alloc(const MemoryType type, const size_t size) override
428 {
429 for (SubDevice &sub : devices) {
430 if (sub.device->info.type != DEVICE_CPU) {
431 return sub.device->host_alloc(type, size);
432 }
433 }
434
435 return Device::host_alloc(type, size);
436 }
437
438 void host_free(const MemoryType type, void *host_pointer, const size_t size) override
439 {
440 for (SubDevice &sub : devices) {
441 if (sub.device->info.type != DEVICE_CPU) {
442 sub.device->host_free(type, host_pointer, size);
443 return;
444 }
445 }
446
447 Device::host_free(type, host_pointer, size);
448 }
449
450 void mem_alloc(device_memory &mem) override
451 {
452 device_ptr key = unique_key++;
453
454 assert(mem.type == MEM_READ_ONLY || mem.type == MEM_READ_WRITE || mem.type == MEM_DEVICE_ONLY);
455 /* The remaining memory types can be distributed across devices */
456 for (const Island island : mem_islands(mem)) {
457 SubDevice *owner_sub = find_suitable_mem_device(key, island);
458 mem.device = owner_sub->device.get();
459 mem.device_pointer = 0;
460 mem.device_size = 0;
461
462 owner_sub->device->mem_alloc(mem);
463 ptr_map_set(*owner_sub, key, mem.device_pointer);
464 }
465
466 mem.device = this;
467 mem.device_pointer = key;
469 }
470
471 void mem_copy_to(device_memory &mem) override
472 {
473 device_ptr existing_key = mem.device_pointer;
474 device_ptr key = (existing_key) ? existing_key : unique_key++;
475 size_t existing_size = mem.device_size;
476
477 for (const Island island : mem_islands(mem)) {
478 SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
479 mem.device = owner_sub->device.get();
480 mem.device_pointer = (existing_key) ? ptr_map_find(*owner_sub, existing_key) : 0;
481 mem.device_size = existing_size;
482
483 owner_sub->device->mem_copy_to(mem);
484 ptr_map_set(*owner_sub, key, mem.device_pointer);
485
486 if (mem.type == MEM_GLOBAL || mem.type == MEM_IMAGE_TEXTURE) {
487 /* Need to create texture objects and update pointer in kernel globals on all devices */
488 for (SubDevice *island_sub : island) {
489 if (island_sub != owner_sub) {
490 island_sub->device->mem_copy_to(mem);
491 }
492 }
493 }
494 }
495
496 mem.device = this;
497 mem.device_pointer = key;
498 stats.mem_alloc(mem.device_size - existing_size);
499 }
500
501 void mem_move_to_host(device_memory &mem) override
502 {
503 assert(mem.type == MEM_GLOBAL || mem.type == MEM_IMAGE_TEXTURE);
504
505 device_ptr existing_key = mem.device_pointer;
506 device_ptr key = (existing_key) ? existing_key : unique_key++;
507 size_t existing_size = mem.device_size;
508
509 for (const Island island : mem_islands(mem)) {
510 SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
511 mem.device = owner_sub->device.get();
512 mem.device_pointer = (existing_key) ? ptr_map_find(*owner_sub, existing_key) : 0;
513 mem.device_size = existing_size;
514
515 if (!owner_sub->device->is_shared(
516 mem.shared_pointer, mem.device_pointer, owner_sub->device.get()))
517 {
518 owner_sub->device->mem_move_to_host(mem);
519 ptr_map_set(*owner_sub, key, mem.device_pointer);
520
521 /* Need to create texture objects and update pointer in kernel globals on all devices */
522 for (SubDevice *island_sub : island) {
523 if (island_sub != owner_sub) {
524 island_sub->device->mem_move_to_host(mem);
525 }
526 }
527 }
528 }
529
530 mem.device = this;
531 mem.device_pointer = key;
532 stats.mem_alloc(mem.device_size - existing_size);
533 }
534
535 bool is_shared(const void *shared_pointer, const device_ptr key, Device *sub_device) override
536 {
537 if (key == 0) {
538 return false;
539 }
540
541 for (SubDevice &sub : devices) {
542 if (sub.device.get() == sub_device) {
543 /* Memory may be owned by a peer device when distributing memory across devices. */
544 SubDevice *owner_sub = find_matching_mem_device(key, sub);
545 const device_ptr ptr = ptr_map_find(*owner_sub, key);
546 if (ptr == 0) {
547 return false;
548 }
549 return owner_sub->device->is_shared(shared_pointer, ptr, owner_sub->device.get());
550 }
551 }
552
553 assert(!"is_shared failed to find matching device");
554 return false;
555 }
556
558 {
559 device_ptr key = mem.device_pointer;
560
561 for (const Island island : mem_islands(mem)) {
562 SubDevice *owner_sub = find_matching_mem_device(key, *island.front());
563 mem.device = owner_sub->device.get();
564 mem.device_pointer = ptr_map_find(*owner_sub, key);
565 owner_sub->device->mem_or_from_device(mem);
566 }
567
568 mem.device = this;
569 mem.device_pointer = key;
570 }
571
573 device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override
574 {
575 device_ptr key = mem.device_pointer;
576 const size_t sub_h = h / devices.size();
577 size_t i = 0;
578
579 for (SubDevice &sub : devices) {
580 size_t sy = y + i * sub_h;
581 size_t sh = (i == (size_t)devices.size() - 1) ? h - sub_h * i : sub_h;
582
583 SubDevice *owner_sub = find_matching_mem_device(key, sub);
584 mem.device = owner_sub->device.get();
585 mem.device_pointer = ptr_map_find(*owner_sub, key);
586
587 owner_sub->device->mem_copy_from(mem, sy, w, sh, elem);
588 i++;
589 }
590
591 mem.device = this;
592 mem.device_pointer = key;
593 }
594
595 void mem_zero(device_memory &mem) override
596 {
597 device_ptr existing_key = mem.device_pointer;
598 device_ptr key = (existing_key) ? existing_key : unique_key++;
599 size_t existing_size = mem.device_size;
600
601 for (const Island island : mem_islands(mem)) {
602 SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
603 mem.device = owner_sub->device.get();
604 mem.device_pointer = (existing_key) ? ptr_map_find(*owner_sub, existing_key) : 0;
605 mem.device_size = existing_size;
606
607 owner_sub->device->mem_zero(mem);
608 ptr_map_set(*owner_sub, key, mem.device_pointer);
609 }
610
611 mem.device = this;
612 mem.device_pointer = key;
613 stats.mem_alloc(mem.device_size - existing_size);
614 }
615
616 void mem_free(device_memory &mem) override
617 {
618 device_ptr key = mem.device_pointer;
619 size_t existing_size = mem.device_size;
620
621 /* Free memory that was allocated for all devices (see above) on each device */
622 for (const Island island : mem_islands(mem)) {
623 SubDevice *owner_sub = find_matching_mem_device(key, *island.front());
624 mem.device = owner_sub->device.get();
625 mem.device_pointer = ptr_map_find(*owner_sub, key);
626 mem.device_size = existing_size;
627
628 owner_sub->device->mem_free(mem);
629 ptr_map_erase(*owner_sub, key);
630
631 if (mem.type == MEM_IMAGE_TEXTURE) {
632 /* Free texture objects on all devices */
633 for (SubDevice *island_sub : island) {
634 if (island_sub != owner_sub) {
635 island_sub->device->mem_free(mem);
636 }
637 }
638 }
639 }
640
641 mem.device = this;
642 mem.device_pointer = 0;
643 mem.device_size = 0;
644 stats.mem_free(existing_size);
645 }
646
647 void const_copy_to(const char *name, void *host, const size_t size) override
648 {
649 for (SubDevice &sub : devices) {
650 sub.device->const_copy_to(name, host, size);
651 }
652 }
653
654 int device_number(Device *sub_device) override
655 {
656 int i = 0;
657
658 for (SubDevice &sub : devices) {
659 if (sub.device.get() == sub_device) {
660 return i;
661 }
662 i++;
663 }
664
665 return -1;
666 }
667
668 void foreach_device(const std::function<void(Device *)> &callback) override
669 {
670 for (SubDevice &sub : devices) {
671 sub.device->foreach_device(callback);
672 }
673 }
674
675 bool has_unified_image_memory_all() const override
676 {
677 for (const SubDevice &sub : devices) {
678 if (!sub.device->has_unified_image_memory_all()) {
679 return false;
680 }
681 }
682 return true;
683 }
684};
685
687 Stats &stats,
688 Profiler &profiler,
689 bool headless)
690{
691 return make_unique<MultiDevice>(info, stats, profiler, headless);
692}
693
volatile int lock
unsigned long long int uint64_t
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
vector< unique_ptr< BVH > > sub_bvhs
Definition multi.h:17
BVHLayout bvh_layout
Definition params.h:83
bool top_level
Definition params.h:80
Definition bvh/bvh.h:67
static unique_ptr< BVH > create(const BVHParams &params, const vector< Geometry * > &geometry, const vector< Object * > &objects, Device *device)
Definition bvh.cpp:97
vector< Geometry * > geometry
Definition bvh/bvh.h:70
BVHParams params
Definition bvh/bvh.h:69
vector< Object * > objects
Definition bvh/bvh.h:71
vector< DeviceInfo > multi_devices
bool has_peer_memory
DeviceType type
bool use_hardware_raytracing
virtual void host_free(const MemoryType type, void *host_pointer, const size_t size)
Device(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool headless_)
string error_msg
void image_load_requested_gpu(DeviceQueue &queue)
friend class device_memory
Profiler & profiler
Stats & stats
bool headless
DeviceInfo info
static unique_ptr< Device > create(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless)
virtual void * host_alloc(const MemoryType type, const size_t size)
unique_ptr< BVH > bvh
void mem_or_from_device(device_memory &mem) override
bool has_unified_image_memory_all() const override
list< SubDevice > devices
std::atomic< device_ptr > unique_key
void ptr_map_erase(SubDevice &sub, const device_ptr key)
device_ptr ptr_map_find(const SubDevice &sub, const device_ptr key) const
BVHLayoutMask get_bvh_layout_mask(const uint64_t kernel_features) const override
bool is_resident(device_ptr key, Device *sub_device) override
bool load_osl_kernels() override
std::shared_mutex ptr_map_mutex
void ptr_map_set(SubDevice &sub, const device_ptr key, const device_ptr ptr)
const string & error_message() override
int device_number(Device *sub_device) override
void verify_hardware_raytracing()
void mem_copy_to(device_memory &mem) override
bool load_kernels(const uint64_t kernel_features) override
void mem_free(device_memory &mem) override
void * host_alloc(const MemoryType type, const size_t size) override
void set_image_cache_func(KernelImageLoadRequestedCPU image_load_requested_cpu, KernelImageLoadRequestedGPU image_load_requested_gpu) override
vector< vector< SubDevice * > > peer_islands
void mem_zero(device_memory &mem) override
bool is_shared(const void *shared_pointer, const device_ptr key, Device *sub_device) override
void build_bvh(BVH *bvh, Progress &progress, bool refit) override
void const_copy_to(const char *name, void *host, const size_t size) override
void foreach_device(const std::function< void(Device *)> &callback) override
bool ptr_map_contains(const SubDevice &sub, const device_ptr key) const
std::span< SubDevice *const > Island
SubDevice * find_suitable_mem_device(device_ptr key, const Island island)
void host_free(const MemoryType type, void *host_pointer, const size_t size) override
vector< Island > mem_islands(const device_memory &mem) const
MultiDevice(const DeviceInfo &info_, Stats &stats, Profiler &profiler, bool headless)
void mem_alloc(device_memory &mem) override
device_ptr mem_device_ptr(const device_memory &mem, Device *sub_device) override
void mem_copy_from(device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override
OSLGlobals * get_cpu_osl_memory() override
SubDevice * find_matching_mem_device(device_ptr key, SubDevice &sub)
void mem_move_to_host(device_memory &mem) override
device_ptr find_matching_mem(device_ptr key, SubDevice &sub)
void mem_alloc(const size_t size)
Definition util/stats.h:18
void mem_free(const size_t size)
Definition util/stats.h:24
@ MEM_FLAG_PER_DEVICE
@ MEM_IMAGE_TEXTURE
@ MEM_READ_WRITE
@ MEM_DEVICE_ONLY
@ MEM_READ_ONLY
#define CCL_NAMESPACE_END
@ DEVICE_METAL
@ DEVICE_CPU
@ DEVICE_OPTIX
@ DEVICE_HIP
@ DEVICE_ONEAPI
unique_ptr< Device > device_multi_create(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless)
#define assert(assertion)
@ BVH_LAYOUT_OPTIX
@ BVH_LAYOUT_MULTI_HIPRT_EMBREE
@ BVH_LAYOUT_NONE
@ BVH_LAYOUT_MULTI_EMBREEGPU
@ BVH_LAYOUT_METAL
@ BVH_LAYOUT_MULTI_HIPRT
@ BVH_LAYOUT_HIPRT
@ BVH_LAYOUT_EMBREE
@ BVH_LAYOUT_MULTI_OPTIX
@ BVH_LAYOUT_BVH2
@ BVH_LAYOUT_EMBREEGPU
@ BVH_LAYOUT_MULTI_METAL
@ BVH_LAYOUT_MULTI_METAL_EMBREE
@ BVH_LAYOUT_MULTI_EMBREEGPU_EMBREE
@ BVH_LAYOUT_ALL
@ BVH_LAYOUT_MULTI_OPTIX_EMBREE
int BVHLayoutMask
Definition params.h:50
unique_ptr< Device > device
map< device_ptr, device_ptr > ptr_map
uint64_t device_ptr
Definition types_base.h:44
std::function< void(size_t, int, int, int, KernelTileDescriptor &tile_descriptor)> KernelImageLoadRequestedCPU
std::function< void(DeviceQueue &)> KernelImageLoadRequestedGPU