Blender V4.3
types_float8_impl.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2017 Intel Corporation
2 * SPDX-FileCopyrightText: 2018-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 * Originally by Intel Corporation, modified by the Blender Foundation. */
7
8#pragma once
9
10#ifndef __UTIL_TYPES_H__
11# error "Do not include this file directly, include util/types.h instead."
12#endif
13
15
16#ifdef __KERNEL_AVX__
17__forceinline vfloat8::vfloat8() {}
18
19__forceinline vfloat8::vfloat8(const vfloat8 &f) : m256(f.m256) {}
20
21__forceinline vfloat8::vfloat8(const __m256 &f) : m256(f) {}
22
23__forceinline vfloat8::operator const __m256 &() const
24{
25 return m256;
26}
27
28__forceinline vfloat8::operator __m256 &()
29{
30 return m256;
31}
32
33__forceinline vfloat8 &vfloat8::operator=(const vfloat8 &f)
34{
35 m256 = f.m256;
36 return *this;
37}
38#endif /* __KERNEL_AVX__ */
39
40#ifndef __KERNEL_GPU__
41__forceinline float vfloat8::operator[](int i) const
42{
43 util_assert(i >= 0);
44 util_assert(i < 8);
45 return *(&a + i);
46}
47
48__forceinline float &vfloat8::operator[](int i)
49{
50 util_assert(i >= 0);
51 util_assert(i < 8);
52 return *(&a + i);
53}
54#endif
55
57{
58#ifdef __KERNEL_AVX__
59 vfloat8 r(_mm256_set1_ps(f));
60#else
61 vfloat8 r = {f, f, f, f, f, f, f, f};
62#endif
63 return r;
64}
65
67make_vfloat8(float a, float b, float c, float d, float e, float f, float g, float h)
68{
69#ifdef __KERNEL_AVX__
70 vfloat8 r(_mm256_setr_ps(a, b, c, d, e, f, g, h));
71#else
72 vfloat8 r = {a, b, c, d, e, f, g, h};
73#endif
74 return r;
75}
76
77ccl_device_inline vfloat8 make_vfloat8(const float4 a, const float4 b)
78{
79#ifdef __KERNEL_AVX__
80 return vfloat8(_mm256_insertf128_ps(_mm256_castps128_ps256(a), b, 1));
81#else
82 return make_vfloat8(a.x, a.y, a.z, a.w, b.x, b.y, b.z, b.w);
83#endif
84}
85
86ccl_device_inline void print_vfloat8(ccl_private const char *label, const vfloat8 a)
87{
88#ifdef __KERNEL_PRINTF__
89 printf("%s: %.8f %.8f %.8f %.8f %.8f %.8f %.8f %.8f\n",
90 label,
91 (double)a.a,
92 (double)a.b,
93 (double)a.c,
94 (double)a.d,
95 (double)a.e,
96 (double)a.f,
97 (double)a.g,
98 (double)a.h);
99#endif
100}
101
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
local_group_size(16, 16) .push_constant(Type b
#define printf
#define util_assert(statement)
Definition defines.h:98
const char * label
#define ccl_private
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define __forceinline
ccl_device_inline vfloat8 make_vfloat8(float f)
ccl_device_inline void print_vfloat8(ccl_private const char *label, const vfloat8 a)