Skip to content

Commit

Permalink
DBResidueMask() cleanup
Browse files Browse the repository at this point in the history
Reorder things in this function.
Adding 'const' in key places to provide the compiler the extra hint
for the purpose of this computation we don't change the value and the
value never changes externally even across function calls.

I'm sure the compiler (due to macro implementation of TTMaskXxxxx() calls
and visibility of data being changes) will optimise the function in
exactly the way of the reorder.

This also should have the side-effect of making clearer more auto
vectorization possibilities to the compiler or potentially replacing the
loop with (tail-call or inline) to :

simd_TTMaskSetMask_residues(lmask, rmask, TT_TECHDEPBASE, DBNumUserLayers);

Which would be a hand optimized form, that probably has an 'l_residues'
layout that favours SIMD use (2nd order copy from source of truth just in
a different data layout, such as contiguous array of TileTypeBitMask
indexed from 0, with the TileType as the index).
  • Loading branch information
dlmiles committed Feb 13, 2025
1 parent 9a4bf4e commit 94eeb9a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions database/DBtcontact.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,24 +953,22 @@ DBFullResidueMask(type, rmask)
TileType type;
TileTypeBitMask *rmask;
{
TileType t;
TileTypeBitMask *lmask;
LayerInfo *li, *lr;

li = &dbLayerInfo[type];
lmask = &li->l_residues;
TTMaskZero(rmask);
LayerInfo *li = &dbLayerInfo[type];
const TileTypeBitMask *lmask = &li->l_residues;

if (type < DBNumUserLayers)
{
TTMaskSetMask(rmask, &li->l_residues);
TTMaskSetMask(rmask, lmask);
}
else
{
for (t = TT_TECHDEPBASE; t < DBNumUserLayers; t++)
TileType t;
const int tt_last = DBNumUserLayers;
TTMaskZero(rmask);
for (t = TT_TECHDEPBASE; t < tt_last; t++)
if (TTMaskHasType(lmask, t))
{
lr = &dbLayerInfo[t];
LayerInfo *lr = &dbLayerInfo[t];
TTMaskSetMask(rmask, &lr->l_residues);
}
}
Expand Down

0 comments on commit 94eeb9a

Please sign in to comment.