Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rocm: Update to the ROCm plugin to support the latest traces
The traces read by this plugin were generated before using a babeltrace plugin from a sqlite file. Since then, a library was written by Yoann Heitz to generate traces directly from ROC-profiler. This patch updates the ROCm plugin in Trace Compass to handle those traces. It also adds a number of features to derive dependency relations between memory tranfers, synchronisation calls and compute kernel executions. Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com> Change-Id: I2c2db97c0fdaaf342695e9d0a2e6fcfcf066e78a Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/196164 Reviewed-by: Marco Miller <marco.miller@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
- Loading branch information
1 parent
a577af8
commit 90d2eac
Showing
31 changed files
with
2,416 additions
and
401 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
32 changes: 16 additions & 16 deletions
32
...re/analysis/RocmCtfCallStackAnalysis.java → .../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
145 changes: 145 additions & 0 deletions
145
...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,145 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2022 É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.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.tracecompass.common.core.NonNullUtils; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.Activator; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.dependency.HipApiHipActivityDependencyMaker; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.AbstractGpuEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.ApiEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.HipActivityEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.HsaActivityEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.HsaKernelEventHandler; | ||
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.RoctxEventHandler; | ||
import org.eclipse.tracecompass.incubator.rocm.core.analysis.dependency.IDependencyMaker; | ||
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; | ||
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; | ||
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | ||
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; | ||
import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider; | ||
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; | ||
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | ||
import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceWithPreDefinedEvents; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
|
||
/** | ||
* 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> | ||
* |- Processes | ||
* | |- <GPU> | ||
* | | |- HIP Streams | ||
* | | | |- <Stream> -> Each stream implemented as a callstack with corresponding | ||
* | | | | compute kernel activity. | ||
* | | |- Queues | ||
* | | | |- <Queue> -> Each queue implemented as a callstack with corresponding | ||
* | | | | compute kernel activity. | ||
* | |- Memory | ||
* | | | |- Memory transfers -> Callstack with every memory transfer activity. | ||
* | |- System | ||
* | | |- <Thread> | ||
* | | | |- <API> -> Each API is a callstack showing which API call is executed. | ||
* </pre> | ||
* | ||
* @author Arnaud Fiorini | ||
*/ | ||
public class RocmCallStackStateProvider extends AbstractTmfStateProvider { | ||
|
||
private static final String ID = "org.eclipse.tracecompass.incubator.rocm.core.stateprovider.interval"; //$NON-NLS-1$ | ||
|
||
private IDependencyMaker fDependencyMaker; | ||
private Map<String, AbstractGpuEventHandler> fEventNames; | ||
|
||
/** | ||
* @param trace | ||
* trace to follow | ||
*/ | ||
public RocmCallStackStateProvider(@NonNull ITmfTrace trace) { | ||
super(trace, ID); | ||
fDependencyMaker = getDependencyMaker((ITmfTraceWithPreDefinedEvents) trace); | ||
fEventNames = buildEventNames(); | ||
} | ||
|
||
private Map<String, AbstractGpuEventHandler> buildEventNames() { | ||
ImmutableMap.Builder<String, AbstractGpuEventHandler> builder = ImmutableMap.builder(); | ||
|
||
builder.put(RocmStrings.HIP_API, new ApiEventHandler(this)); | ||
builder.put(RocmStrings.HSA_API, new ApiEventHandler(this)); | ||
builder.put(RocmStrings.HIP_ACTIVITY, new HipActivityEventHandler(this)); | ||
builder.put(RocmStrings.ROCTX, new RoctxEventHandler(this)); | ||
builder.put(RocmStrings.HSA_ACTIVITY, new HsaActivityEventHandler(this)); | ||
if (fDependencyMaker == null) { // Disable HSA Activity in case we have | ||
// hip activity events | ||
builder.put(RocmStrings.KERNEL_EVENT, new HsaKernelEventHandler(this)); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
|
||
private static IDependencyMaker getDependencyMaker(ITmfTraceWithPreDefinedEvents trace) { | ||
IDependencyMaker dependencyMaker = null; | ||
for (ITmfEventType eventType : (trace).getContainedEventTypes()) { | ||
if (eventType.getName().equals(RocmStrings.HIP_ACTIVITY)) { | ||
dependencyMaker = new HipApiHipActivityDependencyMaker(); | ||
break; | ||
} | ||
} | ||
return dependencyMaker; | ||
} | ||
|
||
@Override | ||
public int getVersion() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public @NonNull ITmfStateProvider getNewInstance() { | ||
return new RocmCallStackStateProvider(getTrace()); | ||
} | ||
|
||
@Override | ||
protected void eventHandle(@NonNull ITmfEvent event) { | ||
String eventName = event.getName(); | ||
ITmfStateSystemBuilder ssb = NonNullUtils.checkNotNull(getStateSystemBuilder()); | ||
try { | ||
AbstractGpuEventHandler handler = fEventNames.get(eventName); | ||
if (handler != null) { | ||
handler.handleEvent(ssb, event); | ||
} | ||
} catch (AttributeNotFoundException e) { | ||
Activator.getInstance().logError("Exception while building the RocmCallStack state system", e); //$NON-NLS-1$ | ||
} | ||
if (fDependencyMaker != null) { | ||
fDependencyMaker.processEvent(event, ssb); | ||
} | ||
} | ||
|
||
/** | ||
* Accessor for the current dependency maker. | ||
* | ||
* The dependency maker is instantiated in the constructor depending the | ||
* event types present in the rocm trace. | ||
* | ||
* @return dependency maker | ||
*/ | ||
public IDependencyMaker getDependencyMaker() { | ||
return fDependencyMaker; | ||
} | ||
} |
Oops, something went wrong.