-
Notifications
You must be signed in to change notification settings - Fork 111
WIP: Lazy stencil expressions for kernel fusion #3401
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
base: next
Are you sure you want to change the base?
Changes from all commits
c9955c3
acb30ab
4fd34af
1238f4b
19502b4
6c15db4
38fb3c2
ccf8f69
ef76bbe
8c85aa0
d05c227
85648fd
23d308b
e00fcd1
f0173dd
3fc221a
ff7f003
15ab3c1
c43ebf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,17 +65,9 @@ int main(int argc, char** argv) { | |
| // Nested loops over block data | ||
| ITERATOR_TEST_BLOCK("DDZ Default", result = DDZ(a);); | ||
|
|
||
| ITERATOR_TEST_BLOCK("DDZ C2", result = DDZ(a, CELL_DEFAULT, "DIFF_C2");); | ||
| ITERATOR_TEST_BLOCK("DDZ C2", result = DDZ(a, CELL_DEFAULT, DIFF_C2);); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "DIFF_C2" is directly included [misc-include-cleaner] ITERATOR_TEST_BLOCK("DDZ C2", result = DDZ(a, CELL_DEFAULT, DIFF_C2););
^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'start' of type 'SteadyClock' (aka 'time_pointstd::chrono::steady_clock') can be declared 'const' [misc-const-correctness] ITERATOR_TEST_BLOCK("DDZ C2", result = DDZ(a, CELL_DEFAULT, DIFF_C2););
^Additional contextexamples/performance/ddz/ddz.cxx:27: expanded from macro 'ITERATOR_TEST_BLOCK' SteadyClock start = steady_clock::now(); \
^ |
||
|
|
||
| ITERATOR_TEST_BLOCK("DDZ C4", result = DDZ(a, CELL_DEFAULT, "DIFF_C4");); | ||
|
|
||
| ITERATOR_TEST_BLOCK("DDZ S2", result = DDZ(a, CELL_DEFAULT, "DIFF_S2");); | ||
|
|
||
| ITERATOR_TEST_BLOCK("DDZ W2", result = DDZ(a, CELL_DEFAULT, "DIFF_W2");); | ||
|
|
||
| ITERATOR_TEST_BLOCK("DDZ W3", result = DDZ(a, CELL_DEFAULT, "DIFF_W3");); | ||
|
|
||
| ITERATOR_TEST_BLOCK("DDZ FFT", result = DDZ(a, CELL_DEFAULT, "DIFF_FFT");); | ||
| ITERATOR_TEST_BLOCK("DDZ C4", result = DDZ(a, CELL_DEFAULT, DIFF_C4);); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "DIFF_C4" is directly included [misc-include-cleaner] ITERATOR_TEST_BLOCK("DDZ C4", result = DDZ(a, CELL_DEFAULT, DIFF_C4););
^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'start' of type 'SteadyClock' (aka 'time_pointstd::chrono::steady_clock') can be declared 'const' [misc-const-correctness] ITERATOR_TEST_BLOCK("DDZ C4", result = DDZ(a, CELL_DEFAULT, DIFF_C4););
^Additional contextexamples/performance/ddz/ddz.cxx:27: expanded from macro 'ITERATOR_TEST_BLOCK' SteadyClock start = steady_clock::now(); \
^ |
||
|
|
||
| if (profileMode) { | ||
| int nthreads = 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,10 +4,9 @@ | |||||
| * Definition of derivative methods storage class | ||||||
| * | ||||||
| ************************************************************************** | ||||||
| * Copyright 2018 | ||||||
| * D.Dickinson, P.Hill, B.Dudson | ||||||
| * Copyright 2018 - 2026 BOUT++ contributors | ||||||
| * | ||||||
| * Contact: Ben Dudson, bd512@york.ac.uk | ||||||
| * Contact: Ben Dudson, dudson2@llnl.gov | ||||||
| * | ||||||
| * This file is part of BOUT++. | ||||||
| * | ||||||
|
|
@@ -26,22 +25,24 @@ | |||||
| * | ||||||
| **************************************************************************/ | ||||||
|
|
||||||
| #ifndef __DERIV_STORE_HXX__ | ||||||
| #define __DERIV_STORE_HXX__ | ||||||
| #ifndef DERIV_STORE_HXX | ||||||
| #define DERIV_STORE_HXX | ||||||
|
|
||||||
| #include <cstddef> | ||||||
| #include <functional> | ||||||
| #include <map> | ||||||
| #include <set> | ||||||
| #include <string> | ||||||
| #include <type_traits> | ||||||
| #include <unordered_map> | ||||||
|
|
||||||
| #include "bout/field3d.hxx" | ||||||
| #include <bout/scorepwrapper.hxx> | ||||||
|
|
||||||
| #include <bout/bout_types.hxx> | ||||||
| #include <bout/boutexception.hxx> | ||||||
| #include <bout/field3d.hxx> | ||||||
| #include <bout/options.hxx> | ||||||
| #include <bout/output.hxx> | ||||||
| #include <bout/scorepwrapper.hxx> | ||||||
| #include <bout/utils.hxx> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: included header scorepwrapper.hxx is not used directly [misc-include-cleaner]
Suggested change
|
||||||
|
|
||||||
| /// Here we have a templated singleton that is used to store DerivativeFunctions | ||||||
| /// for all types of derivatives. It is templated on the FieldType (2D or 3D) as | ||||||
|
|
@@ -100,9 +101,8 @@ struct DerivativeStore { | |||||
| auto key = getKey(direction, stagger, toString(derivType)); | ||||||
| if (isEmpty(key)) { | ||||||
| return std::set<std::string>{}; | ||||||
| } else { | ||||||
| return registeredMethods.at(key); | ||||||
| } | ||||||
| return registeredMethods.at(key); | ||||||
| }; | ||||||
|
|
||||||
| /// Outputs a list of all registered method names for the | ||||||
|
|
@@ -308,21 +308,23 @@ struct DerivativeStore { | |||||
| }; | ||||||
|
|
||||||
| void initialise(Options* options) { | ||||||
| defaultMethods.clear(); | ||||||
| setDefaults(); | ||||||
|
|
||||||
| // To replicate the existing behaviour we first search for a section called | ||||||
| //"dd?" and if the option isn't in there we search a section called "diff" | ||||||
| auto backupSection = options->getSection("diff"); | ||||||
| auto* backupSection = options->getSection("diff"); | ||||||
|
|
||||||
| std::map<DIRECTION, std::string> directions = {{DIRECTION::X, "ddx"}, | ||||||
| {DIRECTION::Y, "ddy"}, | ||||||
| {DIRECTION::YOrthogonal, "ddy"}, | ||||||
| {DIRECTION::Z, "ddz"}}; | ||||||
| const std::map<DIRECTION, std::string> directions = {{DIRECTION::X, "ddx"}, | ||||||
| {DIRECTION::Y, "ddy"}, | ||||||
| {DIRECTION::YOrthogonal, "ddy"}, | ||||||
| {DIRECTION::Z, "ddz"}}; | ||||||
|
|
||||||
| std::map<DERIV, std::string> derivTypes = {{DERIV::Standard, "first"}, | ||||||
| {DERIV::StandardSecond, "second"}, | ||||||
| {DERIV::StandardFourth, "fourth"}, | ||||||
| {DERIV::Upwind, "upwind"}, | ||||||
| {DERIV::Flux, "flux"}}; | ||||||
| const std::map<DERIV, std::string> derivTypes = {{DERIV::Standard, "first"}, | ||||||
| {DERIV::StandardSecond, "second"}, | ||||||
| {DERIV::StandardFourth, "fourth"}, | ||||||
| {DERIV::Upwind, "upwind"}, | ||||||
| {DERIV::Flux, "flux"}}; | ||||||
|
|
||||||
| for (const auto& direction : directions) { | ||||||
| for (const auto& deriv : derivTypes) { | ||||||
|
|
@@ -342,7 +344,7 @@ struct DerivativeStore { | |||||
| //------------------------------------------------------------- | ||||||
|
|
||||||
| // The direction specific section to consider | ||||||
| auto specificSection = options->getSection(direction.second); | ||||||
| auto* specificSection = options->getSection(direction.second); | ||||||
|
|
||||||
| // Find the appropriate value for theDefault either from | ||||||
| // the input file or if not found then use the value in | ||||||
|
|
@@ -355,6 +357,11 @@ struct DerivativeStore { | |||||
| backupSection->get(derivName, theDefault, ""); | ||||||
| } | ||||||
|
|
||||||
| if (uppercase(theDefault) == toString(DIFF_DEFAULT)) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "uppercase" is directly included [misc-include-cleaner] include/bout/deriv_store.hxx:39: - #include <bout/scorepwrapper.hxx>
+ #include "bout/utils.hxx"
+ #include <bout/scorepwrapper.hxx> |
||||||
| throw BoutException("Default derivative options must resolve to a concrete " | ||||||
| "method"); | ||||||
| } | ||||||
|
|
||||||
| // Now we have the default method we should store it in defaultMethods | ||||||
| theDefault = uppercase(theDefault); | ||||||
| defaultMethods[getKey(theDirection, STAGGER::None, theDerivTypeString)] = | ||||||
|
|
@@ -377,6 +384,11 @@ struct DerivativeStore { | |||||
| specificSection->get(derivName, theDefault, ""); | ||||||
| } | ||||||
|
|
||||||
| if (uppercase(theDefault) == toString(DIFF_DEFAULT)) { | ||||||
| throw BoutException("Default derivative options must resolve to a concrete " | ||||||
| "method"); | ||||||
| } | ||||||
|
|
||||||
| // Now we have the default method we should store it in defaultMethods | ||||||
| theDefault = uppercase(theDefault); | ||||||
| defaultMethods[getKey(theDirection, STAGGER::L2C, theDerivTypeString)] = | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |||
| #include "bout/field2d.hxx" | ||||
| #include "bout/field3d.hxx" | ||||
| #include "bout/metric_tensor.hxx" | ||||
| #include "bout/stencil_expr.hxx" | ||||
| #include "bout/vector2d.hxx" | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: included header stencil_expr.hxx is not used directly [misc-include-cleaner]
Suggested change
|
||||
| #include "bout/vector3d.hxx" | ||||
|
|
||||
|
|
@@ -53,10 +54,6 @@ | |||
| /// If not given, defaults to DIFF_DEFAULT | ||||
| /// @param[in] region What region is expected to be calculated | ||||
| /// If not given, defaults to RGN_NOBNDRY | ||||
| Field3D DDX(const Field3D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& method = "DEFAULT", | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Calculate first partial derivative in X | ||||
| /// | ||||
| /// \f$\partial / \partial x\f$ | ||||
|
|
@@ -124,9 +121,9 @@ bout::FieldMetric DDY(const Field2D& f, CELL_LOC outloc = CELL_DEFAULT, | |||
| /// If not given, defaults to DIFF_DEFAULT | ||||
| /// @param[in] region What region is expected to be calculated | ||||
| /// If not given, defaults to RGN_NOBNDRY | ||||
| Field3D DDZ(const Field3D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& method = "DEFAULT", | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
| bout::FieldMetric DDZ(const Field2D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& method = "DEFAULT", | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Calculate first partial derivative in Z | ||||
| /// | ||||
|
|
@@ -140,9 +137,20 @@ Field3D DDZ(const Field3D& f, CELL_LOC outloc = CELL_DEFAULT, | |||
| /// If not given, defaults to DIFF_DEFAULT | ||||
| /// @param[in] region What region is expected to be calculated | ||||
| /// If not given, defaults to RGN_NOBNDRY | ||||
| bout::FieldMetric DDZ(const Field2D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& method = "DEFAULT", | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
| Field3D DDZ(const Field3D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
| DIFF_METHOD method = DIFF_DEFAULT, const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Compatibility overload for string-based callers. | ||||
| Field3D DDZ(const Field3D& f, CELL_LOC outloc, const std::string& method, | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Calculate the Z derivative using the FFT-based implementation. | ||||
| /// | ||||
| /// This is kept separate from the stencil-expression `DDZ_stencil` overload | ||||
| /// because FFT differentiation cannot be represented by the stencil-expression | ||||
| /// machinery. | ||||
| Field3D DDZ_FFT(const Field3D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Calculate first partial derivative in Z | ||||
| /// | ||||
|
|
@@ -156,6 +164,11 @@ bout::FieldMetric DDZ(const Field2D& f, CELL_LOC outloc = CELL_DEFAULT, | |||
| /// If not given, defaults to DIFF_DEFAULT | ||||
| /// @param[in] region What region is expected to be calculated | ||||
| /// If not given, defaults to RGN_NOBNDRY | ||||
| Vector3D DDZ(const Vector3D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:96: the definition seen here Vector3D DDZ(const Vector3D& v, CELL_LOC outloc, DIFF_METHOD method,
^include/bout/derivs.hxx:133: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:113: the definition seen here Vector3D DDZ(const Vector3D& v, CELL_LOC outloc, DIFF_METHOD method,
^include/bout/derivs.hxx:150: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:99: the definition seen here Vector3D DDZ(const Vector3D& v, CELL_LOC outloc, DIFF_METHOD method,
^include/bout/derivs.hxx:146: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:114: the definition seen here Vector3D DDZ(const Vector3D& v, CELL_LOC outloc, DIFF_METHOD method,
^include/bout/derivs.hxx:166: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:115: the definition seen here Vector3D DDZ(const Vector3D& v, CELL_LOC outloc, DIFF_METHOD method,
^include/bout/derivs.hxx:166: differing parameters are named here: ('f'), in definition: ('v') ^ |
||||
| DIFF_METHOD method = DIFF_DEFAULT, | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Compatibility overload for string-based callers. | ||||
| Vector3D DDZ(const Vector3D& v, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& method = "DEFAULT", | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
@@ -172,6 +185,11 @@ Vector3D DDZ(const Vector3D& v, CELL_LOC outloc = CELL_DEFAULT, | |||
| /// If not given, defaults to DIFF_DEFAULT | ||||
| /// @param[in] region What region is expected to be calculated | ||||
| /// If not given, defaults to RGN_NOBNDRY | ||||
| Vector2D DDZ(const Vector2D& f, CELL_LOC outloc = CELL_DEFAULT, | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:156: the definition seen here Vector2D DDZ(const Vector2D& v, CELL_LOC UNUSED(outloc), DIFF_METHOD UNUSED(method),
^include/bout/derivs.hxx:153: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:149: the definition seen here Vector2D DDZ(const Vector2D& v, CELL_LOC UNUSED(outloc), DIFF_METHOD UNUSED(method),
^include/bout/derivs.hxx:171: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:135: the definition seen here Vector2D DDZ(const Vector2D& v, CELL_LOC UNUSED(outloc), DIFF_METHOD UNUSED(method),
^include/bout/derivs.hxx:167: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:150: the definition seen here Vector2D DDZ(const Vector2D& v, CELL_LOC UNUSED(outloc), DIFF_METHOD UNUSED(method),
^include/bout/derivs.hxx:187: differing parameters are named here: ('f'), in definition: ('v') ^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: function 'DDZ' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] ^Additional contextsrc/sys/derivs.cxx:151: the definition seen here Vector2D DDZ(const Vector2D& v, CELL_LOC UNUSED(outloc), DIFF_METHOD UNUSED(method),
^include/bout/derivs.hxx:187: differing parameters are named here: ('f'), in definition: ('v') ^ |
||||
| DIFF_METHOD method = DIFF_DEFAULT, | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
| /// Compatibility overload for string-based callers. | ||||
| Vector2D DDZ(const Vector2D& v, CELL_LOC outloc = CELL_DEFAULT, | ||||
| const std::string& method = "DEFAULT", | ||||
| const std::string& region = "RGN_NOBNDRY"); | ||||
|
|
||||
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.
warning: no header providing "CELL_DEFAULT" is directly included [misc-include-cleaner]