Πίσω
Παράδειγμα 6:
ΔΡΑΣΤΗΡΙΟΤΗΤΑ
Δίνεται ο παρακάτω βρόχος. (Αγνοήστε προσωρινά τις πρώτες πέντε γραμμές που προηγούνται του βρόχου αυτού.)
.data
|
|
.word
| 0,0, ;0,2;2,0;-1,-2
|
.text
|
|
main:
| lw r2,$DATA(r0)
|
| lw r3,$DATA +4(r0)
|
L:
| add r1,r2,r3
|
| beqz r1,skipnext
|
| subi r2,r2,#1
|
| bnez r2,L
|
| add r5,r3,r3
|
skipnext:
| addi r7,r1,#8
|
| trap #0
|
- Να εκτελέσετε το βρόχο με βάση όσα γνωρίζετε και συγκρίνετε εκ νέου τα αποτελέσματά σας με αυτά του προσομοιωτή WinDLX. (Σημείωση:Στον προσομοιωτή θα λάβετε υπόψη σας και τις πρώτες πέντε γραμμές).
- Να εκτελέσετε τον κώδικα για τις τέσσερις διαφορετικές εκδοχές εισόδου που σας παρέχονται. Τι παρατηρείτε για κάθε μια από αυτές; Eπαληθεύονται τα αποτελέσματά σας από την χρήση του προσομοιωτή;
- Εντοπίστε και μελετήστε τι εξαρτήσεις ελέγχου που υπάρχουν. Πιστεύετε ότι υπάρχουν και κίνδυνοι ελέγχου στο παράδειγμα αυτό;
Ανάλυση:
σσΤο παράδειγμα συμπεριφέρεται διαφορετικά για διαφορετικές τιμές εισόδου δεδομένων ( (0,0),(0,2),(2,0),(-1,-2) ), εστιάζοντας στις εξαρτήσεις ελέγχου μεταξύ των εντολών διακλάδωσης.
Περιπτώσεις:
0x1000:0
intOset:0
0x1000:0
intOset:2
0x1000:2
intOset:0
0x1000:-1
intOset:-2
Total:
13 Cycle(s) executed.
ID executed by 6 Instruction(s).
2 Instruction(s) currently in Pipeline.
Harware configuration:
Memory size: 32768 Bytes
faddEX-Stages: 1,required Cycles:2
fmulEX-Stages: 1,required Cycles:5
fdivEX-Stages: 1,required Cycles:19 Forwarding enabled.
Stalls:
RAW stalls: 3 (23.08% of all Cycles), thereof:
LD stalls: 1 (33.33% of RAW stalls)
Branch/Jump stalls: 1 (33.33% of RAW stalls)
Floating point stalls: 1 (33.33% of RAW stalls)
WAW stalls: 0 (00.00% of all Cycles)
Structural stalls: 0 (00.00% of all Cycles)
Control stalls: 1 (7.69% of all Cycles)
Trap stalls: 3 (23.08% of all Cycles)
Total: 7 Stall(s) (53.85% of all Cycles)
Conditional Branches:
Total: 1 (16.67% of all Instructions), thereof:
taken: 1 (100.00% of all cond. Branches)
not taken: 0 (0.00% of all cond. Branches)
Load- / Store-Instructions:
Total: 2 (33.33% of all Instructions), thereof:
Loads: 2 (100.00% of Load-/Store-Instructions)
Stores: 0 (0.00% of Load-/Store-Instructions)
Floating point stage instructions:
Total: 0 (0.00% of all Instructions), thereof:
Additions: 0 (0.00% of Floating point stage inst.)
Multiplications: 0 (0.00% of Floating point stage inst.)
Divisions: 0 (0.00% of Floating point stage inst.)
Traps:
Traps:1 (16.67% of all Instructions)
Στην περίπτωση αυτή:
- Αληθεύει η εντολή beqz r1,skipnext
- Εκτελείται η addi r7,r1,#8
- Η καθυστέρηση οφείλεται στην τιμή του r1 που απαιτείται στην εντολή διακλάδωσης μετά της εντολής add.
- Τερματισμός
Total:
27 Cycle(s) executed.
ID executed by 14 Instruction(s).
2 Instruction(s) currently in Pipeline.
Harware configuration:
Memory size: 32768 Bytes
faddEX-Stages: 1,required Cycles:2
fmulEX-Stages: 1,required Cycles:5
fdivEX-Stages: 1,required Cycles:19 Forwarding enabled.
Stalls:
RAW stalls: 7 (25.92% of all Cycles), thereof:
LD stalls: 1 (14.28% of RAW stalls)
Branch/Jump stalls: 5 (71.43% of RAW stalls)
Floating point stalls: 1 (14.28% of RAW stalls)
WAW stalls: 0 (00.00% of all Cycles)
Structural stalls: 0 (00.00% of all Cycles)
Control stalls: 3 (11.11% of all Cycles)
Trap stalls: 3 (11.11% of all Cycles)
Total: 13 Stall(s) (48.15% of all Cycles)
Conditional Branches:
Total: 5 (35.71% of all Instructions), thereof:
TRUE-> taken: 3 (60.00% of all cond. Branches)
FALSE-> not taken: 2 (40.00% of all cond. Branches)
Load- / Store-Instructions:
Total: 2 (14.28% of all Instructions), thereof:
Loads: 2 (100.00% of Load-/Store-Instructions)
Stores: 0 (0.00% of Load-/Store-Instructions)
Floating point stage instructions:
Total: 0 (0.00% of all Instructions), thereof:
Additions: 0 (0.00% of Floating point stage inst.)
Multiplications: 0 (0.00% of Floating point stage inst.)
Divisions: 0 (0.00% of Floating point stage inst.)
Traps:
Traps:1 (7.14% of all Instructions)
Στην περίπτωση αυτή:
- Αληθεύει η bnez r2,L δύο φορές λόγω της τιμής του r2 που πάντα θα είναι διάφορη από το 0 και θα σταματήσει να καλείται αυτή η διακλάδωση από την beqz r1, skipnext μιας και ο καταχωρητής r1 μετά από δύο loop πάρει τιμή μηδέν.
- Εκτελείται η addi r7,r1,#8
- Τερματισμός
Total:
23 Cycle(s) executed.
ID executed by 13 Instruction(s).
2 Instruction(s) currently in Pipeline.
Harware configuration:
Memory size: 32768 Bytes
faddEX-Stages: 1,required Cycles:2
fmulEX-Stages: 1,required Cycles:5
fdivEX-Stages: 1,required Cycles:19 Forwarding enabled.
Stalls:
RAW stalls: 6 (26.10% of all Cycles), thereof:
LD stalls: 1 (16.67% of RAW stalls)
Branch/Jump stalls: 4 (66.67% of RAW stalls)
Floating point stalls: 1 (16.67% of RAW stalls)
WAW stalls: 0 (00.00% of all Cycles)
Structural stalls: 0 (00.00% of all Cycles)
Control stalls: 1 (4.35% of all Cycles)
Trap stalls: 3 (13.04% of all Cycles)
Total: 10 Stall(s) (43.48% of all Cycles)
Conditional Branches:
Total: 4 (30.77% of all Instructions), thereof:
taken: 1 (25.00% of all cond. Branches)
not taken: 3 (75.00% of all cond. Branches)
Load- / Store-Instructions:
Total: 2 (15.38% of all Instructions), thereof:
Loads: 2 (100.00% of Load-/Store-Instructions)
Stores: 0 (0.00% of Load-/Store-Instructions)
Floating point stage instructions:
Total: 0 (0.00% of all Instructions), thereof:
Additions: 0 (0.00% of Floating point stage inst.)
Multiplications: 0 (0.00% of Floating point stage inst.)
Divisions: 0 (0.00% of Floating point stage inst.)
Traps:
Traps:1 (7.69% of all Instructions)
Στην περίπτωση αυτή:
- Αληθεύει η bnez r2,L μία φορά λόγω της τιμής του r2 που μειώνει κατά 1 και θα σταματήσει να καλείται αυτή η διακλάδωση όταν δεν θα ισχύει για r2=0 οπότε θα εκτελεστεί η add r5,r3,r3 και μετά η addi r7,r1,#8 έτσι ώστε η beqz r1,skipnext να μην εκτελεστεί ποτέ.
- Τερματισμός
Total:
400 Cycle(s) executed.
ID executed by 299 Instruction(s).
4 Instruction(s) currently in Pipeline.
Harware configuration:
Memory size: 32768 Bytes
faddEX-Stages: 1,required Cycles:2
fmulEX-Stages: 1,required Cycles:5
fdivEX-Stages: 1,required Cycles:19 Forwarding enabled.
Stalls:
RAW stalls: 115 (28.75% of all Cycles), thereof:
LD stalls: 1 (0.87% of RAW stalls)
Branch/Jump stalls: 113 (98.26% of RAW stalls)
Floating point stalls: 1 (0.87% of RAW stalls)
WAW stalls: 0 (00.00% of all Cycles)
Structural stalls: 0 (00.00% of all Cycles)
Control stalls: 56 (14.00% of all Cycles)
Trap stalls: 0 (0.00% of all Cycles)
Total: 171 Stall(s) (42.75% of all Cycles)
Conditional Branches:
Total: 113 (49.34% of all Instructions), thereof:
taken: 56 (49.56% of all cond. Branches)
not taken: 57 (50.44% of all cond. Branches)
Load- / Store-Instructions:
Total: 2 (0.87% of all Instructions), thereof:
Loads: 2 (100.00% of Load-/Store-Instructions)
Stores: 0 (0.00% of Load-/Store-Instructions)
Floating point stage instructions:
Total: 0 (0.00% of all Instructions), thereof:
Additions: 0 (0.00% of Floating point stage inst.)
Multiplications: 0 (0.00% of Floating point stage inst.)
Divisions: 0 (0.00% of Floating point stage inst.)
Traps:
Traps: 0 (0.00% of all Instructions)
Στην περίπτωση αυτή:
- Όλο το πρόγραμμα θα εγκλωβιστεί στην συνθήκη bnez r2,L και το r1 ποτέ δεν θα πάρει τιμή ίση με το μηδέν. Άρα μη τερματισμός του προγράμματος. Στα στατιστικά «παγώνουμε» τον DLX για να έχουμε κάποια εικόνα σχετική μέχρι την στιγμή που τον σταματήσαμε.