[Numpy-discussion] Numpy support for Microblaze

pnp gokul at astrome.co
Sat Jan 11 01:29:35 EST 2020


First of, many thanks to each one of you for taking your time to post your
valuable comments and suggestions. My apologies for not filling in the
details. Here goes:

1.We have linux running on the Microblaze. So, what I am looking at this
point is a software only solution.
2. We have cross compilation tools and buildroot. I was able to compile
python3.8 externally and run it on Microblaze. Note that I compiled python
outside of buildroot since the version of python built from buildroot did
not work.
3. Buildroot did not have support for Numpy. So I added it to the
configuration. To resolve the compilation issues, here is what I did:

diff -r -u
/home/gokul/numpyExpt/numpy-1.16.4/numpy/core/include/numpy/npy_cpu.h
python-numpy-1.16.4.BAK/numpy/core/include/numpy/npy_cpu.h
--- /home/gokul/numpyExpt/numpy-1.16.4/numpy/core/include/numpy/npy_cpu.h      
2019-02-22 06:03:41.000000000 +0530
+++ python-numpy-1.16.4.BAK/numpy/core/include/numpy/npy_cpu.h  2019-12-22
18:52:16.468085099 +0530
@@ -102,6 +102,8 @@
     #define NPY_CPU_ARCEB
 #elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
     #define NPY_CPU_RISCV64
+#elif defined(__MICROBLAZEEL__) 
+    #define NPY_CPU_MICROBLAZEEL
 #else
     #error Unknown CPU, please report this to numpy maintainers with \
     information about your platform (OS, CPU and compiler)
diff -r -u
/home/gokul/numpyExpt/numpy-1.16.4/numpy/core/include/numpy/npy_endian.h
python-numpy-1.16.4.BAK/numpy/core/include/numpy/npy_endian.h
--- /home/gokul/numpyExpt/numpy-1.16.4/numpy/core/include/numpy/npy_endian.h   
2019-02-22 06:03:41.000000000 +0530
+++ python-numpy-1.16.4.BAK/numpy/core/include/numpy/npy_endian.h      
2019-12-22 18:54:08.912859083 +0530
@@ -48,7 +48,8 @@
             || defined(NPY_CPU_MIPSEL)        \
             || defined(NPY_CPU_PPC64LE)       \
             || defined(NPY_CPU_ARCEL)         \
-            || defined(NPY_CPU_RISCV64)
+            || defined(NPY_CPU_RISCV64)       \
+            || defined(NPY_CPU_MICROBLAZEEL)
         #define NPY_BYTE_ORDER NPY_LITTLE_ENDIAN
     #elif defined(NPY_CPU_PPC)                \
             || defined(NPY_CPU_SPARC)         \

diff -ruN -x '*.py'
/home/gokul/numpyExpt/numpy-1.16.4/numpy/core/include/microblaze-fenv.h
python-numpy-1.16.4/numpy/core/include/microblaze-fenv.h
--- /home/gokul/numpyExpt/numpy-1.16.4/numpy/core/include/microblaze-fenv.h    
1970-01-01 05:30:00.000000000 +0530
+++ python-numpy-1.16.4/numpy/core/include/microblaze-fenv.h    2020-01-02
14:06:30.410908275 +0530
@@ -0,0 +1,36 @@
+#ifndef MICROBLAZE_FENV_H
+#define MICROBLAZE_FENV_H 1
+
+enum
+  {
+    FE_INEXACT   =
+#define FE_INEXACT      (0x00)
+      FE_INEXACT,
+    FE_UNDERFLOW =
+#define FE_UNDERFLOW    (0x00)
+      FE_UNDERFLOW,
+    FE_OVERFLOW  =
+#define FE_OVERFLOW     (0x00)
+      FE_OVERFLOW,
+    FE_DIVBYZERO =
+#define FE_DIVBYZERO    (0x00)
+      FE_DIVBYZERO,
+    FE_INVALID   =
+#define FE_INVALID      (0x00)
+      FE_INVALID
+  };
+
+enum
+  {
+    FE_TOWARDZERO =
+#define FE_TOWARDZERO   (0x0)
+      FE_TOWARDZERO,
+    FE_DOWNWARD   =
+#define FE_DOWNWARD     (0x0)
+      FE_DOWNWARD,
+    FE_UPWARD     =
+#define FE_UPWARD       (0x0)
+      FE_UPWARD
+  };
+
+#endif

The last change above was to take care of floating point exception errors in
compilation. Not sure if this is the right approach- I had to do this since
Microblaze didnt support all these exceptions

4. When I run with these changes, I get the following runtime error:
~# /usr/local/bin/python

Python 3.8.0 (default, Jan  3 2020, 16:10:54)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/numpy/__init__.py", line 150, in
<module>
    from . import random
  File "/usr/lib/python3.8/site-packages/numpy/random/__init__.py", line
143, in <module>
    from .mtrand import *
SystemError: execution of module numpy.random.mtrand failed without setting
an exception
>>>





--
Sent from: http://numpy-discussion.10968.n7.nabble.com/


More information about the NumPy-Discussion mailing list