1//===- AMDGPUArch.cpp - list AMDGPU installed ----------*- C++ -*---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a tool for detecting name of AMDGPU installed in system.
10// This tool is used by AMDGPU OpenMP and HIP driver.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Basic/Version.h"
15#include "llvm/Support/CommandLine.h"
16
17using namespace llvm;
18
19static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden);
20
21// Mark all our options with this category.
22static cl::OptionCategory AMDGPUArchCategory("amdgpu-arch options");
23
24static void PrintVersion(raw_ostream &OS) {
25 OS << clang::getClangToolFullVersion(ToolName: "amdgpu-arch") << '\n';
26}
27
28int printGPUsByHSA();
29int printGPUsByHIP();
30
31int main(int argc, char *argv[]) {
32 cl::HideUnrelatedOptions(Category&: AMDGPUArchCategory);
33
34 cl::SetVersionPrinter(PrintVersion);
35 cl::ParseCommandLineOptions(
36 argc, argv,
37 Overview: "A tool to detect the presence of AMDGPU devices on the system. \n\n"
38 "The tool will output each detected GPU architecture separated by a\n"
39 "newline character. If multiple GPUs of the same architecture are found\n"
40 "a string will be printed for each\n");
41
42 if (Help) {
43 cl::PrintHelpMessage();
44 return 0;
45 }
46
47#ifndef _WIN32
48 if (!printGPUsByHSA())
49 return 0;
50#endif
51
52 return printGPUsByHIP();
53}
54

source code of clang/tools/amdgpu-arch/AMDGPUArch.cpp