Skip to content

Instantly share code, notes, and snippets.

@tmasthay
Last active May 31, 2024 22:38
Show Gist options
  • Save tmasthay/2e2e7d9e41db4655f88d99dc6ec6a98f to your computer and use it in GitHub Desktop.
Save tmasthay/2e2e7d9e41db4655f88d99dc6ec6a98f to your computer and use it in GitHub Desktop.
Madagascar Executables Fetching
import os
from subprocess import check_output as co
def print_columns(strings, num_columns, column_padding):
# Find the length of the longest string
max_length = max(len(s) for s in strings)
# Calculate the width of each column
column_width = max_length + column_padding
# Calculate the number of rows needed
num_rows = (len(strings) + num_columns - 1) // num_columns
# Create a list of lists to hold the columns
columns = [[] for _ in range(num_columns)]
# Distribute the strings into the columns
for i, string in enumerate(strings):
columns[i % num_columns].append(string)
# Print the columns row by row
for row in range(num_rows):
row_items = []
for col in range(num_columns):
if row < len(columns[col]):
row_items.append(columns[col][row].ljust(column_width))
else:
row_items.append(' ' * column_width) # Fill the gap with spaces
print(''.join(row_items))
def get_local_madagascar_executables():
# run after running build script in this gist
return set([e.strip() for e in os.listdir(f'{os.environ["RSFROOT"]}/bin')])
def get_julia_executables():
url = (
'https://raw.githubusercontent.com/JuliaPackaging/Yggdrasil/'
'c24fc62a04951c3634a0d4270e36c9e7806f0f5b/M/Madagascar/build_tarballs.jl'
)
cmd = f'curl -o build_tarballs.jl {url}'
os.system(cmd)
cmd = """
cat build_tarballs.jl |
grep "ExecutableProduct" |
sed 's/ExecutableProduct("\(.*\)",.*/\\1/'
"""
out = co(cmd, shell=True).decode('utf-8').split('\n')
out = [e.strip() for e in out if e]
return set(out)
if __name__ == "__main__":
lcl_madagascar = get_local_madagascar_executables()
julia_madagascar = get_julia_executables()
in_lcl_not_julia = lcl_madagascar - julia_madagascar
in_julia_not_lcl = julia_madagascar - lcl_madagascar
pc = lambda x : print_columns(x, 4, 3)
print('\n\nLocal Madagascar executables not in Madagascar_jll:')
pc(in_lcl_not_julia)
print('\n\nMadagascar_jll executables not in Local Madagascar:')
pc(in_julia_not_lcl)
#!/bin/bash
# This is 22.04 LTS for me (Pop!_OS 22.04)
UBUNTU_VERSION=$(lsb_release -r | awk '{print $2}')
# Get the git hash
GIT_URL="https://github.com/ahay/src.git"
GIT_HASH=$(git ls-remote $GIT_URL HEAD | awk '{print $1}')
PREFIX=$(pwd)/__PRECOMPILED_BUILD_UBUNTU_${UBUNTU_VERSION}__${GIT_HASH}__
INCLUDE_PATH=$PREFIX/include
LIB_PATH=$PREFIX/lib
./configure \
--prefix=$PREFIX \
CC=$(which gcc) \
CXX=$(which g++) \
CAIROPATH=$INCLUDE_PATH/cairo \
FFMPEGPATH=$INCLUDE_PATH/ffmpeg \
AR=$(which ar) \
CPPPATH=$INCLUDE_PATH \
LIBPATH=$LIB_PATH \
BLAS=openblas
# Build
NUM_CPUS=$(lscpu | grep "^CPU(s):" | grep -v "NUMA" | awk '{print $2}')
make -j$NUM_CPUS
# Install
make install
bash:> python compare.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 91876 100 91876 0 0 781k 0 --:--:-- --:--:-- --:--:-- 780k
Local Madagascar executables not in Madagascar_jll:
sfmedianbalance sfcorop sffoldmap3D sfvaripick
sfgui sfsepcmplx2rsf sfconstraint sfshuffle3
sfewefd3d_multiNode sfgpurtm vpannotate m8rtest
sftif2byte sftracealign sfMCCCnew sfextend1
sfewefd3d_gpu_p2p sfreplace sfpen sfawefd3dgpu
tiffpen sfstaticcorr sfsharadwav sfrtmgeompetsc
x11pen sfgpufbrec3d sflogzero sffft
sfimage sfrec2ps sfadjgradient2d_coupled_gpu sfvelan
sfshuffle sffiglist runonnode sffdac2d
sfipick sfonelayer sfnpyCorr sfvelxf3
latex2wiki sflas2rsf sfTTinv sfpwave3d
sfhelloworld sfintv2avg sfwavegeompetsc sfmpigpufwi
sftdr sfintv2rms gdpen sfdoc
wxvpconvert sfocor3d sfnpyConv sfthreedcube
sfresults sfgpurayt sfR2to3 sffpca
sfasc2rsf sfprefilt scons2jupyter sfgpufwi
sfprep4plot sfthickat sfrfccp sfnderiv
sfaimplfd1 sffindmax sfzcp tkvpconvert
sfpadpt3D sfrmrf sfpclip sfwxipick
sfmpicfftrtm sfwigb sfbrowser sfcgi
sfversion sftelemig2d oglpen sftwolayer
sfaimplfd2 jpegpen sftop sfextend
sfbackus sfewefd3d_gpu_mpi sfbyte2tif sfkill
sftouch sfpgreywfl vplot2png vplot2gif
sfsos sftour sfpetscawefd2d sfvaricost
ppmpen sfgeopar sfbooklist sfunits
sfseekwin sffshift sfvelinvnew sfwem2d_gpu
xtpen sfinvalid sfrealign sfximage
sfpygraph sfviewbin sfrfspecdiv sfsmopick
sfwuab sfwxresults sfewefd2d_gpu_dev sfsubplot
sffbrec sfpysvd sfwiki2static sfvariminim
sfsbslice sfspecfac sftestlist slurm_nodelist2rsf_cluster
sfbatch sfgpuktmig sfsbclip1 vpconvert
sfmarsiswav sfgpufd3d sfgenshots vplot2avi
sfjpg2byte sfbyte2jpg sfwxzoom sfzoom
sfvelinvww sffdlsrtm sfcqrtm sfadjgradient2d_gpu
sfrwe2d sfAzsort sfplsurf sfvelxf
sfbackusave vplot2eps sfinterp sflrrtm
sfcsv2rsf sfconverted pscons sffdct
sfdbmerge sfsbslice2 sfjitter sfgenmask
sfvr3d sfmpipsp sfhandvel2rsf sffindmaximum
cscons sfmatplotlib sfewefd2d_gpu sfsmiss
sfmqrbf sfsplit sfwem3d_gpu sfenergy
sfkilltraces sfpyran sfheatgmres1 sfstf2telewfld
Madagascar_jll executables not in Local Madagascar:
sfnpef5 vpvr3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment