Top Description Constructors Methods
org.lwjgl.util.mapped

pack-priv final Class CacheLineSize

extends Object
Class Inheritance
Imports
org.lwjgl.LWJGLUtil, .MemoryUtil, java.nio.ByteBuffer, .ByteOrder, .IntBuffer, java.util.concurrent.Callable, .ExecutorCompletionService, .ExecutorService, .Executors

This micro-benchmark tries to detect the CPU's cache line size. This is done by exploiting cache line false sharing in multi-threaded code: When 2 threads simultaneously access the same cache line (and at least 1 access is a write), performance drops considerably. We detect this performance drop while decreasing the memory padding in every test step.
Author
Spasi

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static long
doTest(final int threads, final int repeats, final int padding, final IntBuffer memory, final ExecutorCompletionService<Long> completionService)

pack-priv static int
private static IntBuffer
getMemory(final int START_SIZE)

public static void
main(String[] args)

pack-priv static long
memoryLoop(final int index, final int repeats, final IntBuffer memory, final int padding)

private static void
submitTest(final ExecutorCompletionService<Long> completionService, final int index, final int repeats, final IntBuffer memory, final int padding)

private static long
waitForResults(final int count, final ExecutorCompletionService<Long> completionService)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CacheLineSizeback to summary
private CacheLineSize()

Method Detail

doTestback to summary
private static long doTest(final int threads, final int repeats, final int padding, final IntBuffer memory, final ExecutorCompletionService<Long> completionService)
getCacheLineSizeback to summary
pack-priv static int getCacheLineSize()
getMemoryback to summary
private static IntBuffer getMemory(final int START_SIZE)
mainback to summary
public static void main(String[] args)
memoryLoopback to summary
pack-priv static long memoryLoop(final int index, final int repeats, final IntBuffer memory, final int padding)
submitTestback to summary
private static void submitTest(final ExecutorCompletionService<Long> completionService, final int index, final int repeats, final IntBuffer memory, final int padding)
waitForResultsback to summary
private static long waitForResults(final int count, final ExecutorCompletionService<Long> completionService)