ForestClaw / forestclaw

Quadtree/octree adaptive PDE solver based based on p4est.
http://www.forestclaw.org
BSD 2-Clause "Simplified" License
58 stars 21 forks source link

Fc2d cudaclaw5 merge #126

Closed scottaiton closed 6 years ago

scottaiton commented 6 years ago

@donnaaboise,

I spent the weekend fixing the build system so that cuda compilation can be configured without any fuss (or at least minimal fuss). And it should be able to compile with shared libraries enabled.

Overview of changes:

donnaaboise commented 6 years ago

I just tried configuring, and get the following configure warnings/errors :

o---------------------------------------
| Checking CUDA
o---------------------------------------
checking nvcc in /cm/shared/apps/cuda90/toolkit/bin... found
checking for /cm/shared/apps/cuda90/toolkit/lib64... yes
checking size of long... 8
checking for cuda.h... yes
checking for cuInit in -lcuda... yes
Putting nvcclibtool in /home/donnacalhoun/projects/ForestClaw/code/forestclaw-build-cuda from files in ../forestclaw
checking for gcc... /cm/shared/apps/cuda90/toolkit/bin/nvcc
checking for C compiler default output file name... 
configure: error: in `/home/donnacalhoun/projects/ForestClaw/code/forestclaw/config/nvcc_dummy':
configure: error: C compiler cannot create executables
See `config.log' for more details.
cp: cannot stat `libtool': No such file or directory
o----------------------------------
| Results for ForestClaw are
o----------------------------------
| CPP:         /cm/shared/apps/openacc/18.0/linux86-64/2018/bin/pgcc -Mcpp
| CPPFLAGS:    
| F77:         gfortran
| FFLAGS:      -O0 -g
| CC:          gcc
| NVCC:        /cm/shared/apps/cuda90/toolkit/bin/nvcc
| CFLAGS:      -O0 -g -std=c99
| CXX:         g++
| CXXFLAGS:    -O0 -g
| LDFLAGS:     
| LIBS:          -lz -lm   
| FLIBS:        -L/cm/shared/apps/cuda90/toolkit//lib64/../lib64 -L/cm/shared/apps/slurm/2.6.7/lib64/../lib64 -L/cm/shared/apps/gcc/4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1 -L/cm/shared/apps/gcc/4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/cm/shared/apps/cuda90/toolkit//lib64 -L/cm/shared/apps/slurm/2.6.7/lib64/slurm -L/cm/shared/apps/slurm/2.6.7/lib64 -L/cm/shared/apps/gcc/4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../.. -lgfortran -lm -lquadmath
o----------------------------------

I am setting CC=gcc, CPP=g++, NVCC=nvcc and --with-cuda=/path/to/cuda. It clearly finds cuda, but can't manage to find libtool. The configure completes, however, and builds a Makefile.

(also odd that CPP is being set to pgcc, but that is a different question)

donnaaboise commented 6 years ago

Also, for some reason, the error message above is not showing up in config.log (e.g. a search on nvcc_dummy in config.log doesn't find anything). Instead, I have this :

configure:33333: gcc -c  -m64 -I/cm/shared/apps/cuda90/toolkit/include -O0 -g -std=c99  conftest.c >&5
configure:33340: $? = 0
configure:33355: result: yes
configure:33368: checking for cuInit in -lcuda
configure:33419: gcc -o conftest  -m64 -I/cm/shared/apps/cuda90/toolkit/include -O0 -g -std=c99  -L/cm/shared/apps/cuda90/toolkit/lib64  conftest.c -lcuda    -lz -lm    >&5
configure:33426: $? = 0
configure:33447: result: yes
configure:33891: creating ./config.status

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##
....

and the configure appears to exit normally.

donnaaboise commented 6 years ago

When I try to build, I get :

 F77    src/solvers/fc2d_cudaclaw5/fortran_source/cudaclaw5_bc2_default.lo
  F77    src/solvers/fc2d_cudaclaw5/fortran_source/cudaclaw5_flux2.lo
  FC     src/solvers/fc2d_cudaclaw5/fortran_source/cudaclaw5_step2.lo
  F77    src/solvers/fc2d_cudaclaw5/fortran_source/cudaclaw5_step2_wrap.lo
./nvcclibtool --silent --tag=CC  \
         --mode=compile /cm/shared/apps/cuda90/toolkit/bin/nvcc \
        -DHAVE_CONFIG_H -I. -I../forestclaw -I./src  -DFCLAW_INIDIR=\"/home/donnacalhoun/projects/ForestClaw/code/forestclaw-build-cuda/local/share/ini\" -I../forestclaw/src -I../forestclaw/src/fortran_source2d -I/home/donnacalhoun/projects/ForestClaw/code/p4est-build-serial/local/include -I/home/donnacalhoun/projects/ForestClaw/code/p4est-build-serial/local/include -I/home/donnacalhoun/projects/ForestClaw/code/p4est-build-serial/local/include    -I../forestclaw/src/patches/clawpatch -I../forestclaw/src/patches/metric -I../forestclaw/src/solvers/fc2d_clawpack4.6  -I../forestclaw/src/solvers/fc2d_clawpack5 -I../forestclaw/src/solvers/fc2d_cudaclaw5   -c -o src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_test.lo ../forestclaw/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_test.cu
make[1]: ./nvcclibtool: Command not found
make[1]: *** [src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_test.lo] Error 127
make[1]: Leaving directory `/home/donnacalhoun/projects/ForestClaw/code/forestclaw-build-cuda'
make: *** [all-recursive] Error 1

I don't have a nvcclibtool in my build directory (but libtool is there).

donnaaboise commented 6 years ago

@cburstedde Do you have any comments?

scottaiton commented 6 years ago

the config/nvcc_dummy is just an empty autotools project that creates libtool file with CC=nvcc. The log file should now be saved in nvcc_config.log in the build directory. Run configure and see what the output is.

donnaaboise commented 6 years ago

I see the problem. In my configuration, I set

CC=gcc \
CFLAGS="-O0 -g -std=c99"

Without this option, I get all kinds of errors wherever I have non-standard C code, i.e.

for(int i = 0; i < 5; i++)

Configure is passing CFLAGS to your script and I get the following error :

configure:2373: checking for C compiler default output file name
configure:2395: /cm/shared/apps/cuda90/toolkit/bin/nvcc -O0 -g -std=c99   conftest.c  >&5
nvcc fatal   : Value 'c99' is not defined for option 'std'

I don't run into this problem with later versions of gcc, but then I think nvcc only works with earlier versions. I can get around this by setting CC=g++.

donnaaboise commented 6 years ago

But now I am running into a problem with libtool. Not quite sure how to fix this one.

  CXXLD  src/libforestclaw.la
  CXXLD  src/patches/clawpatch/libclawpatch.la
  CXXLD  src/solvers/fc2d_clawpack4.6/libclawpack4.6.la
  CXXLD  src/solvers/fc2d_clawpack5/libclawpack5.la
./nvcclibtool --silent --tag=CC  \
         --mode=compile /cm/shared/apps/cuda90/toolkit/bin/nvcc \
        -DHAVE_CONFIG_H -I. -I../forestclaw -I./src  -DFCLAW_INIDIR=\"/home/donnacalhoun/projects/ForestClaw/code/forestclaw-build-cuda/local/share/ini\" -I../forestclaw/src -I../forestclaw/src/fortran_source2d -I/home/donnacalhoun/projects/ForestClaw/code/p4est-build-serial/local/include -I/home/donnacalhoun/projects/ForestClaw/code/p4est-build-serial/local/include -I/home/donnacalhoun/projects/ForestClaw/code/p4est-build-serial/local/include    -I../forestclaw/src/patches/clawpatch -I../forestclaw/src/patches/metric -I../forestclaw/src/solvers/fc2d_clawpack4.6  -I../forestclaw/src/solvers/fc2d_clawpack5 -I../forestclaw/src/solvers/fc2d_cudaclaw5   -c -o src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_test.lo ../forestclaw/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_test.cu
nvcclibtool: Version mismatch error.  This is libtool 2.4.6, but the
nvcclibtool: definition of this LT_INIT comes from libtool 2.2.6b.
nvcclibtool: You should recreate aclocal.m4 with macros from libtool 2.4.6
nvcclibtool: and run autoconf again.
make[1]: *** [src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_test.lo] Error 63
make[1]: Leaving directory `/home/donnacalhoun/projects/ForestClaw/code/forestclaw-build-cuda'
make: *** [all-recursive] Error 1

@cburstedde Do you have any ideas?

cburstedde commented 5 years ago

About finding libtool and friends, it's usually about the PATH.

With ForestClaw, try running ./bootstrap. It runs libtoolize, which must be the proper version found in your PATH and match all your other directories/projects using libtool.