Plain – Parallelism Part 1

We did earlier show how we could call a function in a different module. The previous example illustrated a 1:1 call between modules. What I want to do now is a 1:20 call – I want to make 1 call that execute a function in 20 different modules returning different results.

use System
Module ComplexMath
            Func ComputeMe(uint32 x)
                        Raise Continue(x)
            Event Continue (uint32 x)

use System
use ComplexMath
Module MyModule
            int32 arr[30]
            int x     
            for x=0 to 30
                        arr[x] = ComputeMe(x)

This example will not work! It will call ComputeMe 30 times in sequence with no parallelism involved. What I need is a way to request access to 20 x ComplexMath modules simultaneously. I am actually attempting 30, but the last 10 will be in seuence waiting.

This illustrate what I want to do – it is a simple example where I call 20 remote modules and each return the number I give them back into the correct table entry.

use ComplexMath[20] 

This solved the first issue of accessing up to 20 x modules. I create an array and establish a rule that usage from arrays are dynamic by default. Dynamic – as in allocated as I need them so we can access resources in a pool shared with others.

use ComplexMath[20]  static

This however allocate 20 resources that always are allocated to us – no run-time DRA. This will be faster as it don’t need to allocate resources run-time, but it will not share the resources with others.

But, how do I start 20 calls and how do I synchronize their end? Also – I will sometimes require that we call a function and don’t wait on the answer – but as the answer returns I probably would like to process the events. I have to leave these questions in the open for now.

to be continued in part 2 

Leave a Reply