Skip to content

Commit

Permalink
OTF2: Use the new Location class in communicators analysis
Browse files Browse the repository at this point in the history
Updated the communicators state provider so it uses the generic
Location class instead of completely redefine it.

Signed-off-by: yoann-heitz <yoann.heitz@polymtl.ca>
Change-Id: Ic2736329480dfcaf37b2ab1ac4e0d1f53b5d9812
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/190911
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Marco Miller <marco.miller@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-by: Kyrollos Bekhet <kyrollos.bekhet@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
yoann-heitz authored and MatthewKhouzam committed May 31, 2022
1 parent 79ff90d commit c319dba
Showing 1 changed file with 20 additions and 22 deletions.
Expand Up @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.TreeMap;

Expand All @@ -29,6 +30,7 @@
import org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.IOtf2GlobalDefinitions;
import org.eclipse.tracecompass.incubator.internal.otf2.core.mpi.CollectiveOperationIdentifiers;
import org.eclipse.tracecompass.incubator.internal.otf2.core.mpi.MessageIdentifiers;
import org.eclipse.tracecompass.incubator.internal.otf2.core.trace.Location;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;

import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
Expand Down Expand Up @@ -103,9 +105,8 @@ public StateSystemUpdateTriplet(int quark, @Nullable String value, long timestam
*
* @author Yoann Heitz
*/
private class Location {
private class CommunicatorsLocation extends Location {

private final long fId;
private Communicator fCurrentCommunicator;
private String fLatestEnteredRegion;
private long fLatestEnteredTimestamp;
Expand All @@ -117,8 +118,8 @@ private class Location {
private final Deque<IRecvRequest> fIRecvRequests;
private final Deque<StateSystemUpdateTriplet> fPendingStateSystemUpdates;

public Location(long id) {
fId = id;
public CommunicatorsLocation(ITmfEvent event) {
super(event);
fCurrentCommunicator = new Communicator(UNKNOWN_RANK);
fLatestEnteredRegion = IOtf2Constants.UNKNOWN_STRING;
fLatestEnteredTimestamp = 0L;
Expand Down Expand Up @@ -296,7 +297,7 @@ public void mpiSend(ITmfEvent srcEvent, Communicator communicator) {
* communication when encountered.
*/
ITmfEventField content = srcEvent.getContent();
Integer srcRank = getRank(fId, communicator.fId);
Integer srcRank = getRank(getId(), communicator.fId);
Integer destRank = content.getFieldValue(Integer.class, IOtf2Fields.OTF2_RECEIVER);
Integer messageTag = content.getFieldValue(Integer.class, IOtf2Fields.OTF2_MESSAGE_TAG);
if (destRank == null || messageTag == null || srcRank == UNKNOWN_RANK) {
Expand All @@ -314,14 +315,14 @@ public void mpiSend(ITmfEvent srcEvent, Communicator communicator) {
*/
public void mpiRecv(ITmfEvent srcEvent, Communicator communicator, boolean isBlocking) {
ITmfEventField content = srcEvent.getContent();
Integer destRank = getRank(fId, communicator.fId);
Integer destRank = getRank(getId(), communicator.fId);
Integer srcRank = content.getFieldValue(Integer.class, IOtf2Fields.OTF2_SENDER);
Integer messageTag = content.getFieldValue(Integer.class, IOtf2Fields.OTF2_MESSAGE_TAG);
if (srcRank == null || messageTag == null || destRank == UNKNOWN_RANK) {
return;
}

Location srcLocation = fMapLocation.get(communicator.fLocations.get(srcRank));
CommunicatorsLocation srcLocation = fMapLocation.get(communicator.fLocations.get(srcRank));
if (srcLocation == null) {
return;
}
Expand Down Expand Up @@ -374,6 +375,7 @@ public void mpiRecv(ITmfEvent srcEvent, Communicator communicator, boolean isBlo
* for a collective routine
*/
private void mpiCollective(ITmfEvent event, Communicator communicator) {
long id = getId();
ITmfEventField content = event.getContent();
Integer operationCode = content.getFieldValue(Integer.class, IOtf2Fields.OTF2_COLLECTIVE_OPERATION);
if (operationCode == null) {
Expand All @@ -384,7 +386,7 @@ private void mpiCollective(ITmfEvent event, Communicator communicator) {
return;
}
fCurrentCommunicator = communicator;
fRank = getRank(fId, communicator.fId);
fRank = getRank(id, communicator.fId);
/*
* The associated collective operation is searched in the list of
* ongoing collective operations in the associated communicator
Expand All @@ -394,8 +396,8 @@ private void mpiCollective(ITmfEvent event, Communicator communicator) {
* If the communication is found, the state of the communication
* and of the communicator are updated
*/
if (collectiveOperation.isAssociatedOperation(operationCode, root, fId)) {
collectiveOperation.locationCalledOperation(fId, fLatestEnteredTimestamp);
if (collectiveOperation.isAssociatedOperation(operationCode, root, id)) {
collectiveOperation.locationCalledOperation(id, fLatestEnteredTimestamp);
/*
* We store the change for the communicator : one less
* location is expected to use the communicator at this
Expand Down Expand Up @@ -425,7 +427,7 @@ private void mpiCollective(ITmfEvent event, Communicator communicator) {
*/
CollectiveOperationIdentifiers collectiveOperation = new CollectiveOperationIdentifiers(operationCode, root, new ArrayList<>(communicator.fLocations));
communicator.fCollectiveOperations.add(collectiveOperation);
collectiveOperation.locationCalledOperation(fId, fLatestEnteredTimestamp);
collectiveOperation.locationCalledOperation(id, fLatestEnteredTimestamp);

communicator.incrementPendingThreads(event.getTimestamp().toNanos(), -1L);

Expand Down Expand Up @@ -518,7 +520,7 @@ public void updatePendingLocations(ITmfStateSystemBuilder ssb) {
}
}

private final Map<Long, Location> fMapLocation;
private final Map<Long, CommunicatorsLocation> fMapLocation;
private final Map<Integer, Communicator> fMapCommunicator;
private final long fLastTimestamp;

Expand Down Expand Up @@ -573,12 +575,8 @@ protected void processGlobalDefinition(ITmfEvent event, String name) {
break;
}
case IOtf2GlobalDefinitions.OTF2_LOCATION: {
ITmfEventField content = event.getContent();
Long locationReference = content.getFieldValue(Long.class, IOtf2Fields.OTF2_SELF);
if (locationReference == null) {
return;
}
fMapLocation.put(locationReference, new Location(locationReference));
CommunicatorsLocation location = new CommunicatorsLocation(event);
fMapLocation.put(location.getId(), location);
break;
}
case IOtf2GlobalDefinitions.OTF2_COMM: {
Expand Down Expand Up @@ -607,7 +605,7 @@ protected void processGlobalDefinition(ITmfEvent event, String name) {
@Override
protected void processOtf2Event(ITmfEvent event, String name, ITmfStateSystemBuilder ssb) {
Long locationId = getLocationId(event);
Location location = fMapLocation.get(locationId);
CommunicatorsLocation location = fMapLocation.get(locationId);
if (location == null) {
return;
}
Expand Down Expand Up @@ -668,8 +666,8 @@ private void processCommunicatorsAttributes(ITmfStateSystemBuilder ssb) {
* some IRecvRequests were not resolved
*/
private void processLocationsAttributes(ITmfStateSystemBuilder ssb) {
for (Map.Entry<Long, Location> locationEntry : fMapLocation.entrySet()) {
Location location = locationEntry.getValue();
for (Entry<Long, CommunicatorsLocation> locationEntry : fMapLocation.entrySet()) {
CommunicatorsLocation location = locationEntry.getValue();
location.flushAllUpdates(ssb);
}
}
Expand All @@ -678,7 +676,7 @@ private void processLocationsAttributes(ITmfStateSystemBuilder ssb) {
* Calls the corresponding method from the associated location given the
* type of event
*/
private static void processMpiCommunication(ITmfEvent event, ITmfStateSystemBuilder ssb, String name, Location location, Communicator communicator) {
private static void processMpiCommunication(ITmfEvent event, ITmfStateSystemBuilder ssb, String name, CommunicatorsLocation location, Communicator communicator) {
if (!communicator.isInitialized()) {
communicator.initialize(ssb);
}
Expand Down

0 comments on commit c319dba

Please sign in to comment.