Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Creating Profiling Tools to Analyze and
Optimize FiPy
Danya D. Murali
Advisors: Jonathan E. Guyer and Daniel Wheeler
Mater...
Outline
● FiPy Introduction
● How it works
● Examples
● Problems with FiPy
● Profiling Tools
● What are the they?
● How ou...
What is FiPy?
● An open source Python-based program that
uses the Finite Volume method to numerically
solve Partial Differ...
What is a PDE?
Finite Volume Method
● Solve a general PDE on a given domain for a field
Finite Volume Method
● Solve a general PDE on a given domain for a field
● Integrate PDE over general control volumes
Finite Volume Method
● Solve a general PDE on a given domain for a field
● Integrate PDE over general control volumes
● In...
Finite Volume Method
● Solve a general PDE on a given domain for a field
● Integrate PDE over general control volumes
● In...
How FiPy Works
import fipy as fp
L = 1.
N = 100
m = fp.Grid2D(Lx=L, Ly=L, nx=N, ny=N)
v = fp.CellVariable(mesh=m)
x, y = m...
How FiPy Works
import fipy as fp
L = 1.
N = 100
m = fp.Grid2D(Lx=L, Ly=L, nx=N, ny=N)
v = fp.CellVariable(mesh=m)
x, y = m...
Examples of FiPy: Polycrystal and Phase Field
courtesy S. A. David, ORNL
courtesy S. A. David, ORNL
Examples of FiPy: Polycrystal and Phase Field
courtesy S. A. David, ORNL
Examples of FiPy: Polycrystal and Phase Field
heatEq = (TransientTerm(var=dT)
== DiffusionTerm(...
courtesy S. A. David, ORNL
Examples of FiPy: Polycrystal and Phase Field
Examples Of FiPy: Extreme Fill
Examples Of FiPy: Extreme Fill
adsorptionCoeff = dt * suppressor * kPlus
thetaEq = fp.TransientTerm() ==
fp.ExplicitUpwind...
Examples Of FiPy: Extreme Fill
Problems with FiPy
● Potentially time
inefficient and excessive
in memory usage
● But how do we measure
that?
● Why do we ...
Profiling Tools
● What is profiling?
● Tool used to identify and quantify what resources
are being used by certain parts o...
Profiling Tools
● What is profiling?
● Tool used to identify and quantify what resources
are being used by certain parts o...
Profiling Tools
● What is profiling?
● Tool used to identify and quantify what resources
are being used by certain parts o...
Profiling Tools
● What is profiling?
● Tool used to identify and quantify what resources
are being used by certain parts o...
Profiling Tools
● What is profiling?
● Tool used to identify and quantify what resources
are being used by certain parts o...
Speed Profiling
class FiPyProfileTime(FiPyProfile):
def __init__(self, profileFunc, ncells, regenerate=False):
...
def pro...
Memory Profiling
class MemoryProfiler(object):
def __init__(self, profileMethod, runfunc):
...
def decorate(self, func):
d...
Results: Profiling Polycrystal - Memory
Results: Profiling Polycrystal - Speed
Results: Profiling Extreme Fill - Memory
Results: Profiling Extreme Fill - Speed
Results: Profiling Different Solvers
So What?
● Identified that FiPy has memory issues that need
to be addressed
● Limits the size of simulations that we can r...
So What?
● Identified that FiPy has memory issues that need
to be addressed
● Limits the size of simulations that we can r...
So What?
● Identified that FiPy has memory issues that need
to be addressed
● Limits the size of simulations that we can r...
So What?
● Identified that FiPy has memory issues that need
to be addressed
● Limits the size of simulations that we can r...
So What?
● Identified that FiPy has memory issues that need
to be addressed
● Limits the size of simulations that we can r...
Acknowledgements
● Mentors: Dr. Jon Guyer and Dr. Daniel Wheeler
● SHIP Student: Mira Holford
● SURF Program Staff and Pee...
Questions?
Upcoming SlideShare
Loading in …5
×

Creating Profiling Tools to Analyze and Optimize FiPy Presentation

642 views

Published on

Published in: Technology, Spiritual
  • Be the first to comment

Creating Profiling Tools to Analyze and Optimize FiPy Presentation

  1. 1. Creating Profiling Tools to Analyze and Optimize FiPy Danya D. Murali Advisors: Jonathan E. Guyer and Daniel Wheeler Materials Measurement Laboratory Material Science and Engineering Division Center for Theoretical and Computational Material Science
  2. 2. Outline ● FiPy Introduction ● How it works ● Examples ● Problems with FiPy ● Profiling Tools ● What are the they? ● How our tools work ● Results ● Conclusion
  3. 3. What is FiPy? ● An open source Python-based program that uses the Finite Volume method to numerically solve Partial Differential Equations (PDEs) ● Python has many powerful numerical libraries ● Designed for material scientists by material scientists
  4. 4. What is a PDE?
  5. 5. Finite Volume Method ● Solve a general PDE on a given domain for a field
  6. 6. Finite Volume Method ● Solve a general PDE on a given domain for a field ● Integrate PDE over general control volumes
  7. 7. Finite Volume Method ● Solve a general PDE on a given domain for a field ● Integrate PDE over general control volumes ● Integrate PDE over polyhedral control volumes
  8. 8. Finite Volume Method ● Solve a general PDE on a given domain for a field ● Integrate PDE over general control volumes ● Integrate PDE over polyhedral control volumes ● Obtain a set of linear equations
  9. 9. How FiPy Works import fipy as fp L = 1. N = 100 m = fp.Grid2D(Lx=L, Ly=L, nx=N, ny=N) v = fp.CellVariable(mesh=m) x, y = m.cellCenters v[x > L / 2] = 1. v.constrain(0., where=m.facesLeft | m.facesRight) v.constrain(1., where=m.facesTop | m.facesBottom) e = fp.TransientTerm() == fp.DiffusionTerm() for i in range(10): e.solve(v, dt=0.001) fp.Viewer(v).plot()
  10. 10. How FiPy Works import fipy as fp L = 1. N = 100 m = fp.Grid2D(Lx=L, Ly=L, nx=N, ny=N) v = fp.CellVariable(mesh=m) x, y = m.cellCenters v[x > L / 2] = 1. v.constrain(0., where=m.facesLeft | m.facesRight) v.constrain(1., where=m.facesTop | m.facesBottom) e = fp.TransientTerm() == fp.DiffusionTerm() for i in range(10): e.solve(v, dt=0.001) fp.Viewer(v).plot()
  11. 11. Examples of FiPy: Polycrystal and Phase Field courtesy S. A. David, ORNL
  12. 12. courtesy S. A. David, ORNL Examples of FiPy: Polycrystal and Phase Field
  13. 13. courtesy S. A. David, ORNL Examples of FiPy: Polycrystal and Phase Field heatEq = (TransientTerm(var=dT) == DiffusionTerm(coeff=Dt, var=dT) + TransientTerm(var=phase)) psi = theta + arctan2(phase.faceGrad[1], phase.faceGrad[0]) Phi = tan(N * psi / 2) PhiSq = Phi**2 beta = (1. - PhiSq) / (1. + PhiSq) DbetaDpsi = -N * 2 * Phi / (1 + PhiSq) Ddia = (1.+ c * beta) Doff = c * DbetaDpsi D = alpha**2 * (1.+ c * beta) * (Ddia * (( 1, 0), ( 0, 1)) + Doff * (( 0,-1), ( 1, 0))) phaseEq = (TransientTerm(coeff=tau, var=phase) == DiffusionTerm(coeff=D, var=phase) + ImplicitSourceTerm(coeff=(phase - 0.5 - kappa1 / pi * arctan(kappa2 * dT)) * (1 - phase)), var=phase) eq = heatEq & phaseEq
  14. 14. courtesy S. A. David, ORNL Examples of FiPy: Polycrystal and Phase Field
  15. 15. Examples Of FiPy: Extreme Fill
  16. 16. Examples Of FiPy: Extreme Fill adsorptionCoeff = dt * suppressor * kPlus thetaEq = fp.TransientTerm() == fp.ExplicitUpwindConvectionTerm(fp.SurfactantConvectionVariable(di stance)) + adsorptionCoeff * surface - fp.ImplicitSourceTerm(adsorptionCoeff * distance._cellInterfaceFlag) - fp.ImplicitSourceTerm(kMinus * depositionRate * dt)
  17. 17. Examples Of FiPy: Extreme Fill
  18. 18. Problems with FiPy ● Potentially time inefficient and excessive in memory usage ● But how do we measure that? ● Why do we even care? ● How do we find the bottlenecks? ● Need profiling tools!
  19. 19. Profiling Tools ● What is profiling? ● Tool used to identify and quantify what resources are being used by certain parts of a program
  20. 20. Profiling Tools ● What is profiling? ● Tool used to identify and quantify what resources are being used by certain parts of a program ● Our profiler needs to:
  21. 21. Profiling Tools ● What is profiling? ● Tool used to identify and quantify what resources are being used by certain parts of a program ● Our profiler needs to: ● Profile multiple functions at once
  22. 22. Profiling Tools ● What is profiling? ● Tool used to identify and quantify what resources are being used by certain parts of a program ● Our profiler needs to: ● Profile multiple functions at once ● Cache profiling data for many simulations
  23. 23. Profiling Tools ● What is profiling? ● Tool used to identify and quantify what resources are being used by certain parts of a program ● Our profiler needs to: ● Profile multiple functions at once ● Cache profiling data for many simulations ● Produce graphs of performance scaling against system size
  24. 24. Speed Profiling class FiPyProfileTime(FiPyProfile): def __init__(self, profileFunc, ncells, regenerate=False): ... def profile(self, ncell): ... def get_time_for_function(self, function_key): return stats[function_key] def get_key_from_function_pointer(function_pointer): return inspect.getfile(function_pointer) def plot(self, keys, field="cumulative"): ...
  25. 25. Memory Profiling class MemoryProfiler(object): def __init__(self, profileMethod, runfunc): ... def decorate(self, func): def wrapper(*args, **kwargs): ... return self.codeMap def getLineMemory(self, line): ... class MemoryViewer(object): def generateData(self): def worker(ncell, resultQ, profileMethod, runfunc, lines): process = multiprocessing.Process(...)
  26. 26. Results: Profiling Polycrystal - Memory
  27. 27. Results: Profiling Polycrystal - Speed
  28. 28. Results: Profiling Extreme Fill - Memory
  29. 29. Results: Profiling Extreme Fill - Speed
  30. 30. Results: Profiling Different Solvers
  31. 31. So What? ● Identified that FiPy has memory issues that need to be addressed ● Limits the size of simulations that we can run ● Located the classic memory for speed trade off with Gmsh ● Determined that using inline was faster ● Identified that Trilinos is much slower than Pysparse but has the option to run in parallel ● Next Step: Analyze algorithms to figure out how to address these issues
  32. 32. So What? ● Identified that FiPy has memory issues that need to be addressed ● Limits the size of simulations that we can run ● Located the classic memory for speed trade off with Gmsh ● Determined that using inline was faster ● Identified that Trilinos is much slower than Pysparse but has the option to run in parallel ● Next Step: Analyze algorithms to figure out how to address these issues
  33. 33. So What? ● Identified that FiPy has memory issues that need to be addressed ● Limits the size of simulations that we can run ● Located the classic memory for speed trade off with Gmsh ● Determined that using inline was faster ● Identified that Trilinos is much slower than Pysparse but has the option to run in parallel ● Next Step: Analyze algorithms to figure out how to address these issues
  34. 34. So What? ● Identified that FiPy has memory issues that need to be addressed ● Limits the size of simulations that we can run ● Located the classic memory for speed trade off with Gmsh ● Determined that using inline was faster ● Identified that Trilinos is much slower than Pysparse but has the option to run in parallel ● Next Step: Analyze algorithms to figure out how to address these issues
  35. 35. So What? ● Identified that FiPy has memory issues that need to be addressed ● Limits the size of simulations that we can run ● Located the classic memory for speed trade off with Gmsh ● Determined that using inline was faster ● Identified that Trilinos is much slower than Pysparse but has the option to run in parallel ● Next Step: Analyze algorithms to figure out how to address these issues
  36. 36. Acknowledgements ● Mentors: Dr. Jon Guyer and Dr. Daniel Wheeler ● SHIP Student: Mira Holford ● SURF Program Staff and Peers
  37. 37. Questions?

×