ccsb-scripps / AutoDock-Vina

AutoDock Vina
http://vina.scripps.edu
Apache License 2.0
594 stars 208 forks source link

Suggestions to compile vina with AMD AOCC #345

Open xavgit opened 5 days ago

xavgit commented 5 days ago

Hi, on Ubuntu 20.04 I've compiled vina ,latest stable vina version , using the AMD AOCC. In the Makefile I've modified only two lines: GPP=/opt/AMD/aocc-compiler-4.2.0/bin/clang++ C_OPTIONS= -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp It runs without problems and is faster than the g++ compiled version. These optimizations are safe? Any suggestions to improve or make more specific the previous optimizations considering the inner working of vina?

Thanks.

Saverio

rwxayheee commented 3 days ago

Hi @xavgit I never tried, but from a quick look it should be safe to use AOCC compilers. So far did you notice any problems?

It runs without problems and is faster than the g++ compiled version.

Could you elaborate, do you mean the compilation or the docking calculation is faster?

xavgit commented 3 days ago

Hi, as a first experiment I've used Ubuntu 20.04 , AMD Ryzen 7 3700U with Radeon Vega Mobile Gfx, aocc-compiler-4.2.0_1_amd64.deb and AutoDock Vina develop. The compilation time for vina with clang++ needs mooore time with respect g++. The make output is: $ make fatal: not a git repository (or any of the parent directories): .git /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -I ../../../src/lib -o main.o -c ../../../src/main/main.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o ad4cache.o -c ../../../src/lib/ad4cache.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o cache.o -c ../../../src/lib/cache.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o non_cache.o -c ../../../src/lib/non_cache.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o conf_independent.o -c ../../../src/lib/conf_independent.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o coords.o -c ../../../src/lib/coords.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o grid.o -c ../../../src/lib/grid.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o szv_grid.o -c ../../../src/lib/szv_grid.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o model.o -c ../../../src/lib/model.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o monte_carlo.o -c ../../../src/lib/monte_carlo.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o mutate.o -c ../../../src/lib/mutate.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o parallel_mc.o -c ../../../src/lib/parallel_mc.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o parse_pdbqt.o -c ../../../src/lib/parse_pdbqt.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o quasi_newton.o -c ../../../src/lib/quasi_newton.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o quaternion.o -c ../../../src/lib/quaternion.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o random.o -c ../../../src/lib/random.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o utils.o -c ../../../src/lib/utils.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -o vina.o -c ../../../src/lib/vina.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -L/usr/lib -L. -o vina main.o ad4cache.o cache.o non_cache.o conf_independent.o coords.o grid.o szv_grid.o model.o monte_carlo.o mutate.o parallel_mc.o parse_pdbqt.o quasi_newton.o quaternion.o random.o utils.o vina.o -l boost_system -l boost_thread -l boost_serialization -l boost_filesystem -l boost_program_options /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -I ../../../src/lib -o split.o -c ../../../src/split/split.cpp /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -L/usr/lib -L. -o vina_split split.o -l boost_system -l boost_thread -l boost_serialization -l boost_filesystem -l boost_program_options

For the fatal I can' t say nothing.

Then I have make a very tiny benchmark with 10 molecules using time ( not the best tool ... ) to check the processing time.

The results is With g++ compilation real 20m 7.683s user 146m 20.347s sys 0m 19.090s

With aocc clang++ compilation real 17m 35.104s user 127m 25.247s sys 0m 13.176s

Taking into account the used cpu is a mobile one ( exhaustiveness = 32 ) , maybe is it's worth using aocc clang++.

I should like to make a test with a Threadripper 1950X (a most powerful cpu ) but in this case the PC has Ubuntu 22.04 and the same version of aocc gives problems in the vina compilation. It can't include iostream. The same occurs for the hello world cpp example both for aocc version 4.2.0 and 4.1.0. I'm guessing that this is a problem of the installation of the deb in Ubuntu 22.04. During the docking no errors or warnings in the vina output.

Thanks.

Saverio

rwxayheee commented 3 days ago

Hi @xavgit Thanks so much for the information. That's really interesting and very very helpful.

It can't include iostream.

iostream is required for Vina. Was it not in the Include directories (you could do find /usr -name iostream to see candidates)? If it's missing, could you try installing (or re-installing) libstdc++?

xavgit commented 3 days ago

Ok. Thanks for the suggestion. If I can fix the problem I'll try with the Threadripper and then with the Ryzen 9 16C/32T. I can also test with about 10000 molecules.

Thanks.

Saverio

xavgit commented 3 days ago

