Julia equivalent of C compiler intrinsics?


#21

What are “generic intrinsics”?


#22

I mean the platform agnostic ones. Basically the ones in https://llvm.org/docs/LangRef.html. llvm.fma would be the simplest example but there’s now also loads of masked store/load and what’s not in there… AFAICT, they abstract some functions that doesn’t exist in C as builtin operators but are supported in hardware on multiple platforms and this makes it easier to optimize for all platforms. Or in another word, anything that doesn’t have an arch name in the name…


#23

The llvm langref is really really bad for explaining how to use the machine-specific IR calls correctly and contains no entry at all for things that have no builtin because a recognized idiom exists. In contrast, the intel docs are really good, provide a nice API and compose splendidly with Agner Fog’s tables for performance details.

So, which header file in clang should I read exactly, such that I can grep for the intel _mm_something name and see what to do?


#24

I don’t disagree. I also didn’t write it (not that I can do better) and I’ve had the same frustration… I don’t think it’s ever meant to be a user manual for someone that want to write llvm IR (which isn’t really meant to be hand written anyway…) but just a reference of what can be done and you’ll have to refer to either the implementation or the corresponding C function to learn more about them. FWIW, they can’t give you any performance model at this level since it’s really platform dependent…

I totally agree that the mapping between C and LLVM code is a mess, and that’s probably a big part why both gcc and clang implement the intel intrinsics (the C-API) in C instead…

This isn’t strictly true though. The compilers these days are smart enough to not give you the exact instruction you asked for…

I never remember where they are exactly but since the header name is know I just always look for the file directly. locate immintrin.h shows that my clang 5 headers are in /usr/lib/clang/5.0.1/include.