File: test_ppc_PWR9.c

package info (click to toggle)
pveclib 1.0.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 4,772 kB
  • sloc: ansic: 58,922; sh: 4,257; makefile: 233
file content (46 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define GNUC_VERSION (__GNUC__*1000 + __GNUC_MAJOR__*10)
#if (GNUC_VERSION >= 4060) || defined(__clang__)
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif

#include <altivec.h>
int main(int argc, char* argv[])
{
#if defined(_ARCH_PWR9) 
#ifdef __BUILTIN_CPU_SUPPORTS__
    if (__builtin_cpu_is ("power9") || __builtin_cpu_supports ("arch_3_00"))
	{
	    // PWR9
	    __vector unsigned long long r = {1, 2};
	    __vector unsigned __int128 x = { 1000UL };
#ifdef __clang__
	    // early clang did not support ctz/prty but did rev
	    __vector unsigned long long w = vec_revb (r);
	    __vector unsigned __int128 z = vec_revb (x);
#else
	    __vector unsigned long long w = vec_vctz(r);
	    __vector unsigned __int128 z = vec_vprtyb (x);
#endif
            return 0;
	}
#else
	{
	    // PWR9
	    __vector unsigned long long r = {1, 2};
	    __vector unsigned __int128 x = { 1000UL };
#ifdef __clang__
	    // early clang did not support ctz/prty but did rev
	    __vector unsigned long long w = vec_revb (r);
	    __vector unsigned __int128 z = vec_revb (x);
#else
	    __vector unsigned long long w = vec_vctz(r);
	    __vector unsigned __int128 z = vec_vprtyb (x);
#endif
            return 0;
	}
#endif
#else
    int x[-1]; // fail compile
#endif 
  return -1;
}