Blender  V3.3
hip/device_impl.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifdef WITH_HIP
5 
6 # include "device/device.h"
7 # include "device/hip/kernel.h"
8 # include "device/hip/queue.h"
9 # include "device/hip/util.h"
10 
11 # include "util/map.h"
12 
13 # ifdef WITH_HIP_DYNLOAD
14 # include "hipew.h"
15 # endif
16 
18 
19 class DeviceQueue;
20 
21 class HIPDevice : public Device {
22 
23  friend class HIPContextScope;
24 
25  public:
26  hipDevice_t hipDevice;
27  hipCtx_t hipContext;
28  hipModule_t hipModule;
29  size_t device_texture_headroom;
30  size_t device_working_headroom;
31  bool move_texture_to_host;
32  size_t map_host_used;
33  size_t map_host_limit;
34  int can_map_host;
35  int pitch_alignment;
36  int hipDevId;
37  int hipDevArchitecture;
38  int hipRuntimeVersion;
39  bool first_error;
40 
41  struct HIPMem {
42  HIPMem() : texobject(0), array(0), use_mapped_host(false)
43  {
44  }
45 
46  hipTextureObject_t texobject;
47  hArray array;
48 
49  /* If true, a mapped host memory in shared_pointer is being used. */
50  bool use_mapped_host;
51  };
52  typedef map<device_memory *, HIPMem> HIPMemMap;
53  HIPMemMap hip_mem_map;
54  thread_mutex hip_mem_map_mutex;
55 
56  /* Bindless Textures */
57  device_vector<TextureInfo> texture_info;
58  bool need_texture_info;
59 
60  HIPDeviceKernels kernels;
61 
62  static bool have_precompiled_kernels();
63 
64  virtual BVHLayoutMask get_bvh_layout_mask() const override;
65 
66  void set_error(const string &error) override;
67 
68  HIPDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler);
69 
70  virtual ~HIPDevice();
71 
72  bool support_device(const uint /*kernel_features*/);
73 
74  bool check_peer_access(Device *peer_device) override;
75 
76  bool use_adaptive_compilation();
77 
78  virtual string compile_kernel_get_common_cflags(const uint kernel_features);
79 
80  string compile_kernel(const uint kernel_features, const char *name, const char *base = "hip");
81 
82  virtual bool load_kernels(const uint kernel_features) override;
83  void reserve_local_memory(const uint kernel_features);
84 
85  void init_host_memory();
86 
87  void load_texture_info();
88 
89  void move_textures_to_host(size_t size, bool for_texture);
90 
91  HIPMem *generic_alloc(device_memory &mem, size_t pitch_padding = 0);
92 
93  void generic_copy_to(device_memory &mem);
94 
95  void generic_free(device_memory &mem);
96 
97  void mem_alloc(device_memory &mem) override;
98 
99  void mem_copy_to(device_memory &mem) override;
100 
101  void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
102 
103  void mem_zero(device_memory &mem) override;
104 
105  void mem_free(device_memory &mem) override;
106 
107  device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
108 
109  virtual void const_copy_to(const char *name, void *host, size_t size) override;
110 
111  void global_alloc(device_memory &mem);
112 
113  void global_free(device_memory &mem);
114 
115  void tex_alloc(device_texture &mem);
116 
117  void tex_free(device_texture &mem);
118 
119  /* Graphics resources interoperability. */
120  virtual bool should_use_graphics_interop() override;
121 
122  virtual unique_ptr<DeviceQueue> gpu_queue_create() override;
123 
124  int get_num_multiprocessors();
125  int get_max_num_threads_per_multiprocessor();
126 
127  protected:
128  bool get_device_attribute(hipDeviceAttribute_t attribute, int *value);
129  int get_device_default_attribute(hipDeviceAttribute_t attribute, int default_value);
130  hipMemoryType get_memory_type(hipMemoryType mem_type);
131 };
132 
134 
135 #endif
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
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 Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise 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 BVHLayoutMask get_bvh_layout_mask() const =0
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 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
Definition: cuda/compat.h:9
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static void error(const char *str)
Definition: meshlaplacian.c:51
int BVHLayoutMask
Definition: params.h:47
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex
Definition: thread.h:27
uint64_t device_ptr
Definition: util/types.h:43