Skip to content

Instantly share code, notes, and snippets.

@fogti
Last active July 17, 2024 11:49
Show Gist options
  • Save fogti/fec4d1099a61c39550e167d7805b982f to your computer and use it in GitHub Desktop.
Save fogti/fec4d1099a61c39550e167d7805b982f to your computer and use it in GitHub Desktop.
polymake

polymake, bistellar

env

# it is obv. not necessary to install bliss or nauty system-wide (compiling polymake against them didn't work in my tests)
emerge -av dev-libs/stb dev-perl/App-perlbrew sci-libs/{cddlib,lrslib,soplex} sci-mathematics/{flint,normaliz,singular}

additional references:

problems encountered so far

  • OOM (not enough RAM + swap). A single bistellar.* invocation can easily allocate up to 80GiB.
  • segmentation faults (the backtrace wasn't really helpful and I currently can't find it)
  • stack overflows during AVL; FaceMap tree destroy. (during face_map::tree_traits::destroy_node <-> AVL::tree::destroy_nodes recursion)
  • ASAN appears to prohibit tail-call elimination and massively increases memory usage while decreasing performance.
  • It appears to make sense to compile polymake with LTO and debug symbols (e.g. -ggdb3). ASAN is probably not worth it (unless one encounters a very specific symptom that can't be pinned to some introduction chain)
#!/home/fogti/.local/bin/polymake --script
# Simplify simplicial complex using edge contractions and bistellar flips
use application "topaz";
use strict;
use warnings;
#require "./lib.pl"; # load common functions
my $obname = shift @ARGV;
#my $obname="AK_I_015";
my $outpath="$obname.d";
if (! -d $outpath ) {
mkdir $outpath;
}
my $regdesc="_";
STDOUT->autoflush(1);
print(STDOUT "$obname: starting to load data\n");
my $q=load_data("$obname.poly");
#$q=edge_contraction($q);
print(STDOUT "$obname: loaded data\n");
$q=barycentric_subdivision($q);
print(STDOUT "$obname: triangulated data\n");
$q=bistellar_simplification($q);
print(STDOUT "$obname: simplified data\n");
my $vert = @{$q->F_VECTOR}[0];
if (! -d "$outpath/$vert") {
mkdir "$outpath/$vert";
}
print(STDOUT "$obname: saving data\n");
save($q, "$outpath/$vert/$regdesc.poly");
print(STDOUT "$obname: saved data\n");
#!/usr/bin/zsh
. /etc/profile
. "$HOME/perl5/perlbrew/etc/bashrc"
export PATH="$HOME/.local/bin:$PATH"
if ! [ -n "$1" ]; then
echo "ERROR: no instance specified." 1>&2
exit 1
fi
cd /home/fogti/Uni/poly-stuff
perlbrew use pmperl
time ASAN_OPTIONS=detect_odr_violation=0 LD_PRELOAD=/usr/lib/gcc/x86_64-pc-linux-gnu/13/libasan.so.8 ./bistellar.pl "$1" 2>&1 | tee "$1".log
# NOTE: nauty stuff won't compile as-is
# apply the debian + gentoo patches (see also https://packages.gentoo.org/packages/sci-mathematics/nauty + linked ebuilds)
# and remove the entry mentioning rng.c from polymake-4.*/bundled/nauty/apps/graph/src/build_flags.pl
# also, some headers need to be symlinked into the nauty2_8_6/nauty folder so the can be found (yes this is cursed, some of these headers are generated inside of the polymake build tree)
./configure --prefix="$HOME/.local" --without-bliss --with-nauty-src=~/src/nauty2_8_6 --with-cdd=/usr --with-flint=/usr --with-libnormaliz=/usr --with-lrs-include=/usr/include/lrslib --with-singular=/usr --with-soplex=/usr CFLAGS="-O2 -pipe -march=znver4 -flto -ggdb3" CXXFLAGS="-O2 -pipe -march=znver4 -flto -ggdb3" LDFLAGS="-flto"
total 20
4 drwxr-sr-x 2 fogti fogti 4096 Oct 7 21:44 .
12 drwxr-sr-x 4 fogti fogti 8192 Oct 6 16:09 ..
4 -rw-r--r-- 1 fogti fogti 672 Oct 6 16:09 Makefile.am
0 lrwxrwxrwx 1 fogti fogti 50 Oct 7 21:44 gtools.h -> ../../polymake-4.10/build/staticlib/nauty/gtools.h
0 lrwxrwxrwx 1 fogti fogti 11 Oct 7 21:41 gutils.h -> ../gutils.h
0 lrwxrwxrwx 1 fogti fogti 13 Oct 7 21:41 naugroup.h -> ../naugroup.h
0 lrwxrwxrwx 1 fogti fogti 11 Oct 7 21:41 naurng.h -> ../naurng.h
0 lrwxrwxrwx 1 fogti fogti 14 Oct 7 21:41 nausparse.h -> ../nausparse.h
0 lrwxrwxrwx 1 fogti fogti 12 Oct 7 21:41 nautinv.h -> ../nautinv.h
0 lrwxrwxrwx 1 fogti fogti 52 Oct 7 21:44 naututil.h -> ../../polymake-4.10/build/staticlib/nauty/naututil.h
0 lrwxrwxrwx 1 fogti fogti 49 Oct 7 21:44 nauty.h -> ../../polymake-4.10/build/staticlib/nauty/nauty.h
0 lrwxrwxrwx 1 fogti fogti 13 Oct 7 21:41 schreier.h -> ../schreier.h
0 lrwxrwxrwx 1 fogti fogti 11 Oct 7 21:41 traces.h -> ../traces.h
@fogti
Copy link
Author

fogti commented Jul 17, 2024

Luckily, most of this is no longer relevant, as polymake is packaged again in gentoo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment