[petsc-users] compiling petsc.h and cusp's headers

Barry Smith bsmith at mcs.anl.gov
Tue Oct 4 15:15:09 CDT 2011


  Are you using the PETSc makefiles to compile it? Or did you make up that compile line yourself? Why not just use the PETSc makefile to compile it? 

  Presumably cusp/thrust has some pattern for what include files need to be included in what order. If you do not know the pattern then why not start by copying what PETSc does, since that compiles? For example
cuspvecimpl.h has 

#include <cublas.h>
#include <cusp/blas.h>
#include <thrust/device_vector.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/transform.h>
#include <thrust/iterator/permutation_iterator.h>

while cuspmatimpl.h has 

#include <../src/vec/vec/impls/seq/seqcusp/cuspvecimpl.h>
#include <cusp/csr_matrix.h>
#include <cusp/multiply.h>
/*for MatCreateSeqAIJCUSPFromTriple*/
#include <cusp/coo_matrix.h>

so start with at least those.   Generally just picking a couple of random include files from some C++ package (like cusp/thrust)  and including them won't work.

   Barry


On Oct 4, 2011, at 2:07 PM, Shiyuan wrote:

> Hi,
>    I cannot compiling a source file with petsc.h and cusp headers like the following:
> 
> #include"petsc.h"
> #include<iostream>
> #include "cusp/csr_matrix.h"
> #include <cusp/krylov/cg.h>
> int main(void){
>     std::cout<<"Hello World!"<<std::endl;
>     return 0;
> }
> 
> I use the following  to compile it:
> 
> nvcc  -m64 -O -arch=sm_13  -c --compiler-options="-Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -O -I/home/guest/sgu1/softwares/petsc-dev/include -I/home/guest/sgu1/softwares/petsc-dev/helena-cxx-nompi-os64-release/include -I/usr/local/cuda/include -I/home/guest/sgu1/softwares/cusp-library/ -I/home/guest/sgu1/softwares/thrust/ -I/home/guest/sgu1/softwares/petsc-dev/include/mpiuni  -DCUDA=1 -I/home/guest/sgu1/softwares/slepc-dev -I/home/guest/sgu1/softwares/slepc-dev/helena-cxx-nompi-os64-release/include -I/home/guest/sgu1/softwares/slepc-dev/include -I/home/guest/sgu1/softwares/ImageMagick-6.7.2/include/ImageMagick  -D__INSDIR__= -I/home/guest/sgu1/softwares/slepc-dev -I/home/guest/sgu1/softwares/slepc-dev/helena-cxx-nompi-os64-release/include -I/home/guest/sgu1/softwares/slepc-dev/include" MyKspTmp4.cu -o MyKspTmp4.o
> 
> and it gives me error:
> /usr/local/cuda/include/thrust/detail/device/cuda/detail/b40c/vector_types.h(37): error: expected an identifier
> 
> I think I did not do it in a correct way. I took a a look at some of petsc's .cu files, they usually include a  long list of headers. Can petsc.h directly included in a source code with cusp headers? What's the correct way to do it?  Does the makefile system in petsc provide the command or flags to do that? How can I obtain those flags? 
> 
> And after I compile it and obtain .o files, can I use g++ to link the .o files with petcs libs and other .o files as usual, i.e.,
>     g++ -o $(BIN_DIR)/$@ $(CPPFLAGS) $@.s $(objects) $(PETSC_LIB) $(OTHERS)
> or I need to do some extra steps and some specific linking flags to do that?
> Thanks.  
> 
> Shiyuan 
> 
> 
> 



More information about the petsc-users mailing list