[petsc-dev] Makefile.user and CUDA

Matthew Knepley knepley at gmail.com
Mon Oct 12 13:11:25 CDT 2020


On Mon, Oct 12, 2020 at 3:47 AM Patrick Sanan <patrick.sanan at gmail.com>
wrote:

> I have a toy application code built on PETSc which needs to compile and
> link a .cu file.
>
> I'd love to be able to configure PETSc (with CUDA), and then use a
> modified version of share/petsc/Makefile.user to compile and link my code,
> using a consistent set of compilers, libraries, and flags.  Makefile.user
> uses petsc.pc (via pkg-config) and implicit GNU make rules to do almost
> everything for you for C, C++, and Fortran.
>
> However, I don't think it currently supports CUDA, and I'm not familiar
> enough with BuildSystem or pkg-config to quickly add support myself, so I
> resort to the "old" way, including things like this in my Makefile:
>

Okay, here is where the pkgconf file gets generated, and in fact where the
language sections are


https://gitlab.com/petsc/petsc/-/blob/master/config/PETSc/Configure.py#L161

I think you can just put a "CUDA" section in. I do not know what names to
use, so I have not done it.

  Thanks,

     Matt


> include ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables
>
> %.o : %.cu
>         $(CUDAC) -c $(CUDAC_FLAGS) $(CUDA_INCLUDE) -o $@ $<
>
> app : ${OBJ}
>         $(LINK.cc) -o $@ $^ $(LDLIBS) $(CUDA_LIB)
>
>
> Is it possible / easy / advisable to add CUDA support to petsc.pc ?
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20201012/5a93fcdd/attachment.html>


More information about the petsc-dev mailing list