-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add support for @simd #5355
Merged
Merged
Add support for @simd #5355
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ba1b05a
Add @simd support.
0632c7a
Update to work with LLVM 3.4 too (in addition to LLVM 3.3)
83de4ea
Generialize @simd loops to one dimensional ranges instead of requirin…
36b6a2d
Fix names of some TBAA nodes.
34916cf
Fix spelling in comment.
fb35af0
Remove tbaa_decorate from load/stores of local vars described by jl_a…
2e5da98
Treat loading of string pointer as tbaa_const.
c5e4bd1
Improve hoisting of size intrinsic.
2abcadd
Document @simd as experimental.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1319,4 +1319,5 @@ export | |
@sprintf, | ||
@deprecate, | ||
@boundscheck, | ||
@inbounds | ||
@inbounds, | ||
@simd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Support for @simd for | ||
|
||
module SimdLoop | ||
|
||
export @simd | ||
|
||
# Error thrown from ill-formed uses of @simd | ||
type SimdError <: Exception | ||
msg::ASCIIString | ||
end | ||
|
||
# Parse iteration space expression | ||
# symbol '=' range | ||
# symbol 'in' range | ||
function parse_iteration_space( x ) | ||
if !Meta.isexpr(x,[:(=),:in]) | ||
throw( SimdError("= or in expected")) | ||
elseif length(x.args)!=2 | ||
throw( SimdError("simd range syntax is wrong")) | ||
elseif !isa(x.args[1],Symbol) | ||
throw( SimdError("simd loop index must be a symbol")) | ||
else | ||
x.args # symbol, range | ||
end | ||
end | ||
|
||
# Compile Expr x in context of @simd. | ||
function compile(x) | ||
if !Meta.isexpr(x,:for) | ||
throw(SimdError("for loop expected")) | ||
elseif length(x.args)!=2 | ||
throw(SimdError("1D for loop expected")) | ||
else | ||
var,range = parse_iteration_space(x.args[1]) | ||
r = gensym() # Range | ||
n = gensym() # Trip count | ||
s = gensym() # Step | ||
i = gensym() # Index variable | ||
# LLVM vectorizer needs to compute a trip count, so make it obvious. | ||
quote | ||
local $r = $range | ||
local $n = length($r) | ||
local $s = step($r) | ||
local $var = first($r) | ||
local $i = zero($n) | ||
while $i < $n | ||
$(x.args[2]) | ||
$var += $s | ||
$i += 1 | ||
$(Expr(:simdloop)) # Mark loop as SIMD loop | ||
end | ||
end | ||
end | ||
end | ||
|
||
macro simd(forloop) | ||
esc(compile(forloop)) | ||
end | ||
|
||
end # simdloop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might need a
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Now added.