JuliaInterop / Cxx.jl

The Julia C++ Interface
Other
760 stars 107 forks source link

Add env variable JULIA_CXX_CPU to explicitly set LLVM CPU #380

Open oschulz opened 6 years ago

oschulz commented 6 years ago

Currently, precompilation of Cxx.jl results in a PCH-file compiled for the CPU on the current host. This poses a serious problem in environments with multiple CPU types, but shared files (e.g. using different hosts with an NFS home directory). For example, if Cxx.jl is precompiled on a Broadwell CPU, it won't run when logging in to a host with a Skylake CPU, and vice-versa.

I frequently find myself running into this problem, both when switching between workstations of different age, and when running on a compute cluster with two partitions of different CPU type. A workaround is to delete the "Cxx.ji" file every time, but that's not really a viable long-term solution.

A similar problematic situations are read-only software container images with baked-in precompiled Julia packages (we use Singularity containers, a lot).

This PR introduces a new enviroment variable JULIA_CXX_CPU that allows the user to specify the CPU type to be used by Cxx.jl. For example, export JULIA_CXX_CPU="corei7-avx" will allow a shared Cxx.jl installation to be used on a wide range of current (and slightly older) systems.

oschulz commented 6 years ago

Gentle bump.

Gnimuc commented 4 years ago

Hi @oschulz, do you still want this? Please let me know if there is anything I can help with.