Sharing 32KB memory for each core: program code and data

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Sharing 32KB memory for each core: program code and data

Postby etim » Wed Sep 23, 2015 9:01 pm

How do I know how much space of the 32KB I have for data after I load my program onto the core with something like this:

Code: Select all
e_load_group("e_encoder.srec", &dev, 0, 0, platform.rows, platform.cols, E_FALSE);


Also, how do I know the starting address of the available space I can use for data?
etim
 
Posts: 22
Joined: Sat Jun 27, 2015 6:08 pm

Re: Sharing 32KB memory for each core: program code and data

Postby sebraa » Wed Sep 23, 2015 10:01 pm

Run the e-size program on the Epiphany ELF file. It tells you the static memory consumption of your program.
The dynamic memory consumption (stack and heap) is not easily found out.
Since your code should not use the heap at all, just add some margin for the stack to those numbers.

You can use the upper 16 MB of shared memory for your communication needs.
The lower 16 MB are used for miscellanous stuff (see the linker file for details).
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Sharing 32KB memory for each core: program code and data

Postby etim » Thu Sep 24, 2015 8:05 pm

Thanks, Searching for `e-size` lead me here: http://parallella.org/forums/viewtopic.php?f=13&t=702, with more information.
etim
 
Posts: 22
Joined: Sat Jun 27, 2015 6:08 pm

Re: Sharing 32KB memory for each core: program code and data

Postby etim » Thu Sep 24, 2015 8:11 pm

If I run `e-size` for the hello world demo, I get:

Code: Select all
    e-size e_hello_world.elf
    text      data       bss       dec       hex   filename
    36818      2344        88     39250      9952   e_hello_world.elf


Isn't it saying that it's 39KB? If so how can it work if the local core memory is only 32KB?

Thanks again.
etim
 
Posts: 22
Joined: Sat Jun 27, 2015 6:08 pm

Re: Sharing 32KB memory for each core: program code and data

Postby sebraa » Fri Sep 25, 2015 2:06 pm

Exactly. But remember that Epiphany uses a shared address space. It is possible - but extremely slow - to execute code directly from shared memory. The default linker script puts the C library into shared memory.

For optimal performance, use the internal.ldf linker script, but then your program must fit in 32 KB (unless you manage things by hand).
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Sharing 32KB memory for each core: program code and data

Postby etim » Tue Sep 29, 2015 12:12 pm

OK, I think I'm slowly getting it. I'm just running the hello world example from here: https://github.com/adapteva/epiphany-examples/blob/2015.1/apps/hello-world/build.sh. Here's the build file and it uses the `fast.ldf` linker:

Code: Select all
#!/bin/bash

set -e

ESDK=${EPIPHANY_HOME}
ELIBS="-L ${ESDK}/tools/host/lib"
EINCS="-I ${ESDK}/tools/host/include"
ELDF=${ESDK}/bsps/current/fast.ldf

SCRIPT=$(readlink -f "$0")
EXEPATH=$(dirname "$SCRIPT")
cd $EXEPATH

CROSS_PREFIX=
case $(uname -p) in
   arm*)
      # Use native arm compiler (no cross prefix)
      CROSS_PREFIX=
      ;;
      *)
      # Use cross compiler
      CROSS_PREFIX="arm-linux-gnueabihf-"
      ;;
esac

# Build HOST side application
${CROSS_PREFIX}gcc src/hello_world.c -o Debug/hello_world.elf ${EINCS} ${ELIBS} -le-hal -le-loader -lpthread

# Build DEVICE side program
e-gcc -T ${ELDF} src/e_hello_world.c -o Debug/e_hello_world.elf -le-lib

# Convert ebinary to SREC file
e-objcopy --srec-forceS3 --output-target srec Debug/e_hello_world.elf Debug/e_hello_world.srec


According to the SDK docs, this means " Places all user code and static data in local memory, including the stack. Use to implement fast critical functions. It is the user’s responsibility to ensure that the code fits within the local memory." This difference between `fast` and `internal` is that in `fast` the "standard library" is in External SRAM.

If I ran `e-size` on the hello world elf file and it says its 39KB and I'm using the `fast` linker, how is that not a problem? the code runs. Does the 39KB include the "standard library" in the number?
etim
 
Posts: 22
Joined: Sat Jun 27, 2015 6:08 pm


Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 9 guests

cron