I don't use e_read() or e_write() in my code at all. Once I use e_alloc() on the host as sebraa did in his sample, I then use the '.base' member of 'e_mem_t' to determine the base of where the mapped window appears within the host memory address space. As necessary, I then construct/cache pointers to data structures that I care about in shared memory. Thus, e_read() and e_write() turn into "normal" pointer operations. With Ola's help, I also created an extension to the eSDK that facilities the same functionality for Epiphany core memory.
Similarly, on the Epiphany side of things, I use e_get_global_address() to create pointers to memory in other cores. Additionally, I use 'e_emem_config.base' to determine the base address of the external memory from the Epiphany perspective. Thus my e_read() and e_write() are again replaced by pointer operations.
Having reduced things to pointer operations creates three problems. The first, common to either way of doing things (e_read/e_write and pointer arithmetic), is that of synchronization. I implemented some primitives that let me create a common mutex across/between/among the Epiphany cores and the ARM cores. The second is to remember when accessing memory across core/chip boundaries is the 'weak memory order model'. The third is that pointers in memory shared between the ARM and Epiphany are problematic, that is to say, a pointer to a location in shared memory or Epiphany core memory is different than a pointer to that same location from the Epiphany point of view. I solved this by storing offsets from the prospective base pointers, which can be the same. I wrap all of this in C++ classes, and conditionally compile the class to use which ever base is appropriate--the ARM base or the Epiphany base. My class library also supports dynamically allocating/referencing shared memory, from either side of the interface, and when I get time, I plan to add dynamically allocate/reference memory in other Epiphany cores.
I hope my explanation is not to confusing. The end result of the libraries I have written, and the way that I have written them, is that the code I write for the Epiphany looks very similar to the code I write for the ARM. It also avoids hard coded offsets to blocks of external or Epiphany core memory. My code looks like C or C++ code, rather than code with lots of calls to e_read() and e_write(). I push some of the less frequently used code to external memory so that I can reserve Epiphany core memory for the 'good' stuff.
http://parallella.org/forums/viewtopic. ... 4ae9651cc8