How to PAL

Discussion about Parallella (and Epiphany) Software Development

Moderators: simoncook, amylaar, jeremybennett

How to PAL

Postby DJW » Sat Oct 29, 2016 1:13 am

Hello dudes,

I recently installed pal on my parallella board.
I already played a little bit with ePython, but C is a new programming language for me.
Can anyone help me with 3 follwoing questions?

2. Can anybody say something about which format the worker and the manager code has and how I can compile and execute them in bash?
2. Are there any good pal introductions to learn it from scratch?
3. How much faster is pal compared to ePython (I know this questions needs to be differentiated)?

Thank you for your support :)

Greetings from Germany
DJW
DJW
 
Posts: 9
Joined: Fri Aug 26, 2016 12:29 am

Re: How to PAL

Postby peteasa » Wed Nov 02, 2016 6:15 pm

There is a separate forum topic for PAL (viewforum.php?f=54) .. here is my latest post on that forum viewtopic.php?f=54&t=3771&sid=0b435154231e53427edd247ed357b469.. suggest that you continue this thread on that forum... but for now

To build pal it should be as simple as
Code: Select all
$ git clone https://github.com/parallella/pal.git
$ source ./setup-epiphany-sdk-on-target.sh
$ cd pal
$ autoreconf -i --force
$ mkdir -p build
$ cd build
$ ../configure --enable-device-epiphany
$ make -k > make.log 2>&1
$ make install > make-install.log 2>&1


To run the examples is should be as simple as:
Code: Select all
$ make check


To run a specific test on the epiphany chip
Code: Select all
$ cd device/epiphany/tests/math
$ ../runtest check_p_sin_f32
Suite: p_sin_f32_suite
100%: Tests: 2 Run: 2 Pass: 2 Skip: 0 Fail: 0 Hard errors: 0
tc_against_gold: PASS
tc_against_ref: PASS


Look at pal/tests/runtest.epiphany.c to get an idea about what has just happened. In particular the line https://github.com/parallella/pal/blob/ ... hany.c#L47 loads and runs a program, copies the program to the epiphany core and runs the program on the epiphany core then https://github.com/parallella/pal/blob/ ... hany.c#L51 reads the results of the program run from the epiphany memory back into the arm memory.

To answer your questions the worker code that runs on the epiphany chip is built with the e-gcc compiler and is saved in a file in elf format (check_p_sin_f32 for example). The manager code that is compiled with the arm version of gcc creates an arm elf file that can be run from the parallella command prompt (runtest in the above example).

If you want to check the format file is the command for you:
Code: Select all
$ file runtest
runtest: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=cde37c536ed45e4564c4089c0cd3fecba80e387e, not stripped
$ file math/check_p_sin_f32
check_p_sin_f32: ELF 32-bit LSB executable, Adapteva Epiphany (unofficial), version 1 (SYSV), statically linked, BuildID[sha1]=e45e0299742de9f4ee16bbc9258733f5bc5d6381, not stripped


I looked at the examples in pal/examples/base and created a couple of hello world type examples https://github.com/peteasa/examples/tre ... ello-world https://github.com/peteasa/examples/tre ... ello-team.. I suspect that these will not work well for you because my environment is slightly different to the standard parallella environment however. In theory with my examples you just type make in the pal-hello-world folder for example once pal has been installed...

In practice you are on a steep learning curve if you do not know C. I would suggest keep it very simple and run a simple c program on the arm first. Second the pal libraries did not build for me just now when I built them. I still had to apply a linker patch to get examples/math/matmul/matmul-dev-epiphany to build:
Code: Select all
  CCLD     examples/math/matmul/matmul-dev-epiphany
