Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
TargetModel.hpp
Go to the documentation of this file.
1#ifndef PROTEUS_TARGET_MODE_H
2#define PROTEUS_TARGET_MODE_H
3
4#include <llvm/ADT/StringRef.h>
5#include <llvm/TargetParser/Host.h>
6#include <llvm/TargetParser/Triple.h>
7
8#include "proteus/Error.h"
9
10namespace proteus {
11
12using namespace llvm;
13
14enum class TargetModelType { HOST, CUDA, HIP };
15
16inline TargetModelType parseTargetModel(StringRef Target) {
17 if (Target == "host" || Target == "native") {
19 }
20
21 if (Target == "cuda") {
23 }
24
25 if (Target == "hip") {
27 }
28
29 PROTEUS_FATAL_ERROR("Unsupported target " + Target);
30}
31
32inline std::string getTargetTriple(TargetModelType Model) {
33 switch (Model) {
35 return sys::getProcessTriple();
37 return "nvptx64-nvidia-cuda";
39 return "amdgcn-amd-amdhsa";
40 default:
41 PROTEUS_FATAL_ERROR("Unsupported target model");
42 }
43}
44
45} // namespace proteus
46
47#endif
#define PROTEUS_FATAL_ERROR(x)
Definition Error.h:7
Definition Helpers.h:76
Definition CppJitModule.cpp:21
TargetModelType
Definition TargetModel.hpp:14
TargetModelType parseTargetModel(StringRef Target)
Definition TargetModel.hpp:16
std::string getTargetTriple(TargetModelType Model)
Definition TargetModel.hpp:32