Create a gpu memset op and corresponding CUDA and ROCm wrappers.
Details
Diff Detail
- Repository
 - rG LLVM Github Monorepo
 
Event Timeline
| mlir/include/mlir/Dialect/GPU/GPUOps.td | ||
|---|---|---|
| 929 | If this has to be a scalar, why is it not a scalar value but a memref?  | |
| mlir/include/mlir/Dialect/GPU/GPUOps.td | ||
|---|---|---|
| 929 | I would probably infer the type of $value from the the element type of $dst (custom<GpuMemsetType>(type($dst), type($value)) in the assembly format, and provide print/parseGpuMemSetType()). Alternatively, use AnyType for $value and check that it matches the element type of $dst in the verifier.  | |
Updating D107548: [mlir] create gpu memset op
Made changes based on internal review:
- explicitly only supporting 32 bit memset for now
 - cuda wrappers call cuMemsetD32Async directly and no longer import the cuda runtime api
 - extracted out getNumElements for gpu memrefs for logic that was common to memset and memcpy
 - mlir memset op takes in a scalar of AnyType instead of AnyMemRef
 
Looks great. Just a nit.
| mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | ||
|---|---|---|
| 958 | You could also use the SameOperandsElementType trait in the op definition to have this check autogenerated,  | |
| mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | ||
|---|---|---|
| 958 | I've tried this but the tests are failing now, I think because the first operand is actually the async token and so it doesn't match the dst and value types?  | |
| mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | ||
|---|---|---|
| 958 | There is a parametrized one (on mobile, will link once in) where one can specify beyond all matching.  | |
| mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | ||
|---|---|---|
| 958 | AllElementTypesMatch<["dst", "value"]> - you are looking at element type of one and type of another, but I think this should do that.  | |
| mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | ||
|---|---|---|
| 958 | Ah thanks, this did the trick!  | |
Thanks for the approval!
I've tried to land this, but I don't seem to have github permissions for llvm (Permission to llvm/llvm-project.git denied to lorenrose1013.)
Is this something I can request, or is someone else able to land the change instead?
If this has to be a scalar, why is it not a scalar value but a memref?