/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"
72 #if defined(CK_ENABLE_DYNAMIC_WARP_SIZE)
74 #endif
75  ;
76 }
77 
79 {
80  // Check if direct loads from global memory to LDS are supported.
81  return ck::get_device_name() == "gfx90a" || ck::get_device_name() == "gfx942" ||
82  ck::get_device_name() == "gfx950";
83 }
84 
86 {
87  return ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950" ||
89 }
90 
91 inline bool is_gfx101_supported()
92 {
93  return ck::get_device_name() == "gfx1010" || ck::get_device_name() == "gfx1011" ||
94  ck::get_device_name() == "gfx1012";
95 }
96 
97 inline bool is_gfx103_supported()
98 {
99  return ck::get_device_name() == "gfx1030" || ck::get_device_name() == "gfx1031" ||
100  ck::get_device_name() == "gfx1032" || ck::get_device_name() == "gfx1034" ||
101  ck::get_device_name() == "gfx1035" || ck::get_device_name() == "gfx1036";
102 }
103 
104 } // namespace ck
105 #endif
Definition: ck.hpp:267
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:78
bool is_xdl_supported()
Definition: device_prop.hpp:68
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:97
bool is_gfx101_supported()
Definition: device_prop.hpp:91
bool is_gfx11_supported()
Definition: device_prop.hpp:60
bool is_bf16_atomic_supported()
Definition: device_prop.hpp:85