pointer or array in shared_memory?

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

pointer or array in shared_memory?

Postby howardhh » Tue Jan 13, 2015 8:33 am

Hi all,

I have a question about the variables in shared_memory.
I want to put some large-size arrays into the shared_memory by "Mailbox".
For now, I use array ( pos_x[N],pos_y[N]....like this), but the output is not exactly what I want, and the output is different when I change the step and space size of the shared_memory I allocate(this shouldn't happen). But at least, it's close to the right result... Is it possible that the arrays may cause some conflict?
When I try pointer (*pos_x,*pos_y....), the result is totally wrong.

Do you guys have any idea about this situation? Thanks a lot!
howardhh
 
Posts: 28
Joined: Fri Aug 22, 2014 1:50 am

Re: pointer or array in shared_memory?

Postby eliecer » Mon Jan 19, 2015 1:31 pm

Sorry for my English, I'm from Spain.

I can to see that anyone answer your question. I say you my opinion. I think you ask because the data is near but not in the place that you think. If not so excuse me.

If you have int A[3], B[3] and C[3] in the shared memory, if you used a loop "for" from 0 to 20, you can see 0 in 3, 7 and 11 because (0, 1, 2) 3, (4, 5, 6) 7 and (8, 9, 10) 11.

I print two numbers and ENTER to view these

If you have int A[5], B[5] and C[5] in the shared memory, if you used a loop "for" from 0 to 20, you can see 0 in 5, 11 and 17 because (0, 1, 2, 3, 4) 5, (6, 7, 8, 9, 10) 11 and (12, 13, 14, 15, 16) 17.

Why? I think is because the memory is aligned to similar size to 2 integers.

If I try to declared A[3] then Parallella declare A[4] (2x2).
If I try to declared A[5] then Parallella declare A[6] (2x3).

I am not sure, but I think the aligned memory is the problem that you can not to see from host A, B and C continuous. I think you ask because the datas is
User avatar
eliecer
 
Posts: 25
Joined: Fri Sep 26, 2014 1:20 am
Location: Málaga, Spain


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 17 guests

cron