-
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
added print_chunk_costs #983
Conversation
Might not be quite what you want — we probably want to sum the chunks on each process. Updated: PR now prints cost per process. |
src/structure.cpp
Outdated
for (int i = 0; i < count_processors(); i++) | ||
costs[i] = 0; | ||
for (int i = 0; i < num_chunks; i++) | ||
costs[chunks[i]->n_proc()] += chunk_cost(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, this line seems to be producing a segmentation fault at runtime even though make
for this branch/PR finishes without errors.
[simpetus:16699] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f85427c3890]
[simpetus:16699] [ 1] /usr/local/lib/libctlgeom.so.7(+0x3bc4)[0x7f8540759bc4]
[simpetus:16699] [ 2] /usr/local/lib/libctlgeom.so.7(geom_fix_object_ptr+0x479)[0x7f8540761549]
[simpetus:16699] [ 3] /usr/local/lib/libctlgeom.so.7(geom_get_bounding_box+0x34)[0x7f8540761da4]
[simpetus:16699] [ 4] /usr/local/lib/libctlgeom.so.7(overlap_with_object+0x123)[0x7f8540763103]
[simpetus:16699] [ 5] /home/oskooi/install/meep6/src/.libs/libmeep.so.16(_ZN9meep_geom14fragment_stats13compute_statsEv+0x9a)[0x7f8540c156aa]
[simpetus:16699] [ 6] /home/oskooi/install/meep6/src/.libs/libmeep.so.16(_ZN9meep_geom14fragment_stats7computeEv+0x9)[0x7f8540c16269]
[simpetus:16699] [ 7] /home/oskooi/install/meep6/src/.libs/libmeep.so.16(_ZNK4meep11grid_volume8get_costEv+0x55)[0x7f8540be5555]
[simpetus:16699] [ 8] /home/oskooi/install/meep6/src/.libs/libmeep.so.16(_ZNK4meep9structure21print_estimated_costsEv+0xc3)[0x7f8540bab773]
[simpetus:16699] [ 9] /home/oskooi/install/meep6/python/meep/_meep.so(+0x62533)[0x7f8540ebc533]
[simpetus:16699] [10] corrupted double-linked list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a master_printf("n_proc[%d] = %d\n", i, chunks[i]->n_proc());
line above this line to see what the value of n_proc
is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n_proc()
is not the issue (i.e., output is as expected), rather it's the function call chunks[i]->gv.get_cost()
inside chunk_cost(int i)
which is causing the error. Could this have something to do with get_cost()
being a const
function?
empty cell import meep as mp
cell_size = mp.Vector3(10,10,10)
sim = mp.Simulation(resolution=10,
cell_size=(10,10,10),
split_chunks_evenly=False.
collect_stats=True)
sim.init_sim()
sim.structure.print_estimated_costs() output
|
If I call compute_fragment_stats explicitly then it works (it gives a nonzero cost): import meep as mp
cell_size = mp.Vector3(10,10,10)
sim = mp.Simulation(resolution=10,
cell_size=(10,10,10),
split_chunks_evenly=False)
sim.init_sim()
sim._compute_fragment_stats(sim.structure.user_volume)
sim.structure.print_estimated_costs() |
When python passes a Two solutions come to mind:
|
In the following example involving a grating outcoupler, the standard deviation value of the chunk costs is exactly
grating.py import meep as mp
from meep.materials import Si, SiO2_aniso
import math
import argparse
def main(args):
h = args.hh
w = args.w
a = args.a
d = args.d
N = args.N
N = N+1
wvl_cen = 1.55
dair_sub = 0.5
dpml = wvl_cen
boundary_layers = [mp.PML(dpml)]
sxy = 2*(N+dpml)
sz = dpml+dair_sub+h+dair_sub+dpml
cell_size = mp.Vector3(sxy,sxy,sz)
geometry = []
# rings of Bragg grating
for n in range(N,0,-1):
geometry.append(mp.Cylinder(material=Si,
center=mp.Vector3(0,0,0),
radius=n*a,
height=h))
geometry.append(mp.Cylinder(material=mp.air,
center=mp.Vector3(0,0,0),
radius=n*a-d,
height=h))
# remove left half of Bragg grating rings to form semi circle
geometry.append(mp.Block(material=mp.air,
center=mp.Vector3(-0.5*N*a,0,0),
size=mp.Vector3(N*a,2*N*a,h)))
geometry.append(mp.Cylinder(material=Si,
center=mp.Vector3(0,0,0),
radius=a-d,
height=h))
# angle sides of Bragg grating
# rotation angle of sides relative to Y axis (degrees)
rot_theta = -math.radians(args.rot_theta)
pvec = mp.Vector3(0,0.5*w,0)
cvec = mp.Vector3(-0.5*N*a,0.5*N*a+0.5*w,0)
rvec = cvec-pvec
rrvec = rvec.rotate(mp.Vector3(0,0,1), rot_theta)
geometry.append(mp.Block(material=mp.air,
center=pvec+rrvec,
size=mp.Vector3(N*a,N*a,h),
e1=mp.Vector3(1,0,0).rotate(mp.Vector3(0,0,1),rot_theta),
e2=mp.Vector3(0,1,0).rotate(mp.Vector3(0,0,1),rot_theta),
e3=mp.Vector3(0,0,1)))
pvec = mp.Vector3(0,-0.5*w,0)
cvec = mp.Vector3(-0.5*N*a,-(0.5*N*a+0.5*w),0)
rvec = cvec-pvec
rrvec = rvec.rotate(mp.Vector3(0,0,1),-rot_theta)
geometry.append(mp.Block(material=mp.air,
center=pvec+rrvec,
size=mp.Vector3(N*a,N*a,h),
e1=mp.Vector3(1,0,0).rotate(mp.Vector3(0,0,1),-rot_theta),
e2=mp.Vector3(0,1,0).rotate(mp.Vector3(0,0,1),-rot_theta),
e3=mp.Vector3(0,0,1)))
# input waveguide
geometry.append(mp.Block(material=mp.air,
center=mp.Vector3(-0.25*sxy,0.5*w+0.5*a,0),
size=mp.Vector3(0.5*sxy,a,h)))
geometry.append(mp.Block(material=mp.air,
center=mp.Vector3(-0.25*sxy,-(0.5*w+0.5*a),0),
size=mp.Vector3(0.5*sxy,a,h)))
geometry.append(mp.Block(material=Si,
center=mp.Vector3(-0.25*sxy,0,0),
size=mp.Vector3(0.5*sxy,w,h)))
# substrate
geometry.append(mp.Block(material=SiO2_aniso,
center=mp.Vector3(0,0,-0.5*sz+0.25*(sz-h)),
size=mp.Vector3(mp.inf,mp.inf,0.5*(sz-h))))
# mode frequency
fcen = 1/wvl_cen
sim = mp.Simulation(resolution=args.res,
cell_size=cell_size,
boundary_layers=boundary_layers,
geometry=geometry,
dimensions=3,
split_chunks_evenly=False,
eps_averaging=False)
nearfield = sim.add_near2far(fcen, 0.2*fcen, args.nfreq, mp.Near2FarRegion(mp.Vector3(0,0,0.5*sz-dpml), size=mp.Vector3(sxy-2*dpml,sxy-2*dpml,0)))
sim.init_sim()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-hh', type=float, default=0.22, help='wavelength height (default: 0.22 um)')
parser.add_argument('-w', type=float, default=0.50, help='wavelength width (default: 0.50 um)')
parser.add_argument('-a', type=float, default=1.0, help='Bragg grating periodicity/lattice parameter (default: 1.0 um)')
parser.add_argument('-d', type=float, default=0.5, help='Bragg grating thickness (default: 0.5 um)')
parser.add_argument('-N', type=int, default=5, help='number of grating periods')
parser.add_argument('-rot_theta', type=float, default=20, help='rotation angle of sides relative to Y axis (default: 20 degrees)')
parser.add_argument('-res', type=int, default=30, help='resolution (default: 30 pixels/um)')
parser.add_argument('-nfreq', type=int, default=50, help='number of frequency bins (default: 50)')
args = parser.parse_args()
main(args) |
Should be fixed by 7f7e85d |
Now that #994 is merged you will need to call |
* added print_chunk_costs * print estimated cost per process, not per chunk * initialize to zero * tweak * print in choose_chunkdivision * only print cost estimates for split by cost
Add a routine to print the estimated chunk costs. Run it with
sim.structure.print_chunk_costs()
sim.structure.print_estimated_costs()
.Update: now prints as part of
choose_chunkdivision
if!quiet