Skip to content

Add some constexpr values to the material declarations #1086

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

Merged
merged 34 commits into from
Jul 8, 2024

Conversation

davschneller
Copy link
Contributor

A refactoring PR.

We just add values, like e.g. the number of quantities to the material declaration (or quantity names)—so that we can mid-term replace all the external preprocessor definitions, yielding a (hopefully) cleaner and more equation-independent code.

Also, we namespace some structs and make some tensors precision-independent.

@codecov-commenter
Copy link

codecov-commenter commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 6.03175% with 296 lines in your changes are missing coverage. Please review.

Project coverage is 13.73%. Comparing base (9cada46) to head (a9bc9e3).
Report is 9 commits behind head on master.

Files Patch % Lines
src/Equations/anisotropic/Model/datastructures.hpp 0.00% 135 Missing ⚠️
src/Equations/elastic/Model/datastructures.hpp 25.71% 26 Missing ⚠️
src/Equations/elastic/Kernels/Time.cpp 0.00% 22 Missing ⚠️
src/Model/common.hpp 5.88% 16 Missing ⚠️
src/Model/plasticity.hpp 0.00% 11 Missing ⚠️
src/Equations/poroelastic/Model/datastructures.hpp 0.00% 9 Missing ⚠️
src/Equations/elastic/Kernels/Local.cpp 0.00% 8 Missing ⚠️
src/Equations/elastic/Kernels/Neighbor.cpp 0.00% 7 Missing ⚠️
src/Kernels/DynamicRupture.cpp 0.00% 7 Missing ⚠️
src/Initializer/LTS.h 0.00% 6 Missing ⚠️
... and 29 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1086      +/-   ##
==========================================
- Coverage   13.80%   13.73%   -0.07%     
==========================================
  Files         268      268              
  Lines       15007    15055      +48     
==========================================
- Hits         2071     2068       -3     
- Misses      12936    12987      +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sebwolf-de sebwolf-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, most comments are about __attribute__((aligned(X)))

@@ -30,6 +30,10 @@ format() {

# NOTE: once the files of a directory are (almost) fully covered, consider moving it to allowlist_dir instead
local allowlist_file="
src/Equations/elastic/Model/datastructures.hpp
src/Equations/viscoelastic2/Model/datastructures.hpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about viscoelastic(1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still support viscoelastic (1)? Otherwise, yes; I can change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait—we don't have a Model/datastructures.hpp for viscoelastic (1). :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, viscoelastic(1) is a prototype for a non-stiff pde with source term.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a datastructure.hpp for viscoelastic(1), we just use the same as for viscoelastic2.

Comment on lines +4 to +14
def addStiffnessTensor(generator):
stiffnessTensor = Tensor('stiffnessTensor', (3, 3, 3, 3))
direction = Tensor('direction', (3,))
christoffel = Tensor('christoffel', (3,3))

computeChristoffel = christoffel['ik'] <= stiffnessTensor['ijkl'] * direction['j'] * direction['l']
generator.add('computeChristoffel', computeChristoffel)

def includeMatrices(matricesDir):
matrices = parseJSONMatrixFile('{}/sampling_directions.json'.format(matricesDir))
return set([matrices.samplingDirections])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is anisotropy related, do we need it for all equations now?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably won't hurt too much to have it in... But I get it—I'll disable it if we don't have anisotropy enabled.

@@ -176,11 +180,50 @@
except:
print('WARNING: ChainForge was not found. Falling back to GemmForge.')

trueOutputDir = os.path.join(cmdLineArgs.outputDir, 'equation')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use cmdLineArgs.equation here? This would pave the way for having more than one equation in the same binary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could definitely do that. Originally, the equations were also templated, by SeisSol/yateto#62 (cf. what was done in #932; that's where most of this PR is from). It just doesn't completely work with the subroutine.cpp file yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's changed now to equation-{equation}-{order}-{precision}. The order part may be slightly overkill (as the matrices are usually pretty similar). But the equation partially and the precision surely would be necessary, I'd guess

namespace='seissol',
gemm_cfg=gemmTools,
cost_estimator=cost_estimators,
include_tensors=include_tensors)

def generate_general(subfolders):
arch = useArchitectureIdentifiedBy('d' + cmdLineArgs.host_arch[1:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about single precision here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That part was more meant to be precision-agnostic—i.e. the stiffness tensors etc.

(originally, it came from #932, to try to support multi-precision as well... Then forcing double was a good way to avoid templating in these classes as well)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Can you add a comment that you use double here, since this kernel is not used at runtime?

Copy link
Contributor Author

@davschneller davschneller May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. In the same vein, couldn't we probably keep the anisotropy-related kernels (which are also only used during init); especially when going towards multi-material anyways?

@@ -86,13 +86,13 @@ void seissol::kernels::DynamicRupture::setTimeStepWidth(double timestep)
{
#ifdef USE_DR_CELLAVERAGE
static_assert(false, "Cell average currently not supported");
/*double subIntervalWidth = timestep / CONVERGENCE_ORDER;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this commented out code, still?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd guess it's more or less an unfinished idea. If noone wants to continue it, I can remove it.

@davschneller davschneller force-pushed the davschneller/material-annotations branch from c4ad306 to 5f2cf15 Compare July 3, 2024 06:48
@davschneller davschneller added this pull request to the merge queue Jul 8, 2024
Merged via the queue into master with commit c7941c5 Jul 8, 2024
22 of 24 checks passed
@davschneller davschneller deleted the davschneller/material-annotations branch July 8, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants