Lines Matching refs:ctx

73   MatCeedContext ctx;  in MatCeedAssemblePointBlockDiagonalCOO()  local
76 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedAssemblePointBlockDiagonalCOO()
82 for (PetscInt i = 0; i < ctx->num_mats_assembled_pbd; i++) { in MatCeedAssemblePointBlockDiagonalCOO()
83 if (ctx->mats_assembled_pbd[i] == mat_coo) index = i; in MatCeedAssemblePointBlockDiagonalCOO()
99 …PetscCallCeed(ctx->ceed, CeedOperatorLinearAssemblePointBlockDiagonalSymbolic(ctx->op_mult, &num_e… in MatCeedAssemblePointBlockDiagonalCOO()
106 …if (!ctx->coo_values_pbd) PetscCallCeed(ctx->ceed, CeedVectorCreate(ctx->ceed, num_entries, &ctx->… in MatCeedAssemblePointBlockDiagonalCOO()
107 … PetscCall(PetscRealloc(++ctx->num_mats_assembled_pbd * sizeof(Mat), &ctx->mats_assembled_pbd)); in MatCeedAssemblePointBlockDiagonalCOO()
108 ctx->mats_assembled_pbd[ctx->num_mats_assembled_pbd - 1] = mat_coo; in MatCeedAssemblePointBlockDiagonalCOO()
126 …PetscCallCeed(ctx->ceed, CeedOperatorLinearAssemblePointBlockDiagonal(ctx->op_mult, ctx->coo_value… in MatCeedAssemblePointBlockDiagonalCOO()
128 PetscCallCeed(ctx->ceed, CeedVectorGetArrayRead(ctx->coo_values_pbd, mem_type, &values)); in MatCeedAssemblePointBlockDiagonalCOO()
132 PetscCallCeed(ctx->ceed, CeedVectorRestoreArrayRead(ctx->coo_values_pbd, &values)); in MatCeedAssemblePointBlockDiagonalCOO()
151 MatCeedContext ctx; in MatCeedAssembleInnerBlockDiagonalMat() local
154 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedAssembleInnerBlockDiagonalMat()
157 …if (!ctx->mat_assembled_pbd_internal) PetscCall(MatCeedCreateMatCOO(mat_ceed, &ctx->mat_assembled_… in MatCeedAssembleInnerBlockDiagonalMat()
160 PetscCall(MatCeedAssemblePointBlockDiagonalCOO(mat_ceed, ctx->mat_assembled_pbd_internal)); in MatCeedAssembleInnerBlockDiagonalMat()
161 if (mat_inner) *mat_inner = ctx->mat_assembled_pbd_internal; in MatCeedAssembleInnerBlockDiagonalMat()
164 …if (!ctx->mat_assembled_full_internal) PetscCall(MatCeedCreateMatCOO(mat_ceed, &ctx->mat_assembled… in MatCeedAssembleInnerBlockDiagonalMat()
167 PetscCall(MatCeedAssembleCOO(mat_ceed, ctx->mat_assembled_full_internal)); in MatCeedAssembleInnerBlockDiagonalMat()
168 if (mat_inner) *mat_inner = ctx->mat_assembled_full_internal; in MatCeedAssembleInnerBlockDiagonalMat()
184 MatCeedContext ctx; in MatGetVariableBlockDiagonal_Ceed() local
187 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatGetVariableBlockDiagonal_Ceed()
190 PetscCall(MatCeedAssembleInnerBlockDiagonalMat(mat_ceed, ctx->is_ceed_vpbd_valid, mat_vblock)); in MatGetVariableBlockDiagonal_Ceed()
206 MatCeedContext ctx; in MatGetBlockDiagonal_Ceed() local
209 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatGetBlockDiagonal_Ceed()
212 PetscCall(MatCeedAssembleInnerBlockDiagonalMat(mat_ceed, ctx->is_ceed_pbd_valid, mat_block)); in MatGetBlockDiagonal_Ceed()
231 MatCeedContext ctx; in MatGetDiagonalBlock_Ceed() local
234 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatGetDiagonalBlock_Ceed()
237 …if (!ctx->mat_assembled_full_internal) PetscCall(MatCeedCreateMatCOO(mat_ceed, &ctx->mat_assembled… in MatGetDiagonalBlock_Ceed()
240 PetscCall(MatCeedAssembleCOO(mat_ceed, ctx->mat_assembled_full_internal)); in MatGetDiagonalBlock_Ceed()
243 PetscCall(MatGetDiagonalBlock(ctx->mat_assembled_full_internal, mat_block)); in MatGetDiagonalBlock_Ceed()
261 MatCeedContext ctx; in MatView_Ceed() local
265 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatView_Ceed()
285 PetscCall(PetscViewerASCIIPrintf(viewer, "Default COO MatType: %s\n", ctx->coo_mat_type)); in MatView_Ceed()
288 …PetscCall(PetscViewerASCIIPrintf(viewer, "libCEED PB Diagonal Assembly: %s\n", ctx->is_ceed_pbd_va… in MatView_Ceed()
289 …PetscCall(PetscViewerASCIIPrintf(viewer, "libCEED VPB Diagonal Assembly: %s\n", ctx->is_ceed_vpbd_… in MatView_Ceed()
294 PetscCallCeed(ctx->ceed, CeedOperatorSetNumViewTabs(ctx->op_mult, num_tabs)); in MatView_Ceed()
295 if (is_detailed) PetscCallCeed(ctx->ceed, CeedOperatorView(ctx->op_mult, file)); in MatView_Ceed()
296 else PetscCallCeed(ctx->ceed, CeedOperatorViewTerse(ctx->op_mult, file)); in MatView_Ceed()
297 PetscCallCeed(ctx->ceed, CeedOperatorSetNumViewTabs(ctx->op_mult, 0)); in MatView_Ceed()
299 if (ctx->op_mult_transpose) { in MatView_Ceed()
303 PetscCallCeed(ctx->ceed, CeedOperatorGetNumViewTabs(ctx->op_mult_transpose, &prev_num_tabs)); in MatView_Ceed()
304 PetscCallCeed(ctx->ceed, CeedOperatorSetNumViewTabs(ctx->op_mult_transpose, num_tabs)); in MatView_Ceed()
305 if (is_detailed) PetscCallCeed(ctx->ceed, CeedOperatorView(ctx->op_mult_transpose, file)); in MatView_Ceed()
306 else PetscCallCeed(ctx->ceed, CeedOperatorViewTerse(ctx->op_mult_transpose, file)); in MatView_Ceed()
307 PetscCallCeed(ctx->ceed, CeedOperatorSetNumViewTabs(ctx->op_mult_transpose, prev_num_tabs)); in MatView_Ceed()
329 MatCeedContext ctx; in MatSetFromOptions_Ceed() local
334 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatSetFromOptions_Ceed()
341 PetscCall(PetscFree(ctx->coo_mat_type)); in MatSetFromOptions_Ceed()
342 PetscCall(PetscStrallocpy(coo_mat_type_cl, &ctx->coo_mat_type)); in MatSetFromOptions_Ceed()
347 ctx->coo_reuse_preallocation, &ctx->coo_reuse_preallocation, NULL)); in MatSetFromOptions_Ceed()
372 MatCeedContext ctx; in MatCreateCeed() local
411 MATCEED_MULT_CEEDOP, MATCEED_MULT_TRANSPOSE_CEEDOP, &ctx)); in MatCreateCeed()
417 …CreateShell(PetscObjectComm((PetscObject)dm_x), Y_l_size, X_l_size, Y_g_size, X_g_size, ctx, mat)); in MatCreateCeed()
454 ctx->is_ceed_pbd_valid = PETSC_TRUE; in MatCreateCeed()
455 ctx->is_ceed_vpbd_valid = PETSC_TRUE; in MatCreateCeed()
456 PetscCallCeed(ctx->ceed, CeedOperatorIsComposite(op_mult, &is_composite)); in MatCreateCeed()
461 PetscCallCeed(ctx->ceed, CeedOperatorCompositeGetNumSub(op_mult, &num_sub_operators)); in MatCreateCeed()
462 PetscCallCeed(ctx->ceed, CeedOperatorCompositeGetSubList(op_mult, &sub_operators)); in MatCreateCeed()
468 … PetscCallCeed(ctx->ceed, CeedOperatorGetOperatorAssemblyData(sub_operators[i], &assembly_data)); in MatCreateCeed()
469 …PetscCallCeed(ctx->ceed, CeedOperatorAssemblyDataGetBases(assembly_data, &num_bases, &active_bases… in MatCreateCeed()
470 PetscCallCeed(ctx->ceed, CeedBasisGetNumComponents(active_bases[0], &num_comp)); in MatCreateCeed()
472 ctx->is_ceed_pbd_valid = PETSC_FALSE; in MatCreateCeed()
473 ctx->is_ceed_vpbd_valid = PETSC_FALSE; in MatCreateCeed()
475 if (num_comp != block_size) ctx->is_ceed_pbd_valid = PETSC_FALSE; in MatCreateCeed()
476 if (num_comp < max_vblock_size) ctx->is_ceed_vpbd_valid = PETSC_FALSE; in MatCreateCeed()
484 PetscCallCeed(ctx->ceed, CeedOperatorGetOperatorAssemblyData(op_mult, &assembly_data)); in MatCreateCeed()
485 …PetscCallCeed(ctx->ceed, CeedOperatorAssemblyDataGetBases(assembly_data, &num_bases, &active_bases… in MatCreateCeed()
486 PetscCallCeed(ctx->ceed, CeedBasisGetNumComponents(active_bases[0], &num_comp)); in MatCreateCeed()
488 ctx->is_ceed_pbd_valid = PETSC_FALSE; in MatCreateCeed()
489 ctx->is_ceed_vpbd_valid = PETSC_FALSE; in MatCreateCeed()
491 if (num_comp != block_size) ctx->is_ceed_pbd_valid = PETSC_FALSE; in MatCreateCeed()
492 if (num_comp < max_vblock_size) ctx->is_ceed_vpbd_valid = PETSC_FALSE; in MatCreateCeed()
498 local_is_valid[0] = local_is_valid[1] = ctx->is_ceed_pbd_valid; in MatCreateCeed()
500 ctx->is_ceed_pbd_valid = global_is_valid[0]; in MatCreateCeed()
501 local_is_valid[0] = local_is_valid[1] = ctx->is_ceed_vpbd_valid; in MatCreateCeed()
503 ctx->is_ceed_vpbd_valid = global_is_valid[0]; in MatCreateCeed()
514 PetscCall(VecGetType(ctx->X_loc, &vec_type)); in MatCreateCeed()
516 PetscCall(PetscStrallocpy(coo_mat_type, &ctx->coo_mat_type)); in MatCreateCeed()
580 MatCeedContext ctx; in MatCeedCopy() local
583 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedCopy()
584 PetscCall(MatCeedContextReference(ctx)); in MatCeedCopy()
585 PetscCall(MatShellSetContext(mat_other, ctx)); in MatCeedCopy()
589 …if (ctx->op_mult_transpose) PetscCall(MatShellSetOperation(mat_other, MATOP_MULT_TRANSPOSE, (MatSe… in MatCeedCopy()
607 PetscCall(DMGetVecType(ctx->dm_x, &vec_type)); in MatCeedCopy()
624 MatCeedContext ctx; in MatCeedSetAssemblyDataUpdateNeeded() local
627 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedSetAssemblyDataUpdateNeeded()
628 …PetscCallCeed(ctx->ceed, CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(ctx->op_mult, update_nee… in MatCeedSetAssemblyDataUpdateNeeded()
629 if (ctx->op_mult_transpose) { in MatCeedSetAssemblyDataUpdateNeeded()
630 …PetscCallCeed(ctx->ceed, CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(ctx->op_mult_transpose, … in MatCeedSetAssemblyDataUpdateNeeded()
650 MatCeedContext ctx; in MatCeedCreateMatCOO() local
653 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedCreateMatCOO()
655 …PetscCheck(ctx->dm_x == ctx->dm_y, PetscObjectComm((PetscObject)mat_ceed), PETSC_ERR_SUP, "COO ass… in MatCeedCreateMatCOO()
661 PetscCall(DMGetMatType(ctx->dm_x, &dm_mat_type)); in MatCeedCreateMatCOO()
663 PetscCall(DMSetMatType(ctx->dm_x, ctx->coo_mat_type)); in MatCeedCreateMatCOO()
664 PetscCall(DMCreateMatrix(ctx->dm_x, mat_coo)); in MatCeedCreateMatCOO()
665 PetscCall(DMSetMatType(ctx->dm_x, dm_mat_type_copy)); in MatCeedCreateMatCOO()
683 MatCeedContext ctx; in MatCeedSetPreallocationCOO() local
686 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedSetPreallocationCOO()
701 if (!ctx->coo_reuse_preallocation || !coo_struct) { in MatCeedSetPreallocationCOO()
707 …PetscCallCeed(ctx->ceed, CeedOperatorLinearAssembleSymbolic(ctx->op_mult, &num_entries, &rows_ceed… in MatCeedSetPreallocationCOO()
715 PetscCallCeed(ctx->ceed, CeedOperatorLinearAssembleGetNumEntries(ctx->op_mult, &num_entries)); in MatCeedSetPreallocationCOO()
718 …if (!ctx->coo_values_full) PetscCallCeed(ctx->ceed, CeedVectorCreate(ctx->ceed, num_entries, &ctx-… in MatCeedSetPreallocationCOO()
719 … PetscCall(PetscRealloc(++ctx->num_mats_assembled_full * sizeof(Mat), &ctx->mats_assembled_full)); in MatCeedSetPreallocationCOO()
720 ctx->mats_assembled_full[ctx->num_mats_assembled_full - 1] = mat_coo; in MatCeedSetPreallocationCOO()
740 MatCeedContext ctx; in MatCeedAssembleCOO() local
743 PetscCall(MatShellGetContext(mat_ceed, &ctx)); in MatCeedAssembleCOO()
749 for (PetscInt i = 0; i < ctx->num_mats_assembled_full; i++) { in MatCeedAssembleCOO()
750 if (ctx->mats_assembled_full[i] == mat_coo) index = i; in MatCeedAssembleCOO()
766 PetscCallCeed(ctx->ceed, CeedOperatorLinearAssemble(ctx->op_mult, ctx->coo_values_full)); in MatCeedAssembleCOO()
768 PetscCallCeed(ctx->ceed, CeedVectorGetArrayRead(ctx->coo_values_full, mem_type, &values)); in MatCeedAssembleCOO()
772 PetscCallCeed(ctx->ceed, CeedVectorRestoreArrayRead(ctx->coo_values_full, &values)); in MatCeedAssembleCOO()
793 MatCeedContext ctx; in MatCeedSetContextDouble() local
796 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedSetContextDouble()
800 PetscCallCeed(ctx->ceed, CeedOperatorGetContextFieldLabel(ctx->op_mult, name, &label)); in MatCeedSetContextDouble()
806 PetscCallCeed(ctx->ceed, CeedOperatorSetContextDouble(ctx->op_mult, label, &value)); in MatCeedSetContextDouble()
810 if (ctx->op_mult_transpose) { in MatCeedSetContextDouble()
812 … PetscCallCeed(ctx->ceed, CeedOperatorGetContextFieldLabel(ctx->op_mult_transpose, name, &label)); in MatCeedSetContextDouble()
818 … PetscCallCeed(ctx->ceed, CeedOperatorSetContextDouble(ctx->op_mult_transpose, label, &value)); in MatCeedSetContextDouble()
843 MatCeedContext ctx; in MatCeedGetContextDouble() local
846 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetContextDouble()
849 CeedOperator op = ctx->op_mult; in MatCeedGetContextDouble()
851 PetscCallCeed(ctx->ceed, CeedOperatorGetContextFieldLabel(op, name, &label)); in MatCeedGetContextDouble()
852 if (!label && ctx->op_mult_transpose) { in MatCeedGetContextDouble()
853 op = ctx->op_mult_transpose; in MatCeedGetContextDouble()
854 PetscCallCeed(ctx->ceed, CeedOperatorGetContextFieldLabel(op, name, &label)); in MatCeedGetContextDouble()
860 … PetscCallCeed(ctx->ceed, CeedOperatorGetContextDoubleRead(op, label, &num_values, &values_ceed)); in MatCeedGetContextDouble()
862 PetscCallCeed(ctx->ceed, CeedOperatorRestoreContextDoubleRead(op, label, &values_ceed)); in MatCeedGetContextDouble()
1006 PetscErrorCode MatCeedSetContext(Mat mat, PetscCtxDestroyFn f, void *ctx) { in MatCeedSetContext() argument
1010 if (ctx) { in MatCeedSetContext()
1012 PetscCall(PetscContainerSetPointer(user_ctx, ctx)); in MatCeedSetContext()
1030 PetscErrorCode MatCeedGetContext(Mat mat, void *ctx) { in MatCeedGetContext() argument
1035 if (user_ctx) PetscCall(PetscContainerGetPointer(user_ctx, (void **)ctx)); in MatCeedGetContext()
1036 else *(void **)ctx = NULL; in MatCeedGetContext()
1072 MatCeedContext ctx; in MatCeedSetReusePreallocationCOO() local
1075 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedSetReusePreallocationCOO()
1076 ctx->coo_reuse_preallocation = coo_reuse_preallocation; in MatCeedSetReusePreallocationCOO()
1091 MatCeedContext ctx; in MatCeedGetReusePreallocationCOO() local
1094 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetReusePreallocationCOO()
1095 *coo_reuse_preallocation = ctx->coo_reuse_preallocation; in MatCeedGetReusePreallocationCOO()
1110 MatCeedContext ctx; in MatCeedSetCOOMatType() local
1113 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedSetCOOMatType()
1119 PetscCall(PetscStrlen(ctx->coo_mat_type, &len_old)); in MatCeedSetCOOMatType()
1121 if (len_old == len_new) PetscCall(PetscStrncmp(ctx->coo_mat_type, type, len_old, &is_same)); in MatCeedSetCOOMatType()
1126 if (ctx->mat_assembled_full_internal) { in MatCeedSetCOOMatType()
1127 for (PetscInt i = 0; i < ctx->num_mats_assembled_full; i++) { in MatCeedSetCOOMatType()
1128 if (ctx->mats_assembled_full[i] == ctx->mat_assembled_full_internal) { in MatCeedSetCOOMatType()
1129 for (PetscInt j = i + 1; j < ctx->num_mats_assembled_full; j++) { in MatCeedSetCOOMatType()
1130 ctx->mats_assembled_full[j - 1] = ctx->mats_assembled_full[j]; in MatCeedSetCOOMatType()
1132 ctx->num_mats_assembled_full--; in MatCeedSetCOOMatType()
1134 PetscCall(MatDestroy(&ctx->mat_assembled_full_internal)); in MatCeedSetCOOMatType()
1138 if (ctx->mat_assembled_pbd_internal) { in MatCeedSetCOOMatType()
1139 for (PetscInt i = 0; i < ctx->num_mats_assembled_pbd; i++) { in MatCeedSetCOOMatType()
1140 if (ctx->mats_assembled_pbd[i] == ctx->mat_assembled_pbd_internal) { in MatCeedSetCOOMatType()
1141 for (PetscInt j = i + 1; j < ctx->num_mats_assembled_pbd; j++) { in MatCeedSetCOOMatType()
1142 ctx->mats_assembled_pbd[j - 1] = ctx->mats_assembled_pbd[j]; in MatCeedSetCOOMatType()
1145 ctx->num_mats_assembled_pbd--; in MatCeedSetCOOMatType()
1146 PetscCall(MatDestroy(&ctx->mat_assembled_pbd_internal)); in MatCeedSetCOOMatType()
1150 PetscCall(PetscFree(ctx->coo_mat_type)); in MatCeedSetCOOMatType()
1151 PetscCall(PetscStrallocpy(type, &ctx->coo_mat_type)); in MatCeedSetCOOMatType()
1167 MatCeedContext ctx; in MatCeedGetCOOMatType() local
1170 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetCOOMatType()
1171 *type = ctx->coo_mat_type; in MatCeedGetCOOMatType()
1187 MatCeedContext ctx; in MatCeedSetLocalVectors() local
1190 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedSetLocalVectors()
1194 PetscCall(VecGetSize(ctx->X_loc, &len_old)); in MatCeedSetLocalVectors()
1198 PetscCall(VecReferenceCopy(X_loc, &ctx->X_loc)); in MatCeedSetLocalVectors()
1203 PetscCall(VecGetSize(ctx->Y_loc_transpose, &len_old)); in MatCeedSetLocalVectors()
1207 PetscCall(VecReferenceCopy(Y_loc_transpose, &ctx->Y_loc_transpose)); in MatCeedSetLocalVectors()
1224 MatCeedContext ctx; in MatCeedGetLocalVectors() local
1227 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetLocalVectors()
1230 PetscCall(VecReferenceCopy(ctx->X_loc, X_loc)); in MatCeedGetLocalVectors()
1234 PetscCall(VecReferenceCopy(ctx->Y_loc_transpose, Y_loc_transpose)); in MatCeedGetLocalVectors()
1269 MatCeedContext ctx; in MatCeedGetCeedOperators() local
1272 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetCeedOperators()
1275 PetscCallCeed(ctx->ceed, CeedOperatorReferenceCopy(ctx->op_mult, op_mult)); in MatCeedGetCeedOperators()
1279 PetscCallCeed(ctx->ceed, CeedOperatorReferenceCopy(ctx->op_mult_transpose, op_mult_transpose)); in MatCeedGetCeedOperators()
1296 MatCeedContext ctx; in MatCeedRestoreCeedOperators() local
1299 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedRestoreCeedOperators()
1300 if (op_mult) PetscCallCeed(ctx->ceed, CeedOperatorDestroy(op_mult)); in MatCeedRestoreCeedOperators()
1301 if (op_mult_transpose) PetscCallCeed(ctx->ceed, CeedOperatorDestroy(op_mult_transpose)); in MatCeedRestoreCeedOperators()
1317 MatCeedContext ctx; in MatCeedSetLogEvents() local
1320 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedSetLogEvents()
1321 if (log_event_mult) ctx->log_event_mult = log_event_mult; in MatCeedSetLogEvents()
1322 if (log_event_mult_transpose) ctx->log_event_mult_transpose = log_event_mult_transpose; in MatCeedSetLogEvents()
1338 MatCeedContext ctx; in MatCeedGetLogEvents() local
1341 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetLogEvents()
1342 if (log_event_mult) *log_event_mult = ctx->log_event_mult; in MatCeedGetLogEvents()
1343 if (log_event_mult_transpose) *log_event_mult_transpose = ctx->log_event_mult_transpose; in MatCeedGetLogEvents()
1359 MatCeedContext ctx; in MatCeedSetCeedOperatorLogEvents() local
1362 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedSetCeedOperatorLogEvents()
1363 if (log_event_mult) ctx->log_event_ceed_mult = log_event_mult; in MatCeedSetCeedOperatorLogEvents()
1364 if (log_event_mult_transpose) ctx->log_event_ceed_mult_transpose = log_event_mult_transpose; in MatCeedSetCeedOperatorLogEvents()
1380 MatCeedContext ctx; in MatCeedGetCeedOperatorLogEvents() local
1383 PetscCall(MatShellGetContext(mat, &ctx)); in MatCeedGetCeedOperatorLogEvents()
1384 if (log_event_mult) *log_event_mult = ctx->log_event_ceed_mult; in MatCeedGetCeedOperatorLogEvents()
1385 if (log_event_mult_transpose) *log_event_mult_transpose = ctx->log_event_ceed_mult_transpose; in MatCeedGetCeedOperatorLogEvents()
1414 … PetscLogEvent log_event_ceed_mult_transpose, MatCeedContext *ctx) { in MatCeedContextCreate() argument
1419 PetscCall(PetscNew(ctx)); in MatCeedContextCreate()
1420 (*ctx)->ref_count = 1; in MatCeedContextCreate()
1423 (*ctx)->log_event_mult = log_event_mult; in MatCeedContextCreate()
1424 (*ctx)->log_event_mult_transpose = log_event_mult_transpose; in MatCeedContextCreate()
1425 (*ctx)->log_event_ceed_mult = log_event_ceed_mult; in MatCeedContextCreate()
1426 (*ctx)->log_event_ceed_mult_transpose = log_event_ceed_mult_transpose; in MatCeedContextCreate()
1429 PetscCall(DMReferenceCopy(dm_x, &(*ctx)->dm_x)); in MatCeedContextCreate()
1430 PetscCall(DMReferenceCopy(dm_y, &(*ctx)->dm_y)); in MatCeedContextCreate()
1431 if (X_loc) PetscCall(VecReferenceCopy(X_loc, &(*ctx)->X_loc)); in MatCeedContextCreate()
1432 if (Y_loc_transpose) PetscCall(VecReferenceCopy(Y_loc_transpose, &(*ctx)->Y_loc_transpose)); in MatCeedContextCreate()
1440 PetscCall(VecGetArrayReadAndMemType(X, &x, &(*ctx)->mem_type)); in MatCeedContextCreate()
1446 …PetscCheck(CeedOperatorGetCeed(op_mult, &(*ctx)->ceed) == CEED_ERROR_SUCCESS, PETSC_COMM_SELF, PET… in MatCeedContextCreate()
1448 PetscCallCeed((*ctx)->ceed, CeedOperatorGetActiveVectorLengths(op_mult, &x_loc_len, &y_loc_len)); in MatCeedContextCreate()
1449 PetscCallCeed((*ctx)->ceed, CeedOperatorReferenceCopy(op_mult, &(*ctx)->op_mult)); in MatCeedContextCreate()
1450 …if (op_mult_transpose) PetscCallCeed((*ctx)->ceed, CeedOperatorReferenceCopy(op_mult_transpose, &(… in MatCeedContextCreate()
1452 PetscCallCeed((*ctx)->ceed, CeedVectorCreate((*ctx)->ceed, x_loc_len, &(*ctx)->x_loc)); in MatCeedContextCreate()
1454 PetscCallCeed((*ctx)->ceed, CeedVectorCreate((*ctx)->ceed, y_loc_len, &(*ctx)->y_loc)); in MatCeedContextCreate()
1460 PetscCallCeed((*ctx)->ceed, CeedOperatorGetFlopsEstimate(op_mult, &ceed_flops_estimate)); in MatCeedContextCreate()
1461 (*ctx)->flops_mult = ceed_flops_estimate; in MatCeedContextCreate()
1463 …PetscCallCeed((*ctx)->ceed, CeedOperatorGetFlopsEstimate(op_mult_transpose, &ceed_flops_estimate)); in MatCeedContextCreate()
1464 (*ctx)->flops_mult_transpose = ceed_flops_estimate; in MatCeedContextCreate()
1478 PetscCallCeed((*ctx)->ceed, CeedVectorGetLength((*ctx)->x_loc, &ctx_x_loc_len)); in MatCeedContextCreate()
1493 PetscCallCeed((*ctx)->ceed, CeedVectorGetLength((*ctx)->y_loc, &ctx_y_loc_len)); in MatCeedContextCreate()
1516 PetscErrorCode MatCeedContextReference(MatCeedContext ctx) { in MatCeedContextReference() argument
1518 ctx->ref_count++; in MatCeedContextReference()
1533 PetscErrorCode MatCeedContextReferenceCopy(MatCeedContext ctx, MatCeedContext *ctx_copy) { in MatCeedContextReferenceCopy() argument
1535 PetscCall(MatCeedContextReference(ctx)); in MatCeedContextReferenceCopy()
1537 *ctx_copy = ctx; in MatCeedContextReferenceCopy()
1550 PetscErrorCode MatCeedContextDestroy(MatCeedContext *ctx) { in MatCeedContextDestroy() argument
1552 if (!ctx || --(*ctx)->ref_count > 0) PetscFunctionReturn(PETSC_SUCCESS); in MatCeedContextDestroy()
1555 PetscCall(DMDestroy(&(*ctx)->dm_x)); in MatCeedContextDestroy()
1556 PetscCall(DMDestroy(&(*ctx)->dm_y)); in MatCeedContextDestroy()
1557 PetscCall(VecDestroy(&(*ctx)->X_loc)); in MatCeedContextDestroy()
1558 PetscCall(VecDestroy(&(*ctx)->Y_loc_transpose)); in MatCeedContextDestroy()
1559 PetscCall(MatDestroy(&(*ctx)->mat_assembled_full_internal)); in MatCeedContextDestroy()
1560 PetscCall(MatDestroy(&(*ctx)->mat_assembled_pbd_internal)); in MatCeedContextDestroy()
1561 PetscCall(PetscFree((*ctx)->coo_mat_type)); in MatCeedContextDestroy()
1562 PetscCall(PetscFree((*ctx)->mats_assembled_full)); in MatCeedContextDestroy()
1563 PetscCall(PetscFree((*ctx)->mats_assembled_pbd)); in MatCeedContextDestroy()
1566 PetscCallCeed((*ctx)->ceed, CeedVectorDestroy(&(*ctx)->x_loc)); in MatCeedContextDestroy()
1567 PetscCallCeed((*ctx)->ceed, CeedVectorDestroy(&(*ctx)->y_loc)); in MatCeedContextDestroy()
1568 PetscCallCeed((*ctx)->ceed, CeedVectorDestroy(&(*ctx)->coo_values_full)); in MatCeedContextDestroy()
1569 PetscCallCeed((*ctx)->ceed, CeedVectorDestroy(&(*ctx)->coo_values_pbd)); in MatCeedContextDestroy()
1570 PetscCallCeed((*ctx)->ceed, CeedOperatorDestroy(&(*ctx)->op_mult)); in MatCeedContextDestroy()
1571 PetscCallCeed((*ctx)->ceed, CeedOperatorDestroy(&(*ctx)->op_mult_transpose)); in MatCeedContextDestroy()
1572 …PetscCheck(CeedDestroy(&(*ctx)->ceed) == CEED_ERROR_SUCCESS, PETSC_COMM_SELF, PETSC_ERR_LIB, "dest… in MatCeedContextDestroy()
1575 (*ctx)->is_destroyed = PETSC_TRUE; // Flag as destroyed in case someone has stale ref in MatCeedContextDestroy()
1576 PetscCall(PetscFree(*ctx)); in MatCeedContextDestroy()
1593 MatCeedContext ctx; in MatGetDiagonal_Ceed() local
1596 PetscCall(MatShellGetContext(A, &ctx)); in MatGetDiagonal_Ceed()
1600 PetscCall(DMGetLocalVector(ctx->dm_x, &D_loc)); in MatGetDiagonal_Ceed()
1601 PetscCall(VecPetscToCeed(D_loc, &mem_type, ctx->x_loc)); in MatGetDiagonal_Ceed()
1605 …PetscCallCeed(ctx->ceed, CeedOperatorLinearAssembleDiagonal(ctx->op_mult, ctx->x_loc, CEED_REQUEST… in MatGetDiagonal_Ceed()
1609 PetscCall(VecCeedToPetsc(ctx->x_loc, mem_type, D_loc)); in MatGetDiagonal_Ceed()
1613 PetscCall(DMLocalToGlobal(ctx->dm_x, D_loc, ADD_VALUES, D)); in MatGetDiagonal_Ceed()
1614 PetscCall(DMRestoreLocalVector(ctx->dm_x, &D_loc)); in MatGetDiagonal_Ceed()
1631 MatCeedContext ctx; in MatMult_Ceed() local
1634 PetscCall(MatShellGetContext(A, &ctx)); in MatMult_Ceed()
1635 PetscCall(PetscLogEventBegin(ctx->log_event_mult, A, X, Y, NULL)); in MatMult_Ceed()
1639 Vec X_loc = ctx->X_loc, Y_loc; in MatMult_Ceed()
1642 if (!ctx->X_loc) PetscCall(DMGetLocalVector(ctx->dm_x, &X_loc)); in MatMult_Ceed()
1643 PetscCall(DMGetLocalVector(ctx->dm_y, &Y_loc)); in MatMult_Ceed()
1646 PetscCall(DMGlobalToLocal(ctx->dm_x, X, INSERT_VALUES, X_loc)); in MatMult_Ceed()
1649 PetscCall(VecReadPetscToCeed(X_loc, &x_mem_type, ctx->x_loc)); in MatMult_Ceed()
1651 PetscCall(VecPetscToCeed(Y_loc, &y_mem_type, ctx->y_loc)); in MatMult_Ceed()
1654 PetscCall(PetscLogEventBegin(ctx->log_event_ceed_mult, A, X, Y, NULL)); in MatMult_Ceed()
1656 …PetscCallCeed(ctx->ceed, CeedOperatorApplyAdd(ctx->op_mult, ctx->x_loc, ctx->y_loc, CEED_REQUEST_I… in MatMult_Ceed()
1658 if (PetscMemTypeDevice(ctx->mem_type)) PetscCall(PetscLogGpuFlops(ctx->flops_mult)); in MatMult_Ceed()
1659 else PetscCall(PetscLogFlops(ctx->flops_mult)); in MatMult_Ceed()
1661 PetscCall(PetscLogEventEnd(ctx->log_event_ceed_mult, A, X, Y, NULL)); in MatMult_Ceed()
1664 PetscCall(VecReadCeedToPetsc(ctx->x_loc, x_mem_type, X_loc)); in MatMult_Ceed()
1665 PetscCall(VecCeedToPetsc(ctx->y_loc, y_mem_type, Y_loc)); in MatMult_Ceed()
1669 PetscCall(DMLocalToGlobal(ctx->dm_y, Y_loc, ADD_VALUES, Y)); in MatMult_Ceed()
1672 if (!ctx->X_loc) PetscCall(DMRestoreLocalVector(ctx->dm_x, &X_loc)); in MatMult_Ceed()
1673 PetscCall(DMRestoreLocalVector(ctx->dm_y, &Y_loc)); in MatMult_Ceed()
1676 PetscCall(PetscLogEventEnd(ctx->log_event_mult, A, X, Y, NULL)); in MatMult_Ceed()
1692 MatCeedContext ctx; in MatMultTranspose_Ceed() local
1695 PetscCall(MatShellGetContext(A, &ctx)); in MatMultTranspose_Ceed()
1696 PetscCall(PetscLogEventBegin(ctx->log_event_mult_transpose, A, Y, X, NULL)); in MatMultTranspose_Ceed()
1700 Vec X_loc, Y_loc = ctx->Y_loc_transpose; in MatMultTranspose_Ceed()
1703 if (!ctx->Y_loc_transpose) PetscCall(DMGetLocalVector(ctx->dm_y, &Y_loc)); in MatMultTranspose_Ceed()
1704 PetscCall(DMGetLocalVector(ctx->dm_x, &X_loc)); in MatMultTranspose_Ceed()
1707 PetscCall(DMGlobalToLocal(ctx->dm_y, Y, INSERT_VALUES, Y_loc)); in MatMultTranspose_Ceed()
1710 PetscCall(VecReadPetscToCeed(Y_loc, &y_mem_type, ctx->y_loc)); in MatMultTranspose_Ceed()
1712 PetscCall(VecPetscToCeed(X_loc, &x_mem_type, ctx->x_loc)); in MatMultTranspose_Ceed()
1715 PetscCall(PetscLogEventBegin(ctx->log_event_ceed_mult_transpose, A, Y, X, NULL)); in MatMultTranspose_Ceed()
1717 …PetscCallCeed(ctx->ceed, CeedOperatorApplyAdd(ctx->op_mult_transpose, ctx->y_loc, ctx->x_loc, CEED… in MatMultTranspose_Ceed()
1719 if (PetscMemTypeDevice(ctx->mem_type)) PetscCall(PetscLogGpuFlops(ctx->flops_mult_transpose)); in MatMultTranspose_Ceed()
1720 else PetscCall(PetscLogFlops(ctx->flops_mult_transpose)); in MatMultTranspose_Ceed()
1722 PetscCall(PetscLogEventEnd(ctx->log_event_ceed_mult_transpose, A, Y, X, NULL)); in MatMultTranspose_Ceed()
1725 PetscCall(VecReadCeedToPetsc(ctx->y_loc, y_mem_type, Y_loc)); in MatMultTranspose_Ceed()
1726 PetscCall(VecCeedToPetsc(ctx->x_loc, x_mem_type, X_loc)); in MatMultTranspose_Ceed()
1730 PetscCall(DMLocalToGlobal(ctx->dm_x, X_loc, ADD_VALUES, X)); in MatMultTranspose_Ceed()
1733 if (!ctx->Y_loc_transpose) PetscCall(DMRestoreLocalVector(ctx->dm_y, &Y_loc)); in MatMultTranspose_Ceed()
1734 PetscCall(DMRestoreLocalVector(ctx->dm_x, &X_loc)); in MatMultTranspose_Ceed()
1737 PetscCall(PetscLogEventEnd(ctx->log_event_mult_transpose, A, Y, X, NULL)); in MatMultTranspose_Ceed()