jetpacapp / pi-gemm

A Raspberry Pi GPU-accelerated implementation of the GEMM matrix-multiply function
Other
88 stars 22 forks source link

compile errors with aarch64 #5

Open mdhoney opened 2 years ago

mdhoney commented 2 years ago

Trying to compile this to run on a Pi Zero 2 W, running Raspbian aarch64. I removed the following gcc flags: -mfloat-abi=hard -mfpu=vfp and changed -march=armv8-a

But I still get errors...

g++ -Ofast -DTARGET_PI -march=armv8-a  -fPIC -c cstring_helpers.cpp -o cstring_helpers.o
cstring_helpers.cpp: In function 'char* malloc_and_copy_string(const char*)':
cstring_helpers.cpp:20:10: warning: 'char* strncpy(char*, const char*, size_t)' specified bound depends on the length of the source argument [-Wstringop-overflow=]
   20 |   strncpy(result, input, inputByteCount);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cstring_helpers.cpp:18:40: note: length computed here
   18 |   const size_t inputByteCount = (strlen(input) + 1);
      |                                  ~~~~~~^~~~~~~
g++ -Ofast -DTARGET_PI -march=armv8-a  -fPIC -c main.cpp -o main.o
g++ -Ofast -DTARGET_PI -march=armv8-a  -fPIC -c buffer.cpp -o buffer.o
g++ -Ofast -DTARGET_PI -march=armv8-a  -fPIC -c mailbox.cpp -o mailbox.o
mailbox.cpp: In function 'void* mapmem(unsigned int, unsigned int)':
mailbox.cpp:71:33: error: cast from 'void*' to 'int' loses precision [-fpermissive]
   71 |       printf("mmap error %d\n", (int)mem);
      |                                 ^~~~~~~~
mailbox.cpp: In function 'int mbox_open()':
mailbox.cpp:271:46: error: 'makedev' was not declared in this scope
  271 |     if (mknod(DEVICE_PATH, (0777 | S_IFCHR), makedev(MAJOR_NUM, 0)) == -1) {
      |                                              ^~~~~~~
mailbox.cpp: In function 'void* unmapmem(void*, unsigned int)':
mailbox.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
   85 | }
      | ^
make: *** [Makefile:23: mailbox.o] Error 1

Can anyone help...? Thanks!

petewarden commented 2 years ago

Unfortunately I'm not sure what the issue is from inspection. The library is pretty old these days, and I'd recommend more modern alternatives like TensorFlow Lite, since that's better maintained and documented: https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/raspberry_pi

Is there something in particular that you want to do that's not supported by TFL?

mdhoney commented 2 years ago

Thank you for the reply @petewarden. Trying to do matrix multiplication, as fast as possible, and was hoping to be able to speed it up by using the QPU (similar to how it can be done for FFTs). As far as I understand it, TensorFlow doesn't do any hardware acceleration, right?

petewarden commented 2 years ago

You're correct, this is the only project I'm aware of that uses the QPU for matrix multiplication. I'm not sure how much of a performance gap there is now that more modern Pi's have multi-core CPUs with NEON. I've also seen (but not tried) that OpenCL is supported, and I would recommend seeing if that is better than this pretty hacky approach! https://hackaday.com/2019/01/24/running-opencl-on-a-raspberry-pi-gpu/

hyunwen commented 2 years ago

Error 1: cast from 'void*' to 'int' loses precision, mailbox.cpp:71:33: modfy int to long
printf("mmap error %d\n", (long)mem); On 64-bit platforms, pointer values cannot be forced to int, only to long.

Error 2: 'makedev' was not declared in this scope Glibc removes sys/sysmacros.h which defines makedev from sys/types.h since v2.28. [Commit ID: e16deca62e16f] And then glibc suggestions us to include <sys/sysmacros.h>directly if code needs it.

4