refresh-bio / KMC

Fast and frugal disk based k-mer counter
277 stars 72 forks source link

Apple Silicon Build Issue #201

Open jeremiahpslewis opened 2 years ago

jeremiahpslewis commented 2 years ago

Hi! I'm utterly new to the project, but wanted to build your tool for Apple ARM processors and seem to be hitting the following error:

[16:52:36] g++ -Wall -O3 -static-libgcc -static-libstdc++ -pthread -std=c++14 -c kmc_core/cpu_info.cpp -o kmc_core/cpu_info.o
[16:52:36] In member function ‘void CpuInfoImpl::cpuid(int*, int) const’,
[16:52:36]     inlined from ‘const std::string& CpuInfoImpl::GetBrand()’ at kmc_core/cpu_info.cpp:105:8,
[16:52:36]     inlined from ‘static const std::string& CCpuInfo::GetBrand()’ at kmc_core/cpu_info.cpp:135:31:
[16:52:36] kmc_core/cpu_info.cpp:52:17: error: impossible constraint in ‘asm’
[16:52:36]    52 |                 __asm__("cpuid\n\t"
[16:52:36]       |                 ^~~~~~~
[16:52:36] In member function ‘void CpuInfoImpl::cpuid(int*, int) const’,
[16:52:36]     inlined from ‘const std::string& CpuInfoImpl::GetBrand()’ at kmc_core/cpu_info.cpp:112:9,
[16:52:36]     inlined from ‘static const std::string& CCpuInfo::GetBrand()’ at kmc_core/cpu_info.cpp:135:31:
[16:52:36] kmc_core/cpu_info.cpp:52:17: error: impossible constraint in ‘asm’
[16:52:36]    52 |                 __asm__("cpuid\n\t"
[16:52:36]       |                 ^~~~~~~
[16:52:36] make: *** [Makefile:111: kmc_core/cpu_info.o] Error 1
[16:52:36]  ---> make kmc kmc_dump kmc_tools
[16:52:36]  ---> make kmc kmc_dump kmc_tools
[16:52:36] Previous command exited with 2
[16:52:36] Child Process exited, exit code 2

Is this something that might be amenable to a minor tweak?

jeremiahpslewis commented 2 years ago

Here's the PR for packaging the binary for the Julia ecosystem in case you're interested. :) https://github.com/JuliaPackaging/Yggdrasil/pull/5582

marekkokot commented 2 years ago

Hello! Thanks. Adding support for ARM build is quite high on our priorities list, but we have some things that are higher and need to be completed first. Unfortunately, I'm unable to say when we will add ARM support.

Best Marek

jeremiahpslewis commented 2 years ago

Cool! Good to know it's a known topic, will just deactivate the platform for now. :)

jamshed commented 1 year ago

Hi @marekkokot: mentioning a related update! Recently we released cuttlefish v2.2.0, which builds and runs on M1 and M2. For such, we (@TheJasonFan) patched KMC to adopt SIMDe, and this allows KMC to compile natively for ARM. The update-PR is here. This modification should work on other ARM processors too, we believe.

hmusta commented 1 year ago

I was looking into this and I noticed that the only SIMD commands used in KMC (_mm_stream_si64 and _mm_stream_si128) have no equivalents in ARM (at least, none that I could find), so SIMDe defaults to doing a regular copy in its implementations of these. So maybe incorporating SIMDe into KMC for this is overkill.

marekkokot commented 1 year ago

Hi @jeremiahpslewis @hmusta @jamshed, thank you all very much!

In principle, we prefer to fix such things on our own instead of using big libraries (if possible with an acceptable development cost of course), and here it was only a couple of places in the code to be changed. I've just created a new release with precompiled binaries for ARM64. We would really appreciate any feedback if something is wrong. Thanks again!