[petsc-users] compiling petsc.h and cusp's headers
Barry Smith
bsmith at mcs.anl.gov
Wed Oct 5 16:23:12 CDT 2011
The PETSc headers are divided into two parts, the public headers with all definitions etc needed by PETSc users (this you just need petsc.h) and private headers that define all the specific data structures for various parts of PETSc. There really is no "minimal set of headers" that allows access to all private parts, the minimal set would simply be all the headers everywhere. But this is not how it is done in PETSc, each piece of code includes the headers it needs for its computations. Since you wish to access the private parts of the CUSP Vec and AIJ Mat classes you need to include what you have below. As soon as you start using the private data structures of PETSc you move into a world that is going to require more initiative on your part in understand the pieces of code you are changing and how to work with them.
Barry
On Oct 5, 2011, at 4:15 PM, 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.
>
>
> Shiyuan
>
>
>
>
>
>
>
>
>
>
More information about the petsc-users
mailing list