-
Notifications
You must be signed in to change notification settings - Fork 9
/
HsaActivityEventHandler.java
58 lines (52 loc) · 2.91 KB
/
HsaActivityEventHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**********************************************************************
* 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.handlers;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.tracecompass.incubator.callstack.core.instrumented.statesystem.CallStackStateProvider;
import org.eclipse.tracecompass.incubator.callstack.core.instrumented.statesystem.InstrumentedCallStackAnalysis;
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.RocmCallStackStateProvider;
import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.RocmStrings;
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.statesystem.ITmfStateProvider.FutureEventType;
/**
* The HSA activity event handler.<br>
* It is possible to have different backends generate the GPU activity events.
* This event handler is for the GPU activity events generated by HSA.
*
* @author Arnaud Fiorini
*/
public class HsaActivityEventHandler extends AbstractGpuEventHandler {
/**
* @param stateProvider
* The state provider that is using this event handler
*/
public HsaActivityEventHandler(RocmCallStackStateProvider stateProvider) {
super(stateProvider);
}
@Override
public void handleEvent(ITmfStateSystemBuilder ssb, ITmfEvent event) throws AttributeNotFoundException {
int copyQuark = ssb.getQuarkAbsoluteAndAdd(CallStackStateProvider.PROCESSES, RocmStrings.MEMORY);
int tempQuark1 = ssb.getQuarkRelativeAndAdd(copyQuark, StringUtils.EMPTY);
int tempQuark2 = ssb.getQuarkRelativeAndAdd(tempQuark1, RocmStrings.MEMORY_TRANSFERS);
int callStackQuark = ssb.getQuarkRelativeAndAdd(tempQuark2, InstrumentedCallStackAnalysis.CALL_STACK);
Long timestamp = event.getTimestamp().toNanos();
Long timestampEnd = AbstractGpuEventHandler.getEndTime(event);
ssb.pushAttribute(timestamp, RocmStrings.COPY, callStackQuark);
if (timestampEnd != null) {
fStateProvider.addFutureEvent(timestampEnd, null, callStackQuark, FutureEventType.POP);
}
// Add CallStack Identifier (tid equivalent) for the memory quark
HostThreadIdentifier hostThreadIdentifier = new HostThreadIdentifier();
addHostIdToStateSystemIfNotDefined(ssb, event.getTrace(), hostThreadIdentifier, callStackQuark);
}
}