Understanding JULIA_CPU_TARGET

I am trying to generate precompiled files for packages that are reusable across a number of computers that share a common DEPOT_PATH through a shared filesystem. I would ideally want to precompile package .so and .ji files only once, and reuse those files for all julia installations.

Although my clusters are fairly homogeneous architecture wise, I do have a small number of instruction set architectures that have to coexist.

According to the docs and this post Repeated precompilation on a cluster makes life difficult, setting the JULIA_CPU_TARGET to generic or some other variant should do the trick.

According to the docs, you can target a number of different targets separated by semicolons, and if I understood correctly, the host machine will take the most suitable ISA inside that precompiled file.

My question is regarding how to set an appropriate value for JULIA_CPU_TARGET. I don’t understand the exact function of all the flags mentioned in the sysimage documentation, such as rdrnd, haswell base(n) and so on.

It appears that the LLVM might be helpful, but as someone without a formal cs background, I’m feel a little bit lost in that document. Do you know any other documents that may explain the basics of LLVM flags for Julia, so as to decide which set of flags has to be put (if at all, maybe just generic may work but I have to test that), and how to determine the compatibility tree of the different instruction set architectures available through JULIA_CPU_TARGET?

2 Likes

Check Sys.CPU_NAME for the hosts that you want to precompile for, and use these as the targets. Add generic as a fallback.

2 Likes

Thanks for your response! Can I add as many hosts as I want? Do you know if these will impact the size of the precompiled objects?

Yes and yes (more = larger size)

1 Like

Just wanted to leave this link here in case it’s helpful. I had similar questions (but about the automatic package precompilation, not with sysimages, but the process is “similar” :wink: )

The upshot is that I also ended up using generic followed by the CPU architectures returned from Sys.CPU_NAME which I crawled on our cluster with a short script, so something like

generic;sandybridge;icelake-server;znver2;haswell;broadwell;znver1;skylake-avx512;znver3;cascadelake

1 Like

You might want to add ,clone_all to all variants except the first. Without it, specific variants will one be compiled if they are necessary or estimated to be superior to a generic one. With it, everything will be duplicated for all architectures.

See System Image Building · The Julia Language.

4 Likes