SlideShare uma empresa Scribd logo
1 de 37
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
Outline
● FiPy Introduction
● How it works
● Examples
● Problems with FiPy
● Profiling Tools
● What are the they?
● How our tools work
● Results
● Conclusion
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
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
● Integrate PDE over polyhedral control volumes
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
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()
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()
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(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
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.ExplicitUpwindConvectionTerm(fp.SurfactantConvectionVariable(di
stance)) 
+ adsorptionCoeff * surface 
- fp.ImplicitSourceTerm(adsorptionCoeff *
distance._cellInterfaceFlag) 
- fp.ImplicitSourceTerm(kMinus * depositionRate * dt)
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 even care?
● How do we find the
bottlenecks?
● Need profiling tools!
Profiling Tools
● What is profiling?
● Tool used to identify and quantify what resources
are being used by certain parts of a program
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:
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
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
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
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"):
...
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(...)
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 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
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
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
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
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
Acknowledgements
● Mentors: Dr. Jon Guyer and Dr. Daniel Wheeler
● SHIP Student: Mira Holford
● SURF Program Staff and Peers
Questions?

Mais conteúdo relacionado

Mais procurados

Extending Python - FOSDEM 2015
Extending Python - FOSDEM 2015Extending Python - FOSDEM 2015
Extending Python - FOSDEM 2015fcofdezc
 
Using Raspberry Pi GPU for DNN
Using Raspberry Pi GPU for DNNUsing Raspberry Pi GPU for DNN
Using Raspberry Pi GPU for DNNnotogawa
 
Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Younggun Kim
 
Knowing your Python Garbage Collector
Knowing your Python Garbage CollectorKnowing your Python Garbage Collector
Knowing your Python Garbage Collectorfcofdezc
 
Python for Chemistry
Python for ChemistryPython for Chemistry
Python for Chemistryguest5929fa7
 
Python NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | EdurekaPython NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | EdurekaEdureka!
 
SunPy: Python for solar physics
SunPy: Python for solar physicsSunPy: Python for solar physics
SunPy: Python for solar physicssegfaulthunter
 
Building Scalable Semantic Geospatial RDF Stores
Building Scalable Semantic Geospatial RDF StoresBuilding Scalable Semantic Geospatial RDF Stores
Building Scalable Semantic Geospatial RDF StoresKostis Kyzirakos
 

Mais procurados (9)

Extending Python - FOSDEM 2015
Extending Python - FOSDEM 2015Extending Python - FOSDEM 2015
Extending Python - FOSDEM 2015
 
Using Raspberry Pi GPU for DNN
Using Raspberry Pi GPU for DNNUsing Raspberry Pi GPU for DNN
Using Raspberry Pi GPU for DNN
 
Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015
 
defense
defensedefense
defense
 
Knowing your Python Garbage Collector
Knowing your Python Garbage CollectorKnowing your Python Garbage Collector
Knowing your Python Garbage Collector
 
Python for Chemistry
Python for ChemistryPython for Chemistry
Python for Chemistry
 
Python NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | EdurekaPython NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | Edureka
 
SunPy: Python for solar physics
SunPy: Python for solar physicsSunPy: Python for solar physics
SunPy: Python for solar physics
 
Building Scalable Semantic Geospatial RDF Stores
Building Scalable Semantic Geospatial RDF StoresBuilding Scalable Semantic Geospatial RDF Stores
Building Scalable Semantic Geospatial RDF Stores
 

Semelhante a Creating Profiling Tools to Analyze and Optimize FiPy Presentation

Deep Learning Applications (dadada2017)
Deep Learning Applications (dadada2017)Deep Learning Applications (dadada2017)
Deep Learning Applications (dadada2017)Abhishek Thakur
 
FEC2017-Introduction-to-programming
FEC2017-Introduction-to-programmingFEC2017-Introduction-to-programming
FEC2017-Introduction-to-programmingHenrikki Tenkanen
 
Python 101 - Indonesia AI Society.pdf
Python 101 - Indonesia AI Society.pdfPython 101 - Indonesia AI Society.pdf
Python 101 - Indonesia AI Society.pdfHendri Karisma
 
How to Improve Computer Vision with Geospatial Tools
How to Improve Computer Vision with Geospatial ToolsHow to Improve Computer Vision with Geospatial Tools
How to Improve Computer Vision with Geospatial ToolsSafe Software
 
Cutting edge hyperparameter tuning made simple with ray tune
Cutting edge hyperparameter tuning made simple with ray tuneCutting edge hyperparameter tuning made simple with ray tune
Cutting edge hyperparameter tuning made simple with ray tuneXiaoweiJiang7
 
Accelerating Data Processing in Spark SQL with Pandas UDFs
Accelerating Data Processing in Spark SQL with Pandas UDFsAccelerating Data Processing in Spark SQL with Pandas UDFs
Accelerating Data Processing in Spark SQL with Pandas UDFsDatabricks
 
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014Austin Ogilvie
 
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)Databricks
 
Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Omid Vahdaty
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Fwdays
 
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...AI Frontiers
 
