Skip to content

BoundaryCheck. Implement pahole suggestion

After following a variation of @fwinkl and getting pahole in lxplus and mainly playing around with it . it kind of suggests (this is clang but is the same in gcc)

to change this

class BoundaryCheck {
	static const double               s_cos22 = 4606496786581982534; /*     0     0 */
	static const double               s_cos45 = 4604544271217802189; /*     0     0 */
	static const double               s_cos67 = 4600565431771507043; /*     0     0 */
public:

	bool                       checkLoc1;            /*     0     1 */
	bool                       checkLoc2;            /*     1     1 */

	/* XXX 6 bytes hole, try to pack */

	double                     toleranceLoc1;        /*     8     8 */
	double                     toleranceLoc2;        /*    16     8 */
	int                        nSigmas;              /*    24     4 */

	/* XXX 4 bytes hole, try to pack */

	class Matrix<double, 2, 2, 0, 2, 2> lCovariance; /*    32    32 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	enum BoundaryCheckType     bcType;               /*    64     4 */

	/* Force padding: */
	enum BoundaryCheckType     :32;
	enum BoundaryCheckType     :32;
	enum BoundaryCheckType     :32;

	/* size: 80, cachelines: 2, members: 7, static members: 3 */
	/* sum members: 58, holes: 2, sum holes: 10 */
	/* padding: 12 */
	/* last cacheline: 16 bytes */

to

class BoundaryCheck {
	static const double               s_cos22 = 4606496786581982534; /*     0     0 */
	static const double               s_cos45 = 4604544271217802189; /*     0     0 */
	static const double               s_cos67 = 4600565431771507043; /*     0     0 */
public:

	bool                       checkLoc1;            /*     0     1 */
	bool                       checkLoc2;            /*     1     1 */

	/* XXX 2 bytes hole, try to pack */

	int                        nSigmas;              /*     4     4 */
	double                     toleranceLoc1;        /*     8     8 */
	double                     toleranceLoc2;        /*    16     8 */
	enum BoundaryCheckType     bcType;               /*    24     4 */

	/* XXX 4 bytes hole, try to pack */

	class Matrix<double, 2, 2, 0, 2, 2> lCovariance; /*    32    32 */

	/* size: 64, cachelines: 1, members: 7, static members: 3 */
	/* sum members: 58, holes: 2, sum holes: 6 */
};

So giving it kind of a try. As one cacheline is better than two I would guess... (Assuming I get it correctly)

Merge request reports