Blender V4.3
device/hip/compat.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#define __KERNEL_GPU__
8#define __KERNEL_HIP__
9#define CCL_NAMESPACE_BEGIN
10#define CCL_NAMESPACE_END
11
12#ifndef ATTR_FALLTHROUGH
13# define ATTR_FALLTHROUGH
14#endif
15
16#ifdef __HIPCC_RTC__
17typedef unsigned int uint32_t;
18typedef unsigned long long uint64_t;
19#else
20# include <stdint.h>
21#endif
22
23#ifdef CYCLES_HIPBIN_CC
24# define FLT_MIN 1.175494350822287507969e-38f
25# define FLT_MAX 340282346638528859811704183484516925440.0f
26# define FLT_EPSILON 1.192092896e-07F
27#endif
28
29/* Qualifiers */
30
31#define ccl_device __device__ __inline__
32#define ccl_device_extern extern "C" __device__
33#define ccl_device_inline __device__ __inline__
34#define ccl_device_forceinline __device__ __forceinline__
35#define ccl_device_noinline __device__ __noinline__
36#define ccl_device_noinline_cpu ccl_device
37#define ccl_device_inline_method ccl_device
38#define ccl_global
39#define ccl_inline_constant __constant__
40#define ccl_device_constant __constant__ __device__
41#define ccl_static_constexpr static constexpr
42#define ccl_constant const
43#define ccl_gpu_shared __shared__
44#define ccl_private
45#define ccl_ray_data ccl_private
46#define ccl_may_alias
47#define ccl_restrict __restrict__
48#define ccl_loop_no_unroll
49#define ccl_align(n) __align__(n)
50#define ccl_optional_struct_init
51
52#define kernel_assert(cond)
53
54/* Types */
55#ifdef __HIP__
56# include "hip/hip_fp16.h"
57# include "hip/hip_runtime.h"
58#endif
59
60#ifdef _MSC_VER
61# include <immintrin.h>
62#endif
63
64#define ccl_gpu_thread_idx_x (threadIdx.x)
65#define ccl_gpu_block_dim_x (blockDim.x)
66#define ccl_gpu_block_idx_x (blockIdx.x)
67#define ccl_gpu_grid_dim_x (gridDim.x)
68#define ccl_gpu_warp_size (warpSize)
69#define ccl_gpu_thread_mask(thread_warp) uint64_t((1ull << thread_warp) - 1)
70
71#define ccl_gpu_global_id_x() (ccl_gpu_block_idx_x * ccl_gpu_block_dim_x + ccl_gpu_thread_idx_x)
72#define ccl_gpu_global_size_x() (ccl_gpu_grid_dim_x * ccl_gpu_block_dim_x)
73
74/* GPU warp synchronization */
75
76#define ccl_gpu_syncthreads() __syncthreads()
77#define ccl_gpu_ballot(predicate) __ballot(predicate)
78
79/* GPU texture objects */
80typedef hipTextureObject_t ccl_gpu_tex_object_2D;
81typedef hipTextureObject_t ccl_gpu_tex_object_3D;
82
83template<typename T>
85 const float x,
86 const float y)
87{
88 return tex2D<T>(texobj, x, y);
89}
90
91template<typename T>
93 const float x,
94 const float y,
95 const float z)
96{
97 return tex3D<T>(texobj, x, y, z);
98}
99
100/* Use fast math functions */
101
102#define cosf(x) __cosf(((float)(x)))
103#define sinf(x) __sinf(((float)(x)))
104#define powf(x, y) __powf(((float)(x)), ((float)(y)))
105#define tanf(x) __tanf(((float)(x)))
106#define logf(x) __logf(((float)(x)))
107#define expf(x) __expf(((float)(x)))
108
109/* Types */
110
111#include "util/half.h"
112#include "util/types.h"
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
CUtexObject ccl_gpu_tex_object_3D
CUtexObject ccl_gpu_tex_object_2D
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj, const float x, const float y)
#define ccl_device_forceinline
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj, const float x, const float y, const float z)
hipTextureObject_t ccl_gpu_tex_object_3D
hipTextureObject_t ccl_gpu_tex_object_2D
unsigned int uint32_t
Definition stdint.h:80
unsigned __int64 uint64_t
Definition stdint.h:90