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

Satish Balay balay at mcs.anl.gov
Wed Oct 5 16:23:55 CDT 2011


On Wed, 5 Oct 2011, Shiyuan wrote:

> balay at bb30:~/ex>cat ex1.cu
> > #include "petsc.h"
> > #undef VecType
> >
> > #include<iostream>
> > #include <cusp/krylov/cg.h>
> >
> > int main(int argc,char **argv)
> > {
> >  PetscErrorCode ierr;
> >  ierr = PetscInitialize(&argc,&argv,(char *)0,(char*)0);CHKERRQ(ierr);
> >   std::cout<<"Hello World!"<<std::endl;
> >   ierr = PetscFinalize();
> >  return 0;
> > }
> >
> >
> That almost works except that petsc.h doesn't include all
> definitions/declarations.  I have a function which cannot be compiled by
> just adding petsc.h with errors like:
> error: identifier "CUSPARRAY" is undefined
> error: identifier "Mat_SeqAIJ" is undefined
> error: identifier "Mat_SeqAIJCUSP" is undefined
> ect.
> But it can be compiled if I add the following in addition to petsc.h
> 
> PETSC_CUDA_EXTERN_C_BEGIN
> #include "../src/mat/impls/aij/seq/aij.h"          /*I "petscmat.h" I*/
> #include "petscbt.h"
> #include "../src/vec/vec/impls/dvecimpl.h"
> #include "private/vecimpl.h"
> PETSC_CUDA_EXTERN_C_END
> #undef VecType
> #include "../src/mat/impls/aij/seq/seqcusp/cuspmatimpl.h"
> 
> What's the minimal set of headers I can add to petsc.h such that I can call
> alll petsc functions and use all petsc type?
> Thanks.

petsc.h will give you all the public interface functions. [and
datatypes]. If you need to access the private datatypes and functions
- then yes - you have to include the needed private include files.

Since the private includes are not really meant for regular users -
there is no single include file that covers them all. You keep listing
all the ones you need.

Satish


More information about the petsc-users mailing list