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

[Core] Exploit Unused Bits in Dof #12263

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

Conversation

matekelemen
Copy link
Contributor

This PR addresses #11916 and adds a restricted set of flags to Dof, but unlike #12196, it does not increase its size. The price to pay for it is fewer flags and more complex code.

/** True is is fixed */
int mIsFixed : 1;
int mVariableType : 4;
int mReactionType : 4;
int mIndex : 6;
/** Equation identificator of the degree of freedom */
EquationIdType mEquationId : 48;
/** A pointer to nodal data stored in node which is corresponded to this dof */
NodalData* mpNodalData;

In total, 4 extra bits can be used in Dof without increasing its size:

  • the bit size of Dof was 1 + 4 + 4 + 6 + 48 + 64 = 127, which means that one extra bit mIsActive could be squeezed into the list of member variables.
  • NodalData has an alignment requirement of 8 bytes. This means that any valid pointer to a NodalData instance must be a multiple of 8 (2³). As a result, the lowest 8 bits of any NodalData* is always 000 and we can exploit this fact to hide 3 bits of some other information (such as 3 flags) there.

@loumalouomega
Copy link
Member

Looks great, but compilation is failing

@@ -347,26 +343,67 @@ class Dof{
mIsFixed=false;
}

/// @brief Mark this @p Dof active.
Copy link
Member

Choose a reason for hiding this comment

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

We usually use
/**
*
*/
style

@matekelemen
Copy link
Contributor Author

ready for review

@matekelemen
Copy link
Contributor Author

Ping reviewers.

I understand if this, or the other PR, is not exactly the solution you want to see but you need to tell me that if it's the case. #11916 prohibits me from progressing with my work, and I need to know at least the interface of its solution (we can iron out implementation details later, but I need to know how I can get extra information from Dofs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants