-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bisection search for faster splitting #966
Conversation
This is failing
change
to
|
|
The I noticed a problem where my bisection search might not converge and hopefully fixed it. |
Good, so it is coming up with the same (or almost the same…could differ by ±1 pixel) chunking. |
Independent of this PR, it would be nice to understand why some of the corner chunks are a different process (color) than the surrounding chunks — to minimize communication costs, it seems like we would want to assign each process to a contiguous set of chunks where possible. |
The following are the chunk layouts for a tall, skinny, 2d cell with an expensive flux region at one end for the import meep as mp
import matplotlib.pyplot as plt
sx = 30
sy = 5
fcen = 1.0
df = 0.1
nfreq = 500
src = mp.Source(mp.GaussianSource(fcen,fwidth=df),
component=mp.Ez,
center=mp.Vector3())
sim = mp.Simulation(cell_size=mp.Vector3(sx,sy),
sources=[src],
resolution=20,
verbose=True,
k_point=mp.Vector3(0.53,0.14,0),
split_chunks_evenly=False)
flux = sim.add_flux(fcen,
df,
nfreq,
mp.FluxRegion(center=mp.Vector3(14),size=mp.Vector3(y=sy)))
sim.init_sim()
sim.visualize_chunks()
if mp.am_master():
plt.savefig('imbalanced_2d_chunk_layout.png') master
this PR
|
* bisection search for faster splitting * make sure bisection search terminates * refactor split_by_cost to not repeat bisection search n times for split_into_n
This updates the
split_by_cost
function to do a bisection search along each axis to find a balanced splitting, rather than searching every possible splitting, which should speed things up for large simulations.(In most cases the left and right costs should be monotonic functions of the splitting point, in which cases a bisection search should be equivalent to checking every possible point.)
split_into_three
should have similar improvements, but that isn't touched by this PR.