title :: Use multiple CPUs, set OMP_NUM_THREADS presentation :: scripts :: date :: 2020-03 speaker :: Taylor outline :: Many programs in AFNI can use multiple CPUs/threads + More than 30 programs have been compiled with OpenMP + Ex: 3dQwarp, 3dAllineate, 3dClustSim, 3dUnifize, 3dFWHMx, ... Find out how many CPUs you have on your system + easiest way: "afni_system_check.py -check_all | grep CPU" Find out how many CPUs the parallelized progs are using + easiest way: "3dQwarp -hview", and see terminal for thread count + NB: thread count in opened help file might not be correct (could be old) Can change/specify with OMP_NUM_THREADS environment variable + find out your shell with "echo $0" + if it is bash, then open ~/.bashrc - can add line (change '6' as appropriate): "export OMP_NUM_THREADS=6" - then save+close file - in terminal "source ~/.bashrc" or open new terminal - check, e.g., with "3dQwarp -hview" + if it is tcsh, then open ~/.cshrc - can add line (change '6' as appropriate): "setenv OMP_NUM_THREADS 6" - then save+close file - in terminal "source ~/.cshrc" or open new terminal - check, e.g., with "3dQwarp -hview" Examples are given of setting same variable in bash or tcsh scripts + similar syntax as in setting ~/.bashrc or ~/.cshrc + can make sure variable is passed along to sub-shells + special example if using a cluster (such as NIH's biowulf) - can set the OMP_NUM_THREADS to get set to automatically be the same number of CPUs as the submitted batch/slurm command, which is controlled by $SLURM_CPUS_PER_TASK variable (on Biowulf) - other clusters may have different variable names for submitted CPU usage, but same idea applies