void PETScVector::getGlobalVector(PetscScalar u[]) { #ifdef TEST_MEM_PETSC PetscLogDouble mem1, mem2; PetscMemoryGetCurrentUsage(&mem1); #endif PetscScalar *xp = nullptr; VecGetArray(_v, &xp); gatherLocalVectors(xp, u); //This following line may be needed late on // for a communication load balance: //MPI_Barrier(PETSC_COMM_WORLD); VecRestoreArray(_v, &xp); //TEST #ifdef TEST_MEM_PETSC PetscMemoryGetCurrentUsage(&mem2); PetscPrintf(PETSC_COMM_WORLD, "### Memory usage by Updating. Before :%f After:%f Increase:%d\n", mem1, mem2, (int)(mem2 - mem1)); #endif }
void PETScLinearSolver::UpdateSolutions(PetscScalar *u) { #ifdef TEST_MEM_PETSC //TEST PetscLogDouble mem1, mem2; PetscMemoryGetCurrentUsage(&mem1); #endif PetscScalar *xp = NULL; //nullptr; VecGetArray(x, &xp); gatherLocalVectors(xp, u); //MPI_Barrier(PETSC_COMM_WORLD); VecRestoreArray(x, &xp); //TEST #ifdef TEST_MEM_PETSC PetscMemoryGetCurrentUsage(&mem2); PetscPrintf(PETSC_COMM_WORLD, "### Memory usage by Updating. Before :%f After:%f Increase:%d\n", mem1, mem2, (int)(mem2 - mem1)); #endif }