Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
345 stars 230 forks source link

Errors compiling eigen.cpp #2223

Open d-torrance opened 3 years ago

d-torrance commented 3 years ago

After #2221 was merged, there have been some errors compiling eigen.cpp for various PPA builds:

Ubuntu 20.04 arm64

std=gnu++14 -g -fdebug-prefix-map=/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258=. -fstack-protector-strong -Wformat -Werror=format-security -g3 -O2  -Wno-unused-local-typedefs -Wno-unknown-pragmas -std=gnu++17 -Wno-mismatched-tags -I. -DNDEBUG -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -Wdate-time -D_FORTIFY_SOURCE=2 -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.8 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.8 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.8 -I/usr/include -DBOOST_STACKTRACE_LINK -I../d -I./../c -I./../d -Wno-fatal-errors -Wno-unused-variable  -c -Wno-cast-qual eigen.cpp -o eigen.o
virtual memory exhausted: Cannot allocate memory
make[4]: *** [Makefile.common:33: eigen.o] Error 1

(full log)

Ubuntu 21.04 arm64

g++ -pipe -Wall -Wno-shadow -Wcast-qual -Wno-sign-conversion -Wno-sign-compare -Wno-parentheses -Wno-sign-compare  -Wuninitialized -I/usr/include  -Wno-error=pragmas -std=gnu++14 -g -ffile-prefix-map=/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258=. -fstack-protector-strong -Wformat -Werror=format-security -g3 -O2  -Wno-mismatched-tags -Wno-unused-local-typedefs -Wno-unknown-pragmas -std=gnu++17 -Wno-mismatched-tags -I. -DNDEBUG -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -Wdate-time -D_FORTIFY_SOURCE=2 -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cddlib -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.9 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cddlib -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.9 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular -I/usr/include/aarch64-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cddlib -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.9 -I/usr/include -DBOOST_STACKTRACE_LINK -I../d -I./../c -I./../d -Wno-fatal-errors -Wno-unused-variable  -c -Wno-cast-qual eigen.cpp -o eigen.o

as: out of memory allocating 4064 bytes after a total of 1218711552 bytes
{standard input}: Assembler messages:
{standard input}:21415660: Fatal error: eigen.o: memory exhausted
make[3]: *** [Makefile.common:33: eigen.o] Error 2

(full log)

Ubuntu 20.04 ppc64el

