/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/host_utility/device_prop.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/host_utility/device_prop.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck/host_utility/device_prop.hpp Source File
device_prop.hpp
Go to the documentation of this file.
1 // Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
2 // SPDX-License-Identifier: MIT
3 
4 #pragma once
5 
6 #ifndef __HIPCC_RTC__
7 #include <string>
8 #include <string_view>
9 #include <hip/hip_runtime.h>
10 
11 namespace ck {
12 
13 constexpr unsigned int fnv1a_hash(std::string_view str, unsigned int h = 2166136261u)
14 {
15  return str.empty() ? h
16  : fnv1a_hash(str.substr(1),
17  (h ^ static_cast<unsigned char>(str.front())) * 16777619u);
18 }
19 inline std::string get_device_name()
20 {
21  hipDeviceProp_t props{};
22  int device;
23  auto status = hipGetDevice(&device);
24  if(status != hipSuccess)
25  {
26  return std::string();
27  }
28  status = hipGetDeviceProperties(&props, device);
29  if(status != hipSuccess)
30  {
31  return std::string();
32  }
33  const std::string raw_name(props.gcnArchName);
34  const auto name = raw_name.substr(0, raw_name.find(':')); // str.substr(0, npos) returns str.
35  switch(fnv1a_hash(name))
36  {
37  // https://github.com/ROCm/MIOpen/blob/8498875aef84878e04c1eabefdf6571514891086/src/target_properties.cpp#L40
38  case fnv1a_hash("Ellesmere"):
39  case fnv1a_hash("Baffin"):
40  case fnv1a_hash("RacerX"):
41  case fnv1a_hash("Polaris10"):
42  case fnv1a_hash("Polaris11"):
43  case fnv1a_hash("Tonga"):
44  case fnv1a_hash("Fiji"):
45  case fnv1a_hash("gfx800"):
46  case fnv1a_hash("gfx802"):
47  case fnv1a_hash("gfx804"): return "gfx803";
48  case fnv1a_hash("Vega10"):
49  case fnv1a_hash("gfx901"): return "gfx900";
50  case fnv1a_hash("10.3.0 Sienna_Cichlid 18"): return "gfx1030";
51  default: return name;
52  }
53 }
54 
55 inline bool is_gfx12_supported()
56 {
57  return ck::get_device_name() == "gfx1200" || ck::get_device_name() == "gfx1201";
58 }
59 
60 inline bool is_gfx11_supported()
61 {
62  return ck::get_device_name() == "gfx1100" || ck::get_device_name() == "gfx1101" ||
63  ck::get_device_name() == "gfx1102" || ck::get_device_name() == "gfx1103" ||
64  ck::get_device_name() == "gfx1150" || ck::get_device_name() == "gfx1151" ||
65  ck::get_device_name() == "gfx1152" || ck::get_device_name() == "gfx1153";
66 }
67 
68 inline bool is_xdl_supported()
69 {
70  return ck::get_device_name() == "gfx908" || ck::get_device_name() == "gfx90a" ||
71  ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950" ||
73 }
74 
75 template <typename ADataType,
76  typename BDataType,
77  index_t MPerXDL64,
78  index_t NPerXDL64,
79  index_t MPerXDL32 = MPerXDL64,
80  index_t NPerXDL32 = NPerXDL64>
81 inline bool is_xdl_wmma_supported()
82 {
83  if(ck::get_device_name() == "gfx908" || ck::get_device_name() == "gfx90a" ||
84  ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950")
85  {
86  return true;
87  }
89  {
90  if constexpr((MPerXDL32 != 16) || (NPerXDL32 != 16))
91  {
92  return false;
93  }
94  if constexpr(sizeof(ADataType) > 2 || sizeof(BDataType) > 2)
95  {
96  return false;
97  }
98  return true;
99  }
100  else
101  {
102  return false;
103  }
104 }
105 
107 {
108  // Check if direct loads from global memory to LDS are supported.
109  return ck::get_device_name() == "gfx90a" || ck::get_device_name() == "gfx942" ||
110  ck::get_device_name() == "gfx950";
111 }
112 
114 {
115  return ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950" ||
117 }
118 
119 inline bool is_gfx101_supported()
120 {
121  return ck::get_device_name() == "gfx1010" || ck::get_device_name() == "gfx1011" ||
122  ck::get_device_name() == "gfx1012";
123 }
124 
125 inline bool is_gfx103_supported()
126 {
127  return ck::get_device_name() == "gfx1030" || ck::get_device_name() == "gfx1031" ||
128  ck::get_device_name() == "gfx1032" || ck::get_device_name() == "gfx1034" ||
129  ck::get_device_name() == "gfx1035" || ck::get_device_name() == "gfx1036";
130 }
131 
132 inline bool is_wmma_supported()
133 {
135 }
136 
137 inline bool is_tf32_supported()
138 {
139  return ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950";
140 }
141 
142 } // namespace ck
143 #endif
Definition: ck.hpp:270
constexpr unsigned int fnv1a_hash(std::string_view str, unsigned int h=2166136261u)
Definition: device_prop.hpp:13
bool is_lds_direct_load_supported()
Definition: device_prop.hpp:106
bool is_xdl_supported()
Definition: device_prop.hpp:68
bool is_wmma_supported()
Definition: device_prop.hpp:132
bool is_xdl_wmma_supported()
Definition: device_prop.hpp:81
std::string get_device_name()
Definition: device_prop.hpp:19
bool is_gfx12_supported()
Definition: device_prop.hpp:55
bool is_gfx103_supported()
Definition: device_prop.hpp:125
bool is_tf32_supported()
Definition: device_prop.hpp:137
int32_t index_t
Definition: ck.hpp:301
bool is_gfx101_supported()
Definition: device_prop.hpp:119
bool is_gfx11_supported()
Definition: device_prop.hpp:60
bool is_bf16_atomic_supported()
Definition: device_prop.hpp:113