-
Notifications
You must be signed in to change notification settings - Fork 344
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
WIP ARM Neon/AVX2 SIMD implementation. #730
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8c268cd
WIP ARM Neon SIMD implementation.
samyron d8eed56
Removed unnecessary instructions from the Neon portion of convert_UTF…
samyron 9beedac
Added documentation and a bit of refactoring.
samyron 6b6ff88
No extconf.h
byroot edf90b8
Make SIMD configurable via the --enable-use-simd or --disable-use-sim…
samyron 21d5232
Replace HAVE_ARM_NEON_H with ENABLE_SIMD.
samyron 4a04a91
Initial x86 support.
samyron 6ee867a
Fix a typo.
samyron ded09f8
Removed the extconf.h
samyron 8b281a8
Added the extconf.h to .gitignore.
samyron b98ab40
SIMD runtime detection refactor (#1)
samyron 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require "benchmark/ips" | ||
require "json" | ||
require "date" | ||
require "oj" | ||
|
||
Oj.default_options = Oj.default_options.merge(mode: :compat) | ||
|
||
if ENV["ONLY"] | ||
RUN = ENV["ONLY"].split(/[,: ]/).map{|x| [x.to_sym, true] }.to_h | ||
RUN.default = false | ||
elsif ENV["EXCEPT"] | ||
RUN = ENV["EXCEPT"].split(/[,: ]/).map{|x| [x.to_sym, false] }.to_h | ||
RUN.default = true | ||
else | ||
RUN = Hash.new(true) | ||
end | ||
|
||
def implementations(ruby_obj) | ||
state = JSON::State.new(JSON.dump_default_options) | ||
{ | ||
json: ["json", proc { JSON.generate(ruby_obj) }], | ||
oj: ["oj", proc { Oj.dump(ruby_obj) }], | ||
} | ||
end | ||
|
||
def benchmark_encoding(benchmark_name, ruby_obj, check_expected: true, except: []) | ||
json_output = JSON.dump(ruby_obj) | ||
puts "== Encoding #{benchmark_name} (#{json_output.bytesize} bytes)" | ||
|
||
impls = implementations(ruby_obj).select { |name| RUN[name] } | ||
except.each { |i| impls.delete(i) } | ||
|
||
Benchmark.ips do |x| | ||
expected = ::JSON.dump(ruby_obj) if check_expected | ||
impls.values.each do |name, block| | ||
begin | ||
result = block.call | ||
if check_expected && expected != result | ||
puts "#{name} does not match expected output. Skipping" | ||
puts "Expected:" + '-' * 40 | ||
puts expected | ||
puts "Actual:" + '-' * 40 | ||
puts result | ||
puts '-' * 40 | ||
next | ||
end | ||
rescue => error | ||
puts "#{name} unsupported (#{error})" | ||
next | ||
end | ||
x.report(name, &block) | ||
end | ||
x.compare!(order: :baseline) | ||
end | ||
puts | ||
end | ||
|
||
benchmark_encoding "long string", (["this is a test of the emergency broadcast system."*5]*500) |
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.
There is probably a better way to accomplish this.
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.
Yes, also I cleaned up the Rakefile the other day, so this will cause a merge conflict.