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

Avoid abstract types in structs #227

Merged
merged 3 commits into from
Jan 20, 2023
Merged

Avoid abstract types in structs #227

merged 3 commits into from
Jan 20, 2023

Conversation

valeriabarra
Copy link
Member

Co-authored-by: Charles Kawczynski [email protected]

Purpose

This PR concretizes a few types in composite types for better compiler optimizations.

Closes #224

Content

  • In src/Utilities.jl is substitute
struct CoupledSimulation{FT, B, ...}
a::NamedTuple
...
end

with:

struct CoupledSimulation{FT <: Real, NT <: NamedTuple, B, ...}
a::NT
...
end
  • Renamed float_type_cs as float_type and added docstring
  • In BCReader.jl, specify FT <: Real in BCFileInfo struct

Review checklist

I have:

In the Content, I have included

  • relevant unit tests, and integration tests,

  • appropriate docstrings on all functions, structs, and modules, and included relevant documentation.

  • I have read and checked the items on the review checklist.

@valeriabarra
Copy link
Member Author

@LenkaNovak this passes CI and it's ready for review. Thanks!

Copy link
Collaborator

@LenkaNovak LenkaNovak left a comment

Choose a reason for hiding this comment

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

Thanks, @valeriabarra ! Looks good. I wonder if DiagnosticsGroup and DataPackage could benefit from similar optimisations? After that feel free to merge.

@valeriabarra
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 20, 2023

@bors bors bot merged commit 770777d into main Jan 20, 2023
@bors bors bot deleted the valeria/opt-structs branch January 20, 2023 05:20
@valeriabarra valeriabarra changed the title Avoid sbatrct types in structs Avoid abstract types in structs Feb 6, 2023
bors bot added a commit that referenced this pull request Feb 7, 2023
251: BCReader: type safety and avoid abstarct type in struct r=valeriabarra a=valeriabarra

## Purpose 
This PR is a follow-up of #227 . It improves type safety and compiler optimization by removing abstract types in the BCReader struct.

Closes #250 


## Content
It improves type safety and compiler optimization by removing abstract types in the BCReader struct.


Review checklist

I have:
- followed the codebase contribution guide: https://clima.github.io/ClimateMachine.jl/latest/Contributing/
- followed the style guide: https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/
- followed the documentation policy: https://github.com/CliMA/policies/wiki/Documentation-Policy
- checked that this PR does not duplicate an open PR.

In the Content, I have included 
- relevant unit tests, and integration tests, 
- appropriate docstrings on all functions, structs, and modules, and included relevant documentation.


- [x] I have read and checked the items on the review checklist.


Co-authored-by: Valeria Barra <[email protected]>
bors bot added a commit that referenced this pull request Feb 7, 2023
251: BCReader: type safety and avoid abstarct type in struct r=valeriabarra a=valeriabarra

## Purpose 
This PR is a follow-up of #227 . It improves type safety and compiler optimization by removing abstract types in the BCReader struct.

Closes #250 


## Content
It improves type safety and compiler optimization by removing abstract types in the BCReader struct.


Review checklist

I have:
- followed the codebase contribution guide: https://clima.github.io/ClimateMachine.jl/latest/Contributing/
- followed the style guide: https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/
- followed the documentation policy: https://github.com/CliMA/policies/wiki/Documentation-Policy
- checked that this PR does not duplicate an open PR.

In the Content, I have included 
- relevant unit tests, and integration tests, 
- appropriate docstrings on all functions, structs, and modules, and included relevant documentation.


- [x] I have read and checked the items on the review checklist.


Co-authored-by: Valeria Barra <[email protected]>
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.

Avoid abstract types in structs
2 participants