@@ -82,20 +82,22 @@ load.balance <- function(X.spmd, bal.info = NULL, comm = .SPMD.CT$comm,
82
82
stop(" spmd.major = 1 or 2." )
83
83
}
84
84
85
+ storage.mode(X.spmd ) <- " double"
86
+
85
87
send.to <- as.integer(unique(bal.info $ send $ belong ))
86
88
if (length(send.to ) > 0 ){
87
89
if (spmd.major == 1 ){
88
90
for (i in send.to ){
89
91
if (i != COMM.RANK ){
90
92
tmp <- matrix (X.spmd [bal.info $ send $ belong == i ,], ncol = p )
91
- isend(tmp , rank.dest = i , tag = COMM.RANK , comm = comm )
93
+ spmd. isend.double (tmp , rank.dest = i , tag = COMM.RANK , comm = comm )
92
94
}
93
95
}
94
96
} else {
95
97
for (i in send.to ){
96
98
if (i != COMM.RANK ){
97
99
tmp <- matrix (X.spmd [, bal.info $ send $ belong == i ], nrow = p )
98
- isend(tmp , rank.dest = i , tag = COMM.RANK , comm = comm )
100
+ spmd. isend.double (tmp , rank.dest = i , tag = COMM.RANK , comm = comm )
99
101
}
100
102
}
101
103
}
@@ -107,22 +109,26 @@ load.balance <- function(X.spmd, bal.info = NULL, comm = .SPMD.CT$comm,
107
109
if (spmd.major == 1 ){
108
110
for (i in recv.from ){
109
111
if (i != COMM.RANK ){
110
- tmp <- recv(rank.source = i , tag = i , comm = comm )
111
- dim(tmp ) <- c(length(tmp ) / p , p )
112
+ total.row <- sum(bal.info $ recv $ org == i )
113
+ tmp <- spmd.recv.double(double(total.row * p ),
114
+ rank.source = i , tag = i , comm = comm )
115
+ dim(tmp ) <- c(total.row , p )
112
116
} else {
113
117
tmp <- matrix (X.spmd [bal.info $ send $ belong == i ,], ncol = p )
114
118
}
115
- ret <- base ::: rbind(ret , tmp )
119
+ ret <- base :: rbind(ret , tmp )
116
120
}
117
121
} else {
118
122
for (i in recv.from ){
119
123
if (i != COMM.RANK ){
120
- tmp <- recv(rank.source = i , tag = i , comm = comm )
121
- dim(tmp ) <- c(p , length(tmp ) / p )
124
+ total.column <- sum(bal.info $ recv $ org == i )
125
+ tmp <- spmd.recv.double(double(total.column * p ),
126
+ rank.source = i , tag = i , comm = comm )
127
+ dim(tmp ) <- c(p , total.column )
122
128
} else {
123
129
tmp <- matrix (X.spmd [, bal.info $ send $ belong == i ], nrow = p )
124
130
}
125
- ret <- base ::: cbind(ret , tmp )
131
+ ret <- base :: cbind(ret , tmp )
126
132
}
127
133
}
128
134
} else {
@@ -137,6 +143,8 @@ load.balance <- function(X.spmd, bal.info = NULL, comm = .SPMD.CT$comm,
137
143
}
138
144
}
139
145
146
+ spmd.wait()
147
+
140
148
ret
141
149
} # End of load.balance().
142
150
0 commit comments