1
$\begingroup$

So I have sets of functions $A$, $B$, $C$, $D$, $E$, and $F$. I want to run them in a nested way. I also want to run some of them in parallel, and some of them in sequence. Here is how that might look:

In Parallel A {
  In Sequence B {
    In Parallel C {
      In Sequence D {
        In Parallel E {
          In Sequence F
        }
      }
    }
  }
}

Now I start getting lost on how this would look. Here is my attempt at explaining it...

Part I

This part I can sort of understand.

Say we have $n$ $A$ processes running in parallel with $\land$.

$$A = a_1 \land a_2 \land \dots \land a_n$$

Within $a_1$, say we have 5 steps running in sequence with $\to$, and $a_2$ is 10 steps, etc. We have:

\begin{align} \land\ a_1 &= b_1 \to b_2 \to \dots \to b_5\\ \land\ a_2 &= b_1 \to b_2 \to \dots \to b_{10}\\ \land\ a_3 &= b_1 \to b_2\\ \dots\\ \land\ a_n &= b_1 \to b_2 \to \dots \to b_n \end{align}

Now, I would like for "all of $A$ to run at the same time". This means that each $a \in A$ is a whole process. That is, if $a_1$ takes 5 steps and $a_2$ takes 10 steps, the whole process won't start over until 10 steps later.

$$A_{1,s=10} \to A_{2,s=10} \to \dotsc \to A_{n,s=10}$$

That means it will sort of look like this:

\begin{align} A_1 &: s\ s\ s\ s\ s\ s\ s\ s\ s\ s\\ A_2 &: s\ s\ s\ s\ s\ w\ w\ w\ w\ w\\ A_3 &: s\ s\ w\ w\ w\ w\ w\ w\ w\ w\\ \dots\\ A_n &: s_n \dots w_n \end{align}

Where $s$ is a step and $w$ is waiting.

Part II

This part is where I get lost.

Now I want to be able to just apply this reasoning to the nested parallel and sequential processes. Informally, so $A$ has started, this means $a_1$ has started, which means $b_1$ has started. Now $b_1$ wont complete until all of the $C$ nested within it have completed, but they are running in parallel.

$$b_1 = c_1 \land c_2 \land \dots \land c_n$$

So it's like:

| a1. . . . .           | a1. . . . . 
| b1. . b2. .           | b1. . b2. . 
| c .   c . .           | c .   c . . 
| c . . c . .           | c . . c . . 
| c .   c . .           | c .   c . . 
| c .   c . .           | c .   c . . 
| c .   c .             | c .   c .   

| a2. . . . . . . . . . | a2. . . . . . . . . .
| b1. . . . b2. . . . . | b1. . . . b2. . . . .
| c . . .   c . . . . . | c . . .   c . . . . .
| c . .     c .         | c . .     c .        
| c . . . . c . . .     | c . . . . c . . .    
| c . .     c . . .     | c . .     c . . .    
| c .       c . . . .   | c .       c . . . .  

Then it goes into further nesting all the way to $F$, which would be hard to draw and is really hard to think about.

Part III

This is where I get quite lost.

Now to model them sequentially.

I have just been wanting to do this:

for a in A:
  for b in B:
    for c in C:
      run c...

But that isn't right. So then I've tried:

for a in A:
  start a
for b in B:
  start b
for c in C:
  start c
for aa in start a
  ... hmm

Now that's not going to work.

So then it's like, if the functions were all flattened somehow, then we could just iterate through them. But I am already really confused by this point.

Question

My question is, how I simulate this on a sequential machine.

Any help would be greatly appreciated.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.