xref: /petsc/src/vec/vec/impls/mpi/pvec2.c (revision f3d7a62f6533e67ea91ec2c3a22908415b67fd0c)
1 /*
2      Code for some of the parallel vector primitives.
3 */
4 #include <../src/vec/vec/impls/mpi/pvecimpl.h>
5 #include <petscblaslapack.h>
6 
VecDot_MPI(Vec xin,Vec yin,PetscScalar * z)7 PetscErrorCode VecDot_MPI(Vec xin, Vec yin, PetscScalar *z)
8 {
9   PetscFunctionBegin;
10   PetscCall(VecXDot_MPI_Default(xin, yin, z, VecDot_Seq));
11   PetscFunctionReturn(PETSC_SUCCESS);
12 }
13 
VecTDot_MPI(Vec xin,Vec yin,PetscScalar * z)14 PetscErrorCode VecTDot_MPI(Vec xin, Vec yin, PetscScalar *z)
15 {
16   PetscFunctionBegin;
17   PetscCall(VecXDot_MPI_Default(xin, yin, z, VecTDot_Seq));
18   PetscFunctionReturn(PETSC_SUCCESS);
19 }
20 
VecMDot_MPI(Vec xin,PetscInt nv,const Vec y[],PetscScalar * z)21 PetscErrorCode VecMDot_MPI(Vec xin, PetscInt nv, const Vec y[], PetscScalar *z)
22 {
23   PetscFunctionBegin;
24   PetscCall(VecMXDot_MPI_Default(xin, nv, y, z, VecMDot_Seq));
25   PetscFunctionReturn(PETSC_SUCCESS);
26 }
27 
VecMDot_MPI_GEMV(Vec xin,PetscInt nv,const Vec y[],PetscScalar * z)28 PetscErrorCode VecMDot_MPI_GEMV(Vec xin, PetscInt nv, const Vec y[], PetscScalar *z)
29 {
30   PetscFunctionBegin;
31   PetscCall(VecMXDot_MPI_Default(xin, nv, y, z, VecMDot_Seq_GEMV));
32   PetscFunctionReturn(PETSC_SUCCESS);
33 }
34 
VecMTDot_MPI(Vec xin,PetscInt nv,const Vec y[],PetscScalar * z)35 PetscErrorCode VecMTDot_MPI(Vec xin, PetscInt nv, const Vec y[], PetscScalar *z)
36 {
37   PetscFunctionBegin;
38   PetscCall(VecMXDot_MPI_Default(xin, nv, y, z, VecMTDot_Seq));
39   PetscFunctionReturn(PETSC_SUCCESS);
40 }
41 
VecMTDot_MPI_GEMV(Vec xin,PetscInt nv,const Vec y[],PetscScalar * z)42 PetscErrorCode VecMTDot_MPI_GEMV(Vec xin, PetscInt nv, const Vec y[], PetscScalar *z)
43 {
44   PetscFunctionBegin;
45   PetscCall(VecMXDot_MPI_Default(xin, nv, y, z, VecMTDot_Seq_GEMV));
46   PetscFunctionReturn(PETSC_SUCCESS);
47 }
48 
VecNorm_MPI(Vec xin,NormType type,PetscReal * z)49 PetscErrorCode VecNorm_MPI(Vec xin, NormType type, PetscReal *z)
50 {
51   PetscFunctionBegin;
52   PetscCall(VecNorm_MPI_Default(xin, type, z, VecNorm_Seq));
53   PetscFunctionReturn(PETSC_SUCCESS);
54 }
55 
VecMax_MPI(Vec xin,PetscInt * idx,PetscReal * z)56 PetscErrorCode VecMax_MPI(Vec xin, PetscInt *idx, PetscReal *z)
57 {
58   const MPI_Op ops[] = {MPIU_MAXLOC, MPIU_MAX};
59 
60   PetscFunctionBegin;
61   PetscCall(VecMinMax_MPI_Default(xin, idx, z, VecMax_Seq, ops));
62   PetscFunctionReturn(PETSC_SUCCESS);
63 }
64 
VecMin_MPI(Vec xin,PetscInt * idx,PetscReal * z)65 PetscErrorCode VecMin_MPI(Vec xin, PetscInt *idx, PetscReal *z)
66 {
67   const MPI_Op ops[] = {MPIU_MINLOC, MPIU_MIN};
68 
69   PetscFunctionBegin;
70   PetscCall(VecMinMax_MPI_Default(xin, idx, z, VecMin_Seq, ops));
71   PetscFunctionReturn(PETSC_SUCCESS);
72 }
73 
VecMaxPointwiseDivide_MPI(Vec xin,Vec yin,PetscReal * z)74 PetscErrorCode VecMaxPointwiseDivide_MPI(Vec xin, Vec yin, PetscReal *z)
75 {
76   PetscFunctionBegin;
77   PetscCall(VecMaxPointwiseDivide_Seq(xin, yin, z));
78   PetscCallMPI(MPIU_Allreduce(MPI_IN_PLACE, z, 1, MPIU_REAL, MPIU_MAX, PetscObjectComm((PetscObject)xin)));
79   PetscFunctionReturn(PETSC_SUCCESS);
80 }
81