Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Conversation

@deven-amd
Copy link
Contributor

@deven-amd deven-amd commented Sep 26, 2019

This PR introduces the ROCDL Dialect (i.e. the ROCDL ops + the code to lower those ROCDL ops to LLVM intrinsics/functions). Think of ROCDL Dialect as analogous to the NVVM Dialect, but for AMD GPUs. This PR contains just the essentials needed to get a simple example up and running. We expect to make further additions to the ROCDL Dialect.

This is the first of 3 PRs we will be filing. Once this PR is merged it will be followed by

  • a PR to add a pass that lowers GPU Dialect to ROCDL Dialect
  • a PR to add a "mlir-rocm-runner" utility

Note: This PR is a follow-up on PR #63. It builds on the work done by @whchung in that PR, and addresses most of the review comments in that PR.


@whchung @joker-eph

Copy link
Contributor

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks

@joker-eph
Copy link
Contributor

The test failed on MacOS:

FAIL: MLIR :: Dialect/LLVMIR/rocdl.mlir (130 of 293)
******************** TEST 'MLIR :: Dialect/LLVMIR/rocdl.mlir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /tmpfs/src/build/bin/mlir-translate -mlir-to-rocdlir /Volumes/BuildData/tmpfs/src/github/mlir/test/Dialect/LLVMIR/rocdl.mlir | /tmpfs/src/build/bin/FileCheck /Volumes/BuildData/tmpfs/src/github/mlir/test/Dialect/LLVMIR/rocdl.mlir
--
Exit Code: 2

Command Output (stderr):
--
Stack dump:
0.	Program arguments: /tmpfs/src/build/bin/mlir-translate -mlir-to-rocdlir /Volumes/BuildData/tmpfs/src/github/mlir/test/Dialect/LLVMIR/rocdl.mlir 
0  mlir-translate           0x00000001073501a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  mlir-translate           0x000000010734f208 llvm::sys::RunSignalHandlers() + 248
2  mlir-translate           0x00000001073507c8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff5570df5a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000001218 _sigtramp + 18446603339082707672
5  mlir-translate           0x00000001071ff2ed llvm::CallInst::Create(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&, llvm::Instruction*) + 333
6  mlir-translate           0x00000001071ff042 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*) + 66
7  mlir-translate           0x0000000107200aed (anonymous namespace)::createDeviceFunctionCall(llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&, llvm::StringRef, int) + 189
8  mlir-translate           0x0000000107200105 (anonymous namespace)::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) + 853
9  mlir-translate           0x0000000107367ae7 mlir::LLVM::ModuleTranslation::convertBlock(mlir::Block&, bool) + 695
10 mlir-translate           0x0000000107368dc5 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::FuncOp) + 2005
11 mlir-translate           0x0000000107369470 mlir::LLVM::ModuleTranslation::convertFunctions() + 1536
12 mlir-translate           0x00000001071ffba4 mlir::translateModuleToROCDLIR(mlir::ModuleOp) + 372
13 mlir-translate           0x0000000107200b89 std::__1::__function::__func<$_0, std::__1::allocator<$_0>, mlir::LogicalResult (mlir::ModuleOp, llvm::raw_ostream&)>::operator()(mlir::ModuleOp&&, llvm::raw_ostream&) + 25
14 mlir-translate           0x00000001072a618d std::__1::__function::__func<mlir::TranslationParser::TranslationParser(llvm::cl::Option&)::$_1, std::__1::allocator<mlir::TranslationParser::TranslationParser(llvm::cl::Option&)::$_1>, mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&, mlir::MLIRContext*)>::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >&&, llvm::raw_ostream&, mlir::MLIRContext*&&) + 189
15 mlir-translate           0x0000000107250663 main + 1155
16 libdyld.dylib            0x00007fff553ff015 start + 1
FileCheck error: '-' is empty.
FileCheck command line:  /tmpfs/src/build/bin/FileCheck /Volumes/BuildData/tmpfs/src/github/mlir/test/Dialect/LLVMIR/rocdl.mlir

@deven-amd
Copy link
Contributor Author

hmm...same failure on Ubuntu as well, but test is passing for me locally

[1/1] Running lit suite /home/rocm-user/llvm-project/llvm/projects/mlir/test/Dialect/LLVMIR
Testing Time: 0.22s
  Expected Passes    : 7

looking into it further

@deven-amd
Copy link
Contributor Author

Still do not know the cause of the CI failures. My local runs pass, even the one I tried on a machine with no ROCm libraries installed!

Hoping the CI failure was an anomaly and the re-run for the new commit passes.

@deven-amd
Copy link
Contributor Author

links to the CI failure logs from the first run
(just in case we need to refer to them again)

