Dmp
dmp
¶
A dialect for handling distributed memory parallelism (DMP).
This is xDSL only for now.
This dialect aims to provide the tools necessary to facilitate the creation and lowering of stencil (and other) computations in a manner that makes them run on node clusters.
DIM_X = 0
module-attribute
¶
DIM_Y = 1
module-attribute
¶
DIM_Z = 2
module-attribute
¶
DMP = Dialect('dmp', [SwapOp], [ExchangeDeclarationAttr, ShapeAttr, RankTopoAttr, GridSlice2dAttr, GridSlice3dAttr])
module-attribute
¶
ExchangeDeclarationAttr
¶
Bases: ParametrizedAttribute
This declares a region to be "halo-exchanged". The semantics define that the region specified by offset and size is the received part. To get the section that should be sent, use the source_area() method to get the source area.
- offset gives the coordinates from the origin of the stencil field.
- size gives the size of the buffer to be exchanged.
- source_offset gives a translation (n-d offset) where the data should be read from that is exchanged with the other node.
- neighbor gives the offset in rank to the node this data is to be exchanged with
Example:
offset = [4, 0]
size = [10, 1]
source_offset = [0, 1]
neighbor = -1
To visualize: 0 4 14 xxxxxxxxxx 0 oooooooooo 1
Where x signifies the area that should be received,
and o the area that should be read from.
This data will be exchanged with the node of rank (my_rank -1)
Source code in xdsl/dialects/experimental/dmp.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
name = 'dmp.exchange'
class-attribute
instance-attribute
¶
offset_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
size_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
source_offset_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
neighbor_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
offset: tuple[int, ...]
property
¶
size: tuple[int, ...]
property
¶
source_offset: tuple[int, ...]
property
¶
neighbor: tuple[int, ...]
property
¶
elem_count: int
property
¶
dims: int
property
¶
number of dimensions of the grid
__init__(offset: Sequence[int], size: Sequence[int], source_offset: Sequence[int], neighbor: Sequence[int])
¶
Source code in xdsl/dialects/experimental/dmp.py
from_points(points: Sequence[tuple[int, int]], dim: int, dir_sign: Literal[1, -1], neighbor_offset: int = 1)
classmethod
¶
Source code in xdsl/dialects/experimental/dmp.py
source_area() -> ExchangeDeclarationAttr
¶
Since a HaloExchangeDef by default specifies the area to receive into, this method returns the area that should be read from.
Source code in xdsl/dialects/experimental/dmp.py
print_parameters(printer: Printer) -> None
¶
Source code in xdsl/dialects/experimental/dmp.py
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
¶
Source code in xdsl/dialects/experimental/dmp.py
ShapeAttr
dataclass
¶
Bases: ParametrizedAttribute
This represents shape information that is attached to halo operations.
On the terminology used:
In each dimension, we are given four points. We abbreviate them in annotations to an, bn, cn, dn, with n being the dimension. In 2d, these create the following pattern, higher dimensional examples can be derived from this:
a1 b1 c1 d1 +--+-----------+--+ a0 | | | | +--+-----------+--+ b0 | | | | | | | | | | | | | | | | +--+-----------+--+ c0 | | | | +--+-----------+--+ d0
We can now name these points:
- a: buffer_start
- b: core_start
- c: core_end
- d: buffer_end
This class provides easy getters for these four.
We can also define some common sizes on this object:
- buff_size(n) = dn - an
- core_size(n) = cn - bn
- halo_size(n, start) = bn - an
- halo_size(n, end ) = dn - cn
Source code in xdsl/dialects/experimental/dmp.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
name = 'dmp.shape_with_halo'
class-attribute
instance-attribute
¶
buff_lb_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
buff_ub_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
core_lb_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
core_ub_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
buff_lb: tuple[int, ...]
property
¶
buff_ub: tuple[int, ...]
property
¶
core_lb: tuple[int, ...]
property
¶
core_ub: tuple[int, ...]
property
¶
dims: int
property
¶
Number of axis of the data (len(shape))
from_index_attrs(buff_lb: stencil.IndexAttr | Sequence[int], core_lb: stencil.IndexAttr | Sequence[int], core_ub: stencil.IndexAttr | Sequence[int], buff_ub: stencil.IndexAttr | Sequence[int])
staticmethod
¶
Source code in xdsl/dialects/experimental/dmp.py
buffer_start(dim: int) -> int
¶
core_start(dim: int) -> int
¶
buffer_end(dim: int) -> int
¶
core_end(dim: int) -> int
¶
buff_size(dim: int) -> int
¶
core_size(dim: int) -> int
¶
halo_size(dim: int, at_end: bool = False) -> int
¶
Source code in xdsl/dialects/experimental/dmp.py
print_parameters(printer: Printer) -> None
¶
Source code in xdsl/dialects/experimental/dmp.py
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
¶
Parses the attribute, the format of it is:
dmp.shape_with_halo<[a0,b0,c0,d0]x[a1,b1,c1,d1]x...>¶
so different from the way it's stored internally.
This decision was made to improve readability.
Source code in xdsl/dialects/experimental/dmp.py
RankTopoAttr
¶
Bases: ParametrizedAttribute
This attribute specifies the node layout used to distribute the computation.
dmp.grid<3x3> means nine ranks organized in a 3x3 grid.
This allows for higher-dimensional grids as well, e.g. dmp.grid<3x3x3> for 3-dimensional data.
Source code in xdsl/dialects/experimental/dmp.py
name = 'dmp.topo'
class-attribute
instance-attribute
¶
shape: builtin.DenseArrayBase[builtin.I64]
instance-attribute
¶
__init__(shape: Sequence[int])
¶
as_tuple() -> tuple[int, ...]
¶
node_count() -> int
¶
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
¶
Source code in xdsl/dialects/experimental/dmp.py
DomainDecompositionStrategy
dataclass
¶
Bases: ParametrizedAttribute, ABC
Source code in xdsl/dialects/experimental/dmp.py
GridSlice2dAttr
¶
Bases: DomainDecompositionStrategy
Takes a grid with two or more dimensions, slices it along the first two into equally sized segments.
Source code in xdsl/dialects/experimental/dmp.py
name = 'dmp.grid_slice_2d'
class-attribute
instance-attribute
¶
topology: RankTopoAttr
instance-attribute
¶
diagonals: builtin.BoolAttr
instance-attribute
¶
__init__(topo: tuple[int, ...])
¶
calc_resize(shape: tuple[int, ...]) -> tuple[int, ...]
¶
Source code in xdsl/dialects/experimental/dmp.py
halo_exchange_defs(shape: ShapeAttr) -> Iterable[ExchangeDeclarationAttr]
¶
Source code in xdsl/dialects/experimental/dmp.py
GridSlice3dAttr
¶
Bases: DomainDecompositionStrategy
Takes a grid with two or more dimensions, slices it along the first three.
Source code in xdsl/dialects/experimental/dmp.py
name = 'dmp.grid_slice_3d'
class-attribute
instance-attribute
¶
topology: RankTopoAttr
instance-attribute
¶
diagonals: builtin.BoolAttr
instance-attribute
¶
__init__(topo: tuple[int, ...])
¶
calc_resize(shape: tuple[int, ...]) -> tuple[int, ...]
¶
Source code in xdsl/dialects/experimental/dmp.py
halo_exchange_defs(shape: ShapeAttr) -> Iterable[ExchangeDeclarationAttr]
¶
Source code in xdsl/dialects/experimental/dmp.py
SwapOpHasShapeInferencePatterns
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/experimental/dmp.py
get_shape_inference_patterns()
classmethod
¶
SwapOpMemoryEffect
dataclass
¶
Bases: MemoryEffect
Side effect implementation of dmp.swap.
Source code in xdsl/dialects/experimental/dmp.py
get_effects(op: Operation) -> set[EffectInstance]
classmethod
¶
Source code in xdsl/dialects/experimental/dmp.py
SwapOp
dataclass
¶
Bases: IRDLOperation
Declarative swap of memref regions.