/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 // SPDX-License-Identifier: MIT
2 // Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
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";
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, typename BDataType, index_t MPerXDL, index_t NPerXDL>
76 inline bool is_xdl_wmma_supported()
77 {
78  if(ck::get_device_name() == "gfx908" || ck::get_device_name() == "gfx90a" ||
79  ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950")
80  {
81  return true;
82  }
84  {
85  if constexpr((MPerXDL != 16) || (NPerXDL != 16))
86  {
87  return false;
88  }
89  if constexpr(sizeof(ADataType) > 2 || sizeof(BDataType) > 2)
90  {
91  return false;
92  }
93  return true;
94  }
95  else
96  {
97  return false;
98  }
99 }
100 
102 {
103  // Check if direct loads from global memory to LDS are supported.
104  return ck::get_device_name() == "gfx90a" || ck::get_device_name() == "gfx942" ||
105  ck::get_device_name() == "gfx950";
106 }
107 
109 {
110  return ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950" ||
112 }
113 
114 inline bool is_gfx101_supported()
115 {
116  return ck::get_device_name() == "gfx1010" || ck::get_device_name() == "gfx1011" ||
117  ck::get_device_name() == "gfx1012";
118 }
119 
120 inline bool is_gfx103_supported()
121 {
122  return ck::get_device_name() == "gfx1030" || ck::get_device_name() == "gfx1031" ||
123  ck::get_device_name() == "gfx1032" || ck::get_device_name() == "gfx1034" ||
124  ck::get_device_name() == "gfx1035" || ck::get_device_name() == "gfx1036";
125 }
126 
127 inline bool is_wmma_supported()
128 {
130 }
131 
132 inline bool is_tf32_supported() { return (ck::get_device_name() == "gfx942") ? true : false; }
133 
134 } // namespace ck
135 #endif
Definition: ck.hpp:268
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:101
bool is_xdl_supported()
Definition: device_prop.hpp:68
bool is_wmma_supported()
Definition: device_prop.hpp:127
std::string get_device_name()
Definition: device_prop.hpp:19
bool is_gfx12_supported()
Definition: device_prop.hpp:55
bool is_xdl_wmma_supported()
Definition: device_prop.hpp:76
bool is_gfx103_supported()
Definition: device_prop.hpp:120
bool is_tf32_supported()
Definition: device_prop.hpp:132
bool is_gfx101_supported()
Definition: device_prop.hpp:114
bool is_gfx11_supported()
Definition: device_prop.hpp:60
bool is_bf16_atomic_supported()
Definition: device_prop.hpp:108