// Inputs for the Part 3 publication stage (loom-lower-for-to-graph). // A module holds one or more module-scope `dataflow.thread` definitions, each // owning exactly one explicit `loom.spatial_region` publication boundary with // normalized value / stream / memory operand segments and a `graph_name`. // Region sites appear directly in the thread body, inside a fixed `scf.for` // schedule, or inside a nested `scf.if` branch site (nested completion // propagation is supported). `scf.parallel` / `scf.forall` sites are not // sampled. An optional host `func.func` container carries a plain loop that // owns no spatial region. start: {new NTHREAD = random.randint(1, 3); new I = 0; new HOST = random.choice([0, 1])} 'module {\n' host_part thread_list '}\n'; host_part: (HOST == 1) host_func | (HOST == 0) ''; host_func: 'func.func @host_container(%target: memref<4xi32>, %value: i32) {\n' ' %hz = arith.constant 0 : index\n' ' %hf = arith.constant 4 : index\n' ' %ho = arith.constant 1 : index\n' ' scf.for %hi = %hz to %hf step %ho {\n' ' memref.store %value, %target[%hi] : memref<4xi32>\n' ' }\n' ' return\n' '}\n\n'; thread_list: (I < NTHREAD) thread {I += 1} thread_list | (I == NTHREAD) ''; tag: [str(I)]; thread: {new SHAPE = random.choice([0, 1, 2]); new KIND = random.choice([0, 1, 2])} 'dataflow.thread private @thread_' tag ' domain(#dataflow.thread_domain)(%target: memref<1xi32>, %value: i32, %enabled: i1)\n' ' ctrl (%ctrl: none) {\n' body ' dataflow.thread.yield\n' '}\n\n'; body: (SHAPE == 0) region_op | (SHAPE == 1) for_open region_op for_close | (SHAPE == 2) for_open if_open region_op if_close for_close; for_open: ' %c_zero = arith.constant 0 : index\n' ' %c_one = arith.constant 1 : index\n' ' %c_trip = arith.constant 4 : index\n' ' scf.for %iv = %c_zero to %c_trip step %c_one {\n'; for_close: ' }\n'; if_open: ' scf.if %enabled {\n'; if_close: ' }\n'; region_op: (KIND == 0) region_empty | (KIND == 1) region_store | (KIND == 2) region_value; region_empty: ' "loom.spatial_region"()\n' ' <{operandSegmentSizes = array,\n' ' resultSegmentSizes = array}> ({\n' ' ^bb0:\n' ' "loom.spatial_yield"()\n' ' <{operandSegmentSizes = array}> : () -> ()\n' ' }) {graph_name = "graph_' tag '", source_maps = []} : () -> ()\n'; region_store: ' "loom.spatial_region"(%value, %target)\n' ' <{operandSegmentSizes = array,\n' ' resultSegmentSizes = array}> ({\n' ' ^bb0(%payload: i32, %memory: memref<1xi32>):\n' ' %zero = arith.constant 0 : index\n' ' memref.store %payload, %memory[%zero] : memref<1xi32>\n' ' "loom.spatial_yield"()\n' ' <{operandSegmentSizes = array}> : () -> ()\n' ' }) {graph_name = "graph_' tag '", source_maps = []} : (i32, memref<1xi32>) -> ()\n'; region_value: ' %region_out = "loom.spatial_region"(%value)\n' ' <{operandSegmentSizes = array,\n' ' resultSegmentSizes = array}> ({\n' ' ^bb0(%payload: i32):\n' ' %doubled = arith.addi %payload, %payload : i32\n' ' "loom.spatial_yield"(%doubled)\n' ' <{operandSegmentSizes = array}> : (i32) -> ()\n' ' }) {graph_name = "graph_' tag '", source_maps = []} : (i32) -> i32\n';