Blender V5.3
hip/device_impl.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#ifdef WITH_HIP
8
9# include "device/device.h"
10# include "device/hip/kernel.h"
11# include "device/hip/queue.h"
12# include "device/hip/util.h"
13
14# ifdef WITH_HIP_DYNLOAD
15# include "hipew.h"
16# endif
17
19
20class DeviceQueue;
21
22class HIPDevice : public GPUDevice {
23
24 friend class HIPContextScope;
25
26 public:
27 hipDevice_t hipDevice;
28 hipCtx_t hipContext;
29 hipModule_t hipModule;
30 int pitch_alignment;
31 int hipDevId;
32 int hipDevArchitecture;
33 int hipRuntimeVersion;
34 bool first_error;
35
36 HIPDeviceKernels kernels;
37
38 static bool have_precompiled_kernels();
39
40 BVHLayoutMask get_bvh_layout_mask(uint64_t kernel_features) const override;
41
42 void set_error(const string &error) override;
43
44 HIPDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless);
45
46 ~HIPDevice() override;
47
48 bool support_device(const uint64_t /*kernel_features*/);
49
50 bool check_peer_access(Device *peer_device) override;
51
52 bool use_adaptive_compilation();
53
54 string compile_kernel_get_common_cflags(uint64_t kernel_features);
55
56 string compile_kernel(uint64_t kernel_features, const char *name, const char *base = "hip");
57
58 bool load_kernels(uint64_t kernel_features) override;
59 void reserve_local_memory(uint64_t kernel_features);
60
61 /* All memory types. */
62 void mem_alloc(device_memory &mem) override;
63 void mem_copy_to(device_memory &mem) override;
64 void mem_move_to_host(device_memory &mem) override;
65 void mem_copy_from(
66 device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
67 void mem_zero(device_memory &mem) override;
68 void mem_free(device_memory &mem) override;
69
70 device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
71
72 /* Global memory. */
73 void global_alloc(device_memory &mem);
74 void global_copy_to(device_memory &mem);
75 void global_free(device_memory &mem);
76
77 /* Image memory. */
78 void image_alloc(device_image &mem);
79 void image_copy_to(device_image &mem);
80 void image_free(device_image &mem);
81
82 /* Device side memory. */
83 void get_device_memory_info(size_t &total, size_t &free) override;
84 bool alloc_device(void *&device_pointer, const size_t size) override;
85 void free_device(void *device_pointer) override;
86
87 /* Shared memory. */
88 bool shared_alloc(void *&shared_pointer, const size_t size) override;
89 void shared_free(void *shared_pointer, const size_t size) override;
90 void *shared_to_device_pointer(const void *shared_pointer) override;
91
92 /* Memory copy. */
93 void copy_host_to_device(void *device_pointer, void *host_pointer, const size_t size) override;
94 void const_copy_to(const char *name, void *host, const size_t size) override;
95
96 /* Graphics resources interoperability. */
97 bool should_use_graphics_interop(const GraphicsInteropDevice &interop_device,
98 const bool log) override;
99
100 unique_ptr<DeviceQueue> gpu_queue_create() override;
101
102 int get_num_multiprocessors();
103 int get_max_num_threads_per_multiprocessor();
104
105 protected:
106 bool get_device_attribute(hipDeviceAttribute_t attribute, int *value);
107 int get_device_default_attribute(hipDeviceAttribute_t attribute, const int default_value);
108};
109
111
112#endif
unsigned long long int uint64_t
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
#define CCL_NAMESPACE_END
#define attribute(slot)
#define log
int BVHLayoutMask
Definition params.h:50
uint64_t device_ptr
Definition types_base.h:44