@@ -702,12 +702,8 @@ def source_particle_dd(seed, mcdc):
702
702
def distribute_work_dd (N , mcdc , precursor = False ):
703
703
# Total # of work
704
704
work_size_total = N
705
-
706
- if not mcdc ["technique" ]["dd_repro" ]:
707
- work_size , work_start = domain_work (mcdc , mcdc ["dd_idx" ], N )
708
- else :
709
- work_start = 0
710
- work_size = work_size_total
705
+ work_start = 0
706
+ work_size = work_size_total
711
707
712
708
if not precursor :
713
709
mcdc ["mpi_work_start" ] = work_start
@@ -2145,6 +2141,38 @@ def calculate_distance_in_coarse_bin(start, end, distance, center, cs_bin_size):
2145
2141
return distance_inside
2146
2142
2147
2143
2144
+ @njit
2145
+ def dd_reduce (data , mcdc ):
2146
+ tally_bin = data [TALLY ]
2147
+
2148
+ # find number of subdomains
2149
+ d_Nx = mcdc ["technique" ]["dd_mesh" ]["x" ].size - 1
2150
+ d_Ny = mcdc ["technique" ]["dd_mesh" ]["y" ].size - 1
2151
+ d_Nz = mcdc ["technique" ]["dd_mesh" ]["z" ].size - 1
2152
+
2153
+ with objmode ():
2154
+ # assign processors to their subdomain group
2155
+ i = 0
2156
+ for n in range (d_Nx * d_Ny * d_Nz ):
2157
+ dd_group = []
2158
+ for r in range (int (mcdc ["technique" ]["dd_work_ratio" ][n ])):
2159
+ dd_group .append (i )
2160
+ i += 1
2161
+ # create MPI Comm group out of subdomain processors
2162
+ dd_group = MPI .COMM_WORLD .group .Incl (dd_group )
2163
+ dd_comm = MPI .COMM_WORLD .Create (dd_group )
2164
+ # MPI Reduce on subdomain processors
2165
+ buff = np .zeros_like (tally_bin [TALLY_SCORE ])
2166
+ if MPI .COMM_NULL != dd_comm :
2167
+ dd_comm .Reduce (tally_bin [TALLY_SCORE ], buff , MPI .SUM , 0 )
2168
+ if mcdc ["dd_idx" ] == n :
2169
+ tally_bin [TALLY_SCORE ][:] = buff
2170
+ # free comm group
2171
+ dd_group .Free ()
2172
+ if MPI .COMM_NULL != dd_comm :
2173
+ dd_comm .Free ()
2174
+
2175
+
2148
2176
@njit
2149
2177
def tally_reduce (data , mcdc ):
2150
2178
tally_bin = data [TALLY ]
@@ -2162,6 +2190,16 @@ def tally_reduce(data, mcdc):
2162
2190
MPI .COMM_WORLD .Reduce (tally_bin [TALLY_SCORE ], buff , MPI .SUM , 0 )
2163
2191
tally_bin [TALLY_SCORE ][:] = buff
2164
2192
2193
+ else :
2194
+ # find number of subdomains
2195
+ N_dd = 1
2196
+ N_dd *= mcdc ["technique" ]["dd_mesh" ]["x" ].size - 1
2197
+ N_dd *= mcdc ["technique" ]["dd_mesh" ]["y" ].size - 1
2198
+ N_dd *= mcdc ["technique" ]["dd_mesh" ]["z" ].size - 1
2199
+ # DD Reduce if multiple processors per subdomain
2200
+ if N_dd != mcdc ["mpi_size" ]:
2201
+ dd_reduce (data , mcdc )
2202
+
2165
2203
2166
2204
@njit
2167
2205
def tally_accumulate (data , mcdc ):
@@ -2178,6 +2216,42 @@ def tally_accumulate(data, mcdc):
2178
2216
tally_bin [TALLY_SCORE , i ] = 0.0
2179
2217
2180
2218
2219
+ @njit
2220
+ def dd_closeout (data , mcdc ):
2221
+ tally_bin = data [TALLY ]
2222
+
2223
+ # find number of subdomains
2224
+ d_Nx = mcdc ["technique" ]["dd_mesh" ]["x" ].size - 1
2225
+ d_Ny = mcdc ["technique" ]["dd_mesh" ]["y" ].size - 1
2226
+ d_Nz = mcdc ["technique" ]["dd_mesh" ]["z" ].size - 1
2227
+
2228
+ with objmode ():
2229
+ # assign processors to their subdomain group
2230
+ i = 0
2231
+ for n in range (d_Nx * d_Ny * d_Nz ):
2232
+ dd_ranks = []
2233
+ for r in range (int (mcdc ["technique" ]["dd_work_ratio" ][n ])):
2234
+ dd_ranks .append (i )
2235
+ i += 1
2236
+ # create MPI Comm group out of subdomain processors
2237
+ dd_group = MPI .COMM_WORLD .group .Incl (dd_ranks )
2238
+ dd_comm = MPI .COMM_WORLD .Create (dd_group )
2239
+ # MPI Reduce on subdomain processors
2240
+ buff = np .zeros_like (tally_bin [TALLY_SUM ])
2241
+ buff_sq = np .zeros_like (tally_bin [TALLY_SUM_SQ ])
2242
+ if MPI .COMM_NULL != dd_comm :
2243
+ dd_comm .Reduce (tally_bin [TALLY_SUM ], buff , MPI .SUM , 0 )
2244
+ dd_comm .Reduce (tally_bin [TALLY_SUM_SQ ], buff_sq , MPI .SUM , 0 )
2245
+ if mcdc ["dd_idx" ] == n :
2246
+ tally_bin [TALLY_SUM ] = buff
2247
+ tally_bin [TALLY_SUM_SQ ] = buff_sq
2248
+
2249
+ # free comm group
2250
+ dd_group .Free ()
2251
+ if MPI .COMM_NULL != dd_comm :
2252
+ dd_comm .Free ()
2253
+
2254
+
2181
2255
@njit
2182
2256
def tally_closeout (data , mcdc ):
2183
2257
tally = data [TALLY ]
@@ -2199,6 +2273,16 @@ def tally_closeout(data, mcdc):
2199
2273
tally [TALLY_SUM ] = buff
2200
2274
tally [TALLY_SUM_SQ ] = buff_sq
2201
2275
2276
+ else :
2277
+ # find number of subdomains
2278
+ N_dd = 1
2279
+ N_dd *= mcdc ["technique" ]["dd_mesh" ]["x" ].size - 1
2280
+ N_dd *= mcdc ["technique" ]["dd_mesh" ]["y" ].size - 1
2281
+ N_dd *= mcdc ["technique" ]["dd_mesh" ]["z" ].size - 1
2282
+ # DD Reduce if multiple processors per subdomain
2283
+ if N_dd != mcdc ["mpi_size" ]:
2284
+ dd_closeout (data , mcdc )
2285
+ # tally[TALLY_SUM_SQ] /= mcdc["technique"]["dd_work_ratio"][mcdc["dd_idx"]]
2202
2286
# Calculate and store statistics
2203
2287
# sum --> mean
2204
2288
# sum_sq --> standard deviation
0 commit comments