@@ -573,36 +573,28 @@ namespace randomx {
573
573
constexpr int LOOK_FORWARD_CYCLES = 4 ;
574
574
constexpr int MAX_THROWAWAY_COUNT = 256 ;
575
575
576
- #ifndef _DEBUG
577
- constexpr bool TRACE = false ;
578
- constexpr bool INFO = false ;
579
- #else
580
- constexpr bool TRACE = true ;
581
- constexpr bool INFO = true ;
582
- #endif
583
-
584
576
template <bool commit>
585
577
static int scheduleUop (ExecutionPort::type uop, ExecutionPort::type(&portBusy)[CYCLE_MAP_SIZE][3], int cycle) {
586
578
// The scheduling here is done optimistically by checking port availability in order P5 -> P0 -> P1 to not overload
587
579
// port P1 (multiplication) by instructions that can go to any port.
588
580
for (; cycle < CYCLE_MAP_SIZE; ++cycle) {
589
581
if ((uop & ExecutionPort::P5) != 0 && !portBusy[cycle][2 ]) {
590
582
if (commit) {
591
- if (TRACE ) std::cout << " ; P5 at cycle " << cycle << std::endl;
583
+ if (trace ) std::cout << " ; P5 at cycle " << cycle << std::endl;
592
584
portBusy[cycle][2 ] = uop;
593
585
}
594
586
return cycle;
595
587
}
596
588
if ((uop & ExecutionPort::P0) != 0 && !portBusy[cycle][0 ]) {
597
589
if (commit) {
598
- if (TRACE ) std::cout << " ; P0 at cycle " << cycle << std::endl;
590
+ if (trace ) std::cout << " ; P0 at cycle " << cycle << std::endl;
599
591
portBusy[cycle][0 ] = uop;
600
592
}
601
593
return cycle;
602
594
}
603
595
if ((uop & ExecutionPort::P1) != 0 && !portBusy[cycle][1 ]) {
604
596
if (commit) {
605
- if (TRACE ) std::cout << " ; P1 at cycle " << cycle << std::endl;
597
+ if (trace ) std::cout << " ; P1 at cycle " << cycle << std::endl;
606
598
portBusy[cycle][1 ] = uop;
607
599
}
608
600
return cycle;
@@ -621,7 +613,7 @@ namespace randomx {
621
613
// move instructions are eliminated and don't need an execution unit
622
614
if (mop.isEliminated ()) {
623
615
if (commit)
624
- if (TRACE ) std::cout << " ; (eliminated)" << std::endl;
616
+ if (trace ) std::cout << " ; (eliminated)" << std::endl;
625
617
return cycle;
626
618
}
627
619
else if (mop.isSimple ()) {
@@ -677,7 +669,7 @@ namespace randomx {
677
669
678
670
// select a decode configuration
679
671
decodeBuffer = decodeBuffer->fetchNext (currentInstruction.getType (), decodeCycle, mulCount, gen);
680
- if (TRACE ) std::cout << " ; ------------- fetch cycle " << cycle << " (" << decodeBuffer->getName () << " )" << std::endl;
672
+ if (trace ) std::cout << " ; ------------- fetch cycle " << cycle << " (" << decodeBuffer->getName () << " )" << std::endl;
681
673
682
674
int bufferIndex = 0 ;
683
675
@@ -692,15 +684,15 @@ namespace randomx {
692
684
// select an instruction so that the first macro-op fits into the current slot
693
685
currentInstruction.createForSlot (gen, decodeBuffer->getCounts ()[bufferIndex], decodeBuffer->getIndex (), decodeBuffer->getSize () == bufferIndex + 1 , bufferIndex == 0 );
694
686
macroOpIndex = 0 ;
695
- if (TRACE ) std::cout << " ; " << currentInstruction.getInfo ().getName () << std::endl;
687
+ if (trace ) std::cout << " ; " << currentInstruction.getInfo ().getName () << std::endl;
696
688
}
697
689
const MacroOp& mop = currentInstruction.getInfo ().getOp (macroOpIndex);
698
- if (TRACE ) std::cout << mop.getName () << " " ;
690
+ if (trace ) std::cout << mop.getName () << " " ;
699
691
700
692
// calculate the earliest cycle when this macro-op (all of its uOPs) can be scheduled for execution
701
693
int scheduleCycle = scheduleMop<false >(mop, portBusy, cycle, depCycle);
702
694
if (scheduleCycle < 0 ) {
703
- if (TRACE ) std::cout << " Unable to map operation '" << mop.getName () << " ' to execution port (cycle " << cycle << " )" << std::endl;
695
+ if (trace ) std::cout << " Unable to map operation '" << mop.getName () << " ' to execution port (cycle " << cycle << " )" << std::endl;
704
696
// __debugbreak();
705
697
portsSaturated = true ;
706
698
break ;
@@ -711,7 +703,7 @@ namespace randomx {
711
703
int forward;
712
704
// if no suitable operand is ready, look up to LOOK_FORWARD_CYCLES forward
713
705
for (forward = 0 ; forward < LOOK_FORWARD_CYCLES && !currentInstruction.selectSource (scheduleCycle, registers, gen); ++forward) {
714
- if (TRACE ) std::cout << " ; src STALL at cycle " << cycle << std::endl;
706
+ if (trace ) std::cout << " ; src STALL at cycle " << cycle << std::endl;
715
707
++scheduleCycle;
716
708
++cycle;
717
709
}
@@ -720,39 +712,39 @@ namespace randomx {
720
712
if (throwAwayCount < MAX_THROWAWAY_COUNT) {
721
713
throwAwayCount++;
722
714
macroOpIndex = currentInstruction.getInfo ().getSize ();
723
- if (TRACE ) std::cout << " ; THROW away " << currentInstruction.getInfo ().getName () << std::endl;
715
+ if (trace ) std::cout << " ; THROW away " << currentInstruction.getInfo ().getName () << std::endl;
724
716
// cycle = topCycle;
725
717
continue ;
726
718
}
727
719
// abort this decode buffer
728
- if (TRACE ) std::cout << " Aborting at cycle " << cycle << " with decode buffer " << decodeBuffer->getName () << " - source registers not available for operation " << currentInstruction.getInfo ().getName () << std::endl;
720
+ if (trace ) std::cout << " Aborting at cycle " << cycle << " with decode buffer " << decodeBuffer->getName () << " - source registers not available for operation " << currentInstruction.getInfo ().getName () << std::endl;
729
721
currentInstruction = SuperscalarInstruction::Null;
730
722
break ;
731
723
}
732
- if (TRACE ) std::cout << " ; src = r" << currentInstruction.getSource () << std::endl;
724
+ if (trace ) std::cout << " ; src = r" << currentInstruction.getSource () << std::endl;
733
725
}
734
726
// find a destination register that will be ready when this instruction executes
735
727
if (macroOpIndex == currentInstruction.getInfo ().getDstOp ()) {
736
728
int forward;
737
729
for (forward = 0 ; forward < LOOK_FORWARD_CYCLES && !currentInstruction.selectDestination (scheduleCycle, throwAwayCount > 0 , registers, gen); ++forward) {
738
- if (TRACE ) std::cout << " ; dst STALL at cycle " << cycle << std::endl;
730
+ if (trace ) std::cout << " ; dst STALL at cycle " << cycle << std::endl;
739
731
++scheduleCycle;
740
732
++cycle;
741
733
}
742
734
if (forward == LOOK_FORWARD_CYCLES) { // throw instruction away
743
735
if (throwAwayCount < MAX_THROWAWAY_COUNT) {
744
736
throwAwayCount++;
745
737
macroOpIndex = currentInstruction.getInfo ().getSize ();
746
- if (TRACE ) std::cout << " ; THROW away " << currentInstruction.getInfo ().getName () << std::endl;
738
+ if (trace ) std::cout << " ; THROW away " << currentInstruction.getInfo ().getName () << std::endl;
747
739
// cycle = topCycle;
748
740
continue ;
749
741
}
750
742
// abort this decode buffer
751
- if (TRACE ) std::cout << " Aborting at cycle " << cycle << " with decode buffer " << decodeBuffer->getName () << " - destination registers not available" << std::endl;
743
+ if (trace ) std::cout << " Aborting at cycle " << cycle << " with decode buffer " << decodeBuffer->getName () << " - destination registers not available" << std::endl;
752
744
currentInstruction = SuperscalarInstruction::Null;
753
745
break ;
754
746
}
755
- if (TRACE ) std::cout << " ; dst = r" << currentInstruction.getDestination () << std::endl;
747
+ if (trace ) std::cout << " ; dst = r" << currentInstruction.getDestination () << std::endl;
756
748
}
757
749
throwAwayCount = 0 ;
758
750
@@ -773,7 +765,7 @@ namespace randomx {
773
765
ri.latency = retireCycle;
774
766
ri.lastOpGroup = currentInstruction.getGroup ();
775
767
ri.lastOpPar = currentInstruction.getGroupPar ();
776
- if (TRACE ) std::cout << " ; RETIRED at cycle " << retireCycle << std::endl;
768
+ if (trace ) std::cout << " ; RETIRED at cycle " << retireCycle << std::endl;
777
769
}
778
770
codeSize += mop.getSize ();
779
771
bufferIndex++;
0 commit comments