/usr/lib/epiphany-elf/gcc/epiphany-elf/5.2.0/../../../../../epiphany-elf/bin/ld: section .data_bank1 loaded at [0000000000002000,00000000000027ff] overlaps section .text loaded at [00000000000007c8,0000000000002763]
/usr/lib/epiphany-elf/gcc/epiphany-elf/5.2.0/../../../../../epiphany-elf/bin/ld: section .fini loaded at [0000000000002764,000000000000277d] overlaps section .data_bank1 loaded at [0000000000002000,00000000000027ff]
collect2: error: ld returned 1 exit status
Makefile:6170: recipe for target 'examples/math/matmul/matmul-dev-epiphany' failed
make[4]: *** [examples/math/matmul/matmul-dev-epiphany] Error 1

I would be interested if you get / dont get the same problem.

Oh yes and the speed test question.. don't know! Pal is very new and so you may find it more difficult to get going with than ePython. Pal is going to be faster because it is direct epiphany code with little high level language overhead, however it is going to be perhaps 10 times more challenging to get something working because Pal is new and because you have to know quite a bit about how epiphany code is loaded into memory etc...

Have fun!

Peter.
User avatar
peteasa
 
Posts: 108
Joined: Fri Nov 21, 2014 7:04 pm

Re: How to PAL

Postby polas » Thu Nov 03, 2016 10:20 am

Peter's reply is very detailed and answered some of the questions I had wondered about PAL too :) In terms of the ePython vs PAL speed, Peter is right - the interpreted nature of ePython will result in an overhead over and above using PAL from C, but as Peter says there is also a steeper learning curve with PAL+C so there is a trade-off here. Incidentally I have thought about writing a Python module that wraps PAL, so that in ePython somebody could import this and use "native" PAL from their Python code directly which might be a nice way of combining these two technologies.

Nick
polas
 
Posts: 32
Joined: Thu Mar 05, 2015 9:41 pm

Re: How to PAL

Postby shrogers » Sun Nov 06, 2016 1:12 am

A Python wrapper for PAL would be interesting. Once I get both ePython and PAL working I'd like to take a look at this.
shrogers
 
Posts: 5
Joined: Sat Oct 29, 2016 8:39 pm

Re: How to PAL

Postby polas » Sun Nov 06, 2016 9:48 am

shrogers wrote:A Python wrapper for PAL would be interesting. Once I get both ePython and PAL working I'd like to take a look at this.


Great :) I have a few ideas from the ePython side how this might be best achieved (there is a native function call construct in the latest development version of the interpreter which I think would work well here) so feel free to send me a message when you start looking at this.

Nick
polas
 
Posts: 32
Joined: Thu Mar 05, 2015 9:41 pm

Re: How to PAL

Postby mgrecki » Fri Jan 27, 2017 2:58 pm

