November 30, 2017
++ The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 2.0 ("EPL"). A copy of the EPL is + available at http://www.eclipse.org/legal/epl-2.0. + For purposes of the EPL, "Program" will mean the Content. +
+ ++ If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL still apply to any source + code in the Content and such source code may be obtained at http://www.eclipse.org. +
+ + + \ No newline at end of file diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/build.properties b/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/build.properties new file mode 100644 index 000000000..2728cc2dd --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/build.properties @@ -0,0 +1,17 @@ +############################################################################### +# Copyright (c) 2024 É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 +############################################################################### + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/plugin.properties b/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/plugin.properties new file mode 100644 index 000000000..b9a971800 --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/plugin.properties @@ -0,0 +1,13 @@ +############################################################################### +# Copyright (c) 2024 É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 +############################################################################### + +Bundle-Vendor = Eclipse Trace Compass Incubator +Bundle-Name = Trace Compass Incubator GPU Core Tests Plug-in diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/src/org/eclipse/tracecompass/incubator/gpu/core/tests/ActivatorTest.java b/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/src/org/eclipse/tracecompass/incubator/gpu/core/tests/ActivatorTest.java new file mode 100644 index 000000000..cee8e9449 --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core.tests/src/org/eclipse/tracecompass/incubator/gpu/core/tests/ActivatorTest.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2024 É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.gpu.core.tests; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.tracecompass.common.core.TraceCompassActivator; +import org.eclipse.tracecompass.incubator.internal.gpu.core.Activator; +import org.junit.Test; +import org.osgi.framework.BundleContext; + +/** + * Test the activator name. This class is there mostly to create a non empty + * test plugin + * + * @author Geneviève Bastien + */ +public class ActivatorTest extends Plugin { + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + /** + * The plug-in ID + */ + public static final String PLUGIN_ID = "org.eclipse.tracecompass.incubator.gpu.core.tests"; //$NON-NLS-1$ + + /** + * The shared instance + */ + private static Plugin PLUGIN; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * The constructor + */ + public ActivatorTest() { + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Plugin getDefault() { + return PLUGIN; + } + + // ------------------------------------------------------------------------ + // Operators + // ------------------------------------------------------------------------ + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + PLUGIN = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + PLUGIN = null; + super.stop(context); + } + + /** + * Test Activator + */ + @Test + public void testActivator() { + TraceCompassActivator instance = Activator.getInstance(); + assertEquals("org.eclipse.tracecompass.incubator.gpu.core", instance.getPluginId()); + } + + /** + * Return a path to a file relative to this plugin's base directory + * + * @param relativePath + * The path relative to the plugin's root directory + * @return The path corresponding to the relative path in parameter + */ + public static IPath getAbsoluteFilePath(String relativePath) { + Plugin plugin = getDefault(); + if (plugin == null) { + /* + * Shouldn't happen but at least throw something to get the test to + * fail early + */ + throw new IllegalStateException(); + } + URL location = FileLocator.find(plugin.getBundle(), new Path(relativePath), null); + try { + return new Path(FileLocator.toFileURL(location).getPath()); + } catch (IOException e) { + throw new IllegalStateException(); + } + } + +} + diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core/.classpath b/analyses/org.eclipse.tracecompass.incubator.gpu.core/.classpath new file mode 100644 index 000000000..1015d463e --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core/.classpath @@ -0,0 +1,15 @@ + +November 30, 2017
++ The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 2.0 ("EPL"). A copy of the EPL is + available at http://www.eclipse.org/legal/epl-2.0. + For purposes of the EPL, "Program" will mean the Content. +
+ ++ If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL still apply to any source + code in the Content and such source code may be obtained at http://www.eclipse.org. +
+ + + \ No newline at end of file diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core/build.properties b/analyses/org.eclipse.tracecompass.incubator.gpu.core/build.properties new file mode 100644 index 000000000..ae7c9d8b8 --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core/build.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2024 É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 +############################################################################### + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties,\ + plugin.xml diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core/plugin.properties b/analyses/org.eclipse.tracecompass.incubator.gpu.core/plugin.properties new file mode 100644 index 000000000..a3c5eca51 --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core/plugin.properties @@ -0,0 +1,13 @@ +############################################################################### +# Copyright (c) 2024 É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 +############################################################################### + +Bundle-Vendor = Eclipse Trace Compass Incubator +Bundle-Name = Trace Compass GPU Core Plug-in (Incubator) diff --git a/analyses/org.eclipse.tracecompass.incubator.gpu.core/plugin.xml b/analyses/org.eclipse.tracecompass.incubator.gpu.core/plugin.xml new file mode 100644 index 000000000..00aeb8837 --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.gpu.core/plugin.xml @@ -0,0 +1,17 @@ + + ++ * |- OperationQueues + * | |-+ * + * @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); + } + } +} diff --git a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/RocmEventLayout.java b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/RocmEventLayout.java new file mode 100644 index 000000000..1fe2699dd --- /dev/null +++ b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/RocmEventLayout.java @@ -0,0 +1,318 @@ +/******************************************************************************* + * Copyright (c) 2024 É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; + +/** + * Event Layout for ROCm events generated by the CTF plugin + * + * @author Arnaud Fiorini + */ +public class RocmEventLayout { + + /* Event name variables */ + private static final String HIP_PREFIX = "hip"; //$NON-NLS-1$ + private static final String HIP_BEGIN_SUFFIX = "Begin"; //$NON-NLS-1$ + private static final String HIP_END_SUFFIX = "End"; //$NON-NLS-1$ + private static final String HSA_PREFIX = "hsa"; //$NON-NLS-1$ + private static final String HSA_BEGIN_SUFFIX = "_begin"; //$NON-NLS-1$ + private static final String HSA_END_SUFFIX = "_end"; //$NON-NLS-1$ + private static final String HIP_OPERATION_BEGIN = "hip_op_begin"; //$NON-NLS-1$ + private static final String HIP_OPERATION_END = "hip_op_end"; //$NON-NLS-1$ + private static final String HSA_OPERATION_BEGIN = "hsa_op_begin"; //$NON-NLS-1$ + private static final String HSA_OPERATION_END = "hsa_op_end"; //$NON-NLS-1$ + + private static final String HIP_LAUNCH_PREFIX = "hipLaunch"; //$NON-NLS-1$ + private static final String HIP_EXT_LAUNCH_PREFIX = "hipExtLaunch"; //$NON-NLS-1$ + private static final String HIP_MEMCPY_PREFIX = "hipMemcpy"; //$NON-NLS-1$ + private static final String HIP_MEMCPY_BEGIN = "hipMemcpyBegin"; //$NON-NLS-1$ + private static final String HIP_MEMCPY_END = "hipMemcpyEnd"; //$NON-NLS-1$ + private static final String HIP_LAUNCH_KERNEL_BEGIN = "hipLaunchKernelBegin"; //$NON-NLS-1$ + private static final String HIP_LAUNCH_KERNEL_END = "hipLaunchKernelEnd"; //$NON-NLS-1$ + private static final String HIP_STREAM_SYNCHRONIZE_BEGIN = "hipStreamSynchronizeBegin"; //$NON-NLS-1$ + private static final String HIP_STREAM_SYNCHRONIZE_END = "hipStreamSynchronizeEnd"; //$NON-NLS-1$ + + private static final String HSA_HANDLE_TYPE = "hsa_handle_type"; //$NON-NLS-1$ + + /* Common event field names */ + private static final String THREAD_ID = "context._thread_id"; //$NON-NLS-1$ + private static final String QUEUE_ID = "context._queue_id"; //$NON-NLS-1$ + private static final String AGENT_ID = "context._agent_id"; //$NON-NLS-1$ + private static final String CORRELATION_ID = "context._correlation_id"; //$NON-NLS-1$ + + /* HIP event field names */ + private static final String KERNEL_NAME = "context._kernel_name"; //$NON-NLS-1$ + private static final String MEMCPY_KIND = "kind"; //$NON-NLS-1$ + + /* HSA event field names */ + + /* HIP operation event field names */ + private static final String OP_KERNEL_NAME = "kernel_name"; //$NON-NLS-1$ + + /* HSA operation event field names */ + + // ------------------------------------------------------------------------ + // Event names + // ------------------------------------------------------------------------ + + /** + * This event occurs after a call to hipMemcpy which initiates a memory copy + * that involves a GPU. + * + * @return the event name + */ + public String hipMemcpyBegin() { + return HIP_MEMCPY_BEGIN; + } + + /** + * This event occurs right before the call to hipMemcpy ended. + * + * @return the event name + */ + public String hipMemcpyEnd() { + return HIP_MEMCPY_END; + } + + /** + * This event occurs after a call to hipMemcpy which initiates a kernel + * launch to a ROCm Agent. + * + * @return the event name + */ + public String hipLaunchKernelBegin() { + return HIP_LAUNCH_KERNEL_BEGIN; + } + + /** + * This event occurs right before the call to hipLaunchKernel ended. + * + * @return the event name + */ + public String hipLaunchKernelEnd() { + return HIP_LAUNCH_KERNEL_END; + } + + /** + * This event occurs after a call to hipStreamSynchronize which initiates a + * barrier call on a HIP stream. + * + * @return the event name + */ + public String hipStreamSynchronizeBegin() { + return HIP_STREAM_SYNCHRONIZE_BEGIN; + } + + /** + * This event occurs right before the call to hipStreamSynchronize ended. + * + * @return the event name + */ + public String hipStreamSynchronizeEnd() { + return HIP_STREAM_SYNCHRONIZE_END; + } + + /** + * This function returns the prefix of each HIP API event name. + * + * @return the prefix + */ + public String getHipPrefix() { + return HIP_PREFIX; + } + + /** + * This function returns the suffix of each HIP API begin event name. + * + * @return the suffix + */ + public String getHipBeginSuffix() { + return HIP_BEGIN_SUFFIX; + } + + /** + * This function returns the suffix of each HIP API end event name. + * + * @return the suffix + */ + public String getHipEndSuffix() { + return HIP_END_SUFFIX; + } + + /** + * This function returns the prefix of each HSA API event name. + * + * @return the prefix + */ + public String getHsaPrefix() { + return HSA_PREFIX; + } + + /** + * This function returns the suffix of each HSA API begin event name. + * + * @return the suffix + */ + public String getHsaBeginSuffix() { + return HSA_BEGIN_SUFFIX; + } + + /** + * This function returns the suffix of each HSA API end event name. + * + * @return the suffix + */ + public String getHsaEndSuffix() { + return HSA_END_SUFFIX; + } + + /** + * This event occurs when a HIP operation has begun on one of the ROCm + * Agents. + * + * @return the event name + */ + public String getHipOperationBegin() { + return HIP_OPERATION_BEGIN; + } + + /** + * This event occurs when a HIP operation has ended on one of the ROCm + * Agents. + * + * @return the event name + */ + public String getHipOperationEnd() { + return HIP_OPERATION_END; + } + + /** + * This event occurs when a HSA operation has begun on one of the ROCm + * Agents. + * + * @return the event name + */ + public String getHsaOperationBegin() { + return HSA_OPERATION_BEGIN; + } + + /** + * This event occurs when a HSA operation has ended on one of the ROCm + * Agents. + * + * @return the event name + */ + public String getHsaOperationEnd() { + return HSA_OPERATION_END; + } + + /** + * This event is emitted during the initialization phase to identify the + * different agents during the execution. + * + * @return the event name + */ + public String getHsaHandleType() { + return HSA_HANDLE_TYPE; + } + + /** + * This event is a call that will result in a memory copy between the host + * and a device or between two devices. + * + * @param eventName + * the event name + * @return whether the event corresponds to a memory copy + */ + public boolean isMemcpyBegin(String eventName) { + return eventName.startsWith(HIP_MEMCPY_PREFIX) && eventName.endsWith(HIP_BEGIN_SUFFIX); + } + + /** + * This event is a call that will result in a kernel launch that will happen + * on a ROCm agent. + * + * @param eventName + * the event name + * @return whether the event corresponds to a kernel launch + */ + public boolean isLaunchBegin(String eventName) { + return (eventName.startsWith(HIP_LAUNCH_PREFIX) || eventName.startsWith(HIP_EXT_LAUNCH_PREFIX)) && eventName.endsWith(HIP_BEGIN_SUFFIX); + } + + // ------------------------------------------------------------------------ + // Event field names + // ------------------------------------------------------------------------ + + /** + * Field indicating the Thread ID where the event described happened. + * + * @return the field name + */ + public String fieldThreadId() { + return THREAD_ID; + } + + /** + * Field indicating the Queue ID where the event was dispatched. + * + * @return the field name + */ + public String fieldQueueId() { + return QUEUE_ID; + } + + /** + * Field indicating the Agent ID where the event has happened. + * + * @return the field name + */ + public String fieldAgentId() { + return AGENT_ID; + } + + /** + * Field indicating an identification number that match one API call to a + * HIP or HSA operation. + * + * @return the field name + */ + public String fieldCorrelationId() { + return CORRELATION_ID; + } + + /** + * Field indicating the kernel function name. + * + * @return the field name + */ + public String fieldKernelName() { + return KERNEL_NAME; + } + + /** + * Field indicating the kind of memory copy, i.e. whether it is from or to + * the host or between GPUs. + * + * @return the field name + */ + public String fieldMemcpyKind() { + return MEMCPY_KIND; + } + + /** + * Field indicating the kernel function name for operation events. + * + * @return the field name + */ + public String fieldOperationName() { + return OP_KERNEL_NAME; + } +} diff --git a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/dependency/AbstractDependencyMaker.java b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/dependency/AbstractDependencyMaker.java deleted file mode 100644 index 636cd8847..000000000 --- a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/dependency/AbstractDependencyMaker.java +++ /dev/null @@ -1,73 +0,0 @@ -/********************************************************************** - * 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.dependency; - -import java.util.List; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread; -import org.eclipse.tracecompass.incubator.callstack.core.base.EdgeStateValue; -import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.old.RocmStrings; -import org.eclipse.tracecompass.incubator.rocm.core.analysis.dependency.IDependencyMaker; -import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; - -/** - * This dependency maker adds default methods for dependencies - * - * @author Arnaud Fiorini - */ -public abstract class AbstractDependencyMaker implements IDependencyMaker { - - /** - * DependencyMake constructor - */ - protected AbstractDependencyMaker() { - } - - /** - * Creates and adds an arrow to the state system - * - * @param ssb - * The state system to add the arrows - * @param startTime - * The start time of the arrow - * @param endTime - * The end time of the arrow - * @param id - * The id to identify the arrow - * @param src - * The source hostThread - * @param dest - * The destination hostThread - */ - public static void addArrow(ITmfStateSystemBuilder ssb, Long startTime, Long endTime, int id, - @NonNull HostThread src, @NonNull HostThread dest) { - int edgeQuark = getAvailableEdgeQuark(ssb, startTime); - Object edgeStateValue = new EdgeStateValue(id, src, dest); - ssb.modifyAttribute(startTime, edgeStateValue, edgeQuark); - ssb.modifyAttribute(endTime, (Object) null, edgeQuark); - } - - private static int getAvailableEdgeQuark(ITmfStateSystemBuilder ssb, long startTime) { - int edgeRoot = ssb.getQuarkAbsoluteAndAdd(RocmStrings.EDGES); - List<@NonNull Integer> subQuarks = ssb.getSubAttributes(edgeRoot, false); - - for (int quark : subQuarks) { - long start = ssb.getOngoingStartTime(quark); - Object value = ssb.queryOngoing(quark); - if (value == null && start <= startTime) { - return quark; - } - } - return ssb.getQuarkRelativeAndAdd(edgeRoot, Integer.toString(subQuarks.size())); - } -} diff --git a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/dependency/HipApiHipActivityDependencyMaker.java b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/dependency/HipApiHipActivityDependencyMaker.java deleted file mode 100644 index 84a7d3e1e..000000000 --- a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/dependency/HipApiHipActivityDependencyMaker.java +++ /dev/null @@ -1,262 +0,0 @@ -/********************************************************************** - * 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.dependency; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.Queue; - -import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread; -import org.eclipse.tracecompass.incubator.internal.rocm.core.Activator; -import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.old.AbstractGpuEventHandler; -import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.old.ApiEventHandler; -import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.old.HostThreadIdentifier; -import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.handlers.old.HostThreadIdentifier.KERNEL_CATEGORY; -import org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.old.RocmStrings; -import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; -import org.eclipse.tracecompass.tmf.core.util.Pair; - -/** - * As the dependencies relies on specific information depending on the types of - * event that are available, one class is implemented for each use case. - * - * In this case this dependency maker works in the case where both the HIP API - * events and the HIP activity events are available. - * - * @author Arnaud Fiorini - */ -public class HipApiHipActivityDependencyMaker extends AbstractDependencyMaker { - - private final Map+ * | | |- -> Each depth represents one operation that has been queued, + * | | | other depths are for other queued operations. + * |- Root + * | |- Processes + * | | |- + * | | | |- -> Each API is a callstack showing which API call is executed. + * | |- Queues + * | | | |- + * | | | | |- -> Each queue implemented as a callstack with corresponding + * | | | | | compute kernel activity. + *
- * |- Processes - * | |-- * - * @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- * | | |- HIP Streams - * | | | |- -> Each stream implemented as a callstack with corresponding - * | | | | compute kernel activity. - * | | |- Queues - * | | | |- -> Each queue implemented as a callstack with corresponding - * | | | | compute kernel activity. - * | |- Memory - * | | | |- Memory transfers -> Callstack with every memory transfer activity. - * | |- System - * | | |- - * | | | |- -> Each API is a callstack showing which API call is executed. - *
- * |- Function names -> begins at the start of the trace, each ns is a different function name. - *- * - * @author Arnaud Fiorini - */ -public class RocmMetadataStateProvider extends AbstractTmfStateProvider { - - private static final String ID = "org.eclipse.tracecompass.incubator.rocm.core.stateprovider.functionname"; //$NON-NLS-1$ - - /** - * Attribute name for the function name map. - */ - public static final String FUNCTION_NAMES = "Function Names"; //$NON-NLS-1$ - - /** - * @param trace - * the trace to analyze - */ - public RocmMetadataStateProvider(@NonNull ITmfTrace trace) { - super(trace, ID); - } - - @Override - public int getVersion() { - return 1; - } - - @Override - public @NonNull ITmfStateProvider getNewInstance() { - return new RocmCallStackStateProvider(getTrace()); - } - - @Override - protected void eventHandle(@NonNull ITmfEvent event) { - if (event.getName().endsWith("function_name")) { //$NON-NLS-1$ - ITmfStateSystemBuilder ssb = getStateSystemBuilder(); - if (ssb == null) { - return; - } - int functionNameQuark = ssb.getQuarkAbsoluteAndAdd(FUNCTION_NAMES); - int apiQuark = ssb.getQuarkRelativeAndAdd(functionNameQuark, - ((Integer) ((RocmTrace) event.getTrace()).getApiId(event.getName().split("_")[0] + "_api")).toString()); //$NON-NLS-1$ //$NON-NLS-2$ - String functionName = event.getContent().getFieldValue(String.class, RocmStrings.NAME); - Integer cid = event.getContent().getFieldValue(Integer.class, RocmStrings.CORRELATION_ID); - if (functionName == null || cid == null) { - return; - } - ssb.modifyAttribute(ssb.getStartTime() + cid, functionName, apiQuark); - } - } - - /** - * Static function to get the function id from an api event cid. - * - * @param event - * An API event - * @return functionId - */ - public static int getFunctionId(@NonNull ITmfEvent event) { - int nApi = ((RocmTrace) event.getTrace()).getNApi(); - Integer cid = event.getContent().getFieldValue(Integer.class, RocmStrings.CID); - if (cid == null) { - cid = event.getContent().getFieldValue(Integer.class, RocmStrings.CORRELATION_ID); - } - if (cid == null) { - return -1; - } - int apiId; - if (event.getName().endsWith("function_name")) { //$NON-NLS-1$ - apiId = ((RocmTrace) event.getTrace()).getApiId(event.getName().split("_")[0] + "_api"); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - apiId = ((RocmTrace) event.getTrace()).getApiId(event.getName()); - } - return cid * nApi + apiId; - } -} diff --git a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/old/RocmStrings.java b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/old/RocmStrings.java deleted file mode 100644 index 16f540f1d..000000000 --- a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/old/RocmStrings.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020 É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.old; - -/** - * Strings used in the ROCm module - * - * @author Arnaud Fiorini - * @noimplement This interface is not intended to be implemented by clients. - */ -@SuppressWarnings({ "javadoc", "nls" }) -public interface RocmStrings { - /* Event types */ - String GPU_KERNEL = "compute_kernels_hsa"; - String HSA_API = "hsa_api"; - String HIP_API = "hip_api"; - String HCC_OPS = "hcc_ops"; - String ROCTX = "roctx"; - String ASYNC_COPY = "async_copy"; - String HIP_ACTIVITY = "hip_activity"; - String HSA_ACTIVITY = "hsa_activity"; - String KERNEL_EVENT = "kernel_event"; - String HIP_FUNCTION_NAME = "hip_function_name"; - String HSA_FUNCTION_NAME = "hsa_function_name"; - String METRIC_DOUBLE = "metric_double"; - String METRIC_INTEGER = "metric_uint64"; - String METRIC_NAME = "metric_name"; - String METRIC_NAME_END = "metric_name_end"; - - /* Field names */ - String NAME = "name"; - String ARGS = "args"; - String KERNEL_NAME = "kernel_name"; - String KERNEL_DISPATCH_ID = "kernel_dispatch_id"; - String GPU_ID = "gpu_id"; - String CORRELATION_ID = "correlation_id"; - String DEVICE_ID = "device_id"; - String QUEUE_ID = "queue_id"; - String QUEUE_INDEX = "queue_index"; - String STREAM_ID = "stream_id"; - /** Function call id, is used to identify the function name */ - String CID = "cid"; - String TID = "tid"; - String PID = "pid"; - String ID = "id"; - String END = "end"; - String MESSAGE = "message"; - String VALUE = "value"; - - /* State categories */ - String EDGES = "Edges"; - String GPU_ACTIVITY = "GPU Activity"; - String GPU = "GPU "; - String GAP_ANALYSIS = "Gap Analysis"; - String THREAD = "Thread "; - String SYSTEM = "System"; - String MEMORY = "Memory"; - String MEMORY_TRANSFERS = "Memory Transfers"; - String STREAMS = "HIP Streams"; - String STREAM = "Stream "; - String QUEUES = "Queues"; - String QUEUE = "Queue "; - String GPU_KERNELS = "GPU Kernels"; - - /* Event Names */ - String KERNEL_EXECUTION = "KernelExecution"; - String KERNEL_LAUNCH = "hipLaunchKernel"; - String HIP_DEVICE_SYNCHRONIZE = "hipDeviceSynchronize"; - String COPY = "Copy"; - - /* State values */ - String IDLE = "Idle"; -} diff --git a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/old/package-info.java b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/package-info.java similarity index 82% rename from analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/old/package-info.java rename to analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/package-info.java index fa9d33bf6..c12d855e2 100644 --- a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/old/package-info.java +++ b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/internal/rocm/core/analysis/package-info.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 École Polytechnique de Montréal + * Copyright (c) 2024 É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 @@ -8,4 +8,5 @@ * * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -package org.eclipse.tracecompass.incubator.internal.rocm.core.analysis.old; \ No newline at end of file +@org.eclipse.jdt.annotation.NonNullByDefault +package org.eclipse.tracecompass.incubator.internal.rocm.core.analysis; diff --git a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/rocm/core/analysis/dependency/IDependencyMaker.java b/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/rocm/core/analysis/dependency/IDependencyMaker.java deleted file mode 100644 index 946ffe584..000000000 --- a/analyses/org.eclipse.tracecompass.incubator.rocm.core/src/org/eclipse/tracecompass/incubator/rocm/core/analysis/dependency/IDependencyMaker.java +++ /dev/null @@ -1,40 +0,0 @@ -/********************************************************************** - * 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.rocm.core.analysis.dependency; - -import java.util.Map; - -import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; - -/** - * This interface is used to separate the event handlers which do not store - * states and dependency making which requires to store some information to - * make the dependencies. - * - * @author Arnaud Fiorini - */ -public interface IDependencyMaker { - - /** - * @param event - * The event to process - * @param ssb - * The state system builder to use to add the dependency - */ - void processEvent(ITmfEvent event, ITmfStateSystemBuilder ssb); - - /** - * @return A Map which stores the event correlations - */ - Map
+ * This object is completely immutable, so no need to create additional
+ * instances via the constructor.
+ *
+ * @return the instance
+ */
+ public static synchronized RocmCtfPluginTraceEventLayout getInstance() {
+ RocmCtfPluginTraceEventLayout instance = INSTANCE;
+ if (instance == null) {
+ instance = new RocmCtfPluginTraceEventLayout();
+ INSTANCE = instance;
+ }
+ return instance;
+ }
+
+ @Override
+ public @NonNull Collection
+ * This object is completely immutable, so no need to create additional
+ * instances via the constructor.
+ *
+ * @return the instance
+ */
+ public static synchronized RocmExatracerTraceEventLayout getInstance() {
+ RocmExatracerTraceEventLayout instance = INSTANCE;
+ if (instance == null) {
+ instance = new RocmExatracerTraceEventLayout();
+ INSTANCE = instance;
+ }
+ return instance;
+ }
+
+ @Override
+ public @NonNull Collection November 30, 2017
+ The Eclipse Foundation makes available all content in this plug-in
+ ("Content"). Unless otherwise indicated below, the Content
+ is provided to you under the terms and conditions of the Eclipse
+ Public License Version 2.0 ("EPL"). A copy of the EPL is
+ available at http://www.eclipse.org/legal/epl-2.0.
+ For purposes of the EPL, "Program" will mean the Content.
+
+ If you did not receive this Content directly from the Eclipse
+ Foundation, the Content is being redistributed by another party
+ ("Redistributor") and different terms and conditions may
+ apply to your use of any object code in the Content. Check the
+ Redistributor's license that was provided with the Content. If no such
+ license exists, contact the Redistributor. Unless otherwise indicated
+ below, the terms and conditions of the EPL still apply to any source
+ code in the Content and such source code may be obtained at http://www.eclipse.org.
+ About This Content
+
+ License
+
+