-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
278 add tutorial for use with openmp (#280)
* adding more build instructions * adding test for openmp * adding cmake stuff to detect libomp installed with homebrew * stubbed openmp tutorial
- Loading branch information
Showing
16 changed files
with
489 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.. _OpenMP: | ||
|
||
OpenMP | ||
====== | ||
|
||
This tutorial will focus on running micm with OpenMP support. | ||
We will use a simple 3-reaction 3-species mechanism. The setup here is the same in | ||
:ref:`Multiple grid cells`, except only one grid cell is used. | ||
|
||
.. math:: | ||
A &\longrightarrow B, &k_{1, \mathrm{user\ defined}} \\ | ||
2B &\longrightarrow B + C, &k_{2, \mathrm{user\ defined}} \\ | ||
B + C &\longrightarrow A + C, \qquad &k_{3, \mathrm{user\ defined}} \\ | ||
If you're looking for a copy and paste, copy below and be on your way! Otherwise, stick around for a line by line explanation. | ||
|
||
.. tabs:: | ||
|
||
.. tab:: OpenAtmos Configuration reading | ||
|
||
.. raw:: html | ||
|
||
<div class="download-div"> | ||
<a href="../_static/tutorials/robertson.zip" download> | ||
<button class="download-button">Download zip configuration</button> | ||
</a> | ||
</div> | ||
|
||
.. literalinclude:: ../../../test/tutorial/test_openmp.cpp | ||
:language: cpp | ||
|
||
Line-by-line explanation | ||
------------------------ | ||
|
||
At present, the Rosenbrock class is not thread safe. Thread safety is being added and will be available soon in new release. | ||
|
||
Until then, you can run one instance of the Rosenbrock solver on its own thread. Configuration data, at least, can be shared | ||
across the threads. This tutorial reads a configuraiton file and then configures three solvers, each on their own thread, | ||
with that same configuration information. | ||
|
||
First we need to bring in the necessary imports and use the micm namespace. | ||
|
||
.. literalinclude:: ../../../test/tutorial/test_openmp.cpp | ||
:language: cpp | ||
:lines: 1-6 | ||
|
||
Then we'll define a funtion that we can call with the configuration information from each thread. This function will build | ||
and run the rosenbrock solver. | ||
|
||
.. literalinclude:: ../../../test/tutorial/test_openmp.cpp | ||
:language: cpp | ||
:lines: 29-69 | ||
|
||
The main function simply reads the configuration file, sets the number of threads, and then sets up an OpenMP blcok | ||
with three threads. The function defined above is called on each thread. | ||
|
||
.. literalinclude:: ../../../test/tutorial/test_openmp.cpp | ||
:language: cpp | ||
:lines: 71-109 | ||
|
||
Running this program should give an output similar to this: | ||
|
||
.. code-block:: console | ||
Thread 1 | ||
A, B, C | ||
2.55e-01, 1.37e-06, 7.45e-01 | ||
Thread 2 | ||
A, B, C | ||
2.55e-01, 1.37e-06, 7.45e-01 | ||
Thread 3 | ||
A, B, C | ||
2.55e-01, 1.37e-06, 7.45e-01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"camp-data": [ | ||
{ | ||
"name": "reaction rates no user defined", | ||
"type": "MECHANISM", | ||
"reactions": [ | ||
{ | ||
"type": "PHOTOLYSIS", | ||
"reactants": { | ||
"A": {} | ||
}, | ||
"products": { | ||
"B": {} | ||
}, | ||
"MUSICA name": "r1" | ||
}, | ||
{ | ||
"type": "PHOTOLYSIS", | ||
"reactants": { | ||
"B": { "qty": 2} | ||
}, | ||
"products": { | ||
"B": {}, | ||
"C": {} | ||
}, | ||
"MUSICA name": "r2" | ||
}, | ||
{ | ||
"type": "PHOTOLYSIS", | ||
"reactants": { | ||
"B": {}, | ||
"C": {} | ||
}, | ||
"products": { | ||
"A": {}, | ||
"C": {} | ||
}, | ||
"MUSICA name": "r3" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"camp-data": [ | ||
{ | ||
"name": "A", | ||
"type": "CHEM_SPEC" | ||
}, | ||
{ | ||
"name": "B", | ||
"type": "CHEM_SPEC" | ||
}, | ||
{ | ||
"name": "C", | ||
"type": "CHEM_SPEC" | ||
} | ||
] | ||
} |
Oops, something went wrong.