CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
141 lines
3.7 KiB
C++
141 lines
3.7 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <cstdio>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <stdexcept>
|
|
#include <string.h>
|
|
#include <string>
|
|
|
|
#include "GPUArchitectureGenerator/GPUArchitectureGenerator.hpp"
|
|
|
|
const std::string HELP_MESSAGE
|
|
= "Usage: GPUArchitectureGenerator OUTPUT_FILE [ASSEMBLER_LOCATION]\n"
|
|
"OUTPUT_FILE: Location to store generated file.\n"
|
|
"ASSEMBLER_LOCATION: Path to assembler executable.\n"
|
|
"\n"
|
|
"Options:\n"
|
|
" -Y output YAML (msgpack by default)\n"
|
|
" --split split yaml file output into a file per architecture\n"
|
|
" --xml_dir source directory for ISA xml files\n"
|
|
" --yaml one or more yaml files to convert to the desired output\n"
|
|
" -h, --help display this help and exit";
|
|
|
|
const std::string YAML_ARG = "-Y";
|
|
const std::string XML_DIR_ARG = "--xml_dir";
|
|
const std::string YAML_IN_ARG = "--yaml";
|
|
const std::string SPLIT_ARG = "--split";
|
|
|
|
struct ProgramArgs
|
|
{
|
|
std::string outputFile;
|
|
std::string assembler = GPUArchitectureGenerator::DEFAULT_ASSEMBLER;
|
|
bool useYAML = false;
|
|
bool splitYAML = false;
|
|
std::string xmlDir = "";
|
|
std::vector<std::string> yamlIns;
|
|
|
|
static ProgramArgs ParseArgs(int argc, const char* argv[]);
|
|
[[noreturn]] static void Help(bool error = false);
|
|
};
|
|
|
|
ProgramArgs ProgramArgs::ParseArgs(int argc, const char* argv[])
|
|
{
|
|
if(argc <= 1)
|
|
Help(true);
|
|
|
|
std::vector<std::string> args(argv + 1, argv + argc);
|
|
ProgramArgs rv;
|
|
|
|
for(auto iter = args.begin(); iter != args.end(); iter++)
|
|
{
|
|
if(*iter == "-h" || *iter == "--help")
|
|
Help(false);
|
|
if(*iter == YAML_ARG)
|
|
{
|
|
rv.useYAML = true;
|
|
iter = args.erase(iter);
|
|
iter--;
|
|
}
|
|
if(*iter == SPLIT_ARG)
|
|
{
|
|
rv.splitYAML = true;
|
|
iter = args.erase(iter);
|
|
iter--;
|
|
}
|
|
if(*iter == XML_DIR_ARG)
|
|
{
|
|
iter = args.erase(iter);
|
|
rv.xmlDir = *iter;
|
|
iter = args.erase(iter);
|
|
iter--;
|
|
}
|
|
if(*iter == YAML_IN_ARG)
|
|
{
|
|
iter = args.erase(iter);
|
|
rv.yamlIns.push_back(*iter);
|
|
iter = args.erase(iter);
|
|
iter--;
|
|
}
|
|
}
|
|
|
|
if(args.empty() || args.size() > 2)
|
|
Help(true);
|
|
|
|
rv.outputFile = args[0];
|
|
if(args.size() > 1)
|
|
rv.assembler = args[1];
|
|
|
|
return rv;
|
|
}
|
|
|
|
[[noreturn]] void ProgramArgs::Help(bool error)
|
|
{
|
|
fprintf(stderr, "%s\n", HELP_MESSAGE.c_str());
|
|
|
|
if(error)
|
|
exit(1);
|
|
else
|
|
exit(0);
|
|
}
|
|
|
|
int main(int argc, const char* argv[])
|
|
{
|
|
auto args = ProgramArgs::ParseArgs(argc, argv);
|
|
|
|
if(!GPUArchitectureGenerator::CheckAssembler(args.assembler))
|
|
{
|
|
fprintf(stderr, "Error using assembler:\n%s\n", args.assembler.c_str());
|
|
return 1;
|
|
}
|
|
|
|
if(args.yamlIns.size() > 0)
|
|
{
|
|
GPUArchitectureGenerator::LoadYamls(args.yamlIns);
|
|
}
|
|
else
|
|
{
|
|
GPUArchitectureGenerator::FillArchitectures(args.assembler, args.xmlDir);
|
|
}
|
|
|
|
try
|
|
{
|
|
GPUArchitectureGenerator::GenerateFile(args.outputFile, args.useYAML, args.splitYAML);
|
|
}
|
|
catch(std::exception& e)
|
|
{
|
|
fprintf(stderr,
|
|
"The following exception was encountered while generating the source file:\n%s\n",
|
|
e.what());
|
|
return 1;
|
|
}
|
|
catch(...)
|
|
{
|
|
fprintf(stderr, "An unkown error was encountered while generating the source file.");
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|