Author: Richard Plangger <[email protected]>
Branch: ppc-vsx-support
Changeset: r85176:ebfa9b3a75d6
Date: 2016-06-15 14:48 +0200
http://bitbucket.org/pypy/pypy/changeset/ebfa9b3a75d6/
Log: detect altivec at runtime on linux
diff --git a/rpython/jit/backend/ppc/detect_feature.py
b/rpython/jit/backend/ppc/detect_feature.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/backend/ppc/detect_feature.py
@@ -0,0 +1,37 @@
+import sys
+import struct
+import platform
+from rpython.rtyper.lltypesystem import lltype, rffi
+from rpython.rtyper.tool import rffi_platform
+from rpython.rlib.rmmap import alloc, free
+from rpython.rlib.rstruct.runpack import runpack
+
+AT_HWCAP = rffi_platform.getconstantinteger('AT_HWCAP', '#include
"linux/auxvec.h"')
+AT_NULL = rffi_platform.getconstantinteger('AT_NULL', '#include
"linux/auxvec.h"')
+PPC_FEATURE_HAS_ALTIVEC =
rffi_platform.getconstantinteger('PPC_FEATURE_HAS_ALTIVEC',
+ '#include "asm/cputable.h"')
+SYSTEM = platform.system()
+
+def detect_vsx_linux():
+ with open('/proc/self/auxv', 'rb') as fd:
+ while True:
+ buf = fd.read(16)
+ if not buf:
+ break
+ key, value = runpack("LL", buf)
+ if key == AT_HWCAP:
+ if value & PPC_FEATURE_HAS_ALTIVEC:
+ return True
+ if key == AT_NULL:
+ return False
+ return False
+
+def detect_vsx():
+ if SYSTEM == 'Linux':
+ return detect_vsx_linux()
+ return False
+
+if __name__ == '__main__':
+ print 'The following extensions are supported:'
+ if detect_vsx():
+ print ' - AltiVec'
diff --git a/rpython/jit/backend/ppc/runner.py
b/rpython/jit/backend/ppc/runner.py
--- a/rpython/jit/backend/ppc/runner.py
+++ b/rpython/jit/backend/ppc/runner.py
@@ -11,6 +11,10 @@
class PPC_CPU(AbstractLLCPU):
+ vector_extension = False # may be set to true in setup
+ vector_register_size = 16
+ vector_horizontal_operations = False
+
supports_floats = True
# missing: supports_singlefloats
@@ -38,6 +42,9 @@
def setup(self):
self.assembler = AssemblerPPC(self)
+ if detect_vsx():
+ self.vector_extension = True
+ # ??? self.vector_horizontal_operations = True
@rgc.no_release_gil
def setup_once(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit