Blender V4.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# include "util/map.h"
15
16# ifdef WITH_HIP_DYNLOAD
17# include "hipew.h"
18# endif
19
21
22class DeviceQueue;
23
24class HIPDevice : public GPUDevice {
25
26 friend class HIPContextScope;
27
28 public:
29 hipDevice_t hipDevice;
30 hipCtx_t hipContext;
31 hipModule_t hipModule;
32 int pitch_alignment;
33 int hipDevId;
34 int hipDevArchitecture;
35 int hipRuntimeVersion;
36 bool first_error;
37
38 HIPDeviceKernels kernels;
39
40 static bool have_precompiled_kernels();
41
42 virtual BVHLayoutMask get_bvh_layout_mask(uint /*kernel_features*/) const override;
43
44 void set_error(const string &error) override;
45
46 HIPDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless);
47
48 virtual ~HIPDevice();
49
50 bool support_device(const uint /*kernel_features*/);
51
52 bool check_peer_access(Device *peer_device) override;
53
54 bool use_adaptive_compilation();
55
56 virtual string compile_kernel_get_common_cflags(const uint kernel_features);
57
58 virtual string compile_kernel(const uint kernel_features,
59 const char *name,
60 const char *base = "hip");
61
62 virtual bool load_kernels(const uint kernel_features) override;
63 void reserve_local_memory(const uint kernel_features);
64
65 virtual void get_device_memory_info(size_t &total, size_t &free) override;
66 virtual bool alloc_device(void *&device_pointer, size_t size) override;
67 virtual void free_device(void *device_pointer) override;
68 virtual bool alloc_host(void *&shared_pointer, size_t size) override;
69 virtual void free_host(void *shared_pointer) override;
70 virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer) override;
71 virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) override;
72
73 void mem_alloc(device_memory &mem) override;
74
75 void mem_copy_to(device_memory &mem) override;
76
77 void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
78
79 void mem_zero(device_memory &mem) override;
80
81 void mem_free(device_memory &mem) override;
82
83 device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
84
85 virtual void const_copy_to(const char *name, void *host, size_t size) override;
86
87 void global_alloc(device_memory &mem);
88
89 void global_free(device_memory &mem);
90
91 void tex_alloc(device_texture &mem);
92
93 void tex_free(device_texture &mem);
94
95 /* Graphics resources interoperability. */
96 virtual bool should_use_graphics_interop() override;
97
98 virtual unique_ptr<DeviceQueue> gpu_queue_create() override;
99
100 int get_num_multiprocessors();
101 int get_max_num_threads_per_multiprocessor();
102
103 protected:
104 bool get_device_attribute(hipDeviceAttribute_t attribute, int *value);
105 int get_device_default_attribute(hipDeviceAttribute_t attribute, int default_value);
106 hipMemoryType get_memory_type(hipMemoryType mem_type);
107};
108
110
111#endif
void BLI_kdtree_nd_ free(KDTree *tree)
unsigned int uint
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
virtual void const_copy_to(const char *name, void *host, size_t size)=0
virtual void mem_zero(device_memory &mem)=0
virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)=0
virtual unique_ptr< DeviceQueue > gpu_queue_create()
virtual bool load_kernels(uint)
virtual bool check_peer_access(Device *)
virtual void mem_free(device_memory &mem)=0
virtual BVHLayoutMask get_bvh_layout_mask(uint kernel_features) const =0
virtual void set_error(const string &error)
virtual void mem_copy_to(device_memory &mem)=0
virtual device_ptr mem_alloc_sub_ptr(device_memory &, size_t, size_t)
virtual void mem_alloc(device_memory &mem)=0
virtual bool should_use_graphics_interop()
#define CCL_NAMESPACE_END
static void error(const char *str)
int BVHLayoutMask
Definition params.h:51
virtual void get_device_memory_info(size_t &total, size_t &free)=0
virtual bool alloc_host(void *&shared_pointer, size_t size)=0
virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer)=0
virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size)=0
virtual void free_host(void *shared_pointer)=0
virtual void free_device(void *device_pointer)=0
virtual bool alloc_device(void *&device_pointer, size_t size)=0
uint64_t device_ptr
Definition util/types.h:45