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

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

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-7.0.0/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-2023, 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_xdl_supported()
56 {
57  return ck::get_device_name() == "gfx908" || ck::get_device_name() == "gfx90a" ||
58  ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950";
59 }
60 
62 {
63  // Check if direct loads from global memory to LDS are supported.
64  return ck::get_device_name() == "gfx90a" || ck::get_device_name() == "gfx942" ||
65  ck::get_device_name() == "gfx950";
66 }
67 
69 {
70  return ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950";
71 }
72 
73 inline bool is_gfx101_supported()
74 {
75  return ck::get_device_name() == "gfx1010" || ck::get_device_name() == "gfx1011" ||
76  ck::get_device_name() == "gfx1012";
77 }
78 
79 inline bool is_gfx103_supported()
80 {
81  return ck::get_device_name() == "gfx1030" || ck::get_device_name() == "gfx1031" ||
82  ck::get_device_name() == "gfx1032" || ck::get_device_name() == "gfx1034" ||
83  ck::get_device_name() == "gfx1035" || ck::get_device_name() == "gfx1036";
84 }
85 
86 inline bool is_gfx11_supported()
87 {
88  return ck::get_device_name() == "gfx1100" || ck::get_device_name() == "gfx1101" ||
89  ck::get_device_name() == "gfx1102" || ck::get_device_name() == "gfx1103" ||
90  ck::get_device_name() == "gfx1150" || ck::get_device_name() == "gfx1151" ||
91  ck::get_device_name() == "gfx1152";
92 }
93 
94 inline bool is_gfx12_supported()
95 {
96  return ck::get_device_name() == "gfx1200" || ck::get_device_name() == "gfx1201";
97 }
98 
99 } // namespace ck
100 #endif
Definition: ck.hpp:269
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:61
bool is_xdl_supported()
Definition: device_prop.hpp:55
std::string get_device_name()
Definition: device_prop.hpp:19
bool is_gfx12_supported()
Definition: device_prop.hpp:94
bool is_gfx103_supported()
Definition: device_prop.hpp:79
bool is_gfx101_supported()
Definition: device_prop.hpp:73
bool is_gfx11_supported()
Definition: device_prop.hpp:86
bool is_bf16_atomic_supported()
Definition: device_prop.hpp:68