Skip to content

Commit c2f565a

Browse files
author
Kai Luo
committed
Add test case for host running on pwr10
1 parent 99a765f commit c2f565a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %clangxx -fPIC -c -o %t %s
2+
// RUN: %llvm_jitlink %t
3+
4+
#include <fstream>
5+
#include <iostream>
6+
#include <string>
7+
8+
thread_local int x = 0;
9+
thread_local int y = 1;
10+
thread_local int z = -1;
11+
12+
static int __attribute__((target("arch=pwr10"))) TestPOWER10() {
13+
return x + y + z;
14+
}
15+
16+
static int Test() { return x + y + z; }
17+
18+
static bool CPUModelIsPOWER10() {
19+
std::string line;
20+
std::ifstream cpuinfo("/proc/cpuinfo", std::ios::in);
21+
if (!cpuinfo.is_open())
22+
return false;
23+
while (std::getline(cpuinfo, line)) {
24+
if (line.find("cpu") != std::string::npos &&
25+
line.find("POWER10") != std::string::npos)
26+
return true;
27+
}
28+
return false;
29+
}
30+
31+
int main() {
32+
if (CPUModelIsPOWER10())
33+
return TestPOWER10();
34+
return Test();
35+
}

0 commit comments

Comments
 (0)