g++ -pipe -Wall -Wno-shadow -Wcast-qual -Wno-sign-conversion -Wno-sign-compare -Wno-parentheses -Wno-sign-compare  -Wuninitialized -I/usr/include  -Wno-error=pragmas -std=gnu++14 -g -fdebug-prefix-map=/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258=. -fstack-protector-strong -Wformat -Werror=format-security -g3 -O2  -Wno-unused-local-typedefs -Wno-unknown-pragmas -std=gnu++17 -Wno-mismatched-tags -I. -DNDEBUG -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/include -I/<<BUILDDIR>>/macaulay2-1.18.0.1+git202109031258/M2/usr-host/include  -Wdate-time -D_FORTIFY_SOURCE=2 -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.8 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.8 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular -I/usr/include/powerpc64le-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.8 -I/usr/include -DBOOST_STACKTRACE_LINK -I../d -I./../c -I./../d -Wno-fatal-errors -Wno-unused-variable  -c -Wno-cast-qual eigen.cpp -o eigen.o
{standard input}: Assembler messages:
{standard input}:23153114: Warning: end of file not at end of a line; newline inserted
{standard input}:23154279: Error: unknown pseudo-op: `.2byt'
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[4]: *** [Makefile.common:33: eigen.o] Error 1

(full log)

DanGrayson commented 3 years ago

Oops, we may have to roll that back, unless Anton can quickly figure it out. @antonleykin ?

(There's no reason for as to use 1.2 gb of RAM.)

antonleykin commented 3 years ago

Unfortunately, it does take quite a bit of RAM to compile eigen. It takes even more RAM, if we NO_LAPACK flag is on --- this unleashes eigen for machine precision (which is adds even more templates to resolve).

Perhaps, you can find a way to reduce RAM usage by turning off some optimizations?

DanGrayson commented 3 years ago

... that would be done by overriding make-variables on a file-by-file basis, e.g., by appending -O0 to CXXFLAGS.

antonleykin commented 3 years ago

The only file in play is e/eigen.cpp. I'd be able to attempt fixing this only on Monday night...

On Fri, Sep 3, 2021, 3:44 PM Daniel R. Grayson @.***> wrote:

... that would be done by overriding make-variables on a file-by-file basis, e.g., by appending -O0 to CXXFLAGS.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Macaulay2/M2/issues/2223#issuecomment-912770486, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANPI3FECMYVXSXWNQ3K5ATUAEQSDANCNFSM5DMBXTTQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

DanGrayson commented 3 years ago

The configure script accepts an option --disable-optimize, which disables all optimization. Maybe Doug could add that downstream. I'd like not to disable optimization upstream unless we have to. Alternatively, Doug could add the line eigen.o : CXXFLAGS += -O0 to e/Makefile.in.

DanGrayson commented 3 years ago

Doug, Anton tried an experiment with adding -O0 to that line, and compiling eigen.cpp still takes a lot of time and a lot of memory.

The file is only 560 lines long, so splitting it up might not be fruitful.

DanGrayson commented 3 years ago

Doug, can you somehow get more memory for those PPA builds?

Do we have any users on those architectures?

DanGrayson commented 3 years ago

Maybe we should forget about eigen and switch to MPLAPACK: https://github.com/nakatamaho/mplapack

DanGrayson commented 3 years ago

Here's a discussion that says clang does better than g++ at compiling eigen.

https://stackoverflow.com/questions/11282305/compiler-memory-consumption-with-template-libraries-boost-eigen

d-torrance commented 3 years ago

Doug, can you somehow get more memory for those PPA builds?

I don't think so.

Do we have any users on those architectures?

ppc64el, probably not, but arm64, maybe. I believe the newer Raspberry Pis are 64 bit, and I imagine some folks may want to install a Debian-based Linux on an Apple Silicon machine.

Here's a discussion that says clang does better than g++ at compiling eigen.

https://stackoverflow.com/questions/11282305/compiler-memory-consumption-with-template-libraries-boost-eigen

This link also mentions that newer versions of GCC are better, too. And indeed, there haven't been any problems compiling eigen.cpp on any architecture in Ubuntu 21.10, which has GCC 11 as the default.

DanGrayson commented 3 years ago

gcc-11 is available, at least, on 21.04.

antonleykin commented 3 years ago

My experiment with clang (ver. 1.0.0-4ubuntu1) on ubuntu 20.04 shows some improvement. At least, it is faster than gcc (ver. 9.3.0).

The following still fails if 4(Gb) is changed to 3.

aleykin3@cos-3m2467:~/M2repos/anton-LAcore/M2/BUILD/anton/builds.tmp/auto-clang/Macaulay2/e$ touch ../../../../../../Macaulay2/e/eigen.c\
pp; ulimit -Sv 4000000; time make
make: Entering directory '/home/aleykin3/M2repos/anton-LAcore/M2/BUILD/anton/builds.tmp/auto-clang/Macaulay2/e'
MKDEP eigen.cpp
 ** making TAGS file
CXX eigen.cpp
make: Leaving directory '/home/aleykin3/M2repos/anton-LAcore/M2/BUILD/anton/builds.tmp/auto-clang/Macaulay2/e'

real    0m51.017s
user    0m49.006s
sys     0m1.943s
DanGrayson commented 2 years ago

I just had to increase the RAM assigned to my Debian virtual machine from 2.4GB to 6GB, just to compile this one file (eigen. cpp). A solution would be good.

d-torrance commented 2 years ago

The latest mipsel build of the Debian package failed at this step:

g++ -pipe -Wall -Wno-shadow -Wcast-qual -Wno-sign-conversion -Wno-sign-compare -Wno-parentheses -Wno-sign-compare  -Wuninitialized -I/usr/include  -Wno-error=pragmas -std=gnu++14 -g -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -g3 -O2  -Wno-mismatched-tags -Wno-unused-local-typedefs -Wno-unknown-pragmas -std=gnu++17 -Wno-mismatched-tags -I. -DNDEBUG -I/<<PKGBUILDDIR>>/M2/include -I/<<PKGBUILDDIR>>/M2/include -I/<<PKGBUILDDIR>>/M2/usr-host/include -I/<<PKGBUILDDIR>>/M2/include -I/<<PKGBUILDDIR>>/M2/include -I/<<PKGBUILDDIR>>/M2/usr-host/include -I/<<PKGBUILDDIR>>/M2/include -I/<<PKGBUILDDIR>>/M2/include -I/<<PKGBUILDDIR>>/M2/usr-host/include -Wdate-time -D_FORTIFY_SOURCE=2 -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cddlib -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.9 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cddlib -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.9 -I/usr/include -DBOOST_STACKTRACE_LINK -isystem /usr/include/libxml2   -DSING_NDEBUG -DOM_NDEBUG -DSING_NDEBUG -DOM_NDEBUG -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular -I/usr/include/mipsel-linux-gnu/singular -I/usr/include/singular   -I/usr/src/gtest  -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG  -I/usr/include/cddlib -I/usr/include/cdd -I/usr/include/eigen3 -I/usr/include/python3.9 -I/usr/include -DBOOST_STACKTRACE_LINK -I../d -I./../c -I./../d -Wno-fatal-errors -Wno-unused-variable -I./memtailor -I./mathic -I./mathicgb  -c -Wno-cast-qual eigen.cpp -o eigen.o

cc1plus: out of memory allocating 7000048 bytes after a total of 20054016 bytes
make[3]: *** [Makefile.common:33: eigen.o] Error 1
DanGrayson commented 2 years ago

Doug, this is preventing the release of M2 on various architectures, right? ( @antonleykin )

DanGrayson commented 2 years ago

One idea is to divide the code in eigen.cpp into 4 separate files. Another idea would be to compile without any optimization.

d-torrance commented 2 years ago

Doug, this is preventing the release of M2 on various architectures, right?

Just on mipsel, which it's never successfully built on, so this isn't super critical.

antonleykin commented 2 years ago

Following up on the idea of breaking eigen.cpp into smaller pieces, here is approximate RAM consumption on Ubuntu 20.04 with gcc.

Compile time/RAM don't seem to be affected much by going down from -O2 to -O0. Compile times are not additive: if we break up eigen.cpp function by function the compile time will definitely grow (it wouldn't be dramatic, but it may double).