it is a shame, that clearly pointed-out errors are not corrected for months. There is nothing more irritating than downloading a software package and be not able to compile it following README etc. I want to say that the idea of parallella board is wonderful and even hardware in spite of bad USB experience is OK, but the SW part is really painful. That concerns also PAL which should be fully reliable. Look, the hardware platform is the same, the software base (OS and ESDK) is the same - why the package developer cannot see it is not compilable? Always something must be corrected and adjusted....
That was general remark, now going back to PAL. On fresh system with newest ESDK and PAL you cannot compile examples. That was already mentioned November last year... Further, even if the examples are excluded in .configure it is not possible to make "make install", since the installation scripts cannot find epiphany-elf-ranlib. You have to put the full path to it in the libtool script (at pal/devices/epiphany directory) to complete installation.... (probably there is simpler and more elegant way, but this one was easiest to find).
Then, since examples cannot be compiled, I wrote a simple PAL program (I just copied the example from PAL README.md. Almost immediately it has occurred the p_load function has lost func parameter. In compensation the p_run function has got it. OK, I have corrected.... Compile again, some minor other corrections and viola: there is linked program. Run it..... and "SIGSEGV. In p_close function.
OK, I want to debug library. No idea how to compile with -g, maybe setting CFLAGS will enable it. Trying to ./configure -> error. I have to make make distclean before. Well, trying -> errors. And now it is hopeless situation. I cannot make configure, the only way is probably get a fresh clone and start again. Well, it is not impossible, but should it be like that?
No idea why there are these problems... if I can run any example and then make it more rich and complex I can even find and correct some library errors. But only when I have some starting point.... If already at the begging there are problems I am discouraged. And tired.
So the PAL in current version require further debugging. Probably I will dig in a little, but this way is completely not effective and heavily losing time.
mgrecki
 
Posts: 3
Joined: Sat Mar 28, 2015 1:22 am

Re: How to PAL

Postby peteasa » Sun Jan 29, 2017 3:45 pm

Hi,

See the new pull request https://github.com/parallella/pal/pull/231 plus changes to fix the problems that I think you are experiencing.

The problems that I mentioned in my earlier posts were all sorted quite quickly. One that I could not get confirmation about was the linking of matmul examples that produces an error like this:
Code: Select all
/usr/lib/epiphany-elf/gcc/epiphany-elf/5.2.0/../../../../../epiphany-elf/bin/ld: section .data_bank1 loaded at [0000000000002000,00000000000027ff] overlaps section .text loaded at [00000000000007c8,0000000000002763]
/usr/lib/epiphany-elf/gcc/epiphany-elf/5.2.0/../../../../../epiphany-elf/bin/ld: section .fini loaded at [0000000000002764,000000000000277d] overlaps section .data_bank1 loaded at [0000000000002000,00000000000027ff]
collect2: error: ld returned 1 exit status
Makefile:6170: recipe for target 'examples/math/matmul/matmul-dev-epiphany' failed
make[4]: *** [examples/math/matmul/matmul-dev-epiphany] Error 1

The problem is caused by the size of the example being larger than the space in BANK0_SRAM.. The released code has data and text linked to BANK0_SRAM
Code: Select all
        . = ADDR(.reserved_crt0) + SIZEOF(.reserved_crt0);
        .data_bank0 . : {*.o(.data_bank0)} > BANK0_SRAM
        . = ADDR(.data_bank0) + SIZEOF(.data_bank0);
        .text_bank0 . : {*.o(.text_bank0)} > BANK0_SRAM

        .data_bank1   : {*.o(.data_bank1)} > BANK1_SRAM
        .text_bank1   : {*.o(.text_bank1)} > BANK1_SRAM

My simple fix was to move the text to whole of BANK0 and the data to whole of BANK1 in pal/examples/math/matmul/matmul-internal.ldf:
Code: Select all
   . = ADDR(.reserved_crt0) + SIZEOF(.reserved_crt0);
    .data_bank0 . : {*.o(.data_bank0)} > BANK0_SRAM
-   . = ADDR(.data_bank0) + SIZEOF(.data_bank0);
-   .text_bank0 . : {*.o(.text_bank0)} > BANK0_SRAM
-   
-   .data_bank1   : {*.o(.data_bank1)} > BANK1_SRAM
    .text_bank1   : {*.o(.text_bank1)} > BANK1_SRAM

I have now made a fix for this available.

The test problem you may find is simple to fix.. the build scripts at the moment do not correctly locate the pal/config/test-driver file.. depending on the version of autotools I think... I have provided a simple fix for this and made it available on my pal clone.

Plus you have to comment out a few of the tests that hang at the moment
Code: Select all
============================================================================
Testsuite summary for Parallel Architectures Library 0.3
============================================================================
# TOTAL: 102
# PASS:  74
# SKIP:  26
# XFAIL: 0
# FAIL:  2
# XPASS: 0
# ERROR: 0


So in summary if you just want to get some experience with pal libraries then have a go and clone https://github.com/peteasa/pal/tree/peter-updates.. Not sure if this helps you in anyway.. I suspect that you might using different versions of automake and the sdk and that is causing problems. You can see from the travis build results that the official build and tests do not have any problems.. see https://travis-ci.org/parallella/pal/branches

Peter.
User avatar
peteasa
 
Posts: 108
Joined: Fri Nov 21, 2014 7:04 pm


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 1 guest