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
check_bytes_arrays_within_dist
function added.
#10
Conversation
Also `hamming_distance_sse41_byte_max_dist` and `hamming_distance_loop_byte_max_dist` added as underlying functions. Added 2 tests(for input args checks and calculations check) and 1 benchmark(with result check too). Version changed from 1.4 to 2.1
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.
This LGTM, just one comment in test_check_bytes_arrays_within_dist_bench
. Once you address it, I'll merge and cut a release!
test/test_hexhamming.py
Outdated
) | ||
def test_check_bytes_arrays_within_dist_bench(benchmark, bytes1, bytes2, max_dist, result): | ||
result = benchmark(check_bytes_arrays_within_dist, bytes1, bytes2, max_dist) | ||
assert result == result |
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.
You can either omit this assert
or rename the passed in result
to expected
. I'm happy for you to just omit the assert
given that you're already testing check_bytes_arrays_within_dist
.
68b7299
to
335c27f
Compare
remove `result` from `test_check_bytes_arrays_within_dist_bench`
done |
Tomorrow and probably next day after too I will have free time, and I will rewrite my code. So don't merge please. |
How can i detect during compilation(or execution) that module was compiled on this machine?(to safely call __builtin_popcount on x86 CPU?) Need this is for binary distribution w/o problems. |
Perhaps you could use Function Multiversioning. |
No, that a bit different thing.... Can be there addition arg in |
something like: and i will check it(assume it will have name or opposite name like |
Just so I understand, are you asking how to
or both? In the case where you're on a platform where a matching wheel exists, it won't build it from source. Therefore, the function multi-versioning might actually be useful because at runtime it will choose the most optimal available function at runtime (provided the targets are defined properly). Note: this is essentially how Tensorflow and Pytorch work with their SIMD accelerated function versions (they actually likely use dynamic library loading instead or in addition, but the concept is similar). However, if you're on a platform where a matching wheel doesn't exist, then I believe it uses the tarball to build (i.e., it basically runs |
"automatically determine what's available (and most optimal) when someone does a python setup.py build/install"
|
You could use
Off-hand, I don't know whether that would clobber existing flags (you should check). Otherwise, I suppose you could do something in setup.py like ...
extra_args = [...]
if os.environ.get("FROM_SRC"):
extra_args.append("-DFROM_SRC")
setup(
...
extra_args=extra_args,
) |
those what i pushed need some review and testing, i tested it with hands as i could. a few benchs of this(i changed your popcnt128 to sse_popcnt128 with realization on SSE3, it was faster on my two PC(82xx,109xxk Intel CPU's):
And there is something a bug(dont pass all tests), need some times to found & fix it... |
That what i pushed is working, but want to try one more thing for hamming_distance_bytes function for sse/avx realization. |
…n `int`(this is a high cost operation for CPU) during distance calculation, and store it only at end.
that's all, finished. this code is ready for binary distribution throw wheel(i think), and is not slower than previous. |
To compile it with studio add to start of "python_hexhamming.h" after line number
|
894137a
to
2e13d1a
Compare
I pulled this into master to cut a new release with it. For further optimizations, feel free to open a new PR. Thanks for your work @bigcat88!! |
Also
hamming_distance_sse41_byte_max_dist
andhamming_distance_loop_byte_max_dist
added as underlying functions.Added 2 tests(for input args checks and calculations check) and 1 benchmark(with result check too).
Version changed from 1.4 to 2.1