How to know whether the program on the cores is done

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

How to know whether the program on the cores is done

Postby howardhh » Tue Dec 16, 2014 7:55 am

Hi all,

How can I know whether the program on the Epiphany cores is done?
There is a way in the example-program "dotproduct" like setting a flag in the cores. But I don't want to use that method.
howardhh
 
Posts: 28
Joined: Fri Aug 22, 2014 1:50 am

Re: How to know whether the program on the cores is done

Postby notzed » Wed Dec 17, 2014 1:11 am

howardhh wrote:There is a way in the example-program "dotproduct" like setting a flag in the cores. But I don't want to use that method.


Why not?
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: How to know whether the program on the cores is done

Postby howardhh » Wed Dec 17, 2014 1:41 am

Because I want to run the program in the cores several times, which means that I need to assign "0" to the address "0x7000" each loop.
But this can't work except using "e_reset_group(&dev)". Once we reset the device, we need to write data to the cores again, which will cost a lot of time.
Code: Select all
e_write(&dev, i, j, 0x7000, &clr, sizeof(clr));
howardhh
 
Posts: 28
Joined: Fri Aug 22, 2014 1:50 am

Re: How to know whether the program on the cores is done

Postby sebraa » Wed Dec 17, 2014 1:25 pm

I have an iteration counter in shared memory, plus a flag for synchronization. The cores set the flag when they are done, and the host resets it when it is ready for the next iteration.
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: How to know whether the program on the cores is done

Postby notzed » Thu Dec 18, 2014 5:19 am

howardhh wrote:Because I want to run the program in the cores several times, which means that I need to assign "0" to the address "0x7000" each loop.
But this can't work except using "e_reset_group(&dev)". Once we reset the device, we need to write data to the cores again, which will cost a lot of time.
Code: Select all
e_write(&dev, i, j, 0x7000, &clr, sizeof(clr));


Ahh, well that's not what you asked?

Anyway, setting a memory location is the best option but obviously not just setting a fixed address and halting. You can set whatever you want: there's no cache so it's simple to poll a shared variable and use that to synchronise and communicate. Just create a reusable primitive and use that.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: How to know whether the program on the cores is done

Postby howardhh » Thu Dec 18, 2014 9:03 am

Dear sebraa and notzed,

I'm not familiar with the shared memory, could you please give me some hints about that? Just some information about how to set the flag in shared memory is OK.
howardhh
 
Posts: 28
Joined: Fri Aug 22, 2014 1:50 am

Re: How to know whether the program on the cores is done

Postby notzed » Fri Dec 19, 2014 8:28 am

howardhh wrote:Dear sebraa and notzed,

I'm not familiar with the shared memory, could you please give me some hints about that? Just some information about how to set the flag in shared memory is OK.


Ok, sorry. It's a pretty fundamental thing for any multi-threaded/multi-core programming so it's something you should try and get familiar with. There should be tons of info about it on the net as its the type of stuff in a first-semester computer science operating systems course.

All memory is actually shared in this system so you can store it wherever you want so long as each end can find it.

I was going to try to come up with a trivial example but it's not really that trivial and i wouldn't want to give you broken code, and besides that it's something i've already solved a couple of times. In ezesdk i have a thing called an 'ez-port' which provides a double-ended cyclic counter which I use for this type of thing. It's easier in ezesdk because I didn't try to abstract memory accesses (everything is just a pointer as in normal C) but the same type of thing should work in esdk using e_read/write().

The reason it's not entirely trivial is you have to think in parallel and make sure every possible access sequence is properly accounted for (and understand the C language enough to make sure it's doing what you think it is); ideally like ezesdk the esdk should just include some of these primitives where somebody else has already done the tricky bits (I think it might come ... eventually).

All the samples/tests in ezesdk do some sort of shared memory communications from buffers to simple polled variables to graphs of asynchronous message passing. It's still a little rough and I haven't been playing with it much for a few months either.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: How to know whether the program on the cores is done

Postby greytery » Fri Dec 19, 2014 11:10 am

notzed wrote:All memory is actually shared in this system so you can store it wherever you want so long as each end can find it.

Not sure what memory you mean. Any core can address all the physical memory on chip, but the thread talks about writing a flag back to shared memory.
Current limit of addressable shared memory is the top 32MB of the 1GB of host DRAM. This is reserved during the kernel boot, and also assumed in constants when building the SDK.

As discussed here increase shared memory.
ysapir wrote:Theoretically, there is no prevention for the Epiphany to access ALL of the DRAM on the board. Technically, this is really a shared, flat memory space.

BUT, the FPGA eLink interface is currently 'wired' (see here) to perform the address translation from the Epiphany-->Host. This also governs what shared memory the Epiphany cores can physically address.

The whole area is currently in flux and a new version of the shared memory management is planned to be available by Christmas.
This includes (back on-topic) a mailbox mechanism which may suit this purpose.

Season's Greetings,
tery
User avatar
greytery
 
Posts: 205
Joined: Sat Dec 07, 2013 12:19 pm
Location: ^Wycombe, UK

Re: How to know whether the program on the cores is done

Postby notzed » Sun Dec 21, 2014 3:52 am

greytery wrote:
notzed wrote:All memory is actually shared in this system so you can store it wherever you want so long as each end can find it.

Not sure what memory you mean. Any core can address all the physical memory on chip, but the thread talks about writing a flag back to shared memory.


The flag can be on-core or in the external ram. Any core can access it. That means it's shared.

Pretty simple and rather obvious and not too much room for misunderstanding there.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: How to know whether the program on the cores is done

Postby etim » Tue Oct 13, 2015 2:11 pm

I have an iteration counter in shared memory, plus a flag for synchronization. The cores set the flag when they are done, and the host resets it when it is ready for the next iteration.


@sebraa, can you share any code that shows a flag and a counter in shared memory? I've tried for several hours now, but cannot get it to work.
etim
 
Posts: 22
Joined: Sat Jun 27, 2015 6:08 pm

Next

Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 8 guests

cron