Simple (but nontrivial) vectorization in Numpy

f(a, b, c, d) Let’s say we want to explore the behavior of f in some range of parameters. How can we vectorize the function and iterate over all possible combinations? Is building a Cartesian product the best way? We expect this to be very inefficient, like $O(n^2)$ with respect to $O(n)$ inefficient in memory, at least. Let’s say the parameters have a definite number of samples (len(x) or np.shape(x) in pyhon, with x a parameter vector). We change the axis of the numpy vectors, making them multi-dimensional vectors (or, respecting the notion of dimension in algebra, multi-axial): ...

May 9, 2024 · 2 min

Simple Multiprocessing in Julia

In this short post, we analyze the computation of a two-variable function on a grid, that is a common task for exploring physical properties of systems through phase diagrams, and similar using Distributed, Printf @info @sprintf("Number of workers: %d", nprocs()) @everywhere function loop_compute(x) for i in 1:100000000 x += sin(x) end return x end t0 = @elapsed loop_compute(1.0) @info @sprintf("Single eval time [s]: %4.3e", t0) mat = rand(10, 10) t_pmap = @elapsed pmap(loop_compute, mat) @info @sprintf("pmap eval time [s] : %4.3e", t_pmap) t_sing = @elapsed loop_compute.(mat) @info @sprintf("serial eval time [s] : %4.3e", t_sing) @info @sprintf("Speeup ratio: %4444", t_sing/t_pmap) Try to run this simple script using ...

March 27, 2024 · 1 min

Linux Admin Tools

This post is designed to be updated as soon as new tricks come handy. Useful commands Instruction Command Change user su - <username> Change owner chown user:group -R folder Check owner & permissions stat filename List all users with UID cut -d: -f1,3 /etc/passwd List all groups with GID getent group Linux ownership system rwx Owner and permissions: typing la we get informations about the pemissions about a file or a folder ...

February 12, 2024 · 1 min

A clean installation of SLURM scheduler

Desired topology and active services SLURM super quick start guide The guide is available here. On Centos8Stream, we first install MUNGE, then install SLURM by the bzip package. Status of munge can be probed by munge -n | unmunge Installing the SLURM package is done manually wget https://download.schedmd.com/slurm/slurm-23.11.3.tar.bz2 We then unzip, configure, and build SLURM We then need to create, by the SLURM user “slurm”, the directories of log files PID files State save and make them writable. We take inspiration from an existing slurm.conf file. So the directories will be ...

February 11, 2024 · 7 min