Graph processing at scale using spark & graph frames
Graph processing at scale using spark & graph framesGraph processing at scale using spark & graph frames
Graph processing at scale using spark & graph framesRon Barabash
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...GeeksLab Odessa
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP PerspectiveBarry Jones
 

Semelhante a Creating Profiling Tools to Analyze and Optimize FiPy Presentation (20)

Deep Learning Applications (dadada2017)
Deep Learning Applications (dadada2017)Deep Learning Applications (dadada2017)
Deep Learning Applications (dadada2017)
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
FEC2017-Introduction-to-programming
FEC2017-Introduction-to-programmingFEC2017-Introduction-to-programming
FEC2017-Introduction-to-programming
 
Python 101 - Indonesia AI Society.pdf
Python 101 - Indonesia AI Society.pdfPython 101 - Indonesia AI Society.pdf
Python 101 - Indonesia AI Society.pdf
 
How to Improve Computer Vision with Geospatial Tools
How to Improve Computer Vision with Geospatial ToolsHow to Improve Computer Vision with Geospatial Tools
How to Improve Computer Vision with Geospatial Tools
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
PyPy London Demo Evening 2013
PyPy London Demo Evening 2013PyPy London Demo Evening 2013
PyPy London Demo Evening 2013
 
Cutting edge hyperparameter tuning made simple with ray tune
Cutting edge hyperparameter tuning made simple with ray tuneCutting edge hyperparameter tuning made simple with ray tune
Cutting edge hyperparameter tuning made simple with ray tune
 
Accelerating Data Processing in Spark SQL with Pandas UDFs
Accelerating Data Processing in Spark SQL with Pandas UDFsAccelerating Data Processing in Spark SQL with Pandas UDFs
Accelerating Data Processing in Spark SQL with Pandas UDFs
 
Python made easy
Python made easy Python made easy
Python made easy
 
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
Applied Data Science: Building a Beer Recommender | Data Science MD - Oct 2014
 
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
PyTorch - an ecosystem for deep learning with Soumith Chintala (Facebook AI)
 
Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
Training at AI Frontiers 2018 - Lukasz Kaiser: Sequence to Sequence Learning ...
 
Graph processing at scale using spark & graph frames
Graph processing at scale using spark & graph framesGraph processing at scale using spark & graph frames
Graph processing at scale using spark & graph frames
 
Icpp power ai-workshop 2018
Icpp power ai-workshop 2018Icpp power ai-workshop 2018
Icpp power ai-workshop 2018
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP Perspective
 

Último

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 

