Package com.aparapi.internal.kernel
Class KernelDeviceProfile
- java.lang.Object
-
- com.aparapi.internal.kernel.KernelDeviceProfile
-
public class KernelDeviceProfile extends java.lang.ObjectCreated by Barney on 02/09/2015.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classKernelDeviceProfile.Accumulatorprivate classKernelDeviceProfile.GlobalAccumulator
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Thread,KernelDeviceProfile.Accumulator>accsprivate Devicedeviceprivate java.text.DecimalFormatformatprivate KernelDeviceProfile.GlobalAccumulatorglobalAccprivate java.util.concurrent.atomic.AtomicLonginvocationCountGlobalprivate java.lang.Class<? extends Kernel>kernelprivate java.util.concurrent.atomic.AtomicReference<KernelDeviceProfile.Accumulator>lastAccumulatorprivate static java.util.logging.Loggerloggerprivate static doubleMILLIONprivate static intNUM_EVENTSprivate KernelProfileparentKernelProfileprivate static intTABLE_COLUMN_COUNT_WIDTHprivate static intTABLE_COLUMN_HEADER_WIDTHprivate static intTABLE_COLUMN_WIDTHprivate static java.lang.StringtableHeader
-
Constructor Summary
Constructors Constructor Description KernelDeviceProfile(KernelProfile parentProfile, java.lang.Class<? extends Kernel> kernel, Device device)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidappendCell(java.lang.StringBuilder builder, java.lang.String cell)private static voidappendRowHeaders(java.lang.StringBuilder builder, java.lang.String device, java.lang.String count)private KernelDeviceProfile.AccumulatorgetAccForThread()private KernelDeviceProfile.AccumulatorgetAccForThreadPutIfAbsent()java.lang.StringgetAverageAsTableRow()java.lang.StringgetCumulativeAsTableRow()doublegetCumulativeElapsedTimeAllCurrentThread()Elapsed time of entire execution, summed over all executions, for the current thread, if it has executed the kernel on the device assigned to this KernelDeviceProfile instance.doublegetCumulativeElapsedTimeAllGlobal()Elapsed time of entire execution, summed over all executions, for all the threads, that executed the kernel on this device.doublegetCumulativeElapsedTimeCurrrentThread(ProfilingEvent stage)Elapsed time for a single event only, i.e.doublegetCumulativeElapsedTimeGlobal(ProfilingEvent stage)Elapsed time for a single event only, i.e.doublegetElapsedTimeCurrentThread(int stage)Elapsed time for a single event only and for the current thread, i.e.doublegetElapsedTimeCurrentThread(int from, int to)Elapsed time for all eventsfromthroughtofor the current thread.doublegetElapsedTimeLastThread(int stage)Elapsed time for a single event only and for the last thread that finished executing a kernel, i.e.doublegetElapsedTimeLastThread(int from, int to)Elapsed time for all eventsfromthroughtofor the last thread that executed this KernelDeviceProfile instance respective kernel and device.java.lang.StringgetLastAsTableRow()java.lang.ref.WeakReference<ProfileReport>getReportCurrentThread()Retrieves the most recent complete report available for the current thread calling this method.
Note1: If the profile report is intended to be kept in memory, the object should be cloned withProfileReport.clone()
Note2: If the thread didn't execute this KernelDeviceProfile instance respective kernel and device, it will return null.java.lang.ref.WeakReference<ProfileReport>getReportLastThread()Retrieves the most recent complete report available for the last thread that executed this KernelDeviceProfile instance respective kernel and device.
Note1: If the profile report is intended to be kept in memory, the object should be cloned withProfileReport.clone()static java.lang.StringgetTableHeader()private java.lang.StringinternalCumulativeAsTableRow(boolean mean)voidonEvent(ProfilingEvent event)java.lang.StringtoString()private ProfileReportupdateProfileReport(ProfileReport report, long invocationCount, long[] currentTimes)
-
-
-
Field Detail
-
logger
private static java.util.logging.Logger logger
-
NUM_EVENTS
private static final int NUM_EVENTS
-
MILLION
private static final double MILLION
- See Also:
- Constant Field Values
-
TABLE_COLUMN_HEADER_WIDTH
private static final int TABLE_COLUMN_HEADER_WIDTH
- See Also:
- Constant Field Values
-
TABLE_COLUMN_COUNT_WIDTH
private static final int TABLE_COLUMN_COUNT_WIDTH
- See Also:
- Constant Field Values
-
TABLE_COLUMN_WIDTH
private static final int TABLE_COLUMN_WIDTH
-
tableHeader
private static java.lang.String tableHeader
-
parentKernelProfile
private final KernelProfile parentKernelProfile
-
kernel
private final java.lang.Class<? extends Kernel> kernel
-
device
private final Device device
-
format
private final java.text.DecimalFormat format
-
invocationCountGlobal
private final java.util.concurrent.atomic.AtomicLong invocationCountGlobal
-
lastAccumulator
private final java.util.concurrent.atomic.AtomicReference<KernelDeviceProfile.Accumulator> lastAccumulator
-
globalAcc
private final KernelDeviceProfile.GlobalAccumulator globalAcc
-
accs
private final java.util.Map<java.lang.Thread,KernelDeviceProfile.Accumulator> accs
-
-
Constructor Detail
-
KernelDeviceProfile
public KernelDeviceProfile(KernelProfile parentProfile, java.lang.Class<? extends Kernel> kernel, Device device)
-
-
Method Detail
-
getAccForThreadPutIfAbsent
private KernelDeviceProfile.Accumulator getAccForThreadPutIfAbsent()
-
getAccForThread
private KernelDeviceProfile.Accumulator getAccForThread()
-
onEvent
public void onEvent(ProfilingEvent event)
-
updateProfileReport
private ProfileReport updateProfileReport(ProfileReport report, long invocationCount, long[] currentTimes)
-
getElapsedTimeCurrentThread
public double getElapsedTimeCurrentThread(int stage)
Elapsed time for a single event only and for the current thread, i.e. since the previous stage rather than from the start.
-
getElapsedTimeCurrentThread
public double getElapsedTimeCurrentThread(int from, int to)Elapsed time for all eventsfromthroughtofor the current thread.
-
getReportCurrentThread
public java.lang.ref.WeakReference<ProfileReport> getReportCurrentThread()
Retrieves the most recent complete report available for the current thread calling this method.
Note1: If the profile report is intended to be kept in memory, the object should be cloned withProfileReport.clone()
Note2: If the thread didn't execute this KernelDeviceProfile instance respective kernel and device, it will return null.- Returns:
- the profiling report for the current most recent execution
- null, if no profiling report is available for such thread
-
getReportLastThread
public java.lang.ref.WeakReference<ProfileReport> getReportLastThread()
Retrieves the most recent complete report available for the last thread that executed this KernelDeviceProfile instance respective kernel and device.
Note1: If the profile report is intended to be kept in memory, the object should be cloned withProfileReport.clone()- Returns:
- the profiling report for the current most recent execution
- null, if no profiling report is available yet
-
getCumulativeElapsedTimeCurrrentThread
public double getCumulativeElapsedTimeCurrrentThread(ProfilingEvent stage)
Elapsed time for a single event only, i.e. since the previous stage rather than from the start, summed over all executions, for the current thread, if it has executed the kernel on the device assigned to this KernelDeviceProfile instance.- Parameters:
stage- the event stage
-
getCumulativeElapsedTimeAllCurrentThread
public double getCumulativeElapsedTimeAllCurrentThread()
Elapsed time of entire execution, summed over all executions, for the current thread, if it has executed the kernel on the device assigned to this KernelDeviceProfile instance.
-
getElapsedTimeLastThread
public double getElapsedTimeLastThread(int stage)
Elapsed time for a single event only and for the last thread that finished executing a kernel, i.e. single event only - since the previous stage rather than from the start.- Parameters:
stage- the event stage
-
getElapsedTimeLastThread
public double getElapsedTimeLastThread(int from, int to)Elapsed time for all eventsfromthroughtofor the last thread that executed this KernelDeviceProfile instance respective kernel and device.- Parameters:
from- the first event to consider that defines the elapsed period startto- the last event to consider for elapsed period
-
getCumulativeElapsedTimeGlobal
public double getCumulativeElapsedTimeGlobal(ProfilingEvent stage)
Elapsed time for a single event only, i.e. since the previous stage rather than from the start, summed over all executions, for the last thread that executed this KernelDeviceProfile instance respective kernel and device.- Parameters:
stage- the event stage
-
getCumulativeElapsedTimeAllGlobal
public double getCumulativeElapsedTimeAllGlobal()
Elapsed time of entire execution, summed over all executions, for all the threads, that executed the kernel on this device.
-
getTableHeader
public static java.lang.String getTableHeader()
-
getLastAsTableRow
public java.lang.String getLastAsTableRow()
-
getCumulativeAsTableRow
public java.lang.String getCumulativeAsTableRow()
-
getAverageAsTableRow
public java.lang.String getAverageAsTableRow()
-
internalCumulativeAsTableRow
private java.lang.String internalCumulativeAsTableRow(boolean mean)
-
appendRowHeaders
private static void appendRowHeaders(java.lang.StringBuilder builder, java.lang.String device, java.lang.String count)
-
appendCell
private static void appendCell(java.lang.StringBuilder builder, java.lang.String cell)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-