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

Move helper functions out of sse4.2 object #5

Merged
merged 3 commits into from Jul 21, 2017

Conversation

theuni
Copy link

@theuni theuni commented Jun 16, 2017

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.

@theuni
Copy link
Author

theuni commented Jun 16, 2017

Split commits for easier upstreaming. I'll open an upstream PR once ACK'd here.

@@ -18,6 +24,30 @@ static void PthreadCall(const char* label, int result) {
}
}

static inline bool HaveSSE42() {
Copy link
Author

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();
Copy link
Author

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.

@theuni
Copy link
Author

theuni commented Jun 17, 2017

Pushed too soon. I'll re-open after fixing up those issues.

@theuni theuni closed this Jun 17, 2017
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.
@theuni
Copy link
Author

theuni commented Jul 13, 2017

This should be good to go now.

@sipa
Copy link

sipa commented Jul 13, 2017

utACK 4c1e9e0

Copy link

@gmaxwell gmaxwell left a comment

Choose a reason for hiding this comment

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

utACK

@sipa sipa merged commit 8d4eb08 into bitcoin-core:bitcoin-fork Jul 21, 2017
sipa added a commit that referenced this pull request Jul 21, 2017
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
__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;

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?

theuni added a commit to theuni/leveldb that referenced this pull request Jul 31, 2017
- use "#if defined(foo)" rather than "#if foo"
- Use the same guard for the cpuid header and the function
sipa added a commit that referenced this pull request Aug 1, 2017
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
laanwj added a commit to bitcoin/bitcoin that referenced this pull request Aug 2, 2017
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
sickpig pushed a commit to sickpig/BitcoinUnlimited that referenced this pull request Aug 17, 2017
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)
mempko pushed a commit to meritlabs/merit that referenced this pull request Sep 28, 2017
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
cculianu pushed a commit to cculianu/bitcoin-abc that referenced this pull request Oct 5, 2017
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
protonn pushed a commit to argentumproject/argentum that referenced this pull request Jan 11, 2018
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 6, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 6, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 6, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 7, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 8, 2019
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
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
charlesrocket pushed a commit to AXErunners/axe that referenced this pull request Nov 30, 2019
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
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
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
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