/** * Provides a container holding an int value that fills a 64-byte cache line. */ public static class PaddedInt { // Most platforms have 64 byte cache lines so the value variable is padded so 16 four byte ints are consumed. // If a platform has smaller cache lines, this approach will use a little more memory than required but the // performance gains will still be preserved. // Modern Intel and AMD chips commonly have 64 byte cache lines. // TODO: code This should just be 15, shouldn't it? public int value = 0, padding1, padding2, padding3, padding4, padding5, padding6, padding7, padding8, padding9, padding10, padding11, padding13, padding14, padding15, padding16; /** * Provides access to the value of this PaddedInt. * @param pi is the PaddedInt containing the desired value. * @return the value contained by the provided int. */ public static int get(PaddedInt pi) { return pi.value; } /** * Sets the value of the provided PaddedInt. * @param pi is the padded int to contain the value. * @param value is the value to be put into the padded int. */ public static void set(PaddedInt pi, int value) { pi.value = value; }
/** * Provides a container holding an int value that fills a 64-byte cache line. */ public static class PaddedInt { // Most platforms have 64 byte cache lines so the value variable is padded so 16 four byte ints are consumed. // If a platform has smaller cache lines, this approach will use a little more memory than required but the // performance gains will still be preserved. // Modern Intel and AMD chips commonly have 64 byte cache lines. // TODO: code This should just be 15, shouldn't it? public int value = 0, padding1, padding2, padding3, padding4, padding5, padding6, padding7, padding8, padding9, padding10, padding11, padding13, padding14, padding15, padding16; /** * Provides access to the value of this PaddedInt. * @param pi is the PaddedInt containing the desired value. * @return the value contained by the provided int. */ public static int get(PaddedInt pi) { return pi.value; } /** * Sets the value of the provided PaddedInt. * @param pi is the padded int to contain the value. * @param value is the value to be put into the padded int. */ public static void set(PaddedInt pi, int value) { pi.value = value; }
/** * Provides a container holding an int value that fills a 64-byte cache line. */ public static class PaddedInt { // Most platforms have 64 byte cache lines so the value variable is padded so 16 four byte ints are consumed. // If a platform has smaller cache lines, this approach will use a little more memory than required but the // performance gains will still be preserved. // Modern Intel and AMD chips commonly have 64 byte cache lines. // TODO: code This should just be 15, shouldn't it? public int value = 0, padding1, padding2, padding3, padding4, padding5, padding6, padding7, padding8, padding9, padding10, padding11, padding13, padding14, padding15, padding16; /** * Provides access to the value of this PaddedInt. * @param pi is the PaddedInt containing the desired value. * @return the value contained by the provided int. */ public static int get(PaddedInt pi) { return pi.value; } /** * Sets the value of the provided PaddedInt. * @param pi is the padded int to contain the value. * @param value is the value to be put into the padded int. */ public static void set(PaddedInt pi, int value) { pi.value = value; }