-
Notifications
You must be signed in to change notification settings - Fork 37
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
Move helper functions out of sse4.2 object #5
Conversation
Split commits for easier upstreaming. I'll open an upstream PR once ACK'd here. |
port/port_posix.cc
Outdated
@@ -18,6 +24,30 @@ static void PthreadCall(const char* label, int result) { | |||
} | |||
} | |||
|
|||
static inline bool HaveSSE42() { |
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.
Whoops, this needs x86(64) guards.
port/port_win.h
Outdated
@@ -168,6 +168,7 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { | |||
return false; | |||
} | |||
|
|||
bool CanAccelerateCRC32C(); |
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.
And the implementation here will need to be copied from port_posix.
Pushed too soon. I'll re-open after fixing up those issues. |
As this file is compiled with sse42 flags, it's possible that the feature discovery ends up using an unsupported runtime flag. Fix this by adding HasAcceleratedCRC32C to the port api, and requiring that it be checked before using AcceleratedCRC32C.
This should be good to go now. |
utACK 4c1e9e0 |
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.
utACK
8d4eb08 Add HasAcceleratedCRC32C to port_win.h (Cory Fields) 77cfbfd crc32: move helper functions out of port_posix_sse.cc (Cory Fields) 4c1e9e0 silence compiler warnings about uninitialized variables (Cory Fields) Pull request description: Addresses #4. As this file is compiled with sse42 flags, it's possible that the feature discovery ends up using an unsupported instruction at runtime. Fix this by adding CanAccelerateCRC32C to the port api, and requiring that it be checked before using AcceleratedCRC32C. Tree-SHA512: 166cc0f4758bc0f22adda2126acad83e0251605a3a14d695fbb34a1d40f2328c4d938fbdcd624964281e6b9fcb3b233d3a8bde010ab889d82ae4f94479c6e545
port/port_posix_sse.cc
Outdated
__cpuid(cpu_info, 1); | ||
return (cpu_info[2] & (1 << 20)) != 0; | ||
#elif defined(__GNUC__) | ||
unsigned int eax, ebx, ecx, edx; | ||
unsigned int eax, ebx, ecx=0, edx; |
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 this isn't the best way to silence this warning. :P The warning was because the compiler is smart enough to see that __cpuid can fail. it'll still work but it's ugly, better to handle the failure like Bitcoin core does?
- use "#if defined(foo)" rather than "#if foo" - Use the same guard for the cpuid header and the function
8b1cd37 fixup define checks. Cleans up some oopses from #5. (Cory Fields) Pull request description: - use "#if defined(foo)" rather than "#if foo" - Use the same guard for the cpuid header and the function Tree-SHA512: fe83895055faf9f5491b9af44262a4dc15d9f56ec8f818e7d66c1002bb6568a90345662828abc7baab0772baa646f9cf13f8ba586ebad5fc3678731b27585885
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962ff0..c521b3ac6 (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields)
b13a68e Squashed 'src/leveldb/' changes from 196962ff0..c521b3ac6 (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
Summary: Includes: bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from Bitcoin-ABC#5 (Cory Fields) Removes many warnings on MacOSX of the form: In file included from leveldb/util/cache.cc:10: In file included from ./leveldb/port/port.h:14: In file included from ./leveldb/port/port_posix.h:47: ./leveldb/port/atomic_pointer.h:55:3: warning: 'OSMemoryBarrier' is deprecated: first deprecated in macOS 10.12 - Use std::atomic_thread_fence() from <atomic> instead [-Wdeprecated-declarations] OSMemoryBarrier(); ^ The bitcoin core patches have been included in BU already by sickpig. Test Plan: make check. Installed and running fine. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D584
Summary: Includes: bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Removes many warnings on MacOSX of the form: In file included from leveldb/util/cache.cc:10: In file included from ./leveldb/port/port.h:14: In file included from ./leveldb/port/port_posix.h:47: ./leveldb/port/atomic_pointer.h:55:3: warning: 'OSMemoryBarrier' is deprecated: first deprecated in macOS 10.12 - Use std::atomic_thread_fence() from <atomic> instead [-Wdeprecated-declarations] OSMemoryBarrier(); ^ The bitcoin core patches have been included in BU already by sickpig. Test Plan: make check. Installed and running fine. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D584
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962ff0..c521b3ac6 (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
b13a68e Squashed 'src/leveldb/' changes from 196962f..c521b3a (Pieter Wuille) Pull request description: Includes: * bitcoin-core/leveldb-subtree#2: Prefer std::atomic over MemoryBarrier (Pieter Wuille) * bitcoin-core/leveldb-subtree#5: Move helper functions out of sse4.2 object (Cory Fields) * bitcoin-core/leveldb-subtree#6: Fixes typo (Dimitris Tsapakidis) * bitcoin-core/leveldb-subtree#10: Clean up compile-time warnings (gcc 7.1) (Matt Corallo) * bitcoin-core/leveldb-subtree#11: fixup define checks. Cleans up some oopses from #5 (Cory Fields) Tree-SHA512: 2b88a99a86ed8c74c860de13a123ea7f5424d35d314be564820cf83aaae8308383403f7cd56f17c241cfee4885699796141fed666559c21044eaabaeea073315
Addresses #4.
As this file is compiled with sse42 flags, it's possible that the feature discovery ends up using an unsupported instruction at runtime.
Fix this by adding CanAccelerateCRC32C to the port api, and requiring that it be checked before using AcceleratedCRC32C.