Último (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 

Creating Profiling Tools to Analyze and Optimize FiPy Presentation

  • 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. Outline ● FiPy Introduction ● How it works ● Examples ● Problems with FiPy ● Profiling Tools ● What are the they? ● How our tools work ● Results ● Conclusion
  • 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. What is a PDE?
  • 5. Finite Volume Method ● Solve a general PDE on a given domain for a field
  • 6. Finite Volume Method ● Solve a general PDE on a given domain for a field ● Integrate PDE over general control volumes
  • 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. 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. 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. 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. Examples of FiPy: Polycrystal and Phase Field courtesy S. A. David, ORNL
  • 12. courtesy S. A. David, ORNL Examples of FiPy: Polycrystal and Phase Field
  • 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. courtesy S. A. David, ORNL Examples of FiPy: Polycrystal and Phase Field
  • 15. Examples Of FiPy: Extreme Fill
  • 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. Examples Of FiPy: Extreme Fill
  • 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. Profiling Tools ● What is profiling? ● Tool used to identify and quantify what resources are being used by certain parts of a program
  • 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. 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. 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. 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. 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. 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(...)
  • 28. Results: Profiling Extreme Fill - Memory
  • 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. 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. 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. 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. 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. Acknowledgements ● Mentors: Dr. Jon Guyer and Dr. Daniel Wheeler ● SHIP Student: Mira Holford ● SURF Program Staff and Peers

Notas do Editor

  1. Scientists need use PDEs in their work but they don’t’ want to spend the time trying to solve them
  2. This is a general PDE that describes some phenomena such as the diffusion of heat transfer, fluid flow, mass transfer over an arbitrary domain. Because this domain is very complicated, it is not possible find an analytical solution.
  3. To solve the PDE, you must split the domain into nodes (or control volumes) and approximate the values at each node. You domain is now called a mesh.
  4. But we don’t know how to calculate the volume of random nodes.So we discetize the domain into polyhedral nodes and integrate the PDE over them. Ex. To get the area of a triangle, we would split it into right triangles
  5. So solve this PDE, we can put the discretized equations from each node into a row of a matrix and solve that matrix for your field, theta.
  6. FiPy is cool because it has built in functions for the attributes of the mesh and parts of the PDE (ex. Transient term, cell variable, diffusion term).
  7. This is a simple diffusion problem that FiPy solves over 10 time steps. For a simple 2D diffusion problem, as this FiPy code shows, it outputs a simulation of the diffusion as shown here.
  8. This image shows the evolution of polycrystals to form a turbine blade which is shown on the left.It is very difficult to see these crystals as they form so we can’t see how different processing conditions affect the microstructure evolution.
  9. Using PDEs we can simulate the evolution of the microstructures and thus obtain information about their properties such as strength and corrosion resistance.
  10. Once again, we can easily implement the PDE onto FiPy.
  11. Here you can see a snapshot of FiPy’s simulation of the evolving microstructure. You’ll notice that it has the same dendrite (or tree like) structure as the experimental microstructures do.
  12. This is an image of a computer chip with copper depositing into trenches using electroplating to create wires are varying times. The aim is to deposit copper into these trenches without any voids or gaps in the wire. Theta is the coverage of the chemical that regulates copper growth. V is the deposition rate which is dependent on theta. K+ is the absorption of theta and K- is the consumption of theta.
  13. The code represents the theta evolution equation. Equation handles the evolution of the surfactant on the electrochemical interface.
  14. The image is generated by FiPy and shows the deposition for different values of k+. You can see that a k+ value of 80 is optimal and does not have any voids. Quick aside: How FiPy has been assisting in the modeling of photovoltaic cells can be seen with Nathan Smith’s presentation
  15. Interesting note: we had someone email the FiPy mailing list in June with the concern of the speed performance FiPy had.
  16. The problem with many profilers is that it gives you a very small glimpse of how your resources are being used and we wanted a bigger picture.
  17. This is the skeleton of our speed profilers. It took in a function to profile and took in the number of cells you wanted to profile that function for.
  18. We had a problem with profiling memory because in order to profile a function you would have to manually go into that code find the function you were trying to code and then put a function decorator on that function.We also had to work in multiple processes on the computer because every time we profiled the memory, the
  19. Gmsh stores all of the attributes of the mesh, while the regular mesh requires you to calculate the attributes of the mesh each time you need to use them.As you can see, the Gmsh takes up quite a bit more memory to set up and all together. We also counted the number of floats (floats are numbers) that each cell in the mesh had. A single float takes up 64 bits of memory so counting up the total number of floats gave up an idea of memory usage.
  20. On a speed test however, Gmsh takes up quite less time than the regular mesh. So now we face the classic case of memory for speed trade off. Also noticed that the solver only takes up 10% of the total runtime, so most of the time goes into setting up the problem.
  21. Wanted to see how a different type of problem scaled. You can see that we still have the problem of using 500 floats per cell even for this kind of problem.
  22. When profiling speed for extreme fill we wanted to see how using inline would affect our results. Inline refers to using C kernals to do simple computation (such as a+b+c+d) instead of using the python package Numpy. The problem with Numpy is that it must perform checks on the variable types before completing computation and we had a feeling that it took up time.
  23. Pysparse and Trilinos are different matrix solver suites. One thing we wanted to see was what solver was more time efficient. Trilinos is interesting because it can be run in parallel.