Skip to content

Commit

Permalink
initialize pycuda context *after* petsc cuda context init
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikcfd committed Sep 22, 2024
1 parent df3d335 commit df44a18
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions firedrake/petsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
from mpi4py import MPI
from petsc4py import PETSc
from pyop2 import mpi
import firedrake_configuration


if firedrake_configuration.get_config()["options"].get("cuda"):
if 0:
# FIXME: Enable this once
# https://gitlab.com/petsc/petsc/-/merge_requests/5400
# is merged.
PETSc.Sys.initializeDevice(PETSc.Device.Type.CUDA)
else:
# Hacky way to initialize context on the device
x = PETSc.Vec().create(PETSc.COMM_WORLD)
x.setType("cuda")
x.setSizes(size=100)
x.set(2)
x.norm()
del x

import pycuda.autoprimaryctx # noqa: F401


__all__ = (
Expand Down

0 comments on commit df44a18

Please sign in to comment.