-
Notifications
You must be signed in to change notification settings - Fork 622
Description
Hey, I've been looking into extending spirv-val
so it can take directories as an input, and I'd like some feedback from the project maintainers on whether they would be happy with such change, and what's their preferred approach for it. For a bit of context (more at the end), this change is needed to improve how we validate SPIR-V MLIR dialect in the LLVM Project, where we need to pass a directory of SPIR-V binaries to spirv-val
.
As currently spirv-val
only accepts a single file, I see 2 ways to extended it:
- [preferred] Allow
spir-val
to accept directories as an input. The tool will internally check if the passed name is a directory or a file, and if it's a directory, it will process all files in that directory (potentially filtered on the magic number to allow mix of files in the directory). This would be fully transparent to the user. - Same as above but we would have a flag (e.g.,
--validate-dir
) indicating that the passed name is a directory, so passing a directory cannot be done accidently.
Once a consensus is reached, I'll work on the implementation and open a PR. I'm also happy to provide any more information.
For more context, in SPIR-V MLIR we have many tests that serialize SPIR-V MLIR into SPIR-V binaries and deserializes it back into MLIR (roundtrip test), however this does not guarantee that the SPIR-V modules that go through the roundtrip adhere to the spec and validation rules. We now want to extend those tests so after serializing MLIR into SPIR-V, spirv-val
is run on the binary to confirm that the SPIR-V MLIR module is a valid SPIR-V. All good for now. The problem that we're facing is that a single MLIR test can contain multiple SPIR-V modules. Until recently all those modules were serialized into a single file, making it unusable with SPIR-V tools (multiple modules in a single file are not allowed). To that end we extended mlir-translate
to create a separate .spv
file for each module in the test (llvm/llvm-project#152678). Now we're able to run spirv-val
on those files using xargs
(llvm/llvm-project#153227), e.g., ls %t/module*.spv | xargs -I{} spirv-val {}
. This however depends on having a shell and external utilities and we would like to avoid it, and pass the directory directly to spirv-val
so the invocation simplifies to spirv-val %t/
.
Many thanks,
Igor