-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rocm: Add new analysis to support new trace format
As a new plugin was added to generate CTF traces with different event types and format, these new analysis and trace were added to support this new type. Each API function now has its own event type, and some fields are now passed as context fields. As this change uses the tracecompass.analysis.callstack and the rocm plugin depends on it, the callstack plugin was added as a dependency to the trace server. [Added] New ROCm trace type to support new plugin [Added] New ROCm CallStack that displays API and GPU activity Signed-off-by: Arnaud Fiorini <[email protected]>
- Loading branch information
Showing
14 changed files
with
1,001 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/RocmCallStackAnalysis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 École Polytechnique de Montréal | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tracecompass.incubator.internal.rocm.core.analysis; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.tracecompass.internal.provisional.analysis.profiling.core.instrumented.InstrumentedCallStackAnalysis; | ||
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; | ||
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; | ||
|
||
/** | ||
* This analysis is a callstack analysis which summarizes the execution of a | ||
* ROCm GPU program. | ||
* | ||
* It separates the execution into two categories: the GPU queues and the system | ||
* API calls. Furthermore, some dependencies were modeled using arrows to show | ||
* the user how these abstract layers relate to each other. | ||
* | ||
* @author Arnaud Fiorini | ||
*/ | ||
@SuppressWarnings("restriction") | ||
public class RocmCallStackAnalysis extends InstrumentedCallStackAnalysis { | ||
|
||
private static final String EDGES = "EDGES"; //$NON-NLS-1$ | ||
|
||
@Override | ||
protected @NonNull Collection<Integer> getEdgeQuarks() { | ||
ITmfStateSystem ss = getStateSystem(); | ||
if (ss == null) { | ||
return Collections.emptyList(); | ||
} | ||
int edgeQuark = ss.optQuarkAbsolute(EDGES); | ||
if (edgeQuark == ITmfStateSystem.INVALID_ATTRIBUTE) { | ||
return Collections.emptyList(); | ||
} | ||
return ss.getSubAttributes(edgeQuark, false); | ||
} | ||
|
||
@Override | ||
protected @NonNull ITmfStateProvider createStateProvider() { | ||
return new RocmCallStackStateProvider(Objects.requireNonNull(getTrace()), new RocmEventLayout()); | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
...clipse/tracecompass/incubator/internal/rocm/core/analysis/RocmCallStackStateProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 École Polytechnique de Montréal | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tracecompass.incubator.internal.rocm.core.analysis; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.ApiEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.IRocmEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.OperationEventHandler; | ||
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; | ||
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | ||
import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider; | ||
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; | ||
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | ||
|
||
/** | ||
* This state provider creates callstacks and apply different event handlers. | ||
* There are multiple types of events, each described in their respective | ||
* handler. | ||
* | ||
* Attribute tree: | ||
* | ||
* <pre> | ||
* |- OperationQueues | ||
* | |- <Queue> | ||
* | | |- <Depth> -> Each depth represents one operation that has been queued, | ||
* | | | other depths are for other queued operations. | ||
* |- Root | ||
* | |- Processes | ||
* | | |- <Thread> | ||
* | | | |- <API> -> Each API is a callstack showing which API call is executed. | ||
* | |- Queues | ||
* | | | |- <ROCm Agent / GPU> | ||
* | | | | |- <Queue> -> Each queue implemented as a callstack with corresponding | ||
* | | | | | compute kernel activity. | ||
* </pre> | ||
* | ||
* @author Arnaud Fiorini | ||
*/ | ||
public class RocmCallStackStateProvider extends AbstractTmfStateProvider { | ||
|
||
private static final String ID = "org.eclipse.tracecompass.incubator.rocm.core.stateprovider.atomic"; //$NON-NLS-1$ | ||
/** Name of the root attribute */ | ||
public static final String ROOT = "root"; //$NON-NLS-1$ | ||
/** Name of the sub-attribute where the name of the operation is stored */ | ||
public static final String NAME = "name"; //$NON-NLS-1$ | ||
/** Name of the sub-attribute where the correlation id is stored */ | ||
public static final String CORRELATION_ID = "correlation_id"; //$NON-NLS-1$ | ||
/** Name of the sub-attribute where the operations are stored */ | ||
public static final String HIP_OPERATION_QUEUES = "hip_operation_queues"; //$NON-NLS-1$ | ||
|
||
private final RocmEventLayout fLayout; | ||
private IRocmEventHandler fApiEventHandler; | ||
private IRocmEventHandler fOperationEventHandler; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param trace | ||
* Trace to follow | ||
* @param layout | ||
* The layout of the events | ||
*/ | ||
public RocmCallStackStateProvider(ITmfTrace trace, RocmEventLayout layout) { | ||
super(trace, ID); | ||
fLayout = layout; | ||
fApiEventHandler = new ApiEventHandler(); | ||
fOperationEventHandler = new OperationEventHandler(); | ||
} | ||
|
||
@Override | ||
public int getVersion() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public @NonNull ITmfStateProvider getNewInstance() { | ||
return new RocmCallStackStateProvider(getTrace(), fLayout); | ||
} | ||
|
||
@Override | ||
protected void eventHandle(ITmfEvent event) { | ||
ITmfStateSystemBuilder ssb = getStateSystemBuilder(); | ||
if (ssb == null) { | ||
return; | ||
} | ||
if (event.getName().equals(fLayout.getHsaOperationBegin()) || event.getName().equals(fLayout.getHsaOperationEnd())) { | ||
fOperationEventHandler.handleEvent(event, ssb, fLayout); | ||
} else if (event.getName().equals(fLayout.getHipOperationBegin()) || event.getName().equals(fLayout.getHipOperationEnd())) { | ||
fOperationEventHandler.handleEvent(event, ssb, fLayout); | ||
} else if (event.getName().startsWith(fLayout.getHipPrefix()) || event.getName().startsWith(fLayout.getHsaPrefix())) { | ||
fApiEventHandler.handleEvent(event, ssb, fLayout); | ||
} | ||
} | ||
} |
Oops, something went wrong.