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

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/docs-6.4.3/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-6.4.3/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 #include <string>
7 #include <map>
8 #include <hip/hip_runtime.h>
9 
10 namespace ck {
11 
12 inline std::string get_device_name()
13 {
14  hipDeviceProp_t props{};
15  int device;
16  auto status = hipGetDevice(&device);
17  if(status != hipSuccess)
18  {
19  return std::string();
20  }
21 
22  status = hipGetDeviceProperties(&props, device);
23  if(status != hipSuccess)
24  {
25  return std::string();
26  }
27  const std::string raw_name(props.gcnArchName);
28 
29  // https://github.com/ROCm/MIOpen/blob/8498875aef84878e04c1eabefdf6571514891086/src/target_properties.cpp#L40
30  static std::map<std::string, std::string> device_name_map = {
31  {"Ellesmere", "gfx803"},
32  {"Baffin", "gfx803"},
33  {"RacerX", "gfx803"},
34  {"Polaris10", "gfx803"},
35  {"Polaris11", "gfx803"},
36  {"Tonga", "gfx803"},
37  {"Fiji", "gfx803"},
38  {"gfx800", "gfx803"},
39  {"gfx802", "gfx803"},
40  {"gfx804", "gfx803"},
41  {"Vega10", "gfx900"},
42  {"gfx901", "gfx900"},
43  {"10.3.0 Sienna_Cichlid 18", "gfx1030"},
44  };
45 
46  const auto name = raw_name.substr(0, raw_name.find(':')); // str.substr(0, npos) returns str.
47 
48  auto match = device_name_map.find(name);
49  if(match != device_name_map.end())
50  return match->second;
51  return name;
52 }
53 
54 inline bool is_xdl_supported()
55 {
56  return ck::get_device_name() == "gfx908" || ck::get_device_name() == "gfx90a" ||
57  ck::get_device_name() == "gfx940" || ck::get_device_name() == "gfx941" ||
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() == "gfx940" ||
65  ck::get_device_name() == "gfx941" || ck::get_device_name() == "gfx942" ||
66  ck::get_device_name() == "gfx950";
67 }
68 
70 {
71  return ck::get_device_name() == "gfx940" || ck::get_device_name() == "gfx941" ||
72  ck::get_device_name() == "gfx942" || ck::get_device_name() == "gfx950";
73 }
74 
75 inline bool is_gfx101_supported()
76 {
77  return ck::get_device_name() == "gfx1010" || ck::get_device_name() == "gfx1011" ||
78  ck::get_device_name() == "gfx1012";
79 }
80 
81 inline bool is_gfx103_supported()
82 {
83  return ck::get_device_name() == "gfx1030" || ck::get_device_name() == "gfx1031" ||
84  ck::get_device_name() == "gfx1032" || ck::get_device_name() == "gfx1034" ||
85  ck::get_device_name() == "gfx1035" || ck::get_device_name() == "gfx1036";
86 }
87 
88 inline bool is_gfx11_supported()
89 {
90  return ck::get_device_name() == "gfx1100" || ck::get_device_name() == "gfx1101" ||
91  ck::get_device_name() == "gfx1102" || ck::get_device_name() == "gfx1103";
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
Definition: ck.hpp:264
bool is_lds_direct_load_supported()
Definition: device_prop.hpp:61
bool is_xdl_supported()
Definition: device_prop.hpp:54
std::string get_device_name()
Definition: device_prop.hpp:12
bool is_gfx12_supported()
Definition: device_prop.hpp:94
bool is_gfx103_supported()
Definition: device_prop.hpp:81
bool is_gfx101_supported()
Definition: device_prop.hpp:75
bool is_gfx11_supported()
Definition: device_prop.hpp:88
bool is_bf16_atomic_supported()
Definition: device_prop.hpp:69