Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,28 @@ public void testChromeosTrace() throws TmfTraceException {
assertEquals(expectedProperties, properties);
}

/**
* Test a chromeOs system trace
*
* @throws TmfTraceException
* should not happen
*/
@Test
public void testPytorchTrace() throws TmfTraceException {
String[] env = { "Type", "Trace-Event"};
Map<String, String> expectedProperties = new LinkedHashMap<>();
for (int i = 0; i < env.length; i += 2) {
expectedProperties.put(env[i], env[i + 1]);
}
String path = "traces/stable-diffusion.json";
int nbEvents = 12;
ITmfTimestamp startTime = TmfTimestamp.fromNanos(5624160250199160L);
ITmfTimestamp endTime = TmfTimestamp.fromNanos(5624160263891443L);
Map<String, String> properties = testTrace(path, nbEvents, startTime, endTime);
assertNotNull(properties);
assertEquals(expectedProperties, properties);
}

private static Map<String, String> testTrace(String path, int nbEvents, ITmfTimestamp startTime, ITmfTimestamp endTime) throws TmfTraceException {
ITmfTrace trace = new TraceEventTrace();
try {
Expand Down Expand Up @@ -329,7 +351,7 @@ public void testEmptyEvent() throws TmfTraceException {
assertEquals("X", eventField.getField("ph").getValue());
assertEquals("event1", eventField.getField("name").getValue());
assertEquals("12", eventField.getField("pid").getValue());
assertEquals(12, eventField.getField("tid").getValue());
assertEquals("12", eventField.getField("tid").getValue());
assertEquals("456123453", eventField.getField("ts").getValue()); // it's in microseconds
} finally {
trace.dispose();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"schemaVersion": 1,
"deviceProperties": [
{
"id": 0, "name": "AMD Radeon RX 6700 XT", "totalGlobalMem": 12868124672,
"computeMajor": 10, "computeMinor": 3,
"maxThreadsPerBlock": 1024, "maxThreadsPerMultiprocessor": 2048,
"regsPerBlock": 65536, "warpSize": 32,
"sharedMemPerBlock": 65536, "numSms": 20
, "maxSharedMemoryPerMultiProcessor": 65536
}
],
"record_shapes": 1,
"profile_memory": 1,
"traceEvents": [
{
"ph": "X", "cat": "cpu_op", "name": "aten::empty", "pid": 301562, "tid": 455947,
"ts": 5624160250199.160, "dur": 25.537,
"args": {
"External id": 1,"Record function id": 0, "Concrete Inputs": ["[1, 77]", "4", "0", "", "False", ""], "Input type": ["ScalarList", "Scalar", "Scalar", "", "Scalar", ""], "Input Strides": [[], [], [], [], [], []], "Input Dims": [[], [], [], [], [], []], "Ev Idx": 0
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::to", "pid": 301562, "tid": 455947,
"ts": 5624160251010.565, "dur": 1.312,
"args": {
"External id": 2,"Record function id": 0, "Concrete Inputs": ["", "", "4", "False", "False", ""], "Input type": ["long int", "", "Scalar", "Scalar", "Scalar", ""], "Input Strides": [[77, 1], [], [], [], [], []], "Input Dims": [[1, 77], [], [], [], [], []], "Ev Idx": 1
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::lift_fresh", "pid": 301562, "tid": 455947,
"ts": 5624160251455.876, "dur": 1.172,
"args": {
"External id": 3,"Record function id": 0, "Concrete Inputs": [""], "Input type": ["long int"], "Input Strides": [[77, 1]], "Input Dims": [[1, 77]], "Ev Idx": 2
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::to", "pid": 301562, "tid": 455947,
"ts": 5624160251470.503, "dur": 2330.181,
"args": {
"External id": 4,"Record function id": 0, "Concrete Inputs": ["", "4", "0", "", "", "False", "False", ""], "Input type": ["long int", "Scalar", "Scalar", "", "", "Scalar", "Scalar", ""], "Input Strides": [[77, 1], [], [], [], [], [], [], []], "Input Dims": [[1, 77], [], [], [], [], [], [], []], "Ev Idx": 3
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::_to_copy", "pid": "Spans", "tid": "PyTorch Profiler",
"ts": 5624160252062.298, "dur": 1737.624,
"args": {
"External id": 5,"Record function id": 0, "Concrete Inputs": ["", "4", "0", "", "", "False", ""], "Input type": ["long int", "Scalar", "Scalar", "", "", "Scalar", ""], "Input Strides": [[77, 1], [], [], [], [], [], []], "Input Dims": [[1, 77], [], [], [], [], [], []], "Ev Idx": 4
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::empty_strided", "pid": 301562, "tid": 455947,
"ts": 5624160252071.275, "dur": 17.252,
"args": {
"External id": 6,"Record function id": 0, "Concrete Inputs": ["[1, 77]", "[77, 1]", "4", "0", "", "False"], "Input type": ["ScalarList", "ScalarList", "Scalar", "Scalar", "", "Scalar"], "Input Strides": [[], [], [], [], [], []], "Input Dims": [[], [], [], [], [], []], "Ev Idx": 5
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::copy_", "pid": 301562, "tid": 455947,
"ts": 5624160252092.114, "dur": 1703.270,
"args": {
"External id": 7,"Record function id": 0, "Concrete Inputs": ["", "", "False"], "Input type": ["long int", "long int", "Scalar"], "Input Strides": [[77, 1], [77, 1], []], "Input Dims": [[1, 77], [1, 77], []], "Ev Idx": 6
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::view", "pid": 301562, "tid": 455947,
"ts": 5624160253949.171, "dur": 17.723,
"args": {
"External id": 8,"Record function id": 0, "Concrete Inputs": ["", "[-1, 77]"], "Input type": ["long int", "ScalarList"], "Input Strides": [[77, 1], []], "Input Dims": [[1, 77], []], "Ev Idx": 7
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::slice", "pid": 301562, "tid": 455947,
"ts": 5624160263728.188, "dur": 60.773,
"args": {
"External id": 9,"Record function id": 0, "Concrete Inputs": ["", "0", "0", "9223372036854775807", "1"], "Input type": ["long int", "Scalar", "Scalar", "Scalar", "Scalar"], "Input Strides": [[77, 1], [], [], [], []], "Input Dims": [[1, 77], [], [], [], []], "Ev Idx": 8
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::as_strided", "pid": 301562, "tid": 455947,
"ts": 5624160263767.241, "dur": 5.159,
"args": {
"External id": 10,"Record function id": 0, "Concrete Inputs": ["", "[1, 77]", "[77, 1]", "0"], "Input type": ["long int", "ScalarList", "ScalarList", "Scalar"], "Input Strides": [[77, 1], [], [], []], "Input Dims": [[1, 77], [], [], []], "Ev Idx": 9
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::embedding", "pid": 301562, "tid": 455947,
"ts": 5624160263879.590, "dur": 140.292,
"args": {
"External id": 11,"Record function id": 0, "Concrete Inputs": ["", "", "-1", "False", "False"], "Input type": ["c10::Half", "long int", "Scalar", "Scalar", "Scalar"], "Input Strides": [[768, 1], [77, 1], [], [], []], "Input Dims": [[49408, 768], [1, 77], [], [], []], "Ev Idx": 10
}
},
{
"ph": "X", "cat": "cpu_op", "name": "aten::reshape", "pid": 301562, "tid": 455947,
"ts": 5624160263891.443, "dur": 7.193,
"args": {
"External id": 12,"Record function id": 0, "Concrete Inputs": ["", "[-1]"], "Input type": ["long int", "ScalarList"], "Input Strides": [[77, 1], []], "Input Dims": [[1, 77], []], "Ev Idx": 11
}
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@

package org.eclipse.tracecompass.incubator.internal.traceevent.core.event;

import java.util.List;
import java.util.Map;
import java.util.logging.Level;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
import org.eclipse.tracecompass.incubator.internal.traceevent.core.trace.TraceEventTrace;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;

import com.google.common.collect.ImmutableList;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;

/**
* Aspects for Trace Compass Logs
Expand Down Expand Up @@ -60,7 +61,7 @@ public class TraceEventAspects {
public static @NonNull Iterable<@NonNull ITmfEventAspect<?>> getAspects() {
Iterable<@NonNull ITmfEventAspect<?>> aspectSet = aspects;
if (aspectSet == null) {
aspectSet = ImmutableList.of(
aspectSet = List.of(
new TraceCompassScopeLogLabelAspect(),
TmfBaseAspects.getTimestampAspect(),
new TraceCompassLogPhaseAspect(),
Expand Down Expand Up @@ -159,7 +160,15 @@ public boolean isHiddenByDefault() {
@Override
public @Nullable Integer resolve(@NonNull ITmfEvent event) {
if (event instanceof TraceEventEvent) {
return ((TraceEventEvent) event).getField().getTid();
ITmfTrace trace = event.getTrace();
Object tid = ((TraceEventEvent) event).getField().getTid();
if (trace instanceof TraceEventTrace) {
TraceEventTrace traceEventTrace = (TraceEventTrace) trace;
return traceEventTrace.registerTid(tid);
}
if (tid instanceof Integer) {
return (Integer) tid;
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TraceEventField {
private final String fName;
private ITmfEventField fContent;
private final @Nullable Map<String, Object> fArgs;
private final @Nullable Integer fTid;
private final @Nullable Object fTid;
private final @Nullable String fCategory;
private final @Nullable String fId;
private final @Nullable Long fDuration;
Expand Down Expand Up @@ -91,10 +91,7 @@ public class TraceEventField {
}
// We differentiate between the duration exit and the other exits for some reason
String name = String.valueOf(optString(root, ITraceEventConstants.NAME, TraceEventPhases.DURATION_END.equals(phase) ? UNKNOWN_DURATION_EXIT_EVENT : UNKNOWN_EXIT_EVENT));
Integer tid = optInt(root, ITraceEventConstants.TID);
if (tid == Integer.MIN_VALUE) {
tid = null;
}
String tid = optString(root, ITraceEventConstants.TID, null);
JsonElement jsonElement = root.get(ITraceEventConstants.PID);
JsonPrimitive primitive = jsonElement == null ? null : jsonElement.isJsonPrimitive() ? jsonElement.getAsJsonPrimitive() : null;
Object pid = primitive == null ? null : primitive.isNumber() ? primitive.getAsNumber() : primitive.isString() ? primitive.getAsString() : null;
Expand Down Expand Up @@ -143,11 +140,6 @@ private static double optDouble(JsonObject root, String key) {
return jsonElement != null ? jsonElement.getAsDouble() : Double.NaN;
}

private static int optInt(JsonObject root, String key) {
JsonElement jsonElement = root.get(key);
return jsonElement != null ? jsonElement.getAsInt() : Integer.MIN_VALUE;
}

private static @Nullable JsonObject optJSONObject(JsonObject root, String key) {
JsonElement jsonElement = root.get(key);
return jsonElement != null ? jsonElement.getAsJsonObject() : null;
Expand Down Expand Up @@ -184,7 +176,7 @@ private static int optInt(JsonObject root, String key) {
* @param fields
* event fields (arguments)
*/
protected TraceEventField(String name, long ts, String phase, @Nullable Object pid, @Nullable Integer tid, @Nullable String category, @Nullable String id, @Nullable Double duration, Map<String, Object> fields) {
protected TraceEventField(String name, long ts, String phase, @Nullable Object pid, @Nullable Object tid, @Nullable String category, @Nullable String id, @Nullable Double duration, Map<String, Object> fields) {
fName = name;
fPid = pid;
fTid = tid;
Expand Down Expand Up @@ -258,7 +250,7 @@ public char getPhase() {
*
* @return the event TID
*/
public @Nullable Integer getTid() {
public @Nullable Object getTid() {
return fTid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.tracecompass.incubator.internal.traceevent.core.trace;

import java.io.IOException;
import java.util.List;

import org.eclipse.tracecompass.internal.jsontrace.core.job.SortingJob;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
Expand All @@ -31,9 +32,11 @@ public class TraceEventSortingJob extends SortingJob {
* the trace to be sort
* @param path
* the path to the trace file
* @param pathToEvents
* the json key to the events array
*/
public TraceEventSortingJob(ITmfTrace trace, String path) {
super(trace, path, "\"ts\":", 1); //$NON-NLS-1$
public TraceEventSortingJob(ITmfTrace trace, String path, List<String> pathToEvents) {
super(trace, path, "\"ts\":", pathToEvents); //$NON-NLS-1$
}

@Override
Expand Down
Loading
Loading