This is an archive of the discontinued LLVM Phabricator instance.

[mlir] make the bitwidth of device side index computations configurable
ClosedPublic

Authored by gysit on Jun 24 2020, 9:10 AM.

Details

Summary

The patch makes the index type lowering of the GPU to NVVM/ROCDL conversion configurable. It introduces a pass option that controls the bitwidth used when lowering index computations and uses the LowerToLLVMOptions structure to control the Standard to LLVM lowering.

This patch fixes a use-after-free bug in the reverted patch (https://reviews.llvm.org/D80285). It implements the following changes:

  • Added a getDefaultOptions method to the LowerToLLVMOptions struct that returns a reference to statically allocated default options.
  • Use the getDefaultOptions method to provide default LowerToLLVMOptions (instead of an initializer list).
  • Added comments to clarify the required lifetime of the LowerToLLVMOptions (ConvertStandardToLLVM.h:378 and ConvertStandardToLLVMPass.h:65)

Diff Detail

Event Timeline

gysit created this revision.Jun 24 2020, 9:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2020, 9:10 AM
ftynse accepted this revision.Jun 26 2020, 6:54 AM
ftynse added inline comments.
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h
36

thread_local ?

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
111

Nit: be consistent with spaces after */

mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
127

Please comply with clang-tidy (drop trailing underscore)

This revision is now accepted and ready to land.Jun 26 2020, 6:54 AM
gysit updated this revision to Diff 273734.Jun 26 2020, 7:45 AM

Adressed Alex's comments:

  • make default configuration thread_local
  • fixed clang tidy issues
  • removed unnecessary spaces
gysit marked 3 inline comments as done.Jun 26 2020, 7:46 AM
rriddle added inline comments.Jun 26 2020, 12:05 PM
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h
36

These don't need to be thread_local, static initialization is already thread safe.

gysit updated this revision to Diff 273888.Jun 27 2020, 1:31 AM
  • revert to using static instead of thread_local
  • removed more inconsistent spaces
gysit marked an inline comment as done.Jun 27 2020, 1:32 AM
This revision was automatically updated to reflect the committed changes.