Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MultiTaskingClass.f released

28 views
Skip to first unread message

Jos Ven

unread,
Jun 4, 2012, 8:12:56 AM6/4/12
to
I just released MultiTaskingClass.f
This is an update of the previous MultiTask.f

Changes in the MultiTaskingClass.f:
- Moved the task-block out of the dictionary for the taskobjects
- Added cells+@ cells+! #ActiveTasks: task>cfa task>&StkParams
and the waitobject wTask including a demo for wTask.
- Removed the tasks in a chain.
The object wTask does this better and easier.
- ExitTask is now handled by the objects.
Remove ExitTask from your code when it is still there.
- Now maximal 8 parameters can be passed to a task without much
overhead.
All in all it means that many definitions are now able to run
in a submitted task without having to change the submitted definition.

Background information for MultiTaskingClass.f:

CPU's with multiple cores can execute a program faster than cpu's with
a single core. This is done by breaking up a program in smaller
pieces
and than execute all pieces simultaneously.

In multiTaskingClass.f this idea is supported as follows:
Breaking up is possible at the definition level or at the program
level by
the 2 classes iTask and wTask.
Then the pieces are submitted and simultaneously executed in a number
of tasks. The Tasks are clustered in an object for easy access.

Objects defined with iTask can be used as soon as ONE definition
should
be executed in a parallel way and the definition uses a do...loop.
The method Parallel: divides, distributes and submits for execution
the
specified cfa over a number of tasks.
Parallel: takes in account the number of hardware threads, so all
these
threads wil be used during execution.

A started task can pickup its range for the do...loop part by using
the
method GetTaskRange: The initialization of the objects defined with
iTask is automatic.
It is possible to change the number of simultaneous tasks before they
run.

Objects defined with wTask can be used to execute concurrently one or
more
different definitions.
These objects must be initialized with the method Start:
The method Start: takes the number of simultaneous tasks as a
parameter.
It does not start any task.
Use the method SubmitTask: for starting a definition as a task.
When a new task is submitted and the maximum number of simultaneous
tasks
is reached the following will happen:
1) The system will wait till one or more tasks are complete.
2) Then it will submit the task.

At this moment the system is limited to 63 simultaneous tasks for each
taskobject
that is defined with wTask or iTask.

Tasks of both classes will get their parameters at the start on the
stack as soon as
the method To&Task: is used just before the task is submitted.
MultiTaskingClass.f uses preemptive multitasking system of windows.
No need to use pause.

MultiTaskingClass.f can be downloaded at http://home.planet.nl/~josv


I hope you like this new extension for Win32Forth.
Jos

Albert van der Horst

unread,
Jun 5, 2012, 12:45:42 PM6/5/12
to
In article <507a107f-9c6a-4c7a...@d17g2000vbv.googlegroups.com>,
Jos Ven <josv...@gmail.com> wrote:
>I just released MultiTaskingClass.f
>This is an update of the previous MultiTask.f
>
<SNIP>
>
>Background information for MultiTaskingClass.f:
>
>CPU's with multiple cores can execute a program faster than cpu's with
>a single core. This is done by breaking up a program in smaller
>pieces
>and than execute all pieces simultaneously.
>
>In multiTaskingClass.f this idea is supported as follows:
<SNIP>

>
>
>I hope you like this new extension for Win32Forth.

I'm impressed, but I'm not in a position to experiment with multi-core
cpu's on windows.

If I understand correctly any Forth word may be executed, as long as it
has 8 stack items or less as input.
I would be interested to have an example of sorting a 2 Gbyte array
of cells, where the partitioning is split over as much tasks as there
are processors. Especially the timing results.

Something along the line of
: (QSORT)
partition
#idle-proc 0 > IF ['] (QSORT) separate-task ELSE RECURSE THEN
#idle-proc 0 > IF ['] (QSORT) separate-task ELSE RECURSE THEN
;


Further, I presume there is some .dll involved in Windows.
What is it called? From what version of Windows on is it present?

(I had this parpi programming running as hundreds of parallel processes
under Linux 64 bits, but it was not fully under control.
Unlike qsort it has not the option of not using separate processes.)

>Jos


--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Jos Ven

unread,
Jun 5, 2012, 3:31:19 PM6/5/12
to
Hi Albert,

Thank you for you comment.

> If I understand correctly ANY Forth word may be executed, as long as it
> has 8 stack items or less as input.

A small correction. The exact statement is:
All in all it means that MANY definitions are now able to run
in a submitted task without having to change the submitted definition.

Also note that the maximum of 8 can be changed.
I defined it as default since it was not likely to me that you need
more parameters on the stack.

> I would be interested to have an example of sorting a 2 Gbyte array
> of cells, where the partitioning is split over as much tasks as there
> are processors.

Could be done but it takes quite some time to develop such an example.

> Further, I presume there is some .dll involved in Windows.
> What is it called? From what version of Windows on is it present?

It is quite basic.
All the used functions od Windows were already available in Windows
95.
As soon as I looked to my multicore Pentium I realized that
in most cases only about 12,5% was used of its capacity while I was
waiting.

So I decided to change that and let that monster run for me.

Jos
On 5 jun, 18:45, Albert van der Horst <alb...@spenarnc.xs4all.nl>
wrote:
> In article <507a107f-9c6a-4c7a-9f01-c8b111e9b...@d17g2000vbv.googlegroups.com>,
> Jos Ven  <josve...@gmail.com> wrote:>I just released MultiTaskingClass.f
0 new messages