Skip to content
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

Add some constexpr values to the material declarations #1086

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

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

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?

src/Equations/viscoelastic2/Kernels/Local.cpp Outdated Show resolved Hide resolved
Comment on lines 464 to 468
struct MemoryProperties {
size_t alignment{ALIGNMENT};
size_t pagesizeHeap{PAGESIZE_HEAP};
size_t pagesizeStack{PAGESIZE_STACK};
size_t alignment{Alignment};
size_t pagesizeHeap{PagesizeHeap};
size_t pagesizeStack{PagesizeStack};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this struct? If all of these quantities are constexpr, we can always refer to them directly, insted of using this struct, which could be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are used in the GlobalData allocation only—the values are set according to us being on host or device. We may be good with either keeping everything as is—or we could be moving the struct just there to src/Initializer/GlobalData.h.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then, I'd move the struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/Kernels/Plasticity.cpp Outdated Show resolved Hide resolved
@@ -0,0 +1,40 @@
#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

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

How's our opinion on the non-standard #pragma once?

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'll remove it. (I mainly use it for convenience first—and forgot to replace it here... ;) ... Maybe we'll need some, say, "create-me-an-empty-header-file" script sometime?)

src/Solver/FreeSurfaceIntegrator.cpp Outdated Show resolved Hide resolved
src/Solver/time_stepping/TimeCluster.cpp Outdated Show resolved Hide resolved
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.

None yet

3 participants