1樓:EPboy
手邊MPI的參考書沒帶
用過MS_MPI和MPICH2
這個應該是MPI_SUM 不是函式哦是乙個可以理解成預定義型別吧(我這麼理解的)
屬於 Predefined Reduce Operation
是MPI_Reduce 裡面的乙個引數
具體功能見下面的Tutorial
The following predefined operations are supplied for MPI_REDUCE and related functions MPI_ALLREDUCE, MPI_REDUCE_SCATTER, and MPI_SCAN. These operations are invoked by placing the following in op.
[ Name] Meaning
[ ][ MPI_MAX] maximum
[ MPI_MIN] minimum
[ MPI_SUM] sum
[ MPI_PROD] product
[ MPI_LAND] logical and
[ MPI_BAND] bit-wise and
[ MPI_LOR] logical or
[ MPI_BOR] bit-wise or
[ MPI_LXOR] logical xor
[ MPI_BXOR] bit-wise xor
[ MPI_MAXLOC] max value and location
[ MPI_MINLOC] min value and location
The two operations MPI_MINLOC and MPI_MAXLOC are discussed separately in Sec. MINLOC and MAXLOC . For the other predefined operations, we enumerate below the allowed combinations of op and datatype arguments.
First, define groups of MPI basic datatypes in the following way.
[ C integer:] MPI_INT, MPI_LONG, MPI_SHORT,
MPI_UNSIGNED_SHORT, MPI_UNSIGNED,
MPI_UNSIGNED_LONG
[ Fortran integer:] MPI_INTEGER
[ Floating point:] MPI_FLOAT, MPI_DOUBLE, MPI_REAL,
MPI_DOUBLE_PRECISION, MPI_LONG_DOUBLE
[ Logical:] MPI_LOGICAL
[ Complex:] MPI_COMPLEX
[ Byte:] MPI_BYTE
Now, the valid datatypes for each option is specified below.
[ Op] Allowed Types
[ ][ MPI_MAX, MPI_MIN] C integer, Fortran integer, Floating point
[ MPI_SUM, MPI_PROD] C integer, Fortran integer, Floating point, Complex
[ MPI_LAND, MPI_LOR, MPI_LXOR] C integer, Logical
[ MPI_BAND, MPI_BOR, MPI_BXOR] C integer, Fortran integer, Byte
Example
A routine that computes the dot product of two vectors that are distributed across a group of processes and returns the answer at node zero.
SUBROUTINE PAR_BLAS1(m, a, b, c, comm)
REAL a(m), b(mlocal slice of array
REAL cresult (at node zero)
REAL sum
INTEGER m, comm, i, ierr
! local sum
sum = 0.0
DO i = 1, m
sum = sum + a(i)*b(i)
END DO
! global sum
CALL MPI_REDUCE(sum, c, 1, MPI_REAL, MPI_SUM, 0, comm, ierr)
RETURN
Example
A routine that computes the product of a vector and an array that are distributed across a group of processes and returns the answer at node zero.
SUBROUTINE PAR_BLAS2(m, n, a, b, c, comm)
REAL a(m), b(m,n) ! local slice of array
REAL c(nresult
REAL sum(n)
INTEGER n, comm, i, j, ierr
! local sum
DO j= 1, n
sum(j) = 0.0
DO i = 1, m
sum(j) = sum(j) + a(i)*b(i,j)
END DO
END DO
! global sum
CALL MPI_REDUCE(sum, c, n, MPI_REAL, MPI_SUM, 0, comm, ierr)
! return result at node zero (and garbage at the other nodes)
RETURN
2樓:D Flip Flop
MPI所有名字都是以大寫MPI開頭的,所以我預設你說的是MPI_SUM
MPI_SUM不是乙個函式是乙個巨集,在我電腦上的MS_MPI裡定義是#define MPI_SUM ((MPI_Op)0x58000003)
MPI_Op型別的常用用法之一是在
intMPI_Reduce
(void
*sendbuf
,void
*recvbuf
,int
count
,MPI_Datatype
datatype
,MPI_Opop,
introot
,MPI_Comm
comm
);裡當op引數,如
MPI_Reduce(&
a,&sum,1
,MPI_DOUBLE
,MPI_SUM,0
,MPI_COMM_WORLD
);就是把每個程序中的變數a求和,結果放到0號程序的變數sum裡。
擬凹函式影象是什麼樣啊?
大長桿菌 最近微觀學到了擬凹,也在思考這個問題。根據定義,若函式 f 擬凹,則對定義域上任意兩點x y,都有f ax 1 a y min f x f y 0 a 1。容易證明,函式擬凹的充分必要條是,對任意實數k,集合 S 若非空則都是凸的。通過上面這一定理,可以大致畫出擬凹函式的影象。一 首先從簡...
奇函式加減常數是什麼函式?
黃博THU 定義出發,奇函式f x f x 加了常數C的奇函式g x f x C,則g x f x C f x C 如果所加的常數C是常數0,那麼g x g x 仍然為奇函式。如果原來的奇函式f x 0,g x g x C,為偶函式,常數C是常數0,還同時是奇函式。其它情況下,g x g x 並且g...
函式是什麼?怎麼理解?
首先要理解數學的本質是模型 由變數與常量構成的模型。例如 長度 面積 體積 溫度 壓力 時間 速度等等,我們研究這些量的變化。當這些量保持各種一定的數值,這種量叫做常量 但另外一些量卻有變化,也就是可取各種不同的數值,這種量叫做變數。在數學中,不管是常量還是變數,我們都不顧它們的物理意義,只注意它們...