Exist an alternative to malloc() for the Epiphany?

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Exist an alternative to malloc() for the Epiphany?

Postby davidl » Tue Mar 10, 2015 1:46 pm

Greetings,

I'm trying to implement a parallel GA on the board, and I want to know if exist an alternative to the function malloc() that can be implemented inside the device code.
If not, it's possible to use directly malloc?

Respectfully,

David
davidl
 
Posts: 5
Joined: Tue Feb 17, 2015 7:16 am

Re: Exist an alternative to malloc() for the Epiphany?

Postby sebraa » Tue Mar 10, 2015 2:46 pm

It is relatively easy to write your own malloc() function. You are then free to out the heap anywhere you like (I use a fixed-size array in local memory). There is a malloc() function provided by the C library, but for me it didn't work correctly (it returned addresses from 0x8F000000 onward, instead of (0x8F800000 + 0x80000 * corenum) onward, which should be the heap). Might have been my fault, though.

However, use care when using dynamic memory on the Epiphany. Generally, systems with little memory and without MMU do not provide the best basis for it (think of memory fragmentation). Keep that in mind and you should be fine, though. :-)
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Exist an alternative to malloc() for the Epiphany?

Postby davidl » Wed Mar 11, 2015 8:24 am

Thank you very much! I'm a noob in the programming world, but I'll try to create my own function as you said!
davidl
 
Posts: 5
Joined: Tue Feb 17, 2015 7:16 am


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 8 guests

cron