Skip to content

Commit f6c7ebe

Browse files
[MLIR][SPIRVToLLVM] Updated documentation on entry points and not supported ops
This patch addresses two issues: 1. Not supported ops are updated to pick up the changes in the SPIR-V dialect. 2. Conversion on `spv.ExecutionMode` is updated. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D91881
1 parent 1635dea commit f6c7ebe

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

mlir/docs/SPIRVToLLVMDialectConversion.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,37 @@ non-vector | `spv.CompositeInsert` | `llvm.insertvalue`
368368

369369
### `spv.EntryPoint` and `spv.ExecutionMode`
370370

371-
**Note: these conversions are likely to be changed in the future**
372-
373371
First of all, it is important to note that there is no direct representation of
374-
entry points in LLVM. At the moment, we choose to **remove these ops**, assuming
375-
that the module generated from SPIR-V has no other internal functions (This
376-
assumption is actually made in [`mlir-spirv-cpu-runner`](#`mlir-spirv-cpu-runner`)).
372+
entry points in LLVM. At the moment, we use the following approach:
373+
374+
* `spv.EntryPoint` is simply removed.
375+
376+
* In contrast, `spv.ExecutionMode` may contain important information about the
377+
entry point. For example, `LocalSize` provides information about the
378+
work-group size that can be reused.
377379

378-
However, these ops can be used to see which functions in the module are entry
379-
point functions. `spv.ExecutionMode` also carries the metadata associated with
380-
the entry point such as `LocalSize`, which indicates the workgroup size in the
381-
x, y, and z dimensions. It will be useful to represent this on the LLVM side
382-
(TODO).
380+
In order to preserve this inforamtion, `spv.ExecutionMode` is converted to
381+
a struct global variable that stores the execution mode id and any variables
382+
associated with it. In C, the struct has the structure shown below.
383+
384+
```C
385+
// No values are associated // There are values that are associated
386+
// with this entry point. // with this entry point.
387+
struct { struct {
388+
int32_t executionMode; int32_t executionMode;
389+
}; int32_t values[];
390+
};
391+
```
392+
393+
```mlir
394+
// spv.ExecutionMode @empty "ContractionOff"
395+
llvm.mlir.global external constant @{{.*}}() : !llvm.struct<(i32)> {
396+
%0 = llvm.mlir.undef : !llvm.struct<(i32)>
397+
%1 = llvm.mlir.constant(31 : i32) : !llvm.i32
398+
%ret = llvm.insertvalue %1, %0[0 : i32] : !llvm.struct<(i32)>
399+
llvm.return %ret : !llvm.struct<(i32)>
400+
}
401+
```
383402

384403
### Logical ops
385404

@@ -604,25 +623,31 @@ cover all possible corner cases.
604623

605624
There is no support of the following ops:
606625

607-
* All Atomic ops
626+
* All atomic ops
627+
* All group ops
608628
* All matrix ops
609-
* All GroupNonUniform ops
629+
* All OCL ops
610630

611631
As well as:
612632

613633
* spv.CompositeConstruct
614634
* spv.ControlBarrier
615635
* spv.CopyMemory
616636
* spv.FMod
637+
* spv.GLSL.Acos
638+
* spv.GLSL.Asin
639+
* spv.GLSL.Atan
640+
* spv.GLSL.Cosh
641+
* spv.GLSL.FSign
617642
* spv.GLSL.SAbs
643+
* spv.GLSL.Sinh
618644
* spv.GLSL.SSign
619-
* spv.GLSL.FSign
620645
* spv.MemoryBarrier
621646
* spv.mlir.referenceof
622647
* spv.SMod
623648
* spv.specConstant
624-
* spv.SubgroupBallotKHR
625649
* spv.Unreachable
650+
* spv.VectorExtractDynamic
626651

627652
## Control flow conversion
628653

0 commit comments

Comments
 (0)