Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Chapel LLVM support #9567

Merged
merged 5 commits into from May 17, 2018
Merged

Conversation

mppf
Copy link
Member

@mppf mppf commented May 17, 2018

Update Chapel to work with master LLVM and improve script for working with LLVM master

  • fixes minor API changes from LLVM 7
  • enables update-llvm script to take an argument specifying branch to use
  • update-llvm also checks out Polly to support current development efforts
  • prototype RV integration included but off by default. It is not ready for prime-time but I didn't want to lose track of the small number of changes.

For example, here is the way to use update-llvm.sh to checkout master version of llvm/clang/...:

# to enable LLVM debug information (not required but might be helpful)
export CHPL_LLVM_DEVELOPER=1
# to enable building LLVM with Chapel compiler
export CHPL_LLVM=llvm

# Clear out previous llvm directory / build
make clobber

# check out the branch of LLVM you want to use
# e.g. release_601
# (if no branch is specified, the script will use a branch name
#  computed from LLVM_VERSION
#  which is the version bundled with Chapel)
# Note, running update-llvm again without clobbering
# will 'git pull --rebase'
cd third-party/llvm
./update-llvm.sh master
cd ../..

# build LLVM and Chapel compiler using it
make

# add built LLVM tools to your path
export PATH=`pwd`/third-party/llvm/install/linux64-gnu/bin/:$PATH
  • full local --llvm testing

Reviewed by @dmk42 - thanks!

mppf added 3 commits May 17, 2018 09:58
TODOs:
 - need to be able to build without Region Vectorizer
 - performance testing
 - need to generate reductions in a way RV can understand
@mppf
Copy link
Member Author

mppf commented May 17, 2018

@ysahil97 - this works for me like this (starting from the instructions above to build Chapel with LLVM master, and starting from this branch for Chapel):

in s.chpl (this is just your affine_initialization.chpl example):

config const n = 10;
proc test(){
 var A:[1..n] real;
 for i in 1..n{
  A(i) = i;
 }
}
test();
chpl s.chpl --llvm --llvm-print-ir=test --llvm-print-ir-stage=full > s.ll
opt -O3 -polly -analyze -pass-remarks-missed=polly-detect -pass-remarks=polly-detect -pass-remarks-analysis=polly-detect s.ll

Polly outputs:

remark: <unknown>:0:0: The following errors keep this region from being a Scop.
remark: <unknown>:0:0: No profitable polyhedral optimization found
remark: <unknown>:0:0: Invalid Scop candidate ends here.
remark: <unknown>:0:0: The following errors keep this region from being a Scop.
remark: <unknown>:0:0: Failed to derive an affine function from the loop bounds.
remark: <unknown>:0:0: Invalid Scop candidate ends here.
remark: <unknown>:0:0: The following errors keep this region from being a Scop.
remark: <unknown>:0:0: This function call cannot be handled. Try to inline it.
remark: <unknown>:0:0: Invalid Scop candidate ends here.

@mppf mppf requested a review from dmk42 May 17, 2018 15:13
@mppf mppf changed the title Enable build Chapel with a particular LLVM branch Improve Chapel LLVM support May 17, 2018
@ysahil97
Copy link

Thanks @mppf for this.
The polly output seems to be fine. We can improve on this by appending -g flag after chpl. This helps us in getting the debug info for each and every remark obtained.

@mppf
Copy link
Member Author

mppf commented May 17, 2018

Sure, and that seems to give line numbers for me. But it doesn't say what function was called etc.

@mppf
Copy link
Member Author

mppf commented May 17, 2018

I tried it with --fast too:

$ chpl s.chpl --fast -g --llvm --llvm-print-ir=test --llvm-print-ir-stage=full > s.ll
$ opt -O3 -polly -analyze -pass-remarks-missed=polly-detect -pass-remarks=polly-detect -pass-remarks-analysis=polly-detect s.ll
...
remark: s.chpl:4:0: The following errors keep this region from being a Scop.
remark: s.chpl:4:0: No profitable polyhedral optimization found
remark: s.chpl:5:0: Invalid Scop candidate ends here.
...

Copy link
Contributor

@dmk42 dmk42 left a comment

Choose a reason for hiding this comment

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

Very cool. Looks good.

@mppf mppf merged commit c062427 into chapel-lang:master May 17, 2018
@mppf mppf deleted the disabled-rv-updated-llvm branch May 17, 2018 20:38
dmk42 added a commit that referenced this pull request May 17, 2018
Fix reversed sense of vectorize enable flag (#9577)

[merged to fix breakage in master, asking @mppf to do a post-commit review]

In #9567 , explicit vectorization metadata was enabled when not using the Region Vectorizer, causing messages about failed vectorization to print out. This causes some tests to fail.

This happened because the metadata was enabled when not using the RV, and disabled when using the RV. I believe it was meant to be the other way around.
mppf added a commit that referenced this pull request Jun 12, 2018
Add missing then to update-llvm.sh

Updates a script that can be used manually during LLVM development.
PR #9567 added a conditional but forgot to add the `then` required by bash.

Trivial and not reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants