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

simple.nim example does not detect SIMD type on OSX #4

Open
sdwfrost opened this issue Dec 20, 2017 · 18 comments
Open

simple.nim example does not detect SIMD type on OSX #4

sdwfrost opened this issue Dec 20, 2017 · 18 comments

Comments

@sdwfrost
Copy link

simple.nim compiles and runs fine on my Ubuntu 16.04 box, but fails with the following under OSX, using either clang or gcc-7.

./simple
Illegal instruction: 4
@jackmott
Copy link
Owner

Thanks for testing that, probably something awry with CPU detection. what hardware is the osx box?

@jackmott
Copy link
Owner

Check out this post:
https://stackoverflow.com/questions/14268887/what-is-the-illegal-instruction-4-error-and-why-does-mmacosx-version-min-10

Any chance that is relevant? Can you set minversion and resolve it?

@sdwfrost
Copy link
Author

That didn't fix it. I get the same error on a Mac Pro (Late 2013), with 3 Ghz 8-core Intel Xeon E3, 64GB 1866 Mhz RAM, running OSX v 10.11.3 (El Capitan), as well as on a Mac Mini Server with El Capitan.

@jackmott
Copy link
Owner

jackmott commented Dec 20, 2017

I wonder if you put a bunch of echos in the cpu identification code to narrow down the LOC that causes the fault?
I have no way to debug OSX issues from here

@sdwfrost
Copy link
Author

The code compiles under debug:

Detected cpu type:SSE41
A + B = R
@[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]
@[0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0]
@[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

The error only comes with -d:release, in which case I can't even echo from the first line.

@jackmott
Copy link
Owner

@sdwfrost just wanted to let you know I am occasionally trying to figure this out as I have time. Been inquiring on the nim forums.

@jackmott
Copy link
Owner

jackmott commented Mar 5, 2018

@sdwfrost new version of nim, and all new cpu detection code! If you can get latest and try this with nim 0.18 and let me know what you get I would appreciate it.

@sdwfrost
Copy link
Author

sdwfrost commented Mar 6, 2018

Hi @jackmott

The code doesn't compile under clang at all:

nim/nim_simd/examples/nimcache/nimsimd_nimsimd.c:120:20: error: expected '(' after 'asm'
                    __asm {
                          ^
1 error generated.

As before, the code compiles with gcc under debug, but I still get an illegal instruction with -d:release. I'm using 0.18.1.

@ghost
Copy link

ghost commented Mar 6, 2018

@sdwfrost the error is here because Nim uses GCC-style assembly in its C files (if you embed ASM from nim)

@jackmott
Copy link
Owner

jackmott commented Mar 6, 2018

@Yardanico hmm, I'm trying to emit both styles of assembly depending on the C compiler used.

@ghost
Copy link

ghost commented Mar 6, 2018

@jackmott well, IDK, but it doesn't work with clang

@jackmott
Copy link
Owner

jackmott commented Mar 6, 2018

I'll get clang set up and figure it out, thanks for the feedback!

@jackmott
Copy link
Owner

jackmott commented Mar 6, 2018

@Yardanico @sdwfrost fix for clang is in, got it working on ubuntu. Will be interesting to see if we still get the illegal instruction with it.

@sdwfrost
Copy link
Author

sdwfrost commented Mar 6, 2018

Hi @jackmott
The package now compiles with clang, but I still get the problem with -d:release where I get the illegal instruction (which I don't get with the debug build)

@jackmott
Copy link
Owner

jackmott commented Mar 6, 2018

I guess I have a 3rd excuse to buy a mac

@ghost
Copy link

ghost commented Mar 6, 2018

@jackmott you can also try hackintosh :)

@data-man
Copy link

data-man commented Mar 7, 2018

@jackmott
Maybe these libraries will be useful for you:
google/cpu_features
tycho/cpuid
mgorny/cpuid2cpuflags
anrieff/libcpuid
Maratyszcza/cpuinfo (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)

@whiterock
Copy link

@jackmott
maybe the easiest option just from terminal with no dependencies (?):
sysctl -a | grep machdep.cpu.leaf7_features
and also sysctl -a | grep machdep.cpu.features

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

No branches or pull requests

4 participants