Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions examples/petsc/bpssphere.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ int main(int argc, char **argv) {
PetscCall(PetscOptionsBool("-simplex", "Use simplices, or tensor product cells", NULL, simplex, &simplex, NULL));
PetscOptionsEnd();

// Set up libCEED
CeedInit(ceed_resource, &ceed);
CeedMemType mem_type_backend;
CeedGetPreferredMemType(ceed, &mem_type_backend);

// Set mesh vec_type
switch (mem_type_backend) {
case CEED_MEM_HOST:
vec_type = VECSTANDARD;
break;
case CEED_MEM_DEVICE: {
const char *resolved;

CeedGetResource(ceed, &resolved);
if (strstr(resolved, "/gpu/cuda")) vec_type = VECCUDA;
else if (strstr(resolved, "/gpu/hip/occa")) vec_type = VECSTANDARD; // https://github.com/CEED/libCEED/issues/678
else if (strstr(resolved, "/gpu/hip")) vec_type = VECHIP;
else vec_type = VECSTANDARD;
}
}

// Setup DM
if (read_mesh) {
PetscCall(DMPlexCreateFromFile(PETSC_COMM_WORLD, filename, NULL, PETSC_TRUE, &dm));
Expand All @@ -104,6 +125,7 @@ int main(int argc, char **argv) {
// Refine DMPlex with uniform refinement using runtime option -dm_refine
PetscCall(DMPlexSetRefinementUniform(dm, PETSC_TRUE));
}
PetscCall(DMSetVecType(dm, vec_type));
PetscCall(DMSetFromOptions(dm));
// View DMPlex via runtime option
PetscCall(DMViewFromOptions(dm, NULL, "-dm_view"));
Expand All @@ -125,28 +147,6 @@ int main(int argc, char **argv) {
PetscCall(MatCreateShell(comm, l_size, l_size, g_size, g_size, op_apply_ctx, &mat_O));
PetscCall(MatShellSetOperation(mat_O, MATOP_MULT, (void (*)(void))MatMult_Ceed));

// Set up libCEED
CeedInit(ceed_resource, &ceed);
CeedMemType mem_type_backend;
CeedGetPreferredMemType(ceed, &mem_type_backend);

// Set mesh vec_type
switch (mem_type_backend) {
case CEED_MEM_HOST:
vec_type = VECSTANDARD;
break;
case CEED_MEM_DEVICE: {
const char *resolved;

CeedGetResource(ceed, &resolved);
if (strstr(resolved, "/gpu/cuda")) vec_type = VECCUDA;
else if (strstr(resolved, "/gpu/hip/occa")) vec_type = VECSTANDARD; // https://github.com/CEED/libCEED/issues/678
else if (strstr(resolved, "/gpu/hip")) vec_type = VECHIP;
else vec_type = VECSTANDARD;
}
}
PetscCall(DMSetVecType(dm, vec_type));

// Print summary
if (!test_mode) {
PetscInt P = degree + 1, Q = P + q_extra;
Expand Down
Loading