Blender  V3.3
cpu/compat.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
6 /* Release kernel has too much false-positive maybe-uninitialized warnings,
7  * which makes it possible to miss actual warnings.
8  */
9 #if (defined(__GNUC__) && !defined(__clang__)) && defined(NDEBUG)
10 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
11 # pragma GCC diagnostic ignored "-Wuninitialized"
12 #endif
13 
14 #include "util/half.h"
15 #include "util/math.h"
16 #include "util/simd.h"
17 #include "util/texture.h"
18 #include "util/types.h"
19 
20 /* On x86_64, versions of glibc < 2.16 have an issue where expf is
21  * much slower than the double version. This was fixed in glibc 2.16.
22  */
23 #if !defined(__KERNEL_GPU__) && defined(__x86_64__) && defined(__x86_64__) && \
24  defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
25  (__GLIBC__ <= 2 && __GLIBC_MINOR__ < 16)
26 # define expf(x) ((float)exp((double)(x)))
27 #endif
28 
30 
31 /* Assertions inside the kernel only work for the CPU device, so we wrap it in
32  * a macro which is empty for other devices */
33 
34 #define kernel_assert(cond) assert(cond)
35 
36 /* Macros to handle different memory storage on different devices */
37 
38 #ifdef __KERNEL_SSE2__
39 typedef vector3<sseb> sse3b;
40 typedef vector3<ssef> sse3f;
41 typedef vector3<ssei> sse3i;
42 
43 ccl_device_inline void print_sse3b(const char *label, sse3b &a)
44 {
45  print_sseb(label, a.x);
46  print_sseb(label, a.y);
47  print_sseb(label, a.z);
48 }
49 
50 ccl_device_inline void print_sse3f(const char *label, sse3f &a)
51 {
52  print_ssef(label, a.x);
53  print_ssef(label, a.y);
54  print_ssef(label, a.z);
55 }
56 
57 ccl_device_inline void print_sse3i(const char *label, sse3i &a)
58 {
59  print_ssei(label, a.x);
60  print_ssei(label, a.y);
61  print_ssei(label, a.z);
62 }
63 
64 # if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__)
65 typedef vector3<avxf> avx3f;
66 # endif
67 
68 #endif
69 
#define ccl_device_inline
Definition: cuda/compat.h:34
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
const char * label
static unsigned a[3]
Definition: RandGen.cpp:78