내가 루프 아래 코드의 주요 부분을 찾고 있어요 촬영 한 다음 루프 여기코드 X 시간의 조각은 평균
에서 수집 한 결과의 평균을 계산하는 방법 루프 코드입니다 :
class PingPongVariousLengths {
static public void main(String[] args) {
MPI.Init(args);
int myrank = MPI.COMM_WORLD.Rank();
int tag = 99;
int maxlen = 104857600; //200 megabytes 104857600 characters * 2 bytes per character = 209715200 bytes total, or 200 megabytes
int minlen = 1; // 2 bytes
char [] sendbuff = new char [maxlen];
char [] recvbuff = new char [maxlen];
long speedKbps;
long speedMbps;
if (myrank == 0) {
for (int len = minlen; len <= maxlen; len *= 2) { //len=*2 doubles the ping size each time
long startTime = System.nanoTime();
MPI.COMM_WORLD.Send(sendbuff, 0, len, MPI.CHAR, 1, tag);
MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 1, tag);
long endTime = System.nanoTime();
long duration = endTime - startTime;
long durationseconds = (duration * 10-9); // Converts nanoseconds to seconds
System.out.println("Time for the ping to be sent and recived of " + (len*2) + " bytes is " + durationseconds + " seconds"); // multiples by 2 becuase 1 character is 2 bytes
//double transferRate = ((len*2.0)/durationseconds) ; //amount of data in bytes transferred in 1 second. Currently returning 0 for every result
//System.out.println("transferRate: " + transferRate + " bytes per second");
double transferRateMb = ((len*524288.0)/durationseconds) ; //amount of data in megabytes transferred in 1 second.
System.out.println("transferRate (megabytes) : " + transferRateMb + " megabytes per second");
}
} else if (myrank == 1) {
for (int len = minlen; len <= maxlen; len *= 2) {
MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 0, tag);
MPI.COMM_WORLD.Send(recvbuff, 0, len, MPI.CHAR, 0, tag);
}
}
MPI.Finalize();
}
}
은 내가
,691,363에 for (int len = minlen; len <= maxlen; len *= 2) { //len=*2 doubles the ping size each time
에서, 그것은 10 또는 20 회 말 루프에 코드를 시도하고있다 (210)
long durationseconds = (duration * 10-9); // Converts nanoseconds to seconds
은 내가 당신을 이해하면 내가 어떻게 가장 가장 효율적이
당신이 정말이 요청하는 경우 ... 일반적으로 평균 ... 1/N * 합계 (기간)을 모든 기간을 추가하여 계산 한 후? 사이클의 수에 의해 분할 될 수있다 – gausss
있는지 "를하지 않음 평균을 계산합니다. "너 무슨 소리 야? –
위에서 편집 했으니 희망적으로 첫 번째 혼란스러운 질문에 대해 유감스럽게 생각합니다. – user2065929