Hi, $ find /usr -name iostream /usr/local/cuda-12.3/targets/x86_64-linux/include/cuda/std/detail/libcxx/include/iostream /usr/lib/R/site-library/Rcpp/include/Rcpp/iostream /usr/include/c++/9/iostream /usr/include/c++/11/iostream

A problem of the deb installation?

Thanks.

Saverio

rwxayheee commented 3 days ago

Hi @xavgit There seem to be multiple copies of iostream. What was the exact error you got when trying to include iostream? Was it possibly a compatibility issue because clang++ picked up an incompatible iostream?

In the compilation codes you had: -I /usr/include I think this might have changed the (order of) search paths (I don't know, I might be wrong). If your clang++ was set up with c++/11, could you be more specific (restrictive) about what include path to begin search from, like: -I/usr/include/c++/11

If clang++ can't compile with the corresponding iostream it was set up with, then yes maybe it's a problem with the configuration of the compiler :'( ...

xavgit commented 2 days ago

Hi, thanks again for your suggestions. I've repeated the procedure for compiling vina with aocc clang++. On Ubuntu 20.04

1- Install aocc-4.2.0

2- Run the command: source /opt/AMD/aocc-compiler-4.2.0/setenv_AOCC.sh where its content is:

!/bin/bash

AOCC_INS_DIR="/opt/AMD/aocc-compiler-4.2.0" export PATH=$AOCC_INS_DIR/bin:$AOCC_INS_DIR/share/opt-viewer:$PATH export LIBRARY_PATH=$AOCC_INS_DIR/lib:$AOCC_INS_DIR/lib32:/usr/lib/x86_64-linux-gnu:/usr/lib64:/usr/lib32:/usr/lib:$LIBRARY_PATH export LD_LIBRARY_PATH=$AOCC_INS_DIR/ompd:$AOCC_INS_DIR/lib:$AOCC_INS_DIR/lib32:/usr/lib/x86_64-linux-gnu:/usr/lib64:/usr/lib32:/usr/lib:$LD_LIBRARY_PATH export C_INCLUDE_PATH=$C_INCLUDE_PATH:$AOCC_INS_DIR/include export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$AOCC_INS_DIR/include

3- Run the command: echo $CPLUS_INCLUDE_PATH :/opt/AMD/aocc-compiler-4.2.0/include:/opt/AMD/aocc-compiler-4.2.0/include

4- Add "-c" in in the value of C_OPTIONS of the Makefile in /home/xxxx/sources/AutoDock-Vina-develop/build/linux/release to output more information.

5- Run the command: time make | tee make_output.txt

The compilation ends successfully and I can call vina without problem.

The first output of make is the following: fatal: not a git repository (or any of the parent directories): .git /opt/AMD/aocc-compiler-4.2.0/bin/clang++ -static -pthread -ansi -Wno-long-long -v -O3 -DNDEBUG -std=c++11 -march=znver3 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/include -I ../../../src/lib -o main.o -c ../../../src/main/main.cpp AMD clang version 16.0.3 (CLANG: AOCC_4.2.0-Build#89 2023_12_13) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/AMD/aocc-compiler-4.2.0/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 (in-process) "/opt/AMD/aocc-compiler-4.2.0/bin/clang-16" -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -flto=full -flto-unit -disable-free -clear-ast-before-backend -main-file-name main.cpp -static-define -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu znver3 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/xxxx/sources/AutoDock-Vina-develop/build/linux/release -resource-dir /opt/AMD/aocc-compiler-4.2.0/lib/clang/16 -D NDEBUG -D "VERSION=\"v1.2.5\"" -I /usr/include -I ../../../src/lib -c-isystem . -c-isystem /opt/AMD/aocc-compiler-4.2.0/include -c-isystem /opt/AMD/aocc-compiler-4.2.0/include -cxx-isystem . -cxx-isystem /opt/AMD/aocc-compiler-4.2.0/include -cxx-isystem /opt/AMD/aocc-compiler-4.2.0/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /opt/AMD/aocc-compiler-4.2.0/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-long-long -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/home/xxxx/sources/AutoDock-Vina-develop/build/linux/release -ferror-limit 19 -fopenmp -pthread -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -struct-peel-mem-block-size=16384 -mllvm -x86-convert-cmpmr-to-cmprm -mllvm -enable-branch-combine -mllvm -phi-elim-preserve-cmpjmp-glue -itodcalls -itodcallsbyclone -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o main.o -x c++ ../../../src/main/main.cpp clang -cc1 version 16.0.3 based upon LLVM Mirror.Version.16.0.3 default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include" ignoring nonexistent directory "/include" ignoring duplicate directory "/opt/AMD/aocc-compiler-4.2.0/include" ignoring duplicate directory "/usr/include" as it is a non-system directory that duplicates a system directory

include "..." search starts here:

include <...> search starts here:

../../../src/lib . /opt/AMD/aocc-compiler-4.2.0/include /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward /opt/AMD/aocc-compiler-4.2.0/lib/clang/16/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of the search list. ..................................................

There is again : -I /usr/include.

On Ubuntu 22.04 with the same procedure: $ make | tee make_out_Ubuntu-22.04.txt fatal: not a git repository (or any of the parent directories): .git clang++ -static -pthread -ansi -Wno-long-long -v -O3 -DNDEBUG -std=c++11 -march=znver1 -ftree-vectorize -flto -fopenmp -DVERSION=\"v1.2.5\" -I /usr/local/include -I ../../../src/lib -o main.o -c ../../../src/main/main.cpp AMD clang version 16.0.3 (CLANG: AOCC_4.2.0-Build#89 2023_12_13) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/AMD/aocc-compiler-4.2.0/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12 Candidate multilib: .;@m64 Selected multilib: .;@m64 Found CUDA installation: /usr/local/cuda-12.3, version (in-process) "/opt/AMD/aocc-compiler-4.2.0/bin/clang-16" -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -flto=full -flto-unit -disable-free -clear-ast-before-backend -main-file-name main.cpp -static-define -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu znver1 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/xxxx/sources/AutoDock-Vina-develop/build/linux/release -resource-dir /opt/AMD/aocc-compiler-4.2.0/lib/clang/16 -D NDEBUG -D "VERSION=\"v1.2.5\"" -I /usr/local/include -I ../../../src/lib -c-isystem . -c-isystem /opt/AMD/aocc-compiler-4.2.0/include -cxx-isystem . -cxx-isystem /opt/AMD/aocc-compiler-4.2.0/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++ -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/x86_64-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/backward -internal-isystem /opt/AMD/aocc-compiler-4.2.0/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-long-long -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/home/xxxx/sources/AutoDock-Vina-develop/build/linux/release -ferror-limit 19 -fopenmp -pthread -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -struct-peel-mem-block-size=8192 -mllvm -slp-max-reg-size-def=128 -mllvm -enable-branch-combine -mllvm -phi-elim-preserve-cmpjmp-glue -itodcalls -itodcallsbyclone -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o main.o -x c++ ../../../src/main/main.cpp clang -cc1 version 16.0.3 based upon LLVM Mirror.Version.16.0.3 default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/backward" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" ignoring nonexistent directory "/include" ignoring duplicate directory "/usr/local/include" as it is a non-system directory that duplicates a system directory

include "..." search starts here:

include <...> search starts here:

../../../src/lib . /opt/AMD/aocc-compiler-4.2.0/include /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++ /opt/AMD/aocc-compiler-4.2.0/lib/clang/16/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. ../../../src/main/main.cpp:23:10: fatal error: 'iostream' file not found

include

     ^~~~~~~~~~

1 error generated. make: *** [../../makefile_common:47: main.o] Error 1

Thanks.

Saverio

rwxayheee commented 2 days ago

Hi @xavgit !

I may not be providing the most helpful suggestions, as I'm not able to test on a similar platform.. Just two things I was thinking about after looking at the inputs/outputs:

  1. include search path Could you try -I/usr/include/c++/11?

On ubuntu 20.04, you compiled with: -I /usr/include

but on 22.04, you did with: -I /usr/local/include

I usually don't have a space between -I and the path. If you have iostream located at /usr/include/c++/11, I would try adding -I/usr/include/c++/11 flag and see if clang++ is able to find it. I don't really remember if the search is recursive or not; if not, then it's necessary to specify c++/11 under /usr/include/.

The last thing I would try is to include by full path. Like to replace #include iostream by #inlcude "/usr/include/c++/11/iostream" and see what happens.

  1. compatibility

I'm unfamiliar with AOCC clang++ so i don't know the specific requirements. It seems like AOCC clang++ was set up with GCC 12. I feel that it's best to have the corresponding c++/12 header files, like from libstdc++-12-dev. However, c++/11 files might still work, if there aren't major changes in these files.

The experts in the AOCC (AMD) community might be able to provide better advice on this issue. If you are able to figure this out or have any suggestions on better ways to compile the program, please do let us know :)) thanks again for looking into this

xavgit commented 2 days ago

OK. Thanks again.

Saverio