gem5 v24.0.0.0
Loading...
Searching...
No Matches
binary32.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Advanced Micro Devices, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef __ARCH_AMDGPU_COMMON_DTYPE_BINARY32_HH__
33#define __ARCH_AMDGPU_COMMON_DTYPE_BINARY32_HH__
34
35namespace gem5
36{
37
38namespace AMDGPU
39{
40
41// Same as IEEE 754 binary 32 - Microscaling types are converted to/from
42// this format by default. For now as there do not seem to be any MI300
43// instructions operating directly on the types (i.e., they all cast to FP32
44// first and then perform arithmetic operations).
45typedef union binary32_u
46{
48 {
49 ebits = 8,
50 mbits = 23,
51 sbits = 1,
52 bias = 127,
53
54 inf = 0x7f800000,
55 nan = 0x7f800100,
56 max = 0x7f7fffff
57 };
58
59 uint32_t storage;
60 float fp32;
61 struct
62 {
63 unsigned mant : 23;
64 unsigned exp : 8;
65 unsigned sign : 1;
66 };
67
68 // To help with stdlib functions with T = float.
69 operator float() const
70 {
71 return fp32;
72 }
74static_assert(sizeof(binary32) == 4);
75
76} // namespace AMDGPU
77
78} // namespace gem5
79
80namespace std
81{
82
83template<>
84class numeric_limits<gem5::AMDGPU::binary32>
85{
86 public:
87 static constexpr bool has_quiet_NaN = true;
89 {
91 tmp.fp32 = std::numeric_limits<float>::quiet_NaN();
92 return tmp;
93 }
94
95 static constexpr bool has_infinity = true;
97 {
99 tmp.fp32 = std::numeric_limits<float>::infinity();
100 return tmp;
101 }
102
104 {
106 tmp.fp32 = std::numeric_limits<float>::max();
107 return tmp;
108 }
109};
110
111} // namespace std
112
113#endif // __ARCH_AMDGPU_COMMON_DTYPE_BINARY32_HH__
static gem5::AMDGPU::binary32 max()
Definition binary32.hh:103
static gem5::AMDGPU::binary32 infinity()
Definition binary32.hh:96
static gem5::AMDGPU::binary32 quiet_NaN()
Definition binary32.hh:88
union gem5::AMDGPU::binary32_u binary32
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81

Generated on Tue Jun 18 2024 16:23:39 for gem5 by doxygen 1.11.0