Shop OBEX P1 Docs P2 Docs Learn Events
P2 Taqoz V2.8: Simple Automatic Multiprocessing — Parallax Forums

P2 Taqoz V2.8: Simple Automatic Multiprocessing

Hi,
perhaps this is inspiring for somebody?
Sometimes I find it somewhat difficult to have enough work in an application for 8 cores. :-)

Some time ago I read an article, where people just added some more MC68000 cards into a bus system, to increase power to do a lot of small tasks. "...In fact, the programmer does not even need to know, how many processors are installed...." forth.org/fd/FD-V11N3.pdf

This is a very simple basic version. The tasks are like polled tasks (just tiny words, which are executed once), but they can be grabbed from a list of ready tasks by the word "workerCog" in a round robin scheme. workerCog can be run by one or more than one cog in parallel. The worker takes it's active task out of the list and after completion reinserts it.

" ' cnt0 +ready" does put the task "cnt0" into the list of ready tasks.
There is a major difference to polls: Here we have non-cooperative multitasking, so you have to make sure not to use the same resource at the same time.

Starting more cogs speeds up things:

TAQOZ# ' workerCog 6 run meas --- 1,055,593,884 cycles= 4,294,921,519ns @200MHz ok
TAQOZ# ' workerCog 5 run meas --- 532,473,868 cycles= 2,662,369,340ns @200MHz ok
TAQOZ# ' workerCog 4 run meas --- 361,353,452 cycles= 1,806,767,260ns @200MHz ok
TAQOZ# ' workerCog 3 run meas --- 278,938,236 cycles= 1,394,691,180ns @200MHz ok
TAQOZ# ' workerCog 2 run meas --- 237,404,668 cycles= 1,187,023,340ns @200MHz ok
TAQOZ# ' workerCog 1 run meas --- 222,407,260 cycles= 1,112,036,300ns @200MHz ok

There are only 5 tasks, so 6 cores are not much faster than 5....

Thanks @bob_g4bby for your work with locks!

Have fun, Christof

Comments

Sign In or Register to comment.