Mac : https://source.cloud.google.com/results/invocations/f5be02e6-c7da-4c2e-b72a-0dc7c946b568/log

Ubuntu : https://source.cloud.google.com/results/invocations/0ceb0d9a-d6c2-455a-b2ec-f55181683180/log

@joker-eph
Copy link
Contributor

Hoping the CI failure was an anomaly

I'm not a big believer in the cosmic ray effect here ;)

Did you try the same configuration as the CI? (Release mode?)

@deven-amd
Copy link
Contributor Author

Default is Release mode..right?

Here are the commands I am using to do the build and run

cmake -G Ninja ../llvm -DLLVM_BUILD_EXAMPLES=ON -DLLVM_ENABLE_CXX1Y=Y -DLLVM_TARGETS_TO_BUILD="host"
cmake --build . --target check-mlir

I see that the -DLLVM_ENABLE_CXX1Y=Y is no longer present in the instructions provided on README.md...wonder if that is the difference. Let me try that out.

@deven-amd
Copy link
Contributor Author

that is not it either...

[1584/1584] Running the MLIR regression tests
Testing Time: 4.08s
  Expected Passes    : 289
  Unsupported Tests  : 4

@deven-amd
Copy link
Contributor Author

How do I go about replicating exactly what the Ubuntu CI job is running?

@deven-amd
Copy link
Contributor Author

able to reproduce the error locally now.

It is a Debug vs Release build issue (default build is Debug ... )

looking into it

@deven-amd
Copy link
Contributor Author

found my bug, and fixed it.

@joker-eph , I have squashed all my changes into one commit, and pushed it out. Please re-approve.

thanks

deven

@deven-amd
Copy link
Contributor Author

This PR is missing a test file

  • test/Target/rocdl.mlir is missing
    • also the contents of test/Dialect/LLVMIR/rocdl.mlir contents should be moved here
  • test/Dialect/LLVMIR/rocdl.mlir need updating (use mlir-opt instead of mlir-transform)

will push out these changes as a separate commit in the next PR (Lowering GPU Dialect to ROCDL Dialect), which will be filed once this one is merged.

@joker-eph , let me know if you would rather have that change in this PR

@joker-eph
Copy link
Contributor

I rather have these in the current PR if you can push?

This PR introduces the ROCDL Dialect (i.e. the ROCDL ops + the code to lower those ROCDL ops to LLWM intrinsics/functions). Think of ROCDL Dialect as analogous to the NVVM Dialect, but for AMD GPUs. This PR contains just the essentials needed to get a simple example up and running. We expect to make further additions to the ROCDL Dialect.

This is the first of 3 PRs we will be filing. Once this PR is merged it will be followed by
 * a PR to add a pass that lowers GPU Dialect to ROCDL Dialect
 * a PR to add a "mlir-rocm-runner" utility
@deven-amd
Copy link
Contributor Author

I rather have these in the current PR if you can push?

done. Please re-approve. thanks.

tensorflow-copybara pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 27, 2019
This commit introduces the ROCDL Dialect (i.e. the ROCDL ops + the code to lower those ROCDL ops to LLWM intrinsics/functions). Think of ROCDL Dialect as analogous to the NVVM Dialect, but for AMD GPUs. This patch contains just the essentials needed to get a simple example up and running. We expect to make further additions to the ROCDL Dialect.

This is the first of 3 commits, the follow-up will be:
 * add a pass that lowers GPU Dialect to ROCDL Dialect
 * add a "mlir-rocm-runner" utility

Closes #146

COPYBARA_INTEGRATE_REVIEW=tensorflow/mlir#146 from deven-amd:deven-rocdl-dialect e78e8005c75a78912631116c78dc844fcc4b0de9
PiperOrigin-RevId: 271511259
swift-ci pushed a commit to swiftlang/llvm-project that referenced this pull request Dec 24, 2019
This commit introduces the ROCDL Dialect (i.e. the ROCDL ops + the code to lower those ROCDL ops to LLWM intrinsics/functions). Think of ROCDL Dialect as analogous to the NVVM Dialect, but for AMD GPUs. This patch contains just the essentials needed to get a simple example up and running. We expect to make further additions to the ROCDL Dialect.

This is the first of 3 commits, the follow-up will be:
 * add a pass that lowers GPU Dialect to ROCDL Dialect
 * add a "mlir-rocm-runner" utility

Closes tensorflow/mlir#146

COPYBARA_INTEGRATE_REVIEW=tensorflow/mlir#146 from deven-amd:deven-rocdl-dialect e78e8005c75a78912631116c78dc844fcc4b0de9
PiperOrigin-RevId: 271511259
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants