gem5  v20.1.0.0
multiperspective_perceptron.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Texas A&M University
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from this
16  * software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Author: Daniel A. Jiménez
31  * Adapted to gem5 by: Javier Bueno Hedo
32  *
33  */
34 
35 /*
36  * Multiperspective Perceptron Predictor (by Daniel A. Jiménez)
37  */
38 
39 #ifndef __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_HH__
40 #define __CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_HH__
41 
42 #include <array>
43 #include <vector>
44 
45 #include "cpu/pred/bpred_unit.hh"
46 #include "params/MultiperspectivePerceptron.hh"
47 
49 {
50  protected:
54  class MPPBranchInfo {
56  const unsigned int pc;
58  const unsigned short int pc2;
60  const unsigned short int hpc;
62  const bool condBranch;
63 
67  static inline unsigned int hash1(unsigned int a)
68  {
69  a = (a ^ 0xdeadbeef) + (a<<4);
70  a = a ^ (a>>10);
71  a = a + (a<<7);
72  a = a ^ (a>>13);
73  return a;
74  }
75 
76  static inline unsigned int hash2(unsigned int key)
77  {
78  int c2 = 0x27d4eb2d; // a prime or an odd constant
79  key = (key ^ 61) ^ (key >> 16);
80  key = key + (key << 3);
81  key = key ^ (key >> 4);
82  key = key * c2;
83  key = key ^ (key >> 15);
84  return key;
85  }
86 
87  static inline unsigned int hash(unsigned int key, unsigned int i)
88  {
89  return hash2(key) * i + hash1(key);
90  }
91 
92  static inline unsigned int hashPC(unsigned int pc, int pcshift)
93  {
94  if (pcshift < 0) {
95  return hash(pc, -pcshift);
96  } else if (pcshift < 11) {
97  unsigned int x = pc;
98  x ^= (pc >> pcshift);
99  return x;
100  } else {
101  return pc >> (pcshift-11);
102  }
103  }
104 
105  public:
107  bool filtered;
111  int yout;
112 
113  MPPBranchInfo(Addr _pc, int pcshift, bool cb) : pc((unsigned int)_pc),
114  pc2(pc >> 2), hpc(hashPC(pc, pcshift)), condBranch(cb),
115  filtered(false), prediction(false), yout(0)
116  { }
117 
118  unsigned int getPC() const
119  {
120  return pc;
121  }
122  unsigned short int getPC2() const
123  {
124  return pc2;
125  }
126  unsigned short int getHPC() const
127  {
128  return hpc;
129  }
130  unsigned int getHashFilter(bool last_ghist_bit) const
131  {
132  return last_ghist_bit ^ hpc;
133  }
134  bool isUnconditional() const
135  {
136  return !condBranch;
137  }
138  };
139 
143  struct FilterEntry {
145  bool seenTaken;
148 
149  FilterEntry() : seenTaken(false), seenUntaken(false) {}
150 
152  bool alwaysNotTakenSoFar() const {
153  return seenUntaken & !seenTaken;
154  }
156  bool alwaysTakenSoFar() const {
157  return seenTaken & !seenUntaken;
158  }
160  bool neverSeen() const {
161  return !seenTaken && !seenUntaken;
162  }
163  };
164 
165 
175 
177  unsigned int index(Addr pc) const {
178  return (pc >> 2) % localHistories.size();
179  }
180  public:
181  LocalHistories(int nlocal_histories, int histo_len) :
182  localHistories(nlocal_histories), localHistoryLength(histo_len) {}
183 
185  unsigned int operator[](Addr pc) const
186  {
187  return localHistories[index(pc)];
188  }
189 
191  void update(Addr pc, bool value)
192  {
193  assert(localHistories.size() > 0);
194  unsigned int &pos = localHistories[index(pc)];
195  pos <<= 1;
196  pos |= value;
197  pos &= ((1<<localHistoryLength)-1);
198  }
199 
202  {
203  return localHistoryLength;
204  }
205 
207  int getSize() const
208  {
209  return localHistoryLength * localHistories.size();
210  }
211  };
212 
216  struct HistorySpec {
218  const int p1;
220  const int p2;
222  const int p3;
224  const double coeff;
226  const int size;
228  const int width;
231 
232  HistorySpec(int _p1, int _p2, int _p3, double _coeff, int _size,
233  int _width, MultiperspectivePerceptron &_mpp) : p1(_p1),
234  p2(_p2), p3(_p3), coeff(_coeff), size(_size), width(_width),
235  mpp(_mpp)
236  {}
237 
247  virtual unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t)
248  const = 0;
253  virtual void setBitRequirements() const {}
254  };
255 
257  const int blockSize;
258  const int pcshift;
259  const int threshold;
260  const int bias0;
261  const int bias1;
262  const int biasmostly0;
263  const int biasmostly1;
264  const int nbest;
265  const int tunebits;
266  const int hshift;
267  const unsigned long long int imli_mask1;
268  const unsigned long long int imli_mask4;
269  const unsigned long long int recencypos_mask;
270  const double fudge;
271  const int n_sign_bits;
272  const int pcbit;
273  const int decay;
274  const unsigned int record_mask;
275  const bool hash_taken;
276  const bool tuneonly;
277  const int extra_rounds;
278  const int speed;
279  const int budgetbits;
280  const bool speculative_update;
281 
283  static int xlat[];
285  static int xlat4[];
286 
288  struct ThreadData {
289  ThreadData(int num_filter, int n_local_histories,
290  int local_history_length, int assoc,
292  int path_length, int ghist_length, int block_size,
299 
303 
304  void updateAcyclic(bool hashed_taken, unsigned int hpc) {
305  for (int i = 0; i < acyclic_histories.size(); i += 1) {
306  if (acyclic_histories[i].size() > 0) {
307  acyclic_histories[i][hpc%(i+2)] = hashed_taken;
308  acyclic2_histories[i][hpc%(i+2)] = hpc;
309  }
310  }
311  }
312 
321 
322  void insertRecency(unsigned int pc, int assoc) {
323  int i = 0;
324  for (i = 0; i < assoc; i += 1) {
325  if (recency_stack[i] == pc) {
326  break;
327  }
328  }
329  if (i == assoc) {
330  i = assoc-1;
331  recency_stack[i] = pc;
332  }
333  int j;
334  unsigned int b = recency_stack[i];
335  for (j = i; j >= 1; j -= 1) {
337  }
338  recency_stack[0] = b;
339  }
340 
343 
347  };
349 
353 
357  int assoc;
362  int theta;
371 
373  void insertModhistSpec(int p1, int p2) {
374  int j = insert(modhist_indices, p1);
375  if (modhist_lengths.size() < (j + 1)) {
376  modhist_lengths.resize(j + 1);
377  }
378  if (modhist_lengths[j] < p2 + 1) {
379  modhist_lengths[j] = p2 + 1;
380  }
381  if (p2 >= modghist_length) {
382  modghist_length = p2 + 1;
383  }
384  }
385 
387  void insertModpathSpec(int p1, int p2) {
388  int j = insert(modpath_indices, p1);
389  if (modpath_lengths.size() < (j + 1)) {
390  modpath_lengths.resize(j + 1);
391  }
392  if (modpath_lengths[j] < p2 + 1) {
393  modpath_lengths[j] = p2 + 1;
394  }
395  if (p2 >= path_length) {
396  path_length = p2 + 1;
397  }
398  }
399 
402  {
403  for (int i = 0; i < v.size(); i += 1) {
404  if (v[i] == x) {
405  return i;
406  }
407  }
408  v.push_back(x);
409  return v.size()-1;
410  }
411 
421  void computeBits(int num_filter_entries, int nlocal_histories,
422  int local_history_length, bool ignore_path_size);
423 
427  virtual void createSpecs() = 0;
428 
437  unsigned int getIndex(ThreadID tid, const MPPBranchInfo &bi,
438  const HistorySpec &spec, int index) const;
446  void findBest(ThreadID tid, std::vector<int> &best_preds) const;
447 
455  int computeOutput(ThreadID tid, MPPBranchInfo &bi);
456 
463  void train(ThreadID tid, MPPBranchInfo &bi, bool taken);
464 
473  void satIncDec(bool taken, bool &sign, int &c, int max_weight) const;
474 
476  void addSpec(HistorySpec *spec)
477  {
478  specs.push_back(spec);
479  }
480 
483  class GHIST : public HistorySpec {
484  public:
485  GHIST(int p1, int p2, double coeff, int size, int width,
487  : HistorySpec(p1, p2, 0, coeff, size, width, mpp)
488  {}
489 
490  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
491  override
492  {
493  return hash(mpp.threadData[tid]->ghist_words, mpp.blockSize, p1,
494  p2);
495  }
496 
497  static unsigned int hash(const std::vector<unsigned int> &ghist_words,
498  int block_size, int start_pos, int end_pos)
499  {
500  int a = start_pos;
501  int b = end_pos;
502 
503  unsigned int x = 0;
504  // am is the next multiple of block_size after a
505  int am = (((a/block_size)*block_size)+block_size);
506  // bm is the previous multiple of block_size before b
507  int bm = (b/block_size)*block_size;
508 
509  // the 0th bit of ghist_words[a/block_size] is the most recent bit.
510  // so the number of bits between a and am is the number to shift
511  // right?
512 
513  // start out x as remainder bits from the beginning:
514  // x = [ . . . . . b b b b b ]
515  x += ghist_words[a / block_size] >> (a-am);
516  // add in bits from the middle
517  for (int i=am; i<bm; i+=block_size) {
518  x += ghist_words[i / block_size];
519  }
520  // add in remainder bits from end:
521  // x += [ b b b b b . . . . . ]
522  unsigned int y = ghist_words[bm / block_size] & ((1<<(b - bm))-1);
523  x += y << (block_size - (b - bm));
524  return x;
525  }
526  void setBitRequirements() const override
527  {
528  if (mpp.ghist_length <= p2) {
529  mpp.ghist_length = p2 + 1;
530  }
531  }
532  };
533 
534  class ACYCLIC : public HistorySpec {
535  public:
536  ACYCLIC(int p1, int p2, int p3, double coeff, int size, int width,
538  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
539  {}
540 
541  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
542  override
543  {
544  int a = p1;
545  int shift = p2;
546  int style = p3;
547  std::vector<std::vector<bool>> &acyclic_histories =
548  mpp.threadData[tid]->acyclic_histories;
549  std::vector<std::vector<unsigned int>> &acyclic2_histories =
550  mpp.threadData[tid]->acyclic2_histories;
551 
552  unsigned int x = 0;
553  if (style == -1) {
554  unsigned int k = 0;
555  for (int i = 0; i < a + 2; i += 1) {
556  x ^= acyclic_histories[a][i] << k;
557  k += 1;
558  k %= mpp.blockSize;
559  }
560  } else {
561  for (int i = 0; i < a + 2; i += 1) {
562  x <<= shift;
563  x += acyclic2_histories[a][i];
564  }
565  }
566  return x;
567  }
568  void setBitRequirements() const override
569  {
570  if (mpp.acyclic_bits.size() < (p1 + 1)) {
571  mpp.acyclic_bits.resize(p1 + 1);
572  }
573  if (mpp.acyclic_bits[p1].size() < (p1 + 2)) {
574  mpp.acyclic_bits[p1].resize(p1 + 2, std::vector<bool>(2));
575  }
576  for (int j = 0; j < p1 + 2; j += 1) {
577  mpp.acyclic_bits[p1][j][!p3] = true;
578  }
579  }
580  };
581 
582  class MODHIST : public HistorySpec {
583  public:
584  MODHIST(int p1, int p2, double coeff, int size, int width,
586  : HistorySpec(p1, p2, 0, coeff, size, width, mpp)
587  {}
588 
589  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
590  override
591  {
592  int a = p1;
593  int b = p2;
594  std::vector<std::vector<bool>> &mod_histories =
595  mpp.threadData[tid]->mod_histories;
596 
597  unsigned int x = 0, k = 0;
598  for (int i = 0; i < b; i += 1) {
599  x ^= mod_histories[a][i] << k;
600  k += 1;
601  k %= mpp.blockSize;
602  }
603  return x;
604  }
605  void setBitRequirements() const override
606  {
608  }
609  };
610 
611  class BIAS : public HistorySpec {
612  public:
613  BIAS(double coeff, int size, int width,
615  : HistorySpec(0, 0, 0, coeff, size, width, mpp)
616  {}
617 
618  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
619  override
620  {
621  return 0;
622  }
623  };
624 
625 
626  class RECENCY : public HistorySpec {
627  public:
628  RECENCY(int p1, int p2, int p3, double coeff, int size, int width,
630  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
631  {}
632 
633  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
634  override
635  {
636  int depth = p1;
637  int shift = p2;
638  int style = p3;
639  std::vector<unsigned int short> &recency_stack =
640  mpp.threadData[tid]->recency_stack;
641 
642  if (style == -1) {
643  unsigned int x = 0;
644  for (int i = 0; i < depth; i += 1) {
645  x <<= shift;
646  x += recency_stack[i];
647  }
648  return x;
649  } else {
650  unsigned int x = 0, k = 0;
651  for (int i = 0; i < depth; i += 1) {
652  x ^= (!!(recency_stack[i] & (1 << shift))) << k;
653  k += 1;
654  k %= mpp.blockSize;
655  }
656  return x;
657  }
658  }
659  void setBitRequirements() const override
660  {
661  if (mpp.assoc < p1) {
662  mpp.assoc = p1;
663  }
664  mpp.doing_recency = true;
665  }
666  };
667 
668  class IMLI : public HistorySpec {
669  public:
670  IMLI(int p1, double coeff, int size, int width,
672  : HistorySpec(p1, 0, 0, coeff, size, width, mpp)
673  {}
674 
675  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
676  override
677  {
678  assert(p1 >= 1);
679  assert(p1 <= 4);
680  return mpp.threadData[tid]->imli_counter[p1-1];
681  }
682 
683  void setBitRequirements() const override
684  {
685  mpp.imli_counter_bits[p1 - 1] = 32;
686  }
687  };
688 
689  class PATH : public HistorySpec {
690  public:
691  PATH(int p1, int p2, int p3, double coeff, int size, int width,
693  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
694  {}
695 
696  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
697  override
698  {
699  int depth = p1;
700  int shift = p2;
701  int style = p3;
702  std::vector<unsigned short int> &path_history =
703  mpp.threadData[tid]->path_history;
704 
705  if (style == -1) {
706  unsigned int x = 0;
707  for (int i = 0; i < depth; i += 1) {
708  x <<= shift;
709  x += path_history[i];
710  }
711  return x;
712  } else {
713  unsigned int x = 0;
714  int bm = (depth / mpp.blockSize) * mpp.blockSize;
715  for (int i = 0; i < bm; i += mpp.blockSize) {
716  for (int j = 0; j < mpp.blockSize; j += 1) {
717  x ^= (!!(path_history[i + j] & (1 << shift))) << j;
718  }
719  }
720  int k = 0;
721  for (int i = bm; i < depth; i += 1) {
722  x ^= (!!(path_history[i] & (1 << shift))) << k++;
723  }
724  return x;
725  }
726  }
727  void setBitRequirements() const override
728  {
729  if (mpp.path_length <= p1) {
730  mpp.path_length = p1 + 1;
731  }
732  }
733  };
734 
735  class LOCAL : public HistorySpec {
736  public:
737  LOCAL(int p1, double coeff, int size, int width,
739  : HistorySpec(p1, 0, 0, coeff, size, width, mpp)
740  {}
741 
742  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
743  override
744  {
745  unsigned int x = mpp.threadData[tid]->localHistories[pc];
746  if (p1 != -1) {
747  x &= ((1 << p1) - 1);
748  }
749  return x;
750  }
751  void setBitRequirements() const override
752  {
753  mpp.doing_local = true;
754  }
755  };
756 
757  class MODPATH : public HistorySpec {
758  public:
759  MODPATH(int p1, int p2, int p3, double coeff, int size, int width,
761  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
762  {}
763 
764  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
765  override
766  {
767  int a = p1;
768  int depth = p2;
769  int shift = p3;
770 
771  unsigned int x = 0;
772  for (int i=0; i<depth; i += 1) {
773  x <<= shift;
774  x += mpp.threadData[tid]->modpath_histories[a][i];
775  }
776  return x;
777  }
778  void setBitRequirements() const override
779  {
781  }
782  };
783 
784  class GHISTPATH : public HistorySpec {
785  public:
786  GHISTPATH(int p1, int p2, int p3, double coeff, int size, int width,
788  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
789  {}
790 
791  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
792  override
793  {
794  int depth = p1;
795  int shift = p2;
796  int style = p3;
797  std::vector<unsigned int> &ghist_words =
798  mpp.threadData[tid]->ghist_words;
799  std::vector<unsigned short int> &path_history =
800  mpp.threadData[tid]->path_history;
801 
802  if (style == -1) {
803  unsigned int x = 0;
804  int bm = (depth / mpp.blockSize) * mpp.blockSize;
805  unsigned int w;
806  for (int i = 0; i < bm; i += mpp.blockSize) {
807  w = ghist_words[i / mpp.blockSize];
808  for (int j = 0; j < mpp.blockSize; j += 1) {
809  x <<= shift;
810  x += (path_history[i + j] << 1) | (w & 1);
811  w >>= 1;
812  }
813  }
814  w = ghist_words[bm / mpp.blockSize];
815  for (int i = bm; i < depth; i += 1) {
816  x <<= shift;
817  x += (path_history[i] << 1) | (w & 1);
818  w >>= 1;
819  }
820  return x;
821  } else {
822  unsigned int x = 0;
823  int bm = (depth / mpp.blockSize) * mpp.blockSize;
824  unsigned int w = 0;
825  for (int i = 0; i < bm; i += mpp.blockSize) {
826  w = ghist_words[i / mpp.blockSize];
827  for (int j = 0; j < mpp.blockSize; j += 1) {
828  x ^= (!!(path_history[i + j] & (1 << shift))) << j;
829  x ^= (w & 1) << j;
830  w >>= 1;
831  }
832  }
833  w = ghist_words[bm/mpp.blockSize];
834  int k = 0;
835  for (int i = bm; i < depth; i += 1) {
836  x ^= (!!(path_history[i] & (1 << shift))) << k;
837  x ^= (w & 1) << k;
838  w >>= 1;
839  k += 1;
840  }
841  return x;
842  }
843  }
844 
845  void setBitRequirements() const override
846  {
847  if (mpp.ghist_length <= p1) {
848  mpp.ghist_length = p1 + 1;
849  }
850  if (mpp.path_length <= p1) {
851  mpp.path_length = p1 + 1;
852  }
853  }
854  };
855 
856  class GHISTMODPATH : public HistorySpec {
857  public:
858  GHISTMODPATH(int p1, int p2, int p3, double coeff, int size, int width,
860  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
861  {}
862 
863  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
864  override
865  {
866  int a = p1;
867  int depth = p2;
868  int shift = p3;
869  std::vector<std::vector<unsigned short int>> &modpath_histories =
870  mpp.threadData[tid]->modpath_histories;
871  std::vector<std::vector<bool>> &mod_histories =
872  mpp.threadData[tid]->mod_histories;
873 
874  unsigned int x = 0;
875  for (int i = 0; i < depth; i += 1) {
876  x <<= shift;
877  x += (modpath_histories[a][i] << 1) | mod_histories[a][i];
878  }
879  return x;
880  }
881  void setBitRequirements() const override
882  {
885  }
886  };
887 
888  class BLURRYPATH : public HistorySpec {
889  public:
890  BLURRYPATH(int p1, int p2, int p3, double coeff, int size, int width,
892  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
893  {}
894 
895  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
896  override
897  {
898  int scale = p1;
899  int depth = p2;
900  int shiftdelta = p3;
901 
902  if (shiftdelta == -1) shiftdelta = 0;
903  int sdint = shiftdelta >> 2;
904  int sdfrac = shiftdelta & 3;
905  unsigned int x = 0;
906  int shift = 0;
907  int count = 0;
908  for (int i = 0; i < depth; i += 1) {
909  x += mpp.threadData[tid]->blurrypath_histories[scale][i] >>
910  shift;
911  count += 1;
912  if (count == sdfrac) {
913  shift += sdint;
914  count = 0;
915  }
916  }
917  return x;
918 
919  }
920  void setBitRequirements() const override
921  {
922  if (mpp.blurrypath_bits.size() < (p1 + 1)) {
923  mpp.blurrypath_bits.resize(p1 + 1);
924  }
925  if (mpp.blurrypath_bits[p1].size() < p2) {
926  mpp.blurrypath_bits[p1].resize(p2);
927  }
928  for (int j = 0; j < p2; j += 1) {
929  mpp.blurrypath_bits[p1][j] = 32 - p1;
930  }
931  }
932  };
933 
934  class RECENCYPOS : public HistorySpec {
935  public:
936  RECENCYPOS(int p1, double coeff, int size, int width,
938  : HistorySpec(p1, 0, 0, coeff, size, width, mpp)
939  {}
940 
941  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
942  override
943  {
944  return hash(mpp.threadData[tid]->recency_stack, mpp.table_sizes,
945  pc2, p1, t);
946  }
947 
948  static unsigned int hash(
949  const std::vector<unsigned int short> &recency_stack,
950  const std::vector<int> &table_sizes, unsigned short int pc, int l,
951  int t)
952  {
953  // search for the PC
954 
955  for (int i = 0; i < l; i += 1) {
956  if (recency_stack[i] == pc) {
957  return i * table_sizes[t] / l;
958  }
959  }
960 
961  // return last index in table on a miss
962 
963  return table_sizes[t] - 1;
964  }
965 
966  void setBitRequirements() const override
967  {
968  if (mpp.assoc < p1) {
969  mpp.assoc = p1;
970  }
971  mpp.doing_recency = true;
972  }
973  };
974 
975  class SGHISTPATH : public HistorySpec {
976  public:
977  SGHISTPATH(int p1, int p2, int p3, double coeff, int size, int width,
979  : HistorySpec(p1, p2, p3, coeff, size, width, mpp)
980  {}
981 
982  unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const
983  override
984  {
985  int a = p1;
986  int b = p2;
987  int shift = p3;
988  std::vector<unsigned int> &ghist_words =
989  mpp.threadData[tid]->ghist_words;
990  std::vector<unsigned short int> &path_history =
991  mpp.threadData[tid]->path_history;
992 
993  unsigned int x = 0;
994  int bm = (b / mpp.blockSize) * mpp.blockSize;
995  unsigned int w;
996  for (int i = a; i < bm; i += mpp.blockSize) {
997  w = ghist_words[i / mpp.blockSize];
998  for (int j = 0; j < mpp.blockSize; j += 1) {
999  x <<= shift;
1000  x += (path_history[i+j] << 1) | (w & 1);
1001  w >>= 1;
1002  }
1003  }
1004  w = ghist_words[bm / mpp.blockSize];
1005  for (int i = bm; i < b; i += 1) {
1006  x <<= shift;
1007  x += (path_history[i] << 1) | (w & 1);
1008  w >>= 1;
1009  }
1010  return x;
1011  }
1012  };
1013 
1014  public:
1015  MultiperspectivePerceptron(const MultiperspectivePerceptronParams *params);
1016 
1022  void setExtraBits(int bits);
1023 
1024  void init() override;
1025 
1026  void uncondBranch(ThreadID tid, Addr pc, void * &bp_history) override;
1027  void squash(ThreadID tid, void *bp_history) override;
1028  bool lookup(ThreadID tid, Addr instPC, void * &bp_history) override;
1029  void update(ThreadID tid, Addr instPC, bool taken,
1030  void *bp_history, bool squashed,
1031  const StaticInstPtr & inst,
1032  Addr corrTarget) override;
1033  void btbUpdate(ThreadID tid, Addr branch_addr, void* &bp_history) override;
1034 };
1035 #endif//__CPU_PRED_MULTIPERSPECTIVE_PERCEPTRON_HH__
MultiperspectivePerceptron::LocalHistories::LocalHistories
LocalHistories(int nlocal_histories, int histo_len)
Definition: multiperspective_perceptron.hh:181
MultiperspectivePerceptron::HistorySpec::mpp
MultiperspectivePerceptron & mpp
Reference to the branch predictor class.
Definition: multiperspective_perceptron.hh:230
MultiperspectivePerceptron::HistorySpec::p2
const int p2
Second parameter.
Definition: multiperspective_perceptron.hh:220
MultiperspectivePerceptron::extrabits
int extrabits
Definition: multiperspective_perceptron.hh:363
MultiperspectivePerceptron::imli_mask1
const unsigned long long int imli_mask1
Definition: multiperspective_perceptron.hh:267
MultiperspectivePerceptron::xlat
static int xlat[]
Transfer function for 6-width tables.
Definition: multiperspective_perceptron.hh:283
MultiperspectivePerceptron::fudge
const double fudge
Definition: multiperspective_perceptron.hh:270
MultiperspectivePerceptron::BLURRYPATH::BLURRYPATH
BLURRYPATH(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:890
MultiperspectivePerceptron::bias1
const int bias1
Definition: multiperspective_perceptron.hh:261
MultiperspectivePerceptron::PATH::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:727
MultiperspectivePerceptron::MODPATH::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:764
MultiperspectivePerceptron::LOCAL::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:751
MultiperspectivePerceptron::n_sign_bits
const int n_sign_bits
Definition: multiperspective_perceptron.hh:271
MultiperspectivePerceptron::GHISTMODPATH
Definition: multiperspective_perceptron.hh:856
MultiperspectivePerceptron::RECENCY::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:659
MultiperspectivePerceptron::ACYCLIC
Definition: multiperspective_perceptron.hh:534
MultiperspectivePerceptron::acyclic_bits
std::vector< std::vector< std::vector< bool > > > acyclic_bits
Definition: multiperspective_perceptron.hh:370
MultiperspectivePerceptron::LocalHistories::getSize
int getSize() const
Size in bits required by all history entries.
Definition: multiperspective_perceptron.hh:207
MultiperspectivePerceptron::ThreadData::ThreadData
ThreadData(int num_filter, int n_local_histories, int local_history_length, int assoc, const std::vector< std::vector< int >> &blurrypath_bits, int path_length, int ghist_length, int block_size, const std::vector< std::vector< std::vector< bool >>> &acyclic_bits, const std::vector< int > &modhist_indices, const std::vector< int > &modhist_lengths, const std::vector< int > &modpath_indices, const std::vector< int > &modpath_lengths, const std::vector< int > &table_sizes, int n_sign_bits)
Definition: multiperspective_perceptron.cc:52
MultiperspectivePerceptron::FilterEntry::neverSeen
bool neverSeen() const
Whether this branch has been observed before.
Definition: multiperspective_perceptron.hh:160
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
MultiperspectivePerceptron::update
void update(ThreadID tid, Addr instPC, bool taken, void *bp_history, bool squashed, const StaticInstPtr &inst, Addr corrTarget) override
Updates the BP with taken/not taken information.
Definition: multiperspective_perceptron.cc:609
MultiperspectivePerceptron::HistorySpec::coeff
const double coeff
Coefficient of the feature, models the accuracy of the feature.
Definition: multiperspective_perceptron.hh:224
MultiperspectivePerceptron::GHIST::hash
static unsigned int hash(const std::vector< unsigned int > &ghist_words, int block_size, int start_pos, int end_pos)
Definition: multiperspective_perceptron.hh:497
MultiperspectivePerceptron::ThreadData::blurrypath_histories
std::vector< std::vector< unsigned int > > blurrypath_histories
Definition: multiperspective_perceptron.hh:313
MultiperspectivePerceptron::ThreadData::localHistories
LocalHistories localHistories
Definition: multiperspective_perceptron.hh:319
MultiperspectivePerceptron::MODPATH::MODPATH
MODPATH(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:759
MultiperspectivePerceptron::HistorySpec::p3
const int p3
Third parameter.
Definition: multiperspective_perceptron.hh:222
MultiperspectivePerceptron::addSpec
void addSpec(HistorySpec *spec)
Add a table spec to the prefetcher.
Definition: multiperspective_perceptron.hh:476
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
MultiperspectivePerceptron::ThreadData::imli_counter
std::vector< unsigned int > imli_counter
Definition: multiperspective_perceptron.hh:318
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
MultiperspectivePerceptron::RECENCY
Definition: multiperspective_perceptron.hh:626
MultiperspectivePerceptron::GHIST::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:526
MultiperspectivePerceptron::biasmostly0
const int biasmostly0
Definition: multiperspective_perceptron.hh:262
MultiperspectivePerceptron::GHISTPATH::GHISTPATH
GHISTPATH(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:786
MultiperspectivePerceptron::biasmostly1
const int biasmostly1
Definition: multiperspective_perceptron.hh:263
MultiperspectivePerceptron::GHISTMODPATH::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:881
MultiperspectivePerceptron::ThreadData::acyclic2_histories
std::vector< std::vector< unsigned int > > acyclic2_histories
Definition: multiperspective_perceptron.hh:302
MultiperspectivePerceptron::assoc
int assoc
Definition: multiperspective_perceptron.hh:357
MultiperspectivePerceptron::GHISTPATH::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:845
MultiperspectivePerceptron::pcbit
const int pcbit
Definition: multiperspective_perceptron.hh:272
MultiperspectivePerceptron::IMLI
Definition: multiperspective_perceptron.hh:668
MultiperspectivePerceptron::LocalHistories::localHistoryLength
const int localHistoryLength
Size in bits of each history entry.
Definition: multiperspective_perceptron.hh:174
MultiperspectivePerceptron::doing_recency
bool doing_recency
Definition: multiperspective_perceptron.hh:356
MultiperspectivePerceptron::lookup
bool lookup(ThreadID tid, Addr instPC, void *&bp_history) override
Looks up a given PC in the BP to see if it is taken or not taken.
Definition: multiperspective_perceptron.cc:567
MultiperspectivePerceptron::LOCAL
Definition: multiperspective_perceptron.hh:735
MultiperspectivePerceptron::doing_local
bool doing_local
runtime values and data used to count the size in bits
Definition: multiperspective_perceptron.hh:355
MultiperspectivePerceptron::ACYCLIC::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:568
MultiperspectivePerceptron::modpath_indices
std::vector< int > modpath_indices
Definition: multiperspective_perceptron.hh:367
MultiperspectivePerceptron::ThreadData::ghist_words
std::vector< unsigned int > ghist_words
Definition: multiperspective_perceptron.hh:314
MultiperspectivePerceptron::pcshift
const int pcshift
Definition: multiperspective_perceptron.hh:258
MultiperspectivePerceptron::nbest
const int nbest
Definition: multiperspective_perceptron.hh:264
MultiperspectivePerceptron::RECENCY::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:633
MultiperspectivePerceptron::GHISTPATH::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:791
std::vector< unsigned int >
MultiperspectivePerceptron::FilterEntry::FilterEntry
FilterEntry()
Definition: multiperspective_perceptron.hh:149
MultiperspectivePerceptron::computeBits
void computeBits(int num_filter_entries, int nlocal_histories, int local_history_length, bool ignore_path_size)
Computes the size in bits of the structures needed to keep track of the history and the predictor tab...
Definition: multiperspective_perceptron.cc:172
MultiperspectivePerceptron::MODHIST::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:589
MultiperspectivePerceptron::imli_counter_bits
std::vector< int > imli_counter_bits
Definition: multiperspective_perceptron.hh:364
X86ISA::count
count
Definition: misc.hh:703
MultiperspectivePerceptron::specs
std::vector< HistorySpec * > specs
Predictor tables.
Definition: multiperspective_perceptron.hh:351
MultiperspectivePerceptron::insertModpathSpec
void insertModpathSpec(int p1, int p2)
Auxiliary function for MODPATH and GHISTMODPATH features.
Definition: multiperspective_perceptron.hh:387
MultiperspectivePerceptron::ThreadData::acyclic_histories
std::vector< std::vector< bool > > acyclic_histories
Definition: multiperspective_perceptron.hh:301
MultiperspectivePerceptron::speculative_update
const bool speculative_update
Definition: multiperspective_perceptron.hh:280
MultiperspectivePerceptron::ThreadData::filterTable
std::vector< FilterEntry > filterTable
Definition: multiperspective_perceptron.hh:300
MultiperspectivePerceptron::MODHIST
Definition: multiperspective_perceptron.hh:582
MultiperspectivePerceptron::LocalHistories::update
void update(Addr pc, bool value)
Adds a history bit to the local history entry of a given branch.
Definition: multiperspective_perceptron.hh:191
MultiperspectivePerceptron::FilterEntry::alwaysTakenSoFar
bool alwaysTakenSoFar() const
Whether this branch has always been observed as taken.
Definition: multiperspective_perceptron.hh:156
X86ISA::scale
scale
Definition: types.hh:92
MultiperspectivePerceptron::modhist_lengths
std::vector< int > modhist_lengths
Definition: multiperspective_perceptron.hh:366
MultiperspectivePerceptron::GHISTPATH
Definition: multiperspective_perceptron.hh:784
MultiperspectivePerceptron::MPPBranchInfo::hash
static unsigned int hash(unsigned int key, unsigned int i)
Definition: multiperspective_perceptron.hh:87
MultiperspectivePerceptron::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: multiperspective_perceptron.cc:140
MultiperspectivePerceptron::path_length
int path_length
Definition: multiperspective_perceptron.hh:360
MultiperspectivePerceptron::LocalHistories::localHistories
std::vector< unsigned int > localHistories
The array of histories.
Definition: multiperspective_perceptron.hh:172
MipsISA::c2
Bitfield< 6 > c2
Definition: pra_constants.hh:238
MultiperspectivePerceptron::LocalHistories::index
unsigned int index(Addr pc) const
Index function given the pc of the branch.
Definition: multiperspective_perceptron.hh:177
MultiperspectivePerceptron::hash_taken
const bool hash_taken
Definition: multiperspective_perceptron.hh:275
MultiperspectivePerceptron::MODPATH
Definition: multiperspective_perceptron.hh:757
MultiperspectivePerceptron::ThreadData::insertRecency
void insertRecency(unsigned int pc, int assoc)
Definition: multiperspective_perceptron.hh:322
PowerISA::bi
Bitfield< 20, 16 > bi
Definition: types.hh:63
MultiperspectivePerceptron::SGHISTPATH::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:982
MultiperspectivePerceptron::LocalHistories
Local history entries, each enty contains the history of directions taken by a given branch.
Definition: multiperspective_perceptron.hh:170
MultiperspectivePerceptron::MPPBranchInfo::getHashFilter
unsigned int getHashFilter(bool last_ghist_bit) const
Definition: multiperspective_perceptron.hh:130
ArmISA::j
Bitfield< 24 > j
Definition: miscregs_types.hh:54
MultiperspectivePerceptron::MPPBranchInfo::isUnconditional
bool isUnconditional() const
Definition: multiperspective_perceptron.hh:134
MultiperspectivePerceptron::GHIST::GHIST
GHIST(int p1, int p2, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:485
MultiperspectivePerceptron::tunebits
const int tunebits
Definition: multiperspective_perceptron.hh:265
MultiperspectivePerceptron::insertModhistSpec
void insertModhistSpec(int p1, int p2)
Auxiliary function for MODHIST and GHISTMODPATH features.
Definition: multiperspective_perceptron.hh:373
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
MultiperspectivePerceptron::thresholdCounter
int thresholdCounter
Definition: multiperspective_perceptron.hh:361
MipsISA::k
Bitfield< 23 > k
Definition: dt_constants.hh:78
MultiperspectivePerceptron::blockSize
const int blockSize
Predictor parameters.
Definition: multiperspective_perceptron.hh:257
MultiperspectivePerceptron::ThreadData::occupancy
int occupancy
Definition: multiperspective_perceptron.hh:342
MultiperspectivePerceptron::IMLI::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:675
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
MultiperspectivePerceptron::train
void train(ThreadID tid, MPPBranchInfo &bi, bool taken)
Trains the branch predictor with the given branch and direction.
Definition: multiperspective_perceptron.cc:403
MultiperspectivePerceptron::ACYCLIC::ACYCLIC
ACYCLIC(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:536
MultiperspectivePerceptron::LOCAL::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:742
MultiperspectivePerceptron::BIAS::BIAS
BIAS(double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:613
ArmISA::shift
Bitfield< 6, 5 > shift
Definition: types.hh:126
MultiperspectivePerceptron::setExtraBits
void setExtraBits(int bits)
Sets the starting number of storage bits to compute the number of table entries.
Definition: multiperspective_perceptron.cc:134
SparcISA::am
Bitfield< 3 > am
Definition: miscregs.hh:127
MultiperspectivePerceptron::RECENCYPOS
Definition: multiperspective_perceptron.hh:934
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
MultiperspectivePerceptron::ThreadData::tables
std::vector< std::vector< short int > > tables
Definition: multiperspective_perceptron.hh:345
MultiperspectivePerceptron::RECENCYPOS::RECENCYPOS
RECENCYPOS(int p1, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:936
MultiperspectivePerceptron::ThreadData::last_ghist_bit
bool last_ghist_bit
Definition: multiperspective_perceptron.hh:341
MultiperspectivePerceptron::MODHIST::MODHIST
MODHIST(int p1, int p2, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:584
MultiperspectivePerceptron::createSpecs
virtual void createSpecs()=0
Creates the tables of the predictor.
MultiperspectivePerceptron::ThreadData::mod_histories
std::vector< std::vector< bool > > mod_histories
Definition: multiperspective_perceptron.hh:316
MultiperspectivePerceptron::MPPBranchInfo::MPPBranchInfo
MPPBranchInfo(Addr _pc, int pcshift, bool cb)
Definition: multiperspective_perceptron.hh:113
MultiperspectivePerceptron::MPPBranchInfo::hashPC
static unsigned int hashPC(unsigned int pc, int pcshift)
Definition: multiperspective_perceptron.hh:92
MultiperspectivePerceptron::FilterEntry::seenTaken
bool seenTaken
Has this branch been taken at least once?
Definition: multiperspective_perceptron.hh:145
BPredUnit
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:62
MultiperspectivePerceptron::LocalHistories::operator[]
unsigned int operator[](Addr pc) const
Obtains the local history entry of a given branch.
Definition: multiperspective_perceptron.hh:185
MultiperspectivePerceptron::modhist_indices
std::vector< int > modhist_indices
Definition: multiperspective_perceptron.hh:365
MultiperspectivePerceptron::GHISTMODPATH::GHISTMODPATH
GHISTMODPATH(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:858
MultiperspectivePerceptron::tuneonly
const bool tuneonly
Definition: multiperspective_perceptron.hh:276
MultiperspectivePerceptron::PATH::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:696
MultiperspectivePerceptron::GHIST
Available features.
Definition: multiperspective_perceptron.hh:483
MultiperspectivePerceptron::squash
void squash(ThreadID tid, void *bp_history) override
Definition: multiperspective_perceptron.cc:815
MultiperspectivePerceptron::MPPBranchInfo::filtered
bool filtered
Whether this branch has been filtered by the prefetcher.
Definition: multiperspective_perceptron.hh:107
MultiperspectivePerceptron::MPPBranchInfo::getHPC
unsigned short int getHPC() const
Definition: multiperspective_perceptron.hh:126
MultiperspectivePerceptron::ThreadData::sign_bits
std::vector< std::vector< std::array< bool, 2 > > > sign_bits
Definition: multiperspective_perceptron.hh:346
MultiperspectivePerceptron::threadData
std::vector< ThreadData * > threadData
Definition: multiperspective_perceptron.hh:348
MultiperspectivePerceptron::LOCAL::LOCAL
LOCAL(int p1, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:737
MultiperspectivePerceptron::hshift
const int hshift
Definition: multiperspective_perceptron.hh:266
MultiperspectivePerceptron::MODPATH::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:778
MultiperspectivePerceptron::computeOutput
int computeOutput(ThreadID tid, MPPBranchInfo &bi)
Computes the output of the predictor for a given branch and the resulting best value in case the pred...
Definition: multiperspective_perceptron.cc:303
MultiperspectivePerceptron::modpath_lengths
std::vector< int > modpath_lengths
Definition: multiperspective_perceptron.hh:368
MultiperspectivePerceptron::HistorySpec
Base class to implement the predictor tables.
Definition: multiperspective_perceptron.hh:216
MultiperspectivePerceptron::MPPBranchInfo::getPC2
unsigned short int getPC2() const
Definition: multiperspective_perceptron.hh:122
RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:69
MultiperspectivePerceptron::threshold
const int threshold
Definition: multiperspective_perceptron.hh:259
MultiperspectivePerceptron::bias0
const int bias0
Definition: multiperspective_perceptron.hh:260
MultiperspectivePerceptron::FilterEntry::seenUntaken
bool seenUntaken
Has this branch been not taken at least once?
Definition: multiperspective_perceptron.hh:147
MultiperspectivePerceptron::BLURRYPATH::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:895
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
MultiperspectivePerceptron::HistorySpec::HistorySpec
HistorySpec(int _p1, int _p2, int _p3, double _coeff, int _size, int _width, MultiperspectivePerceptron &_mpp)
Definition: multiperspective_perceptron.hh:232
MultiperspectivePerceptron::BLURRYPATH
Definition: multiperspective_perceptron.hh:888
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
MultiperspectivePerceptron::MPPBranchInfo::yout
int yout
Score of the perceptron.
Definition: multiperspective_perceptron.hh:111
MultiperspectivePerceptron::HistorySpec::getHash
virtual unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const =0
Gets the hash to index the table, using the pc of the branch, and the index of the table.
MultiperspectivePerceptron::SGHISTPATH
Definition: multiperspective_perceptron.hh:975
MultiperspectivePerceptron::theta
int theta
Definition: multiperspective_perceptron.hh:362
MultiperspectivePerceptron::MODHIST::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:605
MultiperspectivePerceptron::MPPBranchInfo::hpc
const unsigned short int hpc
pc of the branch, hashed
Definition: multiperspective_perceptron.hh:60
MultiperspectivePerceptron::LocalHistories::getLocalHistoryLength
int getLocalHistoryLength() const
Returns the number of bits of each local history entry.
Definition: multiperspective_perceptron.hh:201
MultiperspectivePerceptron::HistorySpec::size
const int size
Pre-assigned size in bits assigned to this feature.
Definition: multiperspective_perceptron.hh:226
MultiperspectivePerceptron::MPPBranchInfo::pc2
const unsigned short int pc2
pc of the branch, shifted 2 bits to the right
Definition: multiperspective_perceptron.hh:58
MultiperspectivePerceptron::GHIST::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:490
MultiperspectivePerceptron::satIncDec
void satIncDec(bool taken, bool &sign, int &c, int max_weight) const
Auxiliary function to increase a table counter depending on the direction of the branch.
Definition: multiperspective_perceptron.cc:366
MultiperspectivePerceptron::IMLI::IMLI
IMLI(int p1, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:670
MultiperspectivePerceptron::ghist_length
int ghist_length
Definition: multiperspective_perceptron.hh:358
MultiperspectivePerceptron::PATH::PATH
PATH(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:691
MultiperspectivePerceptron::ACYCLIC::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:541
MultiperspectivePerceptron::getIndex
unsigned int getIndex(ThreadID tid, const MPPBranchInfo &bi, const HistorySpec &spec, int index) const
Get the position index of a predictor table.
Definition: multiperspective_perceptron.cc:272
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
MultiperspectivePerceptron::RECENCYPOS::hash
static unsigned int hash(const std::vector< unsigned int short > &recency_stack, const std::vector< int > &table_sizes, unsigned short int pc, int l, int t)
Definition: multiperspective_perceptron.hh:948
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
bpred_unit.hh
MultiperspectivePerceptron::MPPBranchInfo::pc
const unsigned int pc
pc of the branch
Definition: multiperspective_perceptron.hh:56
MultiperspectivePerceptron::MPPBranchInfo::getPC
unsigned int getPC() const
Definition: multiperspective_perceptron.hh:118
MultiperspectivePerceptron::HistorySpec::p1
const int p1
First parameter.
Definition: multiperspective_perceptron.hh:218
MultiperspectivePerceptron::RECENCYPOS::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:941
MultiperspectivePerceptron::decay
const int decay
Definition: multiperspective_perceptron.hh:273
MultiperspectivePerceptron::recencypos_mask
const unsigned long long int recencypos_mask
Definition: multiperspective_perceptron.hh:269
MultiperspectivePerceptron::HistorySpec::width
const int width
Width of the table in bits
Definition: multiperspective_perceptron.hh:228
MultiperspectivePerceptron::imli_mask4
const unsigned long long int imli_mask4
Definition: multiperspective_perceptron.hh:268
MultiperspectivePerceptron::ThreadData::recency_stack
std::vector< unsigned int short > recency_stack
Definition: multiperspective_perceptron.hh:320
MultiperspectivePerceptron::xlat4
static int xlat4[]
Transfer function for 5-width tables.
Definition: multiperspective_perceptron.hh:285
MultiperspectivePerceptron::MPPBranchInfo::hash2
static unsigned int hash2(unsigned int key)
Definition: multiperspective_perceptron.hh:76
MultiperspectivePerceptron::uncondBranch
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history) override
Definition: multiperspective_perceptron.cc:544
MultiperspectivePerceptron::SGHISTPATH::SGHISTPATH
SGHISTPATH(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:977
MultiperspectivePerceptron::MPPBranchInfo::prediction
bool prediction
Result of the prediction (true is taken)
Definition: multiperspective_perceptron.hh:109
MultiperspectivePerceptron::HistorySpec::setBitRequirements
virtual void setBitRequirements() const
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:253
MultiperspectivePerceptron::record_mask
const unsigned int record_mask
Definition: multiperspective_perceptron.hh:274
MultiperspectivePerceptron::MPPBranchInfo::condBranch
const bool condBranch
Whether this is a conditional branch.
Definition: multiperspective_perceptron.hh:62
MultiperspectivePerceptron::insert
int insert(std::vector< int > &v, int x)
Auxiliary function used by insertModhistSpec and insertModpathSpec.
Definition: multiperspective_perceptron.hh:401
MultiperspectivePerceptron::IMLI::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:683
MultiperspectivePerceptron::GHISTMODPATH::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:863
MultiperspectivePerceptron::table_sizes
std::vector< int > table_sizes
Definition: multiperspective_perceptron.hh:352
MultiperspectivePerceptron::extra_rounds
const int extra_rounds
Definition: multiperspective_perceptron.hh:277
MultiperspectivePerceptron::BLURRYPATH::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:920
MultiperspectivePerceptron::modghist_length
int modghist_length
Definition: multiperspective_perceptron.hh:359
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
MultiperspectivePerceptron::PATH
Definition: multiperspective_perceptron.hh:689
MultiperspectivePerceptron::MPPBranchInfo
Branch information data.
Definition: multiperspective_perceptron.hh:54
RefCountingPtr< StaticInst >
MultiperspectivePerceptron::RECENCY::RECENCY
RECENCY(int p1, int p2, int p3, double coeff, int size, int width, MultiperspectivePerceptron &mpp)
Definition: multiperspective_perceptron.hh:628
MultiperspectivePerceptron::ThreadData::modpath_histories
std::vector< std::vector< unsigned short int > > modpath_histories
Definition: multiperspective_perceptron.hh:315
MultiperspectivePerceptron::FilterEntry
Entry of the branch filter.
Definition: multiperspective_perceptron.hh:143
MultiperspectivePerceptron::ThreadData::mpreds
std::vector< int > mpreds
Definition: multiperspective_perceptron.hh:344
MultiperspectivePerceptron::speed
const int speed
Definition: multiperspective_perceptron.hh:278
MultiperspectivePerceptron::MPPBranchInfo::hash1
static unsigned int hash1(unsigned int a)
PC Hash functions.
Definition: multiperspective_perceptron.hh:67
MultiperspectivePerceptron::ThreadData::path_history
std::vector< unsigned short int > path_history
Definition: multiperspective_perceptron.hh:317
MultiperspectivePerceptron
Definition: multiperspective_perceptron.hh:48
MultiperspectivePerceptron::FilterEntry::alwaysNotTakenSoFar
bool alwaysNotTakenSoFar() const
Whether this branch has always been observed as not taken.
Definition: multiperspective_perceptron.hh:152
MipsISA::l
Bitfield< 5 > l
Definition: pra_constants.hh:320
MultiperspectivePerceptron::BIAS::getHash
unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const override
Gets the hash to index the table, using the pc of the branch, and the index of the table.
Definition: multiperspective_perceptron.hh:618
MultiperspectivePerceptron::blurrypath_bits
std::vector< std::vector< int > > blurrypath_bits
Definition: multiperspective_perceptron.hh:369
MultiperspectivePerceptron::ThreadData
History data is kept for each thread.
Definition: multiperspective_perceptron.hh:288
ArmISA::v
Bitfield< 28 > v
Definition: miscregs_types.hh:51
MultiperspectivePerceptron::btbUpdate
void btbUpdate(ThreadID tid, Addr branch_addr, void *&bp_history) override
If a branch is not taken, because the BTB address is invalid or missing, this function sets the appro...
Definition: multiperspective_perceptron.cc:809
MultiperspectivePerceptron::findBest
void findBest(ThreadID tid, std::vector< int > &best_preds) const
Finds the best subset of features to use in case of a low-confidence branch, returns the result as an...
Definition: multiperspective_perceptron.cc:246
MultiperspectivePerceptron::RECENCYPOS::setBitRequirements
void setBitRequirements() const override
Sets the size requirements of the table, used when initializing to set the proper size of the tables.
Definition: multiperspective_perceptron.hh:966
MultiperspectivePerceptron::budgetbits
const int budgetbits
Definition: multiperspective_perceptron.hh:279
MultiperspectivePerceptron::ThreadData::updateAcyclic
void updateAcyclic(bool hashed_taken, unsigned int hpc)
Definition: multiperspective_perceptron.hh:304
MultiperspectivePerceptron::BIAS
Definition: multiperspective_perceptron.hh:611
MultiperspectivePerceptron::MultiperspectivePerceptron
MultiperspectivePerceptron(const MultiperspectivePerceptronParams *params)
Definition: multiperspective_perceptron.cc:113
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17