[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Parallella Community • View topic - can e_read,e_write pass a two-dimensional array

can e_read,e_write pass a two-dimensional array

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

can e_read,e_write pass a two-dimensional array

Postby Anthony » Wed Jun 03, 2015 9:36 am

hi! i just use two dimensional array in my code,but i dont kown whether the e_read ,e_write can be used like this:

int a[M][N];
for(i=0;i<platform.rows;i++)
for(j=0;j<platform.cols;j++)
e_write(&dev,i,j,0x2000,&a,M*N*sizeof(int));
....


can i pass the array to epiphany platform correctly? Or,how to pass a two-dimensional array between host and device platform

Thanks
Anthony
 
Posts: 16
Joined: Thu May 28, 2015 7:59 am

Re: can e_read,e_write pass a two-dimensional array

Postby skinner » Fri Jun 05, 2015 2:25 pm

Hi !

From what i see, this will only write the content of you two-dimensional array into each eCore on the chip. I guess it could work since you specifically address eCores but you have to keep in mind that each eCore only can have a maximum amout of 32kB of data in his local memory so you have to be careful about the size of your array.

Regards,

Thomas.
skinner
 
Posts: 21
Joined: Mon Jun 01, 2015 11:14 pm

Re: can e_read,e_write pass a two-dimensional array

Postby Anthony » Sun Jun 07, 2015 9:35 am

Hi,Thomas!

you are right,i just want to write arrays to each ecore,,since i want to use the 16 ecores separately run the code,i use the e_load_group function to load programs into them.But i'm not quite sure if there is any difference between one-dimensional array
and two-dimension array,especially the address ,and how to read/write the two-dimension arrays correctly in device/host side.there isn't any examples about two-dimension arrays tranferring :? :? :?

Regards

Anthony
Anthony
 
Posts: 16
Joined: Thu May 28, 2015 7:59 am

Re: can e_read,e_write pass a two-dimensional array

Postby sebraa » Sun Jun 07, 2015 4:34 pm

In C, there are no N-dimensional arrays by default, only one-dimensional arrays. However, if (N-1) dimension sizes are known at compile-time (so that the memory layout is known), then C provides some syntactic sugar. Each element has its own address, and each address is compatible to a void* (and vice versa).

In your example, you copy the whole array into each eCore. But you could also do an e_write of &A[i][j] (one element of the array), with a sizeof(A[0]) for the size, which would only copy one (unique) element to each eCore.
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: can e_read,e_write pass a two-dimensional array

Postby Anthony » Mon Jun 08, 2015 3:29 am

Anthony
 
Posts: 16
Joined: Thu May 28, 2015 7:59 am

Re: can e_read,e_write pass a two-dimensional array

Postby sebraa » Mon Jun 08, 2015 1:18 pm

I think in this case, &a and &a[0][0] are equivalent: The very first element of a C array has the same address as the array itself. You might want to read up on how (multi-dimensional) C arrays are laid out in memory, because that is the magic you need to know here.

If you do e_write(&dev, i, j, 0x2000, &a[0][0], sizeof(a[0])), then you only copy the first element of your array into each core.
If you do e_write(&dev, i, j, 0x2000, &a, M*N*sizeof(a[0][0])), then you copy the whole array into each core (*)
If you do e_write(&dev, i, j, 0x2000, &a[i][j], sizeof(a[0][0])), then you copy a[0][0] to core (0,0), a[0][1] to core (0,1) and so on.

(*) I think that sizeof(a) should work as well, but I am not sure. I tend to avoid these constructs.
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: can e_read,e_write pass a two-dimensional array

Postby Anthony » Mon Jun 08, 2015 1:58 pm

Anthony
 
Posts: 16
Joined: Thu May 28, 2015 7:59 am

Re: can e_read,e_write pass a two-dimensional array

Postby sebraa » Tue Jun 09, 2015 5:15 pm

No idea. I always called e_load() in a loop. I don't think all 16 cores will start simultaneously, so you shouldn't count on it.
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: can e_read,e_write pass a two-dimensional array

Postby skinner » Tue Jun 09, 2015 10:03 pm

I think that if you defined a workgroup containing the 16 cores, striclty regarding the given API you should be able to run your program on all the cores in the same time by using e_load_group. Or rather, if the API is correct, why wouldn't this work ?
skinner
 
Posts: 21
Joined: Mon Jun 01, 2015 11:14 pm

Re: can e_read,e_write pass a two-dimensional array

Postby Anthony » Wed Jun 10, 2015 1:48 am

Anthony
 
Posts: 16
Joined: Thu May 28, 2015 7:59 am


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 13 guests

cron