how to split a domain by sections?

29 views
Skip to first unread message

Zheng Qihang

unread,
Dec 2, 2024, 10:19:57 AM12/2/24
to isl Development
I want to find a map that can transform a domain into a separated one:


{ [d3]: 0 <= d3 < 1024 } ==> { [tid] -> [td3] : 0 <= tid <= 7 and 128tid <= td3 <= 127 + 128tid }


I tried but only managed to come up with an unsightly solution: 

截屏2024-12-02 23.08.20.png

Does it have a map can perform this transformation above?

Sven Verdoolaege

unread,
Dec 2, 2024, 2:41:43 PM12/2/24
to Zheng Qihang, isl Development
On Mon, Dec 02, 2024 at 07:19:57AM -0800, Zheng Qihang wrote:
> I want to find a map that can transform a domain into a separated one:
>
>
> { [d3]: 0 *<=* d3 *<* 1024 } *==>* { [tid] -> [td3] : 0 *<=* tid *<=* 7
> *and* 128tid *<=* td3 *<=* 127 *+* 128tid }

Since you only show an example and didn't actually explain what you want,
I can only guess that maybe you want something like
{ [x] -> [[x//128] -> [x]] }.

> I tried but only managed to come up with an unsightly solution:
>
> [image: 截屏2024-12-02 23.08.20.png]

Please provide text instead.

skimo

Zheng Qihang

unread,
Dec 2, 2024, 9:13:28 PM12/2/24
to isl Development
Actually, I want to separate a contiguous domain by `parallel` parameters to fit the distributed memory architecture. 
For example, given a domain `{ [d3]: 0 <= d3 < 1024 }` that will be separated among 8 devices, then each device owns: 

| 0..128 | 128..256 | 256..384 | 384..512 | 512..640 | 640..768 | 768..896 | 896..1024 |
|  tid 0   |     tid 1     |    tid 2      |    tid 3      |     tid 4     |     tid 5     |     tid 6     |      tid 7      |

so the relation between tid and domain is `{ [tid] -> [td3] : 0 <= tid <= 7 and 128tid <= td3 <= 127 + 128tid }`

I tried this transformation :
```
parallel = 8
bounds = 1024
tile = bounds//parallel
domainA = isl.set(f"{{ [d3]: 0 <= d3 < {bounds} }}")
splitA = isl.map(f"{{ [tid] -> [td3]: 0 <= tid < {parallel} and {tile}*tid <= td3 < {tile}*(tid+1) }}")

splitA Result : isl.map("{ [tid] -> [td3] : 0 <= tid <= 7 and 128tid <= td3 <= 127 + 128tid }")

```
But this one requires that the `tile` factor be computed on the Python side. It might not be a common solution.
 

Sven Verdoolaege

unread,
Dec 4, 2024, 2:41:05 PM12/4/24
to Zheng Qihang, isl Development
On Mon, Dec 02, 2024 at 06:13:27PM -0800, Zheng Qihang wrote:
> Actually, I want to separate a contiguous domain by `parallel` parameters
> to fit the distributed memory architecture.
> For example, given a domain `{ [d3]: 0 <= d3 < 1024 }` that will be
> separated among 8 devices, then each device owns:
>
> | 0..128 | 128..256 | 256..384 | 384..512 | 512..640 | 640..768 | 768..896
> | 896..1024 |
> | tid 0 | tid 1 | tid 2 | tid 3 | tid 4
> | tid 5 | tid 6 | tid 7 |
>
> so the relation between tid and domain is `{ [tid] -> [td3] : 0 *<=* tid
> *<=* 7 *and* 128tid *<=* td3 *<=* 127 *+* 128tid }`
>
> I tried this transformation :
> ```
> parallel = 8
> bounds = 1024
> tile = bounds//parallel
> domainA = isl.set(f"{{ [d3]: 0 <= d3 < {bounds} }}")
> splitA = isl.map(f"{{ [tid] -> [td3]: 0 <= tid < {parallel} and {tile}*tid
> <= td3 < {tile}*(tid+1) }}")
>
> splitA Result : isl.map("{ [tid] -> [td3] : 0 <= tid <= 7 and 128tid <= td3
> <= 127 + 128tid }")
>
> ```
> But this one requires that the `tile` factor be computed on the Python
> side.

Why is computing the tile size in Python a problem?

Note that you could use

f"{{ [tid] -> [td3=0:{bounds}-1]: tid = td3//{tile} }}"

so that you don't need to specify both parallel and tile.

> It might not be a common solution.

If you are worried about cases where the size is not divisible
by the number of devices, you could just use

tile = (bounds+parallel-1)//parallel

skimo

Zheng Qihang

unread,
Dec 4, 2024, 8:56:02 PM12/4/24
to isl Development
Thank you very much for your answer! It helps me a lot.
Reply all
Reply to author
Forward
0 new messages