Skip to content

Commit 9fcd9b1

Browse files
committed
Create superclass to hold utility ThreadedFileReader functions
Both Communication Over Time and Communication Per PE need to determine if two PEs are on the same node, this new superclass allows that utility function to be shared, along with other future shared functionality.
1 parent d85803f commit 9fcd9b1

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

src/projections/Tools/CommunicationOverTime/ThreadedFileReader.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44

5+
import projections.Tools.ThreadedFileReaderBase;
56
import projections.analysis.EndOfLogSuccess;
67
import projections.analysis.GenericLogReader;
78
import projections.analysis.ProjDefs;
@@ -15,16 +16,13 @@
1516
* Written by Samir Mirza, Isaac Dooley, and possibly others
1617
*
1718
*/
18-
class ThreadedFileReader implements Runnable {
19+
class ThreadedFileReader extends ThreadedFileReaderBase implements Runnable {
1920

2021
private int pe;
2122
private long startInterval;
2223
private long endInterval;
2324
private long intervalSize;
2425

25-
private int myRun = 0;
26-
27-
private int PesPerNode;
2826
// Global data that must be safely accumulated into:
2927
private double[][] globalMessagesSend;
3028
private double[][] globalMessagesRecv;
@@ -55,9 +53,6 @@ protected ThreadedFileReader(int pe, long intervalSize, long startInterval, long
5553
this.globalExternalBytesRecv = globalExternalBytesRecv;
5654
this.globalExternalNodeMessageRecv = globalExternalNodeMessageRecv;
5755
this.globalExternalNodeBytesRecv = globalExternalNodeBytesRecv;
58-
59-
StsReader sts = MainWindow.runObject[myRun].getSts();
60-
this.PesPerNode = sts.getNodeSize(); // 1 for non-SMP, value of ++ppn argument for SMP
6156
}
6257

6358

@@ -119,7 +114,7 @@ public void run() {
119114
localExternalMessageRecv[timeInterval][currEPindex]++;
120115
localExternalBytesRecv[timeInterval][currEPindex]+=logdata.msglen;
121116
}
122-
if(pe/PesPerNode != srcPe/PesPerNode)
117+
if(!isSameNode(pe, srcPe))
123118
{
124119
// Update message and byte received external arrays
125120
localExternalNodeMessageRecv[timeInterval][currEPindex]++;

src/projections/Tools/CommunicationPerPE/ThreadedFileReader.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.IOException;
66
import java.util.ArrayList;
77

8+
import projections.Tools.ThreadedFileReaderBase;
89
import projections.analysis.EndOfLogSuccess;
910
import projections.analysis.GenericLogReader;
1011
import projections.analysis.ProjDefs;
@@ -13,13 +14,12 @@
1314
import projections.analysis.StsReader;
1415

1516
/** The reader threads for Communication Per PE Tool. */
16-
class ThreadedFileReader implements Runnable {
17+
class ThreadedFileReader extends ThreadedFileReaderBase implements Runnable {
1718

1819
private int pe;
1920
private int pIdx;
2021
private long startTime;
2122
private long endTime;
22-
private int myRun = 0;
2323
private double[][] sentMsgCount;
2424
private double[][] sentByteCount;
2525
private double[][] receivedMsgCount;
@@ -127,7 +127,7 @@ public void run() {
127127
//trace. So we have to subtract those msgs that are sent to external
128128
//charm smp nodes. -Chao Mei
129129
int pcreation = logdata.pe;
130-
if(pcreation!=pe && isSameNode(pcreation)){
130+
if(pcreation!=pe && isSameNode(pe, pcreation)){
131131
receivedMsgCount[pIdx][EPid]--;
132132
receivedByteCount[pIdx][EPid] -= logdata.msglen;
133133
}
@@ -161,18 +161,7 @@ public void run() {
161161
System.err.println("Error: could not close log file reader for processor " + pe );
162162
}
163163
}
164-
165-
private boolean isSameNode(int p1){
166-
StsReader sts = MainWindow.runObject[myRun].getSts();
167-
int totalPes = sts.getProcessorCount();
168-
int totalNodes = sts.getSMPNodeCount();
169-
int nodesize = sts.getNodeSize();
170-
int n1 = p1/nodesize;
171-
if(p1>=totalNodes*nodesize && p1<totalPes) n1 = p1- totalNodes*nodesize;
172-
int selfN = pe/nodesize;
173-
if(pe>=totalNodes*nodesize && pe<totalPes) selfN = pe - totalNodes*nodesize;
174-
return n1==selfN;
175-
}
164+
176165
}
177166

178167

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package projections.Tools;
2+
3+
import projections.analysis.StsReader;
4+
import projections.gui.MainWindow;
5+
6+
public class ThreadedFileReaderBase {
7+
protected int myRun = 0;
8+
StsReader sts = MainWindow.runObject[myRun].getSts();
9+
final int totalPes = sts.getProcessorCount();
10+
final int totalNodes = sts.getSMPNodeCount();
11+
final int nodesize = sts.getNodeSize();
12+
13+
protected boolean isSameNode(int pe1, int pe2) {
14+
int n1 = pe1 / nodesize;
15+
if (pe1 >= totalNodes * nodesize && pe1 < totalPes) n1 = pe1 - totalNodes * nodesize;
16+
int n2 = pe2 / nodesize;
17+
if (pe2 >= totalNodes * nodesize && pe2 < totalPes) n2 = pe2 - totalNodes * nodesize;
18+
return n1 == n2;
19+
}
20+
}

0 commit comments

Comments
 (0)