1//===-- ParallelLoopMapperAttr.td - Attribute definition ---*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// Defines the attribute used for driving conversion from scf.parallel to 10// gpu.launch operations 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef PARALLEL_LOOP_MAPPER_ATTR 15#define PARALLEL_LOOP_MAPPER_ATTR 16 17include "mlir/Dialect/GPU/IR/GPUBase.td" 18include "mlir/IR/EnumAttr.td" 19 20def BlockX : I64EnumAttrCase<"BlockX", 0, "block_x">; 21def BlockY : I64EnumAttrCase<"BlockY", 1, "block_y">; 22def BlockZ : I64EnumAttrCase<"BlockZ", 2, "block_z">; 23def ThreadX : I64EnumAttrCase<"ThreadX", 3, "thread_x">; 24def ThreadY : I64EnumAttrCase<"ThreadY", 4, "thread_y">; 25def ThreadZ : I64EnumAttrCase<"ThreadZ", 5, "thread_z">; 26def Sequential : I64EnumAttrCase<"Sequential", 6, "sequential">; 27 28def ProcessorEnum : I64EnumAttr<"Processor", "processor for loop mapping", [ 29 BlockX, BlockY, BlockZ, ThreadX, ThreadY, ThreadZ, Sequential]> { 30 let cppNamespace = "::mlir::gpu"; 31} 32 33// Attribute that drives conversion of a scf.parallel to gpu.launch 34// operation. 35// processor: the hardware id to map to. 36// map : An affine map that is used to pre-process hardware ids before 37// substitution. 38// bound : An affine map that is used to compute the bound of the hardware 39// id based on an upper bound of the number of iterations. 40def ParallelLoopDimMappingAttr 41 : GPU_Attr<"ParallelLoopDimMapping", "loop_dim_map"> { 42 let parameters = (ins 43 EnumParameter<ProcessorEnum>:$processor, 44 "AffineMap":$map, 45 "AffineMap":$bound 46 ); 47 let assemblyFormat = "`<` struct(params) `>`"; 48} 49 50def ParallelLoopMappingAttr : 51 TypedArrayAttrBase<ParallelLoopDimMappingAttr, 52 "parallel loop to processor mapping attribute">; 53 54#endif // PARALLEL_LOOP_MAPPER_ATTR 55