1 #include <../src/ksp/ksp/impls/gmres/gmresimpl.h> /*I "petscksp.h" I*/ 2 3 /*@ 4 KSPGMRESSetPreAllocateVectors - Causes `KSPGMRES` and `KSPFGMRES` to preallocate all its 5 needed work vectors at initial setup rather than the default, which 6 is to allocate several at a time when needed. 7 8 Logically Collective 9 10 Input Parameter: 11 . ksp - iterative context obtained from `KSPCreate()` 12 13 Options Database Key: 14 . -ksp_gmres_preallocate - Activates `KSPGmresSetPreAllocateVectors()` 15 16 Level: intermediate 17 18 Notes: 19 If one knows the number of iterations will be greater than or equal to the `KSPGMRESSetRestart()` size then calling 20 this routine can result in faster performance since it minimizes the number of separate memory allocations used 21 and can improve the performance of `VecMDot()` and `VecMAXPY()` which may utilize BLAS 2 operations that benefit from 22 the larger allocations. 23 24 Using this function with vectors in GPU memory may waste GPU memory if not all the restart directions are used in solving the system, 25 that is the solver converges before the number of iterations reaches the restart value. 26 27 .seealso: [](ch_ksp), `KSPGMRESSetRestart()`, `KSPGMRESSetOrthogonalization()`, `KSPGMRESGetOrthogonalization()`, 28 `VecMDot()`, `VecMAXPY()` 29 @*/ 30 PetscErrorCode KSPGMRESSetPreAllocateVectors(KSP ksp) 31 { 32 PetscFunctionBegin; 33 PetscTryMethod(ksp, "KSPGMRESSetPreAllocateVectors_C", (KSP), (ksp)); 34 PetscFunctionReturn(PETSC_SUCCESS); 35 } 36