├── gem ├── lib │ ├── .idea │ │ ├── .name │ │ ├── scopes │ │ │ └── scope_settings.xml │ │ ├── encodings.xml │ │ ├── vcs.xml │ │ ├── modules.xml │ │ ├── lib.iml │ │ └── misc.xml │ └── src │ │ ├── hashTableGUI.jar │ │ ├── myEntry.java │ │ ├── email.rb │ │ ├── Footprint │ │ ├── makefile │ │ ├── makefile.rules │ │ ├── histo.H │ │ ├── linear_fp.cpp │ │ ├── dual_fp.cpp │ │ └── dual_fp_all.cpp │ │ ├── machine.rb │ │ ├── external.rb │ │ ├── env.rb │ │ └── hashTableGUI.java └── loca.gemspec ├── server ├── .idea │ ├── .name │ ├── scopes │ │ └── scope_settings.xml │ ├── encodings.xml │ ├── vcs.xml │ ├── misc.xml │ ├── modules.xml │ └── server.iml ├── data │ └── data.txt ├── favicon.ico ├── static │ ├── coal-file.png │ ├── coal-folder.png │ └── style-paper.css ├── .current.html ├── draw_p.r ├── plot_p.rb ├── plot.rb ├── draw_dual.r ├── draw.r └── server ├── .gitignore ├── policies ├── ForwardOPTStackDistanceAnalyzer │ ├── debugging_OPT.pages │ │ ├── Contents │ │ │ └── PkgInfo │ │ ├── index.xml.gz │ │ └── QuickLook │ │ │ └── Thumbnail.jpg │ ├── 1_array_txt │ ├── temp │ │ ├── 1_array_txt │ │ ├── 1_reverse_txt │ │ ├── 1_rev-OPT-dis_txt │ │ ├── 1_forward-OPT-dis_txt │ │ ├── 2_arrays_txt │ │ ├── 2_reverse_txt │ │ ├── gen-forward-OPT-distance.rb │ │ ├── 2_rev-OPT-dis_txt │ │ └── 2_forward-OPT-dis_txt │ ├── reverse_file │ ├── OPTStackDistanceAnalyzer │ ├── OPTStackDistanceAnalyzer.o │ ├── mrcs │ │ ├── opt_msr_hm_0_mrc │ │ ├── opt_msr_proj_1_mrc │ │ ├── opt_msr_stg_1_mrc │ │ ├── opt_msr_prn_0_mrc │ │ ├── opt_msr_stg_0_mrc │ │ ├── opt_fb_trace3_mrc │ │ ├── opt_fb_trace4_mrc │ │ ├── opt_fb_trace5_mrc │ │ ├── opt_fb_trace6_mrc │ │ ├── opt_msr_src1_1_mrc │ │ ├── opt_msr_prn_1_mrc │ │ ├── opt_msr_proj_0_mrc │ │ ├── opt_twi_trace2_mrc │ │ ├── opt_msr_proj_4_mrc │ │ └── opt_msr_src1_0_mrc │ ├── stream8_reverse_txt │ ├── README.md │ ├── swim_pattern_notes.txt │ ├── 2_arrays_txt │ ├── Makefile │ ├── debugging_original_trace.txt │ ├── gen-forward-OPT-distance.rb │ ├── get_mrc.py │ ├── stream8_rev-OPT-dis_txt │ └── reverse_file.c ├── lc │ └── lc_with_item_size │ │ ├── mrc_mem_data │ │ ├── simulator │ │ ├── lease_lru.o │ │ ├── central_storage.h │ │ ├── attrs.h │ │ ├── declarations.h │ │ ├── Makefile │ │ ├── item.h │ │ ├── README.txt │ │ ├── static.h │ │ ├── dll.h │ │ ├── stack.h │ │ ├── lru_cache.h │ │ ├── workload.h │ │ ├── hash.h │ │ └── lease_bins.h ├── lirs │ ├── lirs │ │ ├── lirs │ │ ├── count_diff.py │ │ ├── Makefile │ │ ├── run │ │ ├── README │ │ └── lirs.h │ ├── Software-for-sharing.zip │ ├── lirs-trc │ │ ├── sprite.par │ │ ├── multi1.par │ │ ├── cpp.par │ │ ├── 2_pools.par │ │ ├── cs.par │ │ ├── multi2.par │ │ ├── ps.par │ │ ├── gli.par │ │ └── multi3.par │ └── lirs-sim │ │ ├── lirs.h │ │ └── lru.c ├── 2q │ ├── mrcs │ │ ├── 2q_msr_proj_1_mrc │ │ ├── 2q_msr_src1_1_mrc │ │ ├── 2q_msr_stg_1_mrc │ │ ├── 2q_msr_stg_0_mrc │ │ ├── 2q_fb_trace4_mrc │ │ ├── 2q_fb_trace6_mrc │ │ ├── 2q_msr_prn_0_mrc │ │ ├── 2q_fb_trace5_mrc │ │ ├── 2q_msr_prn_1_mrc │ │ ├── 2q_msr_proj_0_mrc │ │ ├── 2q_twi_trace2_mrc │ │ ├── 2q_facebook_trace3_mrc │ │ ├── 2q_msr_hm_0_mrc │ │ ├── 2q_msr_proj_4_mrc │ │ ├── 2q_msr_src1_0_mrc │ │ └── facebook_trace3_mrc │ ├── README.md │ └── 2q.py ├── arc │ ├── mrcs │ │ ├── arc_msr_proj_1_mrc │ │ ├── arc_msr_stg_1_mrc │ │ ├── arc_msr_src1_1_mrc │ │ ├── arc_msr_stg_0_mrc │ │ ├── arc_fb_trace6_mrc │ │ ├── arc_fb_trace4_mrc │ │ ├── arc_fb_trace5_mrc │ │ ├── arc_facebook_trace3_mrc │ │ ├── arc_msr_prn_0_mrc │ │ ├── arc_msr_prn_1_mrc │ │ ├── arc_msr_proj_0_mrc │ │ ├── arc_facebook_trace3_mrc_mrc │ │ ├── arc_msr_hm_0_mrc │ │ ├── arc_twi_trace2_mrc │ │ ├── arc_msr_proj_4_mrc │ │ ├── arc_msr_src1_0_mrc │ │ └── facebook_trace3_mrc │ └── README.md ├── lfu │ ├── mrcs │ │ ├── lfu_msr_proj_1_mrc │ │ ├── lfu_msr_src1_1_mrc │ │ ├── lfu_msr_stg_1_mrc │ │ ├── lfu_msr_prn_0_mrc │ │ ├── lfu_msr_stg_0_mrc │ │ ├── lfu_fb_trace4_mrc │ │ ├── lfu_fb_trace5_mrc │ │ ├── lfu_fb_trace6_mrc │ │ ├── lfu_facebook_trace3_mrc │ │ ├── lfu_twi_trace2_mrc │ │ ├── lfu_msr_proj_0_mrc │ │ ├── lfu_msr_prn_1_mrc │ │ ├── lfu_msr_hm_0_mrc │ │ ├── lfu_msr_proj_4_mrc │ │ └── lfu_msr_src1_0_mrc │ ├── README.md │ └── lfu.py ├── README.md └── lru │ ├── README.md │ └── lru.py ├── doc ├── Site │ ├── Media │ │ ├── transparent.gif │ │ └── IE8.css │ ├── installation_files │ │ ├── shapeimage_1.jpg │ │ ├── Graphpaper_bullet_default.png │ │ ├── installationMoz.css │ │ ├── installation.js │ │ ├── installationIE.css │ │ └── installation.css │ ├── Scripts │ │ └── Widgets │ │ │ ├── SharedResources │ │ │ └── None.gif │ │ │ └── Navbar │ │ │ └── navbar.js │ ├── external_software_files │ │ ├── shapeimage_1.jpg │ │ ├── Graphpaper_bullet_default.png │ │ ├── external_softwareMoz.css │ │ ├── external_software.js │ │ ├── external_softwareIE.css │ │ └── external_software.css │ ├── index.html │ └── feed.xml └── index.html ├── INSTALL.md ├── README.md └── dev └── pack.rb /gem/lib/.idea/.name: -------------------------------------------------------------------------------- 1 | lib -------------------------------------------------------------------------------- /server/.idea/.name: -------------------------------------------------------------------------------- 1 | server -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .idea/* 3 | 4 | .* 5 | -------------------------------------------------------------------------------- /server/data/data.txt: -------------------------------------------------------------------------------- 1 | Data for server stored in this folder. 2 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/debugging_OPT.pages/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | ???????? -------------------------------------------------------------------------------- /server/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/server/favicon.ico -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/mrc_mem_data: -------------------------------------------------------------------------------- 1 | 1 64 1.00000 0.00000 2 | 3 | 0.00000 0.00000 4 | -------------------------------------------------------------------------------- /policies/lirs/lirs/lirs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/lirs/lirs/lirs -------------------------------------------------------------------------------- /gem/lib/src/hashTableGUI.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/gem/lib/src/hashTableGUI.jar -------------------------------------------------------------------------------- /server/static/coal-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/server/static/coal-file.png -------------------------------------------------------------------------------- /server/static/coal-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/server/static/coal-folder.png -------------------------------------------------------------------------------- /doc/Site/Media/transparent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/doc/Site/Media/transparent.gif -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/1_array_txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 2 5 | 1 6 | 3 7 | 7 8 | 5 9 | 4 10 | 3 11 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/1_array_txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 2 5 | 1 6 | 3 7 | 7 8 | 5 9 | 4 10 | 3 11 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/simulator: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/lc/lc_with_item_size/simulator -------------------------------------------------------------------------------- /policies/lirs/Software-for-sharing.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/lirs/Software-for-sharing.zip -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/1_reverse_txt: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 5 4 | 7 5 | 3 6 | 1 7 | 2 8 | 4 9 | 3 10 | 2 11 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/lease_lru.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/lc/lc_with_item_size/lease_lru.o -------------------------------------------------------------------------------- /doc/Site/installation_files/shapeimage_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/doc/Site/installation_files/shapeimage_1.jpg -------------------------------------------------------------------------------- /doc/Site/Scripts/Widgets/SharedResources/None.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/doc/Site/Scripts/Widgets/SharedResources/None.gif -------------------------------------------------------------------------------- /doc/Site/external_software_files/shapeimage_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/doc/Site/external_software_files/shapeimage_1.jpg -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/reverse_file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/ForwardOPTStackDistanceAnalyzer/reverse_file -------------------------------------------------------------------------------- /doc/Site/installation_files/Graphpaper_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/doc/Site/installation_files/Graphpaper_bullet_default.png -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/sprite.par: -------------------------------------------------------------------------------- 1 | 100 2 | 200 3 | 300 4 | 400 5 | 500 6 | 600 7 | 700 8 | 800 9 | 900 10 | 1000 11 | 12 | 13 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/multi1.par: -------------------------------------------------------------------------------- 1 | 200 2 | 400 3 | 600 4 | 800 5 | 1000 6 | 1200 7 | 1400 8 | 1600 9 | 1800 10 | 2000 11 | 12 | 13 | -------------------------------------------------------------------------------- /doc/Site/external_software_files/Graphpaper_bullet_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/doc/Site/external_software_files/Graphpaper_bullet_default.png -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/OPTStackDistanceAnalyzer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/ForwardOPTStackDistanceAnalyzer/OPTStackDistanceAnalyzer -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/cpp.par: -------------------------------------------------------------------------------- 1 | 20 2 | 35 3 | 50 4 | 80 5 | 100 6 | 200 7 | 300 8 | 400 9 | 500 10 | 600 11 | 700 12 | 800 13 | 900 14 | 15 | 16 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/OPTStackDistanceAnalyzer.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/ForwardOPTStackDistanceAnalyzer/OPTStackDistanceAnalyzer.o -------------------------------------------------------------------------------- /server/.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /gem/lib/.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/debugging_OPT.pages/index.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/ForwardOPTStackDistanceAnalyzer/debugging_OPT.pages/index.xml.gz -------------------------------------------------------------------------------- /doc/Site/installation_files/installationMoz.css: -------------------------------------------------------------------------------- 1 | .inline-block { 2 | display: -moz-inline-box; 3 | display: inline-block; 4 | vertical-align: baseline; 5 | margin-bottom:3px; 6 | } 7 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/2_pools.par: -------------------------------------------------------------------------------- 1 | 60 2 | 80 3 | 100 4 | 120 5 | 140 6 | 160 7 | 180 8 | 200 9 | 250 10 | 300 11 | 350 12 | 400 13 | 450 14 | 15 | 16 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/cs.par: -------------------------------------------------------------------------------- 1 | 30 2 | 60 3 | 100 4 | 200 5 | 300 6 | 400 7 | 500 8 | 600 9 | 700 10 | 800 11 | 900 12 | 1000 13 | 1100 14 | 1200 15 | 1300 16 | 1400 17 | 18 | -------------------------------------------------------------------------------- /doc/Site/external_software_files/external_softwareMoz.css: -------------------------------------------------------------------------------- 1 | .inline-block { 2 | display: -moz-inline-box; 3 | display: inline-block; 4 | vertical-align: baseline; 5 | margin-bottom:3px; 6 | } 7 | -------------------------------------------------------------------------------- /gem/lib/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /server/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gem/lib/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/debugging_OPT.pages/QuickLook/Thumbnail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcompiler/loca/HEAD/policies/ForwardOPTStackDistanceAnalyzer/debugging_OPT.pages/QuickLook/Thumbnail.jpg -------------------------------------------------------------------------------- /server/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_hm_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.5 3 | 256 0.5 4 | 384 0.5 5 | 512 0.5 6 | 640 0.5 7 | 768 0.5 8 | 896 0.5 9 | 1024 0.5 10 | 1152 0.5 11 | 1280 0.5 12 | 1408 0.5 13 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/multi2.par: -------------------------------------------------------------------------------- 1 | 200 2 | 400 3 | 600 4 | 800 5 | 1000 6 | 1200 7 | 1400 8 | 1600 9 | 1800 10 | 2000 11 | 2200 12 | 2400 13 | 2600 14 | 2800 15 | 3000 16 | 17 | -------------------------------------------------------------------------------- /server/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/ps.par: -------------------------------------------------------------------------------- 1 | 30 2 | 60 3 | 100 4 | 200 5 | 300 6 | 350 7 | 355 8 | 360 9 | 370 10 | 400 11 | 500 12 | 750 13 | 1000 14 | 1250 15 | 1500 16 | 1750 17 | 2000 18 | 2500 19 | 2700 20 | 21 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_proj_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.971135375 3 | 256 0.967895125 4 | 384 0.966531875 5 | 512 0.964606875 6 | 640 0.961923125 7 | 768 0.9594625 8 | 896 0.958674125 9 | 1024 0.958193625 10 | 1152 0.957836375 11 | 1280 0.957463 12 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_proj_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.971437625 3 | 256 0.96887075 4 | 384 0.969503875 5 | 512 0.96125825 6 | 640 0.959643875 7 | 768 0.958716625 8 | 896 0.958051 9 | 1024 0.957541125 10 | 1152 0.95723925 11 | 1280 0.956676125 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_proj_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.98678375 3 | 256 0.982475125 4 | 384 0.979032125 5 | 512 0.975531625 6 | 640 0.972303625 7 | 768 0.968983625 8 | 896 0.96572825 9 | 1024 0.962475 10 | 1152 0.959285875 11 | 1280 0.95653975 12 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/gli.par: -------------------------------------------------------------------------------- 1 | 30 2 | 60 3 | 100 4 | 200 5 | 300 6 | 400 7 | 500 8 | 600 9 | 700 10 | 800 11 | 900 12 | 1000 13 | 1100 14 | 1200 15 | 1300 16 | 1400 17 | 1500 18 | 1600 19 | 1700 20 | 1800 21 | 1900 22 | 2000 23 | 2100 24 | 2200 25 | 2300 26 | 2400 -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_proj_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.956297625 3 | 256 0.9502 4 | 384 0.946104 5 | 512 0.942008 6 | 640 0.93913125 7 | 768 0.93708325 8 | 896 0.935222375 9 | 1024 0.935222375 10 | 1152 0.935222375 11 | 1280 0.935222375 12 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/1_rev-OPT-dis_txt: -------------------------------------------------------------------------------- 1 | 0x3 0x0 INF 2 | 0x4 0x0 INF 3 | 0x5 0x0 INF 4 | 0x7 0x0 INF 5 | 0x3 0x0 2 6 | 0x1 0x0 INF 7 | 0x2 0x0 INF 8 | 0x4 0x0 3 9 | 0x3 0x0 2 10 | 0x2 0x0 3 11 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/1_forward-OPT-dis_txt: -------------------------------------------------------------------------------- 1 | 0x2 0x0 3 2 | 0x3 0x0 2 3 | 0x4 0x0 3 4 | 0x2 0x0 INF 5 | 0x1 0x0 INF 6 | 0x3 0x0 2 7 | 0x7 0x0 INF 8 | 0x5 0x0 INF 9 | 0x4 0x0 INF 10 | 0x3 0x0 INF 11 | -------------------------------------------------------------------------------- /policies/lirs/lirs-trc/multi3.par: -------------------------------------------------------------------------------- 1 | 200 2 | 400 3 | 600 4 | 800 5 | 1000 6 | 1200 7 | 1400 8 | 1600 9 | 1800 10 | 2000 11 | 2200 12 | 2400 13 | 2600 14 | 2800 15 | 3000 16 | 3200 17 | 3400 18 | 3600 19 | 3800 20 | 4000 21 | -------------------------------------------------------------------------------- /doc/Site/Media/IE8.css: -------------------------------------------------------------------------------- 1 | .inline-block { 2 | display: inline-block; 3 | vertical-align: baseline; 4 | } 5 | li.full-width { 6 | width: auto; 7 | } 8 | li div div.inline-block a img { 9 | text-indent: 0; 10 | } 11 | img { 12 | -ms-interpolation-mode: bicubic; 13 | } 14 | -------------------------------------------------------------------------------- /policies/lirs/lirs/count_diff.py: -------------------------------------------------------------------------------- 1 | trace_name = input("input trace name: ") 2 | def count_diff(): 3 | items = set() 4 | trace = open(trace_name) 5 | for key in trace.readlines(): 6 | items.add(key) 7 | trace.close() 8 | print(len(items)) 9 | 10 | count_diff() 11 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_src1_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.9870805 3 | 256 0.9825105 4 | 384 0.978999 5 | 512 0.9765055 6 | 640 0.9724316666666667 7 | 768 0.9689473333333334 8 | 896 0.9658671666666667 9 | 1024 0.9614701666666666 10 | 1152 0.9582651666666666 11 | 1280 0.9553606666666666 12 | 1408 0.952253 13 | -------------------------------------------------------------------------------- /doc/Site/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gem/lib/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_stg_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 16 0.7839289786654686 3 | 32 0.7046230963178827 4 | 48 0.6964382361924583 5 | 64 0.6897500570131656 6 | 80 0.6842321840116421 7 | 96 0.6794016553619004 8 | 112 0.6751697080516246 9 | 128 0.6721722494049465 10 | 144 0.6701024780357064 11 | 160 0.6639741886264083 12 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_stg_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 16 0.710273886240413 3 | 32 0.6959111204577805 4 | 48 0.6930734352332715 5 | 64 0.6822502652648483 6 | 80 0.6743207694979336 7 | 96 0.6717402694116742 8 | 112 0.6664936925913838 9 | 128 0.6640925393094966 10 | 144 0.662381006354066 11 | 160 0.6610664033819162 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_src1_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.9853173333333334 3 | 256 0.9796556666666667 4 | 384 0.9763963333333333 5 | 512 0.97101 6 | 640 0.9690375 7 | 768 0.9668796666666667 8 | 896 0.9636263333333334 9 | 1024 0.9610196666666667 10 | 1152 0.9589571666666666 11 | 1280 0.956807 12 | 1408 0.955006 13 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_stg_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 16 0.7143965867662997 3 | 32 0.7009833576179831 4 | 48 0.6930169910613371 5 | 64 0.6871763848509305 6 | 80 0.6824414471375294 7 | 96 0.6748101040530102 8 | 112 0.6682339028277164 9 | 128 0.6652378097658431 10 | 144 0.6634265891196576 11 | 160 0.6617400918856495 12 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_stg_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 32 0.2447561813271358 3 | 64 0.21518921274400948 4 | 96 0.19653505932055257 5 | 128 0.18204897792374372 6 | 160 0.1707909981461558 7 | 192 0.161631087465502 8 | 224 0.1561409512461132 9 | 256 0.1519669705526819 10 | 288 0.14734146923923452 11 | 320 0.14313646804519145 12 | -------------------------------------------------------------------------------- /server/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_prn_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.548191280667024 3 | 256 0.4932891577092694 4 | 384 0.4543687429353195 5 | 512 0.42824110624527606 6 | 640 0.4037169752479732 7 | 768 0.3842881863324815 8 | 896 0.3673750234072088 9 | 1024 0.3491617981462565 10 | 1152 0.3247049796576586 11 | 1280 0.30638756322631716 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_stg_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 32 0.3133991329031496 3 | 64 0.27732721458062004 4 | 96 0.2552420953117191 5 | 128 0.23506695258048713 6 | 160 0.217370495564807 7 | 192 0.19558327157955896 8 | 224 0.17958063237506247 9 | 256 0.16287289226777094 10 | 288 0.15009983184919112 11 | 320 0.13893294401784417 12 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_fb_trace4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.8540130139927605 3 | 512 0.7173763190491083 4 | 768 0.5929928792611299 5 | 1024 0.48368799377619653 6 | 1280 0.39365897928941124 7 | 1536 0.3277771326746462 8 | 1792 0.2858378731019208 9 | 2048 0.2539575498566324 10 | 2304 0.2247327994405093 11 | 2560 0.19766770276754295 12 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_fb_trace6_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.8517845718116975 3 | 512 0.7138471357710642 4 | 768 0.5883596253956467 5 | 1024 0.478606886362137 6 | 1280 0.3885965914931549 7 | 1536 0.3237584786914623 8 | 1792 0.28257823563436185 9 | 2048 0.25058244256889967 10 | 2304 0.22119565467542013 11 | 2560 0.1941066094286271 12 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_prn_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.30066474682798755 3 | 256 0.27847542896507377 4 | 384 0.2633791667069468 5 | 512 0.24149168099742815 6 | 640 0.2259267374951798 7 | 768 0.21374192026117253 8 | 896 0.2016822398452099 9 | 1024 0.1886486763245795 10 | 1152 0.18093190587849448 11 | 1280 0.1756965681003873 12 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_src1_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.9866946666666667 3 | 256 0.9812478333333333 4 | 384 0.9796208333333334 5 | 512 0.9730815 6 | 640 0.969023 7 | 768 0.9670058333333333 8 | 896 0.9657416666666667 9 | 1024 0.9615855 10 | 1152 0.9587238333333333 11 | 1280 0.9551171666666667 12 | 1408 0.9525826666666667 13 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_stg_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 32 0.23904003860328965 3 | 64 0.21266079574969904 4 | 96 0.19613720909048385 5 | 128 0.18165358963816802 6 | 160 0.16873527449450124 7 | 192 0.15655455792093712 8 | 224 0.14759997341099948 9 | 256 0.1401043372076133 10 | 288 0.13182629504435192 11 | 320 0.12534350280538575 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_fb_trace4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.9321812654347238 3 | 512 0.8637470835392559 4 | 768 0.7939863465027192 5 | 1024 0.7228556756120897 6 | 1280 0.6492493872520002 7 | 1536 0.5717772789120543 8 | 1792 0.48885650113362406 9 | 2048 0.4024419374031911 10 | 2304 0.31604006526128475 11 | 2560 0.2369188081196616 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_fb_trace5_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.9303232183369204 3 | 512 0.8598706785147976 4 | 768 0.7884081784080775 5 | 1024 0.714926727914953 6 | 1280 0.639060762160077 7 | 1536 0.5582160123624572 8 | 1792 0.47286010662696937 9 | 2048 0.3836911884894409 10 | 2304 0.29632273557396405 11 | 2560 0.2183887281834996 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_fb_trace6_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.9310211175226034 3 | 512 0.8613654356294522 4 | 768 0.7909706251026035 5 | 1024 0.7190333102683263 6 | 1280 0.6440159731566277 7 | 1536 0.5650519499647888 8 | 1792 0.4811677541996468 9 | 2048 0.39367594329997346 10 | 2304 0.3065479432508772 11 | 2560 0.22793929249241693 12 | -------------------------------------------------------------------------------- /policies/lirs/lirs/Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | #CFLAGS=-Wall -O2 -g -I. 3 | CFLAGS=-g -I. 4 | 5 | ALLCEXE=$(patsubst %.c,%,$(wildcard *.c)) 6 | 7 | all: $(ALLCEXE) $(ALLCPPEXE) 8 | 9 | .c.o: 10 | $(CC) -c $(CFLAGS) $< 11 | 12 | $(ALLCEXE): %: %.c 13 | $(CC) $(CFLAGS) -o $@ $< 14 | 15 | clean: 16 | rm -f $(ALLCEXE) $(ALLCPPEXE) 17 | 18 | -------------------------------------------------------------------------------- /gem/lib/.idea/lib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_fb_trace5_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.8500976391960057 3 | 512 0.7104388563640498 4 | 768 0.5838567792880721 5 | 1024 0.4734420222645308 6 | 1280 0.3838050879490103 7 | 1536 0.32000198693435433 8 | 1792 0.27967595118661115 9 | 2048 0.24767680029058914 10 | 2304 0.21828957550234124 11 | 2560 0.19102763313430357 12 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_fb_trace6_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.840226816983005 3 | 512 0.6964388728729435 4 | 768 0.5713715573175653 5 | 1024 0.44655950388243904 6 | 1280 0.3364571458818223 7 | 1536 0.24609646491689693 8 | 1792 0.18359790328346484 9 | 2048 0.1351101827147462 10 | 2304 0.11007493314472193 11 | 2560 0.10353803654908628 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_facebook_trace3_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.9318587628262218 3 | 512 0.863383004785828 4 | 768 0.7940934039118661 5 | 1024 0.7229752153205629 6 | 1280 0.6492587567233482 7 | 1536 0.5718079838853812 8 | 1792 0.48884737755541247 9 | 2048 0.4019595152043998 10 | 2304 0.3155382762945247 11 | 2560 0.236585097275446 12 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_twi_trace2_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.46595033333333336 3 | 512 0.420578 4 | 768 0.3888195 5 | 1024 0.36308083333333335 6 | 1280 0.3412285 7 | 1536 0.3223895 8 | 1792 0.3058575 9 | 2048 0.29108833333333334 10 | 2304 0.2778353333333333 11 | 2560 0.2659265 12 | 2816 0.25511 13 | 3072 0.2451055 14 | 3328 0.2358925 15 | -------------------------------------------------------------------------------- /server/.idea/server.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_stg_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 16 0.6987064725533386 3 | 32 0.6831460888968396 4 | 48 0.6723411267258147 5 | 64 0.6649961012553821 6 | 80 0.6606489896265626 7 | 96 0.6575035926260241 8 | 112 0.6556086161118068 9 | 128 0.6541733864818939 10 | 144 0.6532411472551063 11 | 160 0.6523089080283185 12 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_fb_trace4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.8425509941397064 4 | 512 0.6997658875483582 5 | 768 0.5760613530332044 6 | 1024 0.4535022817392477 7 | 1280 0.3426126525287422 8 | 1536 0.25275336436016305 9 | 1792 0.18860685569303934 10 | 2048 0.13924888905979385 11 | 2304 0.11185703133894176 12 | 2560 0.10388841858450144 13 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_fb_trace5_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.8385710915022078 4 | 512 0.6927823057286577 5 | 768 0.5670832890283193 6 | 1024 0.4406463512977553 7 | 1280 0.3308589144663568 8 | 1536 0.24024170745961906 9 | 1792 0.1787387158039672 10 | 2048 0.13155348772951614 11 | 2304 0.10868045826778132 12 | 2560 0.1031511925098784 13 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_prn_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.69777325 3 | 512 0.64933825 4 | 768 0.58869 5 | 1024 0.54592225 6 | 1280 0.5107685 7 | 1536 0.480993 8 | 1792 0.44341925 9 | 2048 0.42185475 10 | 2304 0.406713 11 | 2560 0.39141425 12 | 2816 0.38325325 13 | 3072 0.375611875 14 | 3328 0.36449825 15 | 3584 0.355854875 16 | 3840 0.347306875 17 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_facebook_trace3_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.842112974045919 4 | 512 0.6990066530798759 5 | 768 0.5749193122402606 6 | 1024 0.4523436645633233 7 | 1280 0.34213088465322505 8 | 1536 0.2520579666855123 9 | 1792 0.18846242269298585 10 | 2048 0.13918077071712365 11 | 2304 0.1118163952372568 12 | 2560 0.10386977150045212 13 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_prn_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.26538368308984467 4 | 512 0.2209194745470996 5 | 768 0.19525192601495986 6 | 1024 0.16660186047477518 7 | 1280 0.15211176884025202 8 | 1536 0.14168960841664152 9 | 1792 0.1378921803989555 10 | 2048 0.1350083048597841 11 | 2304 0.13355714742477737 12 | 2560 0.13272164881273982 13 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_proj_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 64 0.7024365348616791 3 | 128 0.642042985197859 4 | 192 0.5844876251146874 5 | 256 0.5304952699996497 6 | 320 0.5013748294482407 7 | 384 0.4828513224211769 8 | 448 0.3536175909996014 9 | 512 0.2913414623754061 10 | 576 0.26009675883010724 11 | 640 0.27837384756247097 12 | 704 0.2420956775248525 13 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_proj_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 64 0.39003944586419675 3 | 128 0.3161430731604318 4 | 192 0.2635184461018567 5 | 256 0.2284910678694215 6 | 320 0.20353867086564073 7 | 384 0.1821083274707399 8 | 448 0.16584069589852016 9 | 512 0.1508546288291888 10 | 576 0.14254292317903744 11 | 640 0.1349091637306357 12 | 704 0.12777983981153854 13 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_prn_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.22778320216345269 3 | 256 0.193102401302139 4 | 384 0.17152390865119696 5 | 512 0.155224256277339 6 | 640 0.1419857118458916 7 | 768 0.1332947002498798 8 | 896 0.1296598247798111 9 | 1024 0.12735401331140664 10 | 1152 0.12735401331140664 11 | 1280 0.12735401331140664 12 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_stg_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 32 0.1908745565422482 3 | 64 0.16264540859661777 4 | 96 0.14775212158066683 5 | 128 0.13644539530211752 6 | 160 0.12985526228325656 7 | 192 0.12491413968580664 8 | 224 0.12088048982847632 9 | 256 0.11813936082997073 10 | 288 0.11612253590130557 11 | 320 0.11410571097264041 12 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_prn_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.6896185 3 | 512 0.604937 4 | 768 0.544243875 5 | 1024 0.504979875 6 | 1280 0.4678905 7 | 1536 0.44951575 8 | 1792 0.433434 9 | 2048 0.400691625 10 | 2304 0.36556875 11 | 2560 0.35397975 12 | 2816 0.328818625 13 | 3072 0.310785875 14 | 3328 0.298309375 15 | 3584 0.28536175 16 | 3840 0.282961625 17 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_prn_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.820883375 3 | 512 0.689719625 4 | 768 0.60420275 5 | 1024 0.528430875 6 | 1280 0.484910125 7 | 1536 0.451657875 8 | 1792 0.424585875 9 | 2048 0.389964 10 | 2304 0.37373825 11 | 2560 0.352934 12 | 2816 0.337695375 13 | 3072 0.321454 14 | 3328 0.309033 15 | 3584 0.28913275 16 | 3840 0.2833075 17 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_proj_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 64 0.3849307046190293 3 | 128 0.30433440548568313 4 | 192 0.24550055816939376 5 | 256 0.2085588814266412 6 | 320 0.18106655329689214 7 | 384 0.16737625351400537 8 | 448 0.14840890950081004 9 | 512 0.13482347360317992 10 | 576 0.12642773481698766 11 | 640 0.11805850789343368 12 | 704 0.10736120803195816 13 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_fb_trace3_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.5336506195838181 3 | 512 0.38010288838393824 4 | 768 0.2800637124841482 5 | 1024 0.20924422354484845 6 | 1280 0.1583024762314869 7 | 1536 0.12265221789229869 8 | 1792 0.10112935381750854 9 | 2048 0.09661322735307948 10 | 2304 0.09661322735307948 11 | 2560 0.09661322735307948 12 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_fb_trace4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.5340807984410941 3 | 512 0.3805631541969284 4 | 768 0.28042102734810015 5 | 1024 0.20940306534065456 6 | 1280 0.15853896706002382 7 | 1536 0.12276137900360422 8 | 1792 0.10116332615848157 9 | 2048 0.09659227059527528 10 | 2304 0.09659227059527528 11 | 2560 0.09659227059527528 12 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_fb_trace5_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.5289178503543496 3 | 512 0.3744280772451776 4 | 768 0.27417540283929814 5 | 1024 0.2034186136941689 6 | 1280 0.1530001544531002 7 | 1536 0.11864636992526488 8 | 1792 0.0988565813707829 9 | 2048 0.09646022987899104 10 | 2304 0.09646022987899104 11 | 2560 0.09646022987899104 12 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_fb_trace6_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.5314894880335573 3 | 512 0.37738941454261477 4 | 768 0.2771231824800048 5 | 1024 0.20616760077387958 6 | 1280 0.15560709808969578 7 | 1536 0.12055698156282554 8 | 1792 0.10000329865399575 9 | 2048 0.09659321919479089 10 | 2304 0.09659321919479089 11 | 2560 0.09659321919479089 12 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_twi_trace2_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.48278333333333334 3 | 512 0.43548766666666666 4 | 768 0.40460483333333336 5 | 1024 0.379749 6 | 1280 0.3583945 7 | 1536 0.3397475 8 | 1792 0.3231535 9 | 2048 0.3081313333333333 10 | 2304 0.29457333333333335 11 | 2560 0.2821725 12 | 2816 0.27073783333333334 13 | 3072 0.26023183333333333 14 | 3328 0.25046016666666665 15 | -------------------------------------------------------------------------------- /gem/loca.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.name = 'loca' 3 | s.version = '0.0.0' 4 | s.date = '' 5 | s.summary = "" 6 | s.description = "" 7 | s.authors = ["Chen Ding and Group"] 8 | s.email = 'cding@cs.rochester.edu' 9 | s.files = ["lib/loca.rb"] 10 | s.homepage = 11 | 'http://rubygems.org/gems/loca' 12 | end 13 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_facebook_trace3_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.8533902126207047 4 | 512 0.7167163583357198 5 | 768 0.5920905620955069 6 | 1024 0.4829829329917746 7 | 1280 0.39322160273211626 8 | 1536 0.32726868166368883 9 | 1792 0.2853298100925988 10 | 2048 0.2534051476033049 11 | 2304 0.22436077611115418 12 | 2560 0.19721417087250054 13 | 2816 0.17256709038678003 14 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_src1_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.9057411475409836 3 | 256 0.8796622950819672 4 | 384 0.864605737704918 5 | 512 0.8547139344262296 6 | 640 0.8466562295081967 7 | 768 0.8385985245901639 8 | 896 0.832114262295082 9 | 1024 0.8267424590163934 10 | 1152 0.8230519672131148 11 | 1280 0.8203660655737705 12 | 1408 0.8176801639344262 13 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_prn_1_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.53980875 3 | 512 0.46827275 4 | 768 0.42302175 5 | 1024 0.388002625 6 | 1280 0.362376 7 | 1536 0.341055625 8 | 1792 0.321372125 9 | 2048 0.304988125 10 | 2304 0.2902125 11 | 2560 0.2779245 12 | 2816 0.266387125 13 | 3072 0.258195125 14 | 3328 0.253694875 15 | 3584 0.249598875 16 | 3840 0.24556125 17 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_proj_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 64 0.2647820204122405 3 | 128 0.19255045065432225 4 | 192 0.15460274340967173 5 | 256 0.1311688606811087 6 | 320 0.11364901702535007 7 | 384 0.10059594879801843 8 | 448 0.0922998662097789 9 | 512 0.08648240606515668 10 | 576 0.08066494592053448 11 | 640 0.07661573232865998 12 | 704 0.07273742556557851 13 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_facebook_trace3_mrc_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.842112974045919 4 | 512 0.6990066530798759 5 | 768 0.5749193122402606 6 | 1024 0.4523436645633233 7 | 1280 0.34213088465322505 8 | 1536 0.2520579666855123 9 | 1792 0.18846242269298585 10 | 2048 0.13918077071712365 11 | 2304 0.1118163952372568 12 | 2560 0.10386977150045212 13 | 2816 0.10256428723458896 14 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_hm_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.36585559469874157 3 | 256 0.32102267889643593 4 | 384 0.2962880974107734 5 | 512 0.27669435626932604 6 | 640 0.25837875089274176 7 | 768 0.2393073826363854 8 | 896 0.22192458598317788 9 | 1024 0.20742009898540462 10 | 1152 0.1957924191323702 11 | 1280 0.1857326091899564 12 | 1408 0.17545593687051061 13 | 1536 0.16875649209829624 14 | -------------------------------------------------------------------------------- /policies/arc/README.md: -------------------------------------------------------------------------------- 1 | # Adaptive replacement cache 2 | 3 | ## How to run 4 | 5 | Please refer to the README file in **LRU** directory. 6 | 7 | 8 | 9 | ## Implementation 10 | 11 | This is an implementation that strictly follows the algorithm in Fig.4 of the [original ARC paper](https://www.usenix.org/legacy/event/fast03/tech/full_papers/megiddo/megiddo.pdf). 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_hm_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.3434015740302045 3 | 256 0.30664064652033546 4 | 384 0.28104287264018174 5 | 512 0.2640554867183063 6 | 640 0.2464272799848547 7 | 768 0.22686258738351786 8 | 896 0.2129358157481151 9 | 1024 0.20077449417977442 10 | 1152 0.19049732102343014 11 | 1280 0.1813673147830024 12 | 1408 0.1724196131736131 13 | 1536 0.16274795182750376 14 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_hm_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 128 0.3925782482528305 3 | 256 0.3413654216195262 4 | 384 0.30216341506657624 5 | 512 0.2760918494804819 6 | 640 0.26051006231412693 7 | 768 0.23859669507747447 8 | 896 0.2226044720728337 9 | 1024 0.20773662790522965 10 | 1152 0.19495652234884492 11 | 1280 0.1834555542311202 12 | 1408 0.17386152260427173 13 | 1536 0.1646303473103556 14 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_twi_trace2_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.371663 3 | 512 0.313303 4 | 768 0.27808066666666664 5 | 1024 0.25346066666666667 6 | 1280 0.234805 7 | 1536 0.219144 8 | 1792 0.20822133333333334 9 | 2048 0.19729866666666668 10 | 2304 0.18993933333333332 11 | 2560 0.184478 12 | 2816 0.17901666666666666 13 | 3072 0.17355533333333334 14 | 3328 0.168094 15 | -------------------------------------------------------------------------------- /policies/lirs/lirs/run: -------------------------------------------------------------------------------- 1 | ./lirs traces/msr/stg_1/trace 1 1 2 | ./lirs traces/msr/stg_1/trace 1 2 3 | ./lirs traces/msr/stg_1/trace 1 3 4 | ./lirs traces/msr/stg_1/trace 1 4 5 | ./lirs traces/msr/stg_1/trace 1 5 6 | ./lirs traces/msr/stg_1/trace 1 6 7 | ./lirs traces/msr/stg_1/trace 1 7 8 | ./lirs traces/msr/stg_1/trace 1 8 9 | ./lirs traces/msr/stg_1/trace 1 9 10 | ./lirs traces/msr/stg_1/trace 1 10 11 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_twi_trace2_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 0 0.0 3 | 256 0.4597501666666667 4 | 512 0.4158905 5 | 768 0.38471133333333335 6 | 1024 0.35962883333333334 7 | 1280 0.3387293333333333 8 | 1536 0.3208088333333333 9 | 1792 0.3050216666666667 10 | 2048 0.2910575 11 | 2304 0.2784776666666667 12 | 2560 0.267041 13 | 2816 0.25647233333333336 14 | 3072 0.24643616666666668 15 | 3328 0.23637283333333334 16 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/central_storage.h: -------------------------------------------------------------------------------- 1 | #ifndef _L_CENTRAL_STORAGE_H_ 2 | #define _L_CENTRAL_STORAGE_H_ 3 | 4 | /* right now I am only a counter. */ 5 | typedef struct _LCentralStorage_t { 6 | int64_t communications; 7 | int64_t fetches; 8 | int64_t fetch_amount; 9 | int64_t returns; 10 | int64_t return_amount; 11 | }LCentralStorage_t; 12 | 13 | #endif /* _L_CENTRAL_STORAGE_H_ */ 14 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_proj_4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.9692601148935164 3 | 512 0.9245539381335705 4 | 768 0.8837462159579278 5 | 1024 0.8726149109159976 6 | 1280 0.8680237173773544 7 | 1536 0.8617736004128903 8 | 1792 0.8571257999402688 9 | 2048 0.8560895527882085 10 | 2304 0.850701222261249 11 | 2560 0.8468109648559098 12 | 2816 0.8441062051252785 13 | 3072 0.8427728489017094 14 | 3328 0.8406369424584329 15 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_proj_4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.945420553173476 3 | 512 0.8926639733520538 4 | 768 0.8798723529105167 5 | 1024 0.8764157726715024 6 | 1280 0.8658381638690313 7 | 1536 0.8577840488774582 8 | 1792 0.8405555893238085 9 | 2048 0.8499653321195322 10 | 2304 0.8382886826808611 11 | 2560 0.7218537873828094 12 | 2816 0.6912996534449263 13 | 3072 0.6577272563469752 14 | 3328 0.6455420724850243 15 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_proj_4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.9662775790606312 3 | 512 0.9309546975944683 4 | 768 0.8980222991107298 5 | 1024 0.8706890378507058 6 | 1280 0.8585046273075252 7 | 1536 0.8573860990383162 8 | 1792 0.8488664461470862 9 | 2048 0.8475375751723844 10 | 2304 0.8463202167643445 11 | 2560 0.8461248764429935 12 | 2816 0.842846468848632 13 | 3072 0.8389756990763017 14 | 3328 0.8227299730158149 15 | -------------------------------------------------------------------------------- /policies/2q/mrcs/2q_msr_src1_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 512 0.9571883636363636 3 | 1024 0.9450958181818182 4 | 1536 0.9354112727272728 5 | 2048 0.925406 6 | 2560 0.9170489090909091 7 | 3072 0.9123192727272728 8 | 3584 0.9082663636363636 9 | 4096 0.9015850909090909 10 | 4608 0.8967989090909091 11 | 5120 0.8952823636363636 12 | 5632 0.8947003636363636 13 | 6144 0.894398 14 | 6656 0.8941652727272728 15 | 7168 0.8939705454545455 16 | -------------------------------------------------------------------------------- /policies/lfu/mrcs/lfu_msr_src1_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 512 0.9564994545454546 3 | 1024 0.9441685454545454 4 | 1536 0.9341361818181818 5 | 2048 0.924496 6 | 2560 0.9138438181818181 7 | 3072 0.9067078181818182 8 | 3584 0.8999489090909091 9 | 4096 0.8958778181818182 10 | 4608 0.8944430909090909 11 | 5120 0.8939 12 | 5632 0.8866876363636363 13 | 6144 0.8793483636363636 14 | 6656 0.8787727272727273 15 | 7168 0.8778532727272728 16 | -------------------------------------------------------------------------------- /policies/arc/mrcs/arc_msr_src1_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 512 0.9534730909090909 3 | 1024 0.9428234545454546 4 | 1536 0.9311592727272727 5 | 2048 0.9256781818181818 6 | 2560 0.9166674545454545 7 | 3072 0.9057534545454545 8 | 3584 0.8998736363636364 9 | 4096 0.895662 10 | 4608 0.894376 11 | 5120 0.8939845454545454 12 | 5632 0.8866683636363636 13 | 6144 0.879341090909091 14 | 6656 0.8787721818181818 15 | 7168 0.8779490909090909 16 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_proj_4_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 256 0.8663333972094638 3 | 512 0.8088304961040974 4 | 768 0.7581502771806468 5 | 1024 0.7119786613511828 6 | 1280 0.6663664643200773 7 | 1536 0.6207542672889718 8 | 1792 0.5787571808447703 9 | 2048 0.5403580373107747 10 | 2304 0.5092053546447614 11 | 2560 0.4920285527849606 12 | 2816 0.4813750040792565 13 | 3072 0.47515056129796296 14 | 3328 0.4700825394056179 15 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/stream8_reverse_txt: -------------------------------------------------------------------------------- 1 | 2000 2 | 1000 3 | 600 4 | 500 5 | 2000 6 | 1000 7 | 400 8 | 300 9 | 2000 10 | 1000 11 | 200 12 | 100 13 | 2000 14 | 1000 15 | 800 16 | 700 17 | 2000 18 | 1000 19 | 600 20 | 500 21 | 2000 22 | 1000 23 | 400 24 | 300 25 | 2000 26 | 1000 27 | 200 28 | 100 29 | 2000 30 | 1000 31 | 600 32 | 500 33 | 2000 34 | 1000 35 | 400 36 | 300 37 | 2000 38 | 1000 39 | 200 40 | 100 41 | 2000 42 | 1000 43 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/mrcs/opt_msr_src1_0_mrc: -------------------------------------------------------------------------------- 1 | memory miss_ratio 2 | 512 0.8895605454545454 3 | 1024 0.8663438181818182 4 | 1536 0.8544281818181818 5 | 2048 0.8425125454545455 6 | 2560 0.8305969090909091 7 | 3072 0.8186812727272728 8 | 3584 0.8067656363636364 9 | 4096 0.79485 10 | 4608 0.7829343636363636 11 | 5120 0.7710187272727272 12 | 5632 0.7591030909090909 13 | 6144 0.7471874545454545 14 | 6656 0.7352718181818182 15 | 7168 0.7233561818181818 16 | -------------------------------------------------------------------------------- /policies/2q/mrcs/facebook_trace3_mrc: -------------------------------------------------------------------------------- 1 | memory accesses misses hits miss_ratio 2 | 256 5276203 4502660 773543 0.8533902126207047 3 | 512 5276203 3781541 1494662 0.7167163583357198 4 | 768 5276203 3123990 2152213 0.5920905620955069 5 | 1024 5276203 2548316 2727887 0.4829829329917746 6 | 1280 5276203 2074717 3201486 0.39322160273211626 7 | 1536 5276203 1726736 3549467 0.32726868166368883 8 | 1792 5276203 1505458 3770745 0.2853298100925988 9 | 2048 5276203 1337017 3939186 0.2534051476033049 10 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/README.md: -------------------------------------------------------------------------------- 1 | # Optimal Cache Replacement 2 | 3 | #### Usage 4 | 5 | 1. make; 6 | 2. ./gen-forward-OPT-distance.rb 7 | 8 | It will give us the reuse distance histogram of the trace. Miss ratio is computed as *mr(C) = Probability (distance > C)* 9 | 10 | After we get the hitogram file, run the Python script get_mrc.py the same way as run the **LRU** simulator. Then we get the miss ratio curve files in directory **mrcs**. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /policies/2q/README.md: -------------------------------------------------------------------------------- 1 | # 2 Queues 2 | 3 | ## How to run 4 | 5 | Please refer to the README file in **LRU** directory. 6 | 7 | 8 | 9 | ## Implementation 10 | 11 | This implementation uses a LRU queue an a First-In-First-Out(FIFO) queue. These two queues are the same long. 12 | 13 | 1. If an accessed item is not in the cache, put it in the FIFO queue. 14 | 2. If the accessed item is in the FIFO, then transfer it from FIFO to LRU queues. 15 | 3. These two queues kick out items by their own rules. 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/attrs.h: -------------------------------------------------------------------------------- 1 | #ifndef _L_ATTRS_H_ 2 | #define _L_ATTRS_H_ 3 | 4 | /* the optimization of if-statement branches */ 5 | #define LIKELY(x) __builtin_expect((x),1) 6 | #define UNLIKELY(x) __builtin_expect((x),0) 7 | 8 | /** 9 | * An attribute that will cause a variable or field to be aligned so that 10 | * it doesn't have false sharing with anything at a smaller memory address. 11 | */ 12 | #define ATTR_ALIGN_TO_AVOID_FALSE_SHARING __attribute__((__aligned__(128))) 13 | 14 | #endif /* _L_ATTRS_H_ */ 15 | -------------------------------------------------------------------------------- /gem/lib/src/myEntry.java: -------------------------------------------------------------------------------- 1 | import java.util.Map.Entry; 2 | 3 | 4 | public class myEntry implements Entry{ 5 | 6 | private K key; 7 | private V value; 8 | 9 | public myEntry(K k, V v){ 10 | key = k; 11 | value = v; 12 | } 13 | 14 | @Override 15 | public K getKey() { 16 | return key; 17 | } 18 | 19 | @Override 20 | public V getValue() { 21 | return value; 22 | } 23 | 24 | @Override 25 | public V setValue(V value) { 26 | this.value = value; 27 | return value; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/swim_pattern_notes.txt: -------------------------------------------------------------------------------- 1 | small: 256x256, 524KB per array size, 2KB per row/column 2 | medium: 384x384, 3 | large: 512x512, 2MB per array 4 | 5 | The distance may drop. 6 | s: 134 14 0.00463311566677469 2855.44071371728 96.65 7 | m: 134 14 -0.00535366697641987 126.418492572122 99.55 8 | 9 | s 116 8 0.13118879581464 673.023725797797 100.00 10 | s 117 8 0.297652759629109 103299.34606804 97.92 11 | 12 | lg 116 8 0.129527519957976 1480.25572348685 100.0 13 | lg 117 8 0.290446575671649 406353.219812399 96.76 14 | -------------------------------------------------------------------------------- /doc/Site/external_software_files/external_software.js: -------------------------------------------------------------------------------- 1 | // Created by iWeb 3.0.3 local-build-20120529 2 | 3 | setTransparentGifURL('Media/transparent.gif');function hostedOnDM() 4 | {return false;} 5 | function onPageLoad() 6 | {loadMozillaCSS('external_software_files/external_softwareMoz.css') 7 | adjustLineHeightIfTooBig('id1');adjustFontSizeIfTooBig('id1');adjustLineHeightIfTooBig('id2');adjustFontSizeIfTooBig('id2');Widget.onload();fixAllIEPNGs('Media/transparent.gif');performPostEffectsFixups()} 8 | function onPageUnload() 9 | {Widget.onunload();} 10 | -------------------------------------------------------------------------------- /doc/Site/installation_files/installation.js: -------------------------------------------------------------------------------- 1 | // Created by iWeb 3.0.3 local-build-20120529 2 | 3 | setTransparentGifURL('Media/transparent.gif');function hostedOnDM() 4 | {return false;} 5 | function onPageLoad() 6 | {loadMozillaCSS('installation_files/installationMoz.css') 7 | adjustLineHeightIfTooBig('id1');adjustFontSizeIfTooBig('id1');adjustLineHeightIfTooBig('id2');adjustFontSizeIfTooBig('id2');Widget.onload();fixupAllIEPNGBGs();fixAllIEPNGs('Media/transparent.gif');performPostEffectsFixups()} 8 | function onPageUnload() 9 | {Widget.onunload();} 10 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/2_arrays_txt: -------------------------------------------------------------------------------- 1 | 1000 2 | 100 3 | 2000 4 | 200 5 | 3000 6 | 300 7 | 4000 8 | 400 9 | 5000 10 | 500 11 | 6000 12 | 600 13 | 7000 14 | 700 15 | 100 16 | 200 17 | 300 18 | 400 19 | 500 20 | 600 21 | 700 22 | 1000 23 | 100 24 | 2000 25 | 200 26 | 3000 27 | 300 28 | 4000 29 | 400 30 | 5000 31 | 500 32 | 6000 33 | 600 34 | 7000 35 | 700 36 | 100 37 | 200 38 | 300 39 | 400 40 | 500 41 | 600 42 | 700 43 | 1000 44 | 10000 45 | 2000 46 | 20000 47 | 3000 48 | 30000 49 | 4000 50 | 40000 51 | 5000 52 | 50000 53 | 6000 54 | 60000 55 | 7000 56 | 70000 57 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/2_arrays_txt: -------------------------------------------------------------------------------- 1 | 1000 2 | 100 3 | 2000 4 | 200 5 | 3000 6 | 300 7 | 4000 8 | 400 9 | 5000 10 | 500 11 | 6000 12 | 600 13 | 7000 14 | 700 15 | 100 16 | 200 17 | 300 18 | 400 19 | 500 20 | 600 21 | 700 22 | 1000 23 | 100 24 | 2000 25 | 200 26 | 3000 27 | 300 28 | 4000 29 | 400 30 | 5000 31 | 500 32 | 6000 33 | 600 34 | 7000 35 | 700 36 | 100 37 | 200 38 | 300 39 | 400 40 | 500 41 | 600 42 | 700 43 | 1000 44 | 10000 45 | 2000 46 | 20000 47 | 3000 48 | 30000 49 | 4000 50 | 40000 51 | 5000 52 | 50000 53 | 6000 54 | 60000 55 | 7000 56 | 70000 57 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/2_reverse_txt: -------------------------------------------------------------------------------- 1 | 70000 2 | 7000 3 | 60000 4 | 6000 5 | 50000 6 | 5000 7 | 40000 8 | 4000 9 | 30000 10 | 3000 11 | 20000 12 | 2000 13 | 10000 14 | 1000 15 | 700 16 | 600 17 | 500 18 | 400 19 | 300 20 | 200 21 | 100 22 | 700 23 | 7000 24 | 600 25 | 6000 26 | 500 27 | 5000 28 | 400 29 | 4000 30 | 300 31 | 3000 32 | 200 33 | 2000 34 | 100 35 | 1000 36 | 700 37 | 600 38 | 500 39 | 400 40 | 300 41 | 200 42 | 100 43 | 700 44 | 7000 45 | 600 46 | 6000 47 | 500 48 | 5000 49 | 400 50 | 4000 51 | 300 52 | 3000 53 | 200 54 | 2000 55 | 100 56 | 1000 57 | -------------------------------------------------------------------------------- /policies/arc/mrcs/facebook_trace3_mrc: -------------------------------------------------------------------------------- 1 | memory accesses misses hits miss_ratio 2 | 128 5276203 4851480 424723 0.9195021495571721 3 | 256 5276203 4443159 833044 0.842112974045919 4 | 384 5276203 4053343 1222860 0.7682310555526389 5 | 512 5276203 3688101 1588102 0.6990066530798759 6 | 640 5276203 3348834 1927369 0.6347052984883258 7 | 768 5276203 3033391 2242812 0.5749193122402606 8 | 896 5276203 2717459 2558744 0.5150406457067706 9 | 1024 5276203 2386657 2889546 0.4523436645633233 10 | 1152 5276203 2067988 3208215 0.3919462537737839 11 | 1280 5276203 1805152 3471051 0.34213088465322505 12 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | #CFLAGS = -O0 -g 3 | CFLAGS = -O2 -Wno-return-type 4 | LDFLAGS = -lm 5 | 6 | all: OPTStackDistanceAnalyzer 7 | 8 | OPTStackDistanceAnalyzer: OPTStackDistanceAnalyzer.o 9 | ${CC} ${LDFLAGS} OPTStackDistanceAnalyzer.o -o OPTStackDistanceAnalyzer 10 | ${CC} ${LDFLAGS} reverse_file.o -o reverse_file 11 | 12 | OPTStackDistanceAnalyzer.o: OPTStackDistanceAnalyzer.c 13 | ${CC} ${CFLAGS} -c OPTStackDistanceAnalyzer.c 14 | ${CC} ${CFLAGS} -c reverse_file.c 15 | 16 | clean: 17 | rm -rf *.o OPTStackDistanceAnalyzer reverse_file 18 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/debugging_original_trace.txt: -------------------------------------------------------------------------------- 1 | 0x8 0 2 | 0x6 0 3 | 0x9 0 4 | 0x9 0 5 | 0x3 0 6 | 0x2 0 7 | 0x2 0 8 | 0x5 0 9 | 0x4 0 10 | 0x2 0 11 | 0x7 0 12 | 0x2 0 13 | 0x5 0 14 | 0x4 0 15 | 0x1 0 16 | 0x3 0 17 | 0x5 0 18 | 0x1 0 19 | 0x3 0 20 | 0x9 0 21 | 0x6 0 22 | 0x2 0 23 | 0x1 0 24 | 0x6 0 25 | 0x3 0 26 | 0x3 0 27 | 0x5 0 28 | 0x9 0 29 | 0x3 0 30 | 0x6 0 31 | 0x2 0 32 | 0x1 0 33 | 0x4 0 34 | 0x1 0 35 | 0x8 0 36 | 0x7 0 37 | 0x7 0 38 | 0x7 0 39 | 0x3 0 40 | 0x6 0 41 | 0x8 0 42 | 0x9 0 43 | 0x9 0 44 | 0x8 0 45 | 0x8 0 46 | 0x3 0 47 | 0x9 0 48 | 0x6 0 49 | 0x2 0 50 | 0x6 0 51 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | -- To install on Mac -- 2 | 1. You need to disable SIP. You can do this by going to Recovery Mode in Mac, by restarting your computer holding down Command+R. 3 | a. After starting in Recovery Mode, Click Utilities and Terminal. 4 | b. In the terminal, type the command 'csrutil disable' 5 | c. Restart the computer, SIP is disabled. 6 | EXTRA: If you still recieve an error about task_for_pid, Make sure 7 | to configure PIN by running their host_config (located in 8 | pin/sbin/host_config) 9 | 10 | 2. GCC vs LLVM 11 | 12 | The LLVM compiler installed on Mac machines is sufficient. 13 | -------------------------------------------------------------------------------- /doc/Site/installation_files/installationIE.css: -------------------------------------------------------------------------------- 1 | .inline-block { 2 | display: inline; 3 | vertical-align: baseline; 4 | margin-bottom:-2em; 5 | margin-top:2em; 6 | position:relative; 7 | top:-2em; 8 | } 9 | .vertical-align-middle-middlebox { 10 | display: block; 11 | height: auto; 12 | position: absolute; 13 | top: 50%; 14 | } 15 | .vertical-align-middle-innerbox { 16 | display: block; 17 | position: relative; 18 | top: -50%; 19 | } 20 | li.full-width { 21 | width: auto; 22 | } 23 | li div div.inline-block a img { 24 | text-indent: 0; 25 | } 26 | img { 27 | -ms-interpolation-mode: bicubic; 28 | } 29 | -------------------------------------------------------------------------------- /doc/Site/external_software_files/external_softwareIE.css: -------------------------------------------------------------------------------- 1 | .inline-block { 2 | display: inline; 3 | vertical-align: baseline; 4 | margin-bottom:-2em; 5 | margin-top:2em; 6 | position:relative; 7 | top:-2em; 8 | } 9 | .vertical-align-middle-middlebox { 10 | display: block; 11 | height: auto; 12 | position: absolute; 13 | top: 50%; 14 | } 15 | .vertical-align-middle-innerbox { 16 | display: block; 17 | position: relative; 18 | top: -50%; 19 | } 20 | li.full-width { 21 | width: auto; 22 | } 23 | li div div.inline-block a img { 24 | text-indent: 0; 25 | } 26 | img { 27 | -ms-interpolation-mode: bicubic; 28 | } 29 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/declarations.h: -------------------------------------------------------------------------------- 1 | #ifndef _DECLARATIONS_H_ 2 | #define _DECLARATIONS_H_ 3 | 4 | struct _LStats_t; 5 | struct _LItem_t; 6 | struct _HashTableElem_t; 7 | struct _HashTable_t; 8 | struct _LLeaseLRUCache_t; 9 | struct _LLRUCache_t; 10 | struct _LOrderedLeaseCache_t; 11 | struct _LWorkload_t; 12 | 13 | typedef struct _HashTable_t HashTable_t; 14 | typedef struct _HashTableElem_t HashTableElem_t; 15 | typedef struct _LLeaseLRUCache_t LLeeCache_t; 16 | typedef struct _LItem_t LItem_t; 17 | typedef struct _LStats_t LStats_t; 18 | typedef struct _LLRUCache_t LLRUCache_t; 19 | typedef struct _LOrderedLeaseCache_t LOrderedLeaseCache_t; 20 | typedef struct _LWorkload_t LWorkload_t; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gem/lib/src/email.rb: -------------------------------------------------------------------------------- 1 | require 'net/smtp' 2 | 3 | def send_email(to,opts={}) 4 | opts[:server] ||= 'localhost' 5 | opts[:from] ||= 'loca_user@unknown.site.com' 6 | opts[:from_alias] ||= 'Loca User' 7 | opts[:subject] ||= "Loca error report" 8 | opts[:body] ||= "empty message" 9 | 10 | msg = < 12 | To: <#{to}> 13 | Subject: #{opts[:subject]} 14 | 15 | #{opts[:body]} 16 | END_OF_MESSAGE 17 | 18 | begin 19 | Net::SMTP.start(opts[:server]) do |smtp| 20 | smtp.send_message msg, opts[:from], to 21 | end 22 | rescue Exception 23 | warn "Loca cannot send the error report. Abort." 24 | warn "Printing message here: " 25 | warn msg 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /gem/lib/src/Footprint/makefile: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # DO NOT EDIT THIS FILE! 4 | # 5 | ############################################################## 6 | 7 | # If the tool is built out of the kit, PIN_ROOT must be specified in the make invocation and point to the kit root. 8 | ifdef PIN_ROOT 9 | CONFIG_ROOT := $(PIN_ROOT)/source/tools/Config 10 | else 11 | CONFIG_ROOT := ../Config 12 | endif 13 | include $(CONFIG_ROOT)/makefile.config 14 | include makefile.rules 15 | include $(TOOLS_ROOT)/Config/makefile.default.rules 16 | 17 | ############################################################## 18 | # 19 | # DO NOT EDIT THIS FILE! 20 | # 21 | ############################################################## 22 | -------------------------------------------------------------------------------- /policies/README.md: -------------------------------------------------------------------------------- 1 | # Cache Replacement Policy Simulators 2 | 3 | We compare 7 policies. 4 | 5 | **OPT** is in directory *ForwardOPTStackDistanceAnalyzer*. The program for computing trace's reuse distance histogram is provided by one of Prof. Chen Ding's former students Xiaoming Gu. The miss ratio generator was written by Jie Zhou. 6 | 7 | **LIRS** is provided by LIRS's author [Prof. Jiang Song](http://ranger.uta.edu/~sjiang/). 8 | 9 | **Lease Cache** was written by Pengcheng Li. 10 | 11 | **LRU**, **LFU**, **ARC**, and **2Q** were implemented by Jie Zhou. They have the same input and output formats. Please refer the README file in directory **lru** to see how to use them. And there is some more information about these four policies, please refer to the respective README files. 12 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/Makefile: -------------------------------------------------------------------------------- 1 | # Get the current OS and architecture 2 | OS ?= $(shell uname -s) 3 | CPU ?= $(shell uname -m) 4 | PLATFORM ?= $(OS).$(CPU) 5 | TARGET_PLATFORM ?= $(PLATFORM) 6 | 7 | # Set the default compilers 8 | CC = gcc 9 | CXX = g++ 10 | CLINK = gcc 11 | 12 | # Compile flag options 13 | CFLAGS ?= -O0 -g 14 | CXXFLAGS ?= $(CFLAGS) -std=c++11 15 | 16 | # Don't require any libraries by default 17 | LIBS ?= -lm 18 | 19 | # Set the default include directories 20 | INCLUDE_DIRS ?= -I. 21 | 22 | # Build by default 23 | all: simulator 24 | 25 | SRCS ?= $(wildcard *.c) 26 | OBJS ?= $(patsubst %.c, %.o, $(SRCS)) 27 | HEADERS ?= $(wildcard *.h) 28 | 29 | simulator: $(OBJS) 30 | $(CLINK) $< -o $@ $(LIBS) 31 | 32 | %.o: %.c 33 | $(CC) $(CFLAGS) $(INCLUDE_DIRS) $< -c -o $@ 34 | 35 | clean: 36 | rm -rf $(OBJS) simulator; 37 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/item.h: -------------------------------------------------------------------------------- 1 | #ifndef _L_ITEM_H_ 2 | #define _L_ITEM_H_ 3 | 4 | typedef enum {NONE, LEASE, LRU} POSITION; 5 | 6 | struct _LItem_t { 7 | struct list_head list; 8 | int64_t key_id; 9 | int64_t value; 10 | int32_t lease_time; 11 | int64_t last_access_time; 12 | POSITION lease_or_lru; 13 | HashTableElem_t * hash_node; /* for an easy traversal. */ 14 | } ATTR_ALIGN_TO_AVOID_FALSE_SHARING; 15 | 16 | void print_item( struct _LItem_t * item ) 17 | { 18 | printf("[LOG] key id: %lld\n", item->key_id); 19 | printf("[LOG] lease time: %d\n", item->lease_time); 20 | printf("[LOG] last access time: %lld\n", item->last_access_time); 21 | printf("[LOG] on lease or lru: %d\n", item->lease_or_lru); 22 | printf("[LOG] address of list: %p\n", &item->list); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /policies/lfu/README.md: -------------------------------------------------------------------------------- 1 | # Least Frequently Used Cache 2 | 3 | ## How to run 4 | 5 | Please refer to the README file in **LRU** directory. 6 | 7 | 8 | 9 | ## Flaw 10 | 11 | This simulator is not perfectly implemented. There is a global varibale *BIN_NUM*. Currently, the simulator can only process traces whose length is less than (1 + 2 + 3 + …. BIN_NUM). For example, if *BIN_NUM* is set to 5000, then the simulator could handle traces that have less than (1 + 2 + 3 + … + 5000) = 12,502,500 accesses. But this shouldn't be a big problem because the sum increases quickly as we increase the value of *BIN_NUM*. When it is set to 10,000, the simulator can handle traces that have 50 million accesses, which is enough for most of the traces we need to test (Jie: maybe not enough for all; I don't know the longest trace from MSR since I haven't tested all of them). 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /server/.current.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /loca 7 | 8 | 9 | 10 | 11 |

./

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 31 | 32 |
Name
22 | [up] 23 |
27 | 28 | dir. static 29 | 30 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /gem/lib/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /server/draw_p.r: -------------------------------------------------------------------------------- 1 | args <- commandArgs(TRUE) 2 | 3 | program <- args[1] 4 | ext <- args[2] 5 | 6 | rawdata <- read.table(paste(program, ext, sep="")) 7 | 8 | #draw footprint curve 9 | saveto <- sprintf("%s.fp.png", program) 10 | x <- rawdata[,1] 11 | y <- rawdata[,2]*64 # "* 64" converts to bytes 12 | xlab <- "window size (accesses)" 13 | ylab <- "footprint (bytes)" 14 | legend <- c("average footprint") 15 | png(file=saveto, width=600, height=450) 16 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, 17 | frame.plot=TRUE, col="red", main="Average Footprint") 18 | dev.off() 19 | 20 | #draw lifetime curve 21 | saveto <- sprintf("%s.lf.png", program) 22 | x <- rawdata[,2]*64 23 | y <- rawdata[,1] 24 | xlab <- "cache size (bytes)" 25 | ylab <- "lifetime (accesses)" 26 | legend <- c("lifetime") 27 | png(file=saveto, width=600, height=450) 28 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, 29 | frame.plot=TRUE, col="red", main="Data Lifetime in Cache") 30 | dev.off() -------------------------------------------------------------------------------- /gem/lib/src/machine.rb: -------------------------------------------------------------------------------- 1 | module Machine 2 | def self.mac_get_machine_env 3 | env = Hash.new 4 | raw = `system_profiler` 5 | lines = raw.split("\n") 6 | info = lines[4..16] << lines[74] 7 | info.each do |pair| 8 | key, val = pair.split(":") 9 | env[key.gsub /^\s+/, ""] = val.gsub /^\s+/, "" 10 | end 11 | return env 12 | end 13 | 14 | def self.get_machine_env 15 | env = Hash.new 16 | env[:uname] = %x[uname -a] 17 | return env 18 | end 19 | 20 | def self.get_output_file_name( cmd ) 21 | require 'socket' 22 | require 'time' 23 | 24 | seed = cmd || $0 # command name 25 | path = 26 | "%s_%s_%s_%s_%d" % [ 27 | Socket.gethostname, 28 | seed, 29 | Process.pid, 30 | Time.now.iso8601(2), 31 | rand(101010) 32 | ] 33 | # File.join( dir, filename ) 34 | return path.gsub(%r/[^0-9a-zA-Z]/,'_').gsub(%r/\s+/, '_') 35 | end 36 | end # module 37 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/README.txt: -------------------------------------------------------------------------------- 1 | This simulator undefines all the reuse distance related computation. 2 | 3 | It reads in the file of how many items per slab class has, and it computes the miss ratio. 4 | 5 | Before running this simulator, make sure the required files such as key_lease, key_slab, slab_mem, etc 6 | are put in the corresponding workload directory. 7 | 8 | In addition to the first two parameters -- mode and trace name, it has a third parameter called policy. 9 | It policy is set to 1, then this simulator reads in a memory allocation file called slab_mem generated by LAMA algorithm, 10 | and it will berunning as the test for LAMA. 11 | By default, policy is 0 and you do not need to type "0" in the command line. 12 | The default policy means thes simulator tests a lease policy with base size set to 0 for all the slab classes. 13 | 14 | ATTENTION: 15 | Remember to generate a all-0 key_lease file before testing LAMA policy. 16 | The all-0 generator script is in the workloads directory. 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | loca 2 | ==== 3 | 4 | Program locality analysis tools 5 | 6 | To download using command-line, run 7 | git clone https://github.com/dcompiler/loca loca 8 | 9 | See doc/index.html for instructions on installing and running the tool. 10 | 11 | Note that the newly tested working Pin tool version is 12 | 'pin-3.6-97554-g31f0a167d-clang-mac' (updated May 2018) on MacOS 10.13 13 | and 'pin-3.0-76991-gcc-linux'. 14 | 15 | To subscribe the mailing list, send a mail to the list subscription address, loca-subscribe@cs.rochester.edu. The subject and body of the message will be ignored, so it doesn't matter what you put there. You will receive a confirmation mail, after reply that mail, you will be added to the mailing list (do not try to click the link in that mail, since that website is not open to user outside URCS department). 16 | 17 | To unsubscribe the mailing list, replace the email address above with loca-unsubscribe@cs.rochester.edu. 18 | 19 | License: Free for open source projects (GPL v.2.0). 20 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/gen-forward-OPT-distance.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | if (ARGV.length != 1) 4 | puts "USAGE: inputTraceFile" 5 | exit 6 | end 7 | 8 | inputFileName = ARGV[0] 9 | 10 | parts = inputFileName.split('_') 11 | testcase_name = parts[0] 12 | suffix = parts[2] 13 | 14 | revFileName = testcase_name+"_reverse_"+suffix 15 | #revFile = File.new(revFileName, "w") 16 | #revFile.puts File.open(inputFileName).readlines.reverse 17 | #revFile.close 18 | cmd = "./reverse_file #{inputFileName} #{revFileName}" 19 | puts cmd 20 | system cmd 21 | 22 | disFileName = testcase_name+"_rev-OPT-dis_"+suffix 23 | cmd = "time -p ./OPTStackDistanceAnalyzer #{revFileName} #{disFileName}" 24 | puts cmd 25 | system cmd 26 | 27 | finalFileName = testcase_name+"_forward-OPT-dis_"+suffix 28 | #finalFile = File.new(finalFileName, "w") 29 | #finalFile.puts File.open(disFileName).readlines.reverse 30 | #finalFile.close 31 | puts "./reverse_file #{disFileName} #{finalFileName}" 32 | system "./reverse_file #{disFileName} #{finalFileName}" 33 | 34 | # system "rm -f #{revFileName} #{disFileName}" 35 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/gen-forward-OPT-distance.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | if (ARGV.length != 1) 4 | puts "USAGE: inputTraceFile" 5 | exit 6 | end 7 | 8 | inputFileName = ARGV[0] 9 | 10 | parts = inputFileName.split('_') 11 | testcase_name = inputFileName 12 | suffix = ".txt" 13 | 14 | revFileName = testcase_name+"_reverse"+suffix 15 | #revFile = File.new(revFileName, "w") 16 | #revFile.puts File.open(inputFileName).readlines.reverse 17 | #revFile.close 18 | cmd = "./reverse_file #{inputFileName} #{revFileName}" 19 | puts cmd 20 | system cmd 21 | 22 | disFileName = testcase_name+"_rev-OPT-dis"+suffix 23 | cmd = "time -p ./OPTStackDistanceAnalyzer #{revFileName} #{disFileName}" 24 | puts cmd 25 | system cmd 26 | 27 | finalFileName = testcase_name+"_forward-OPT-dis"+suffix 28 | #finalFile = File.new(finalFileName, "w") 29 | #finalFile.puts File.open(disFileName).readlines.reverse 30 | #finalFile.close 31 | puts "./reverse_file #{disFileName} #{finalFileName}" 32 | system "./reverse_file #{disFileName} #{finalFileName}" 33 | 34 | # system "rm -f #{revFileName} #{disFileName}" 35 | -------------------------------------------------------------------------------- /policies/lru/README.md: -------------------------------------------------------------------------------- 1 | # LRU 2 | 3 | There are two magic numbers in the code. One is assigned to global variable *ITEM_PER_MB* - it is how many data items 1MB can have. For example, when we test MSR traces, we assume that all the items are 4KB; so *ITEM_PER_MB* should be set 256 (1MB / 4KB). The other is used in *MEM_UNIT*. It is used to control the size of the cache. 4 | 5 | ## How to run 6 | 7 | First you should **change** the code in line 84 to the directory containing the traces in your machine. 8 | 9 | The program has three command line parameters. The first is the trace's path. The second is how many cache sizes we want to run. The third is used to control the size of each cache size. For example, 10 | 11 | `python3 msr/hm_0 12 8` 12 | 13 | The last parameter "8" would multiply by 16 to get the value for *MEM_UNIT* in line 82. The result "128" means a cache unit is 128MB. And with the second parameter "12", the program would generate 12 miss ratios with cache sizes from 128Mb * 1 to 128MB * 12 = 1536MB. 14 | 15 | ## Output 16 | 17 | The output file will be stored in direcory **mrcs** in the same direcotory of the program. 18 | 19 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/static.h: -------------------------------------------------------------------------------- 1 | #ifndef _STATIC_H_ 2 | #define _STATIC_H_ 3 | 4 | #define NUM_SLAB_CLASS 1 5 | 6 | size_t slab_class_to_chunk_size( int32_t slab_class ) 7 | { 8 | return 0; 9 | } 10 | 11 | /* --- timers --- */ 12 | 13 | int64_t global_timer = 0; 14 | int64_t local_timers[NUM_SLAB_CLASS+1] = {0}; 15 | 16 | /* record access time */ 17 | uint32_t *accesses; 18 | 19 | void reset_all_timers() 20 | { 21 | global_timer = 0; 22 | memset( local_timers, 0, sizeof(int64_t) * (NUM_SLAB_CLASS+1) ); 23 | } 24 | 25 | void reset_global_timer() 26 | { 27 | global_timer = 0; 28 | } 29 | 30 | void reset_local_timers( int32_t slab_class ) 31 | { 32 | local_timers[slab_class] = 0; 33 | } 34 | 35 | /* --- mapping relations from key to slab class or lease --- */ 36 | int32_t * key_slab_map = NULL; 37 | int32_t * key_lease_map = NULL; 38 | 39 | int32_t search_lease_time_for_key ( int32_t key_id ) 40 | { 41 | return key_lease_map[key_id]; 42 | } 43 | 44 | int32_t search_slab_class_for_key ( int32_t key_id ) 45 | { 46 | return key_slab_map[key_id]; 47 | } 48 | 49 | /* store how many items each slab class has */ 50 | 51 | #endif /* _STATIC_H_ */ 52 | -------------------------------------------------------------------------------- /doc/Site/feed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | urn:iweb:E6FE4C0A-45BB-499B-A3DC-D70B803830BC 4 | Page list Atom feed 5 | 2012-05-29T23:30:40-04:00 6 | 7 | iWeb 8 | 9 | iWeb 10 | 11 | 12 | urn:iweb:86BAC02A-1970-45B0-8C32-2C5183B21D3C 13 | installation 14 | installation 15 | 86BAC02A-1970-45B0-8C32-2C5183B21D3C 16 | 17 | 2012-05-29T23:30:40.001-04:00 18 | installation 19 | 20 | 21 | urn:iweb:630E69DD-C002-421F-BF82-F66C5F07B311 22 | external software 23 | external software 24 | 630E69DD-C002-421F-BF82-F66C5F07B311 25 | 26 | 2012-05-29T23:30:40.002-04:00 27 | external software 28 | 29 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/2_rev-OPT-dis_txt: -------------------------------------------------------------------------------- 1 | 0x11170 0x0 INF 2 | 0x1b58 0x0 INF 3 | 0xea60 0x0 INF 4 | 0x1770 0x0 INF 5 | 0xc350 0x0 INF 6 | 0x1388 0x0 INF 7 | 0x9c40 0x0 INF 8 | 0xfa0 0x0 INF 9 | 0x7530 0x0 INF 10 | 0xbb8 0x0 INF 11 | 0x4e20 0x0 INF 12 | 0x7d0 0x0 INF 13 | 0x2710 0x0 INF 14 | 0x3e8 0x0 INF 15 | 0x2bc 0x0 INF 16 | 0x258 0x0 INF 17 | 0x1f4 0x0 INF 18 | 0x190 0x0 INF 19 | 0x12c 0x0 INF 20 | 0xc8 0x0 INF 21 | 0x64 0x0 INF 22 | 0x2bc 0x0 2 23 | 0x1b58 0x0 3 24 | 0x258 0x0 4 25 | 0x1770 0x0 5 26 | 0x1f4 0x0 6 27 | 0x1388 0x0 7 28 | 0x190 0x0 8 29 | 0xfa0 0x0 9 30 | 0x12c 0x0 10 31 | 0xbb8 0x0 11 32 | 0xc8 0x0 12 33 | 0x7d0 0x0 13 34 | 0x64 0x0 2 35 | 0x3e8 0x0 14 36 | 0x2bc 0x0 3 37 | 0x258 0x0 4 38 | 0x1f4 0x0 5 39 | 0x190 0x0 6 40 | 0x12c 0x0 7 41 | 0xc8 0x0 8 42 | 0x64 0x0 2 43 | 0x2bc 0x0 3 44 | 0x1b58 0x0 9 45 | 0x258 0x0 4 46 | 0x1770 0x0 10 47 | 0x1f4 0x0 5 48 | 0x1388 0x0 11 49 | 0x190 0x0 6 50 | 0xfa0 0x0 12 51 | 0x12c 0x0 7 52 | 0xbb8 0x0 13 53 | 0xc8 0x0 2 54 | 0x7d0 0x0 14 55 | 0x64 0x0 3 56 | 0x3e8 0x0 8 57 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/temp/2_forward-OPT-dis_txt: -------------------------------------------------------------------------------- 1 | 0x3e8 0x0 8 2 | 0x64 0x0 3 3 | 0x7d0 0x0 14 4 | 0xc8 0x0 2 5 | 0xbb8 0x0 13 6 | 0x12c 0x0 7 7 | 0xfa0 0x0 12 8 | 0x190 0x0 6 9 | 0x1388 0x0 11 10 | 0x1f4 0x0 5 11 | 0x1770 0x0 10 12 | 0x258 0x0 4 13 | 0x1b58 0x0 9 14 | 0x2bc 0x0 3 15 | 0x64 0x0 2 16 | 0xc8 0x0 8 17 | 0x12c 0x0 7 18 | 0x190 0x0 6 19 | 0x1f4 0x0 5 20 | 0x258 0x0 4 21 | 0x2bc 0x0 3 22 | 0x3e8 0x0 14 23 | 0x64 0x0 2 24 | 0x7d0 0x0 13 25 | 0xc8 0x0 12 26 | 0xbb8 0x0 11 27 | 0x12c 0x0 10 28 | 0xfa0 0x0 9 29 | 0x190 0x0 8 30 | 0x1388 0x0 7 31 | 0x1f4 0x0 6 32 | 0x1770 0x0 5 33 | 0x258 0x0 4 34 | 0x1b58 0x0 3 35 | 0x2bc 0x0 2 36 | 0x64 0x0 INF 37 | 0xc8 0x0 INF 38 | 0x12c 0x0 INF 39 | 0x190 0x0 INF 40 | 0x1f4 0x0 INF 41 | 0x258 0x0 INF 42 | 0x2bc 0x0 INF 43 | 0x3e8 0x0 INF 44 | 0x2710 0x0 INF 45 | 0x7d0 0x0 INF 46 | 0x4e20 0x0 INF 47 | 0xbb8 0x0 INF 48 | 0x7530 0x0 INF 49 | 0xfa0 0x0 INF 50 | 0x9c40 0x0 INF 51 | 0x1388 0x0 INF 52 | 0xc350 0x0 INF 53 | 0x1770 0x0 INF 54 | 0xea60 0x0 INF 55 | 0x1b58 0x0 INF 56 | 0x11170 0x0 INF 57 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/get_mrc.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | 5 | ITEM_PER_MB = 128 # every item is 8kb 6 | MEM_UNIT = int(sys.argv[3]) * 16 # set 256MB as one memory unit 7 | 8 | MAX_TRACE_LEN = 8000000 9 | 10 | trace_name = sys.argv[1] 11 | mrc = [] 12 | 13 | def get_mrc(): 14 | global mrc 15 | opt_dis = [] 16 | opt_dis_file = open("../../traces/" + trace_name + "/trace.tr_forward-OPT-dis.txt") 17 | for line in opt_dis_file.readlines(): 18 | dis = line.split()[2] 19 | if "INF" in dis: 20 | opt_dis += [MAX_TRACE_LEN] 21 | else: 22 | opt_dis += [int(dis)] 23 | opt_dis_file.close() 24 | 25 | for i in range(1, int(sys.argv[2])): 26 | mem = i * MEM_UNIT * ITEM_PER_MB 27 | miss = 0 28 | for dis in opt_dis: 29 | if dis > mem: 30 | miss += 1 31 | mrc += [float(miss) / float(len(opt_dis))] 32 | 33 | write_mrc() 34 | 35 | 36 | def write_mrc(): 37 | if not os.path.exists("mrcs"): 38 | os.makedirs("mrcs") 39 | mrc_file = open("mrcs/" + "opt_" + trace_name.split("/")[0] + "_" + trace_name.split("/")[1] + "_mrc", "w") 40 | mrc_file.write("memory miss_ratio\n") 41 | for i in range(0, len(mrc)): 42 | mrc_file.write(str((i + 1) * MEM_UNIT) + " " + str(mrc[i]) + "\n") 43 | mrc_file.close() 44 | 45 | get_mrc() 46 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/dll.h: -------------------------------------------------------------------------------- 1 | #ifndef _DLL_H_ 2 | #define _DLL_H_ 3 | 4 | #include "data_structures.h" 5 | #include "declarations.h" 6 | #include "item.h" 7 | 8 | /* ---- double linked list implementation ---- */ 9 | 10 | /* get the head of a linked list */ 11 | LItem_t * DLLHead( struct list_head * head ) 12 | { 13 | LItem_t * entry; 14 | entry = list_first_entry(head, LItem_t, list); 15 | 16 | return entry; 17 | } 18 | 19 | /* get the tail of a linked list */ 20 | LItem_t * DLLTail( struct list_head * head ) 21 | { 22 | LItem_t * entry; 23 | entry = list_entry(head->prev, LItem_t, list); 24 | 25 | return entry; 26 | } 27 | 28 | /* move the node "list" to the head of the linked list "head" */ 29 | void DLLUpdateHead( struct list_head * head, struct list_head * list ) 30 | { 31 | list_del(list); 32 | list_add(list, head); 33 | } 34 | 35 | /* move the node "list" to the tail of the linked list "head" */ 36 | void DLLMoveToTail( struct list_head * head, struct list_head * list ) 37 | { 38 | list_move_tail(list, head); 39 | } 40 | 41 | void DLLRemove( struct list_head * list ) 42 | { 43 | list_del(list); 44 | } 45 | 46 | void DLLAdd( struct list_head * head, struct list_head * list ) 47 | { 48 | list_add(list, head); 49 | } 50 | 51 | int DLLEmpty( struct list_head * head ) 52 | { 53 | return list_empty(head); 54 | } 55 | 56 | #endif /* _DLL_H_ */ 57 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/stream8_rev-OPT-dis_txt: -------------------------------------------------------------------------------- 1 | 0x2000 0x7fff5fc3fb64 INF 2 | 0x1000 0x7fff5fc3fb64 INF 3 | 0x600 0x7fff5fc3fb64 INF 4 | 0x500 0x7fff5fc3fb64 INF 5 | 0x2000 0x7fff5fc3fb64 2 6 | 0x1000 0x7fff5fc3fb64 3 7 | 0x400 0x7fff5fc3fb64 INF 8 | 0x300 0x7fff5fc3fb64 INF 9 | 0x2000 0x7fff5fc3fb64 2 10 | 0x1000 0x7fff5fc3fb64 3 11 | 0x200 0x7fff5fc3fb64 INF 12 | 0x100 0x7fff5fc3fb64 INF 13 | 0x2000 0x7fff5fc3fb64 2 14 | 0x1000 0x7fff5fc3fb64 3 15 | 0x800 0x7fff5fc3fb64 INF 16 | 0x700 0x7fff5fc3fb64 INF 17 | 0x2000 0x7fff5fc3fb64 2 18 | 0x1000 0x7fff5fc3fb64 3 19 | 0x600 0x7fff5fc3fb64 4 20 | 0x500 0x7fff5fc3fb64 5 21 | 0x2000 0x7fff5fc3fb64 2 22 | 0x1000 0x7fff5fc3fb64 3 23 | 0x400 0x7fff5fc3fb64 6 24 | 0x300 0x7fff5fc3fb64 7 25 | 0x2000 0x7fff5fc3fb64 2 26 | 0x1000 0x7fff5fc3fb64 3 27 | 0x200 0x7fff5fc3fb64 8 28 | 0x100 0x7fff5fc3fb64 9 29 | 0x2000 0x7fff5fc3fb64 2 30 | 0x1000 0x7fff5fc3fb64 3 31 | 0x600 0x7fff5fc3fb64 4 32 | 0x500 0x7fff5fc3fb64 5 33 | 0x2000 0x7fff5fc3fb64 2 34 | 0x1000 0x7fff5fc3fb64 3 35 | 0x400 0x7fff5fc3fb64 6 36 | 0x300 0x7fff5fc3fb64 7 37 | 0x2000 0x7fff5fc3fb64 2 38 | 0x1000 0x7fff5fc3fb64 3 39 | 0x200 0x7fff5fc3fb64 8 40 | 0x100 0x7fff5fc3fb64 4 41 | 0x2000 0x7fff5fc3fb64 2 42 | 0x1000 0x7fff5fc3fb64 3 43 | -------------------------------------------------------------------------------- /dev/pack.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | tmp_dir = "/Users/cding/Temp" 4 | # tmp_dir = "/tmp" 5 | 6 | puts "Usage: #{$0} [rev]" if ARGV.size > 1 7 | 8 | pk_dir = File.expand_path( File.dirname( __FILE__ ) ) 9 | repo_dir = File.join( tmp_dir, "loca" ) 10 | 11 | def run_cmd( cmd ) 12 | puts cmd 13 | system cmd 14 | end 15 | 16 | run_cmd( "rm -rf #{repo_dir}" ) if File.exists?("/tmp/loca") 17 | 18 | # create a local copy of the repository 19 | run_cmd( "mkdir #{repo_dir}" ) 20 | run_cmd( "cd #{repo_dir}" ) 21 | Dir.chdir( repo_dir ) 22 | run_cmd( "hg init" ) 23 | run_cmd( "hg pull #{File.join( pk_dir, ".." )}" ) 24 | 25 | # update the files to the desired revision 26 | if ARGV.size == 1 27 | rev = ARGV[0] 28 | else 29 | # rev = run_cmd( "hg tip" ).split(":")[1].to_i 30 | rev = `hg tip`.split(":")[1].to_i 31 | end 32 | run_cmd( "hg up -r #{rev}" ) 33 | 34 | File.open( File.join( repo_dir, "doc", "version.txt" ), "w" ) do |f| 35 | f.puts "Locality Lab revision #{rev} created #{Time.now}" 36 | end 37 | 38 | # remove everything except for needed directories 39 | needed = ["doc", "gem", "server"] 40 | 41 | def remove( parent_dir, exceptions ) 42 | Dir.new( parent_dir ).each do |file| 43 | next if [".", ".."].find_index( file ) != nil 44 | run_cmd( "rm -rf #{file}" ) unless exceptions.find_index( file ) != nil 45 | end 46 | end 47 | 48 | remove( repo_dir, needed ) 49 | 50 | # make a package 51 | Dir.chdir( File.join(repo_dir, "..") ) 52 | run_cmd "tar -cf loca.tar #{repo_dir.split("/")[-1]}" 53 | run_cmd "gzip #{File.join( repo_dir, '../loca.tar' )}" 54 | run_cmd "rm -rf #{repo_dir}" 55 | -------------------------------------------------------------------------------- /server/plot_p.rb: -------------------------------------------------------------------------------- 1 | module Plot_p 2 | 3 | require 'fileutils' #instead of 'ftools' 4 | 5 | ## Plots the curves for all available data and copy each file 6 | # as zoom.file (complicated because file is called by path, 7 | # i.e. directory/file is copied to directory/zoom.file). 8 | 9 | def self.rplot (currentDir, program, ext, zoom) 10 | if zoom == true 11 | arg1 = File.join(currentDir, "zoom_#{program}") 12 | arg2 = ext 13 | `Rscript #{LocaServerDir}/draw_p.r #{arg1} #{arg2}` 14 | else 15 | arg1 = File.join(currentDir, program) 16 | arg2 = ext 17 | `Rscript #{LocaServerDir}/draw_p.r #{arg1} #{arg2}` 18 | end 19 | end 20 | 21 | def self.default (currentDir, program, ext) 22 | rplot(currentDir, program, ext, false) 23 | ["fp", "lf"].each do |metric| 24 | FileUtils.cp(File.join( currentDir, \ 25 | program + ".#{metric}.png"), \ 26 | File.join( currentDir, \ 27 | "zoom_" + program + ".#{metric}.png")) 28 | end 29 | end 30 | 31 | def self.zoom (currentDir, program, ext, xmin, xmax, metric) 32 | columnNum = (metric == "fp" or metric == "lf")? 1 : 2 33 | File.open(File.join( currentDir, "zoom_#{program}#{ext}"), "w") do |writefile| 34 | File.open(File.join( currentDir, "#{program}#{ext}"), "r") do |f| 35 | if (metric == "fp") 36 | while line = f.gets # Print rest of lines where column 1 is in range 37 | if (line.split[columnNum].to_f >= xmin) \ 38 | and (line.split[columnNum].to_f <= xmax) 39 | writefile.puts line 40 | end 41 | end 42 | else 43 | while line = f.gets # Print rest of lines where column 1 is in range 44 | if (line.split[columnNum].to_f*64.0 >= xmin) \ 45 | and (line.split[columnNum].to_f*64.0 <= xmax) 46 | writefile.puts line 47 | end 48 | end 49 | end 50 | end 51 | end 52 | rplot(currentDir, program, ext, true) 53 | end 54 | 55 | end -------------------------------------------------------------------------------- /policies/lirs/lirs/README: -------------------------------------------------------------------------------- 1 | Descriptions: 2 | The LIRS algorithm is described in the wiki page: 3 | http://en.wikipedia.org/wiki/LIRS_caching_algorithm. 4 | In the wiki page, there is a graph illustrating the operations 5 | of LIRS on two stacks (Stack S and Stack Q) 6 | 7 | ./trace/{2_pools, cs, cpp, gli, ps, sprite, multi1, 8 | multi2, multi3}.trc are the trace files. As these traces have long 9 | reference sequences, if you just want to run partial of them(from the 10 | very beginning to a certain point rather than the very end), you can 11 | simply insert a breakpoint "*" after a certain line, indicating that the stack 12 | information needs to be printed into files right after the 13 | reference before the "*" is processed. By default, there is a 14 | breakpoint at the end of trace file. 15 | 16 | For example, there are two "*" in ./traces/cs.trc, indicating that 17 | the HIR/LIR stack information as well as eviction sequence should be 18 | printed for the following three access sequences: 19 | {0..14}, {0..22} and {0..file-end}. The output file name format is: 20 | TRACENAME-output-{LIR, HIR, EVICTED}-CHECKPOINTNUM.log. In the names, 21 | "LIR" means the contents of the LIRS stack (Stack S in the wiki 22 | page), "HIR" means the contents of the LIRS queue (Stack Q in the 23 | wiki page), and "EVICTED" means the sequence of pages that are 24 | evicted. Please see the sample files under ./traces for details. 25 | 26 | In the output file of LIR stack, 27 | "R" refers as "resident"; "NR" refers as "non-resident"; 28 | "H" refers as "HIR block"; "L" refers as "LIR block"; 29 | 30 | For other details, please read the source codes. 31 | 32 | How to run the program: 33 | ./lirs ./traces/TRACE_NAME 34 | For example, "./lirs ./traces/cs" will run the LIRS simulation 35 | on the trace "cs.trc" and the information of HIR/LIR, as well as 36 | the eviction sequence will be printed out into the files respectively. 37 | -------------------------------------------------------------------------------- /server/plot.rb: -------------------------------------------------------------------------------- 1 | module Plot 2 | 3 | require 'fileutils' #instead of 'ftools' 4 | 5 | ## Plots the curves for all available data and copy each file 6 | # as zoom.file (complicated because file is called by path, 7 | # i.e. directory/file is copied to directory/zoom.file). 8 | 9 | def self.rplot (currentDir, program, ext, zoom) 10 | 11 | if zoom == true 12 | arg1 = File.join(currentDir, "zoom_#{program}") 13 | arg2 = ext 14 | arg3 = File.join("./data/", "zoom_#{program}") 15 | `Rscript #{LocaServerDir}/draw_dual.r #{arg1} #{arg2} #{arg3}` 16 | else 17 | arg1 = File.join(currentDir, program) 18 | arg2 = ext 19 | arg3 = File.join("./data/", program) 20 | `Rscript #{LocaServerDir}/draw_dual.r #{arg1} #{arg2} #{arg3}` 21 | end 22 | end 23 | 24 | def self.default (currentDir, program, ext) 25 | rplot(currentDir, program, ext, false) 26 | dataDir = "./data/" 27 | ["fp", "lf", "mr", "rd"].each do |metric| 28 | FileUtils.cp(File.join( dataDir, \ 29 | program + ".#{metric}.png"), \ 30 | File.join( dataDir, \ 31 | "zoom_" + program + ".#{metric}.png")) 32 | end 33 | end 34 | 35 | def self.zoom (currentDir, program, ext, xmin, xmax, metric) 36 | dataDir = "./data/" 37 | columnNum = (metric == "fp")? 1 : 2 38 | File.open(File.join( dataDir, "zoom_#{program}#{ext}"), "w") do |writefile| 39 | File.open(File.join( dataDir, "#{program}#{ext}"), "r") do |f| 40 | writefile.puts f.gets #print 1st line. 41 | if (metric == "fp") 42 | while line = f.gets # Print rest of lines where column 1 is in range 43 | if (line.split[columnNum].to_f >= xmin) \ 44 | and (line.split[columnNum].to_f <= xmax) 45 | writefile.puts line 46 | end 47 | end 48 | else 49 | while line = f.gets # Print rest of lines where column 1 is in range 50 | if (line.split[columnNum].to_f*64.0 >= xmin) \ 51 | and (line.split[columnNum].to_f*64.0 <= xmax) 52 | writefile.puts line 53 | end 54 | end 55 | end 56 | end 57 | end 58 | rplot(currentDir, program, ext, true) 59 | end 60 | 61 | end -------------------------------------------------------------------------------- /server/draw_dual.r: -------------------------------------------------------------------------------- 1 | args <- commandArgs(TRUE) 2 | 3 | app <- args[1] 4 | ext <- args[2] 5 | write <- args[3] 6 | title <- sprintf("average footprint curves of %s", app) 7 | rawdata <- read.table(sprintf("%s%s", app,ext), skip=1) 8 | legend <- c("cache block size is 64 bytes", "cache block size is 4 bytes") 9 | ltys <- c(1, 2) 10 | cols <- c("red", "blue") 11 | 12 | #draw footprint curve 13 | saveto <- sprintf("%s.fp.png", write) 14 | x <- rawdata[,2] 15 | y <- rawdata[,3] 16 | y2 <- rawdata[,6] 17 | xlab <- "window size" 18 | ylab <- "footprint" 19 | png(file=saveto, width=600, height=450) 20 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, frame.plot=TRUE, col="red", main=title) 21 | legend("topleft", legend, lty=ltys, col=cols) 22 | lines(x, y2, type="l",lty=2, col="blue") 23 | dev.off() 24 | 25 | #draw lifetime curve 26 | title <- sprintf("lifetime curves of %s", write) 27 | saveto <- sprintf("%s.lf.png", write) 28 | x <- rawdata[,3] 29 | y <- rawdata[,2] 30 | x2 <- rawdata[,6] 31 | xlab <- "cache size" 32 | ylab <- "lifetime" 33 | png(file=saveto, width=600, height=450) 34 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, frame.plot=TRUE, col="red", main=title) 35 | legend("topleft", legend, lty=ltys, col=cols) 36 | lines(x2, y, type="l",lty=2, col="blue") 37 | dev.off() 38 | 39 | 40 | #draw reuse signature 41 | title <- sprintf("reuse signature of %s", write) 42 | saveto <- sprintf("%s.rd.png", write) 43 | x <- rawdata[,3] 44 | y <- rawdata[,4] 45 | x2 <- rawdata[,6] 46 | y2 <- rawdata[,7] 47 | xlab <- "reuse distance" 48 | ylab <- "percentage" 49 | png(file=saveto, width=600, height=450) 50 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, frame.plot=TRUE, col="red", main=title) 51 | legend("topright", legend, lty=ltys, col=cols) 52 | lines(x2, y2, type="l",lty=2, col="blue") 53 | dev.off() 54 | 55 | 56 | #draw miss ratio curve 57 | title <- sprintf("miss ratio curves of %s", write) 58 | saveto <- sprintf("%s.mr.png", write) 59 | x <- rawdata[,3] 60 | y <- rawdata[,5] 61 | x2 <- rawdata[,6] 62 | y2 <- rawdata[,8] 63 | xlab <- "cache size" 64 | ylab <- "miss ratio" 65 | png(file=saveto, width=600, height=450) 66 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, frame.plot=TRUE, col="red", main=title) 67 | legend("topright", legend, lty=ltys, col=cols) 68 | lines(x2, y2, type="l",lty=2, col="blue") 69 | dev.off() 70 | -------------------------------------------------------------------------------- /server/draw.r: -------------------------------------------------------------------------------- 1 | args <- commandArgs(TRUE) 2 | 3 | program <- args[1] 4 | ext <- args[2] 5 | 6 | rawdata <- read.table(paste(program, ext, sep=""), skip=1) 7 | N <- strsplit(strsplit(readLines(paste(program, ext, sep=""), 1), " ")[[1]][1], ":")[[1]][2] 8 | M <- strsplit(strsplit(readLines(paste(program, ext, sep=""), 1), " ")[[1]][2], ":")[[1]][2] 9 | M <- toString(as.numeric(M) * 64) 10 | 11 | message <- paste("Length of Trace = ", N, " ", "Data Size = ", M) 12 | 13 | #draw footprint curve 14 | saveto <- sprintf("%s.fp.png", program) 15 | x <- rawdata[,2] 16 | y <- rawdata[,3] * 64 # "* 64" converts to bytes 17 | xlab <- "window size (accesses)" 18 | ylab <- "footprint (bytes)" 19 | legend <- c("average footprint") 20 | png(file=saveto, width=600, height=450) 21 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, 22 | frame.plot=TRUE, col="red", main="Average Footprint") 23 | legend("topleft", legend, lty=1, col="red", title=message) 24 | dev.off() 25 | 26 | #draw lifetime curve 27 | saveto <- sprintf("%s.lf.png", program) 28 | x <- rawdata[,3] * 64 29 | y <- rawdata[,2] 30 | xlab <- "cache size (bytes)" 31 | ylab <- "lifetime (accesses)" 32 | legend <- c("lifetime") 33 | png(file=saveto, width=600, height=450) 34 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, 35 | frame.plot=TRUE, col="red", main="Data Lifetime in Cache") 36 | legend("topleft", legend, lty=1, col="red", title=message) 37 | dev.off() 38 | 39 | #draw miss ratio curve 40 | saveto <- sprintf("%s.mr.png", program) 41 | x <- rawdata[,3] * 64 42 | y <- rawdata[,5] * 100 43 | xlab <- "cache size (bytes)" 44 | ylab <- "miss ratio (percentage)" 45 | legend <- c("miss ratio") 46 | png(file=saveto, width=600, height=450) 47 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, 48 | frame.plot=TRUE, col="red", main="Miss Ratio Curve") 49 | legend("topright", legend, lty=1, col="red", title=message) 50 | dev.off() 51 | 52 | #draw reuse signature 53 | saveto <- sprintf("%s.rd.png", program) 54 | x <- rawdata[,3] * 64 55 | y <- rawdata[,4] * 100 56 | xlab <- "reuse distance (bytes)" 57 | ylab <- "percentage" 58 | legend <- c("reuse signature") 59 | png(file=saveto, width=600, height=450) 60 | plot(x, y, type="l", lty=1, xlab=xlab, ylab=ylab, 61 | frame.plot=TRUE, col="red", main="Reuse Distance Distribution") 62 | legend("topright", legend, lty=1, col="red", title=message) 63 | dev.off() 64 | -------------------------------------------------------------------------------- /policies/ForwardOPTStackDistanceAnalyzer/reverse_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) { 5 | if (argc != 3) { 6 | fprintf(stderr, "USAGE: ./reverse_file inputFileName outputFileName\n"); 7 | exit(1); 8 | } 9 | 10 | char *input_file_name = argv[1]; 11 | char *output_file_name = argv[2]; 12 | FILE * input_file = fopen(input_file_name, "r"); 13 | FILE * output_file = fopen(output_file_name, "w"); 14 | 15 | fseek(input_file, 0, SEEK_END); 16 | long int input_file_size = ftell(input_file); 17 | //fprintf(stderr, "input file size: %d\n", input_file_size); 18 | 19 | long int buf_size = 10; 20 | long int offset = -buf_size; 21 | char buffer[buf_size]; 22 | long int buf_pos; 23 | char line[256]; 24 | long int line_pos = 0; 25 | long int total = 0; 26 | 27 | while (total < input_file_size) { 28 | //fprintf(stderr, "--------\n"); 29 | fseek(input_file, offset, SEEK_END); 30 | long int real_length = fread (buffer, 1, buf_size, input_file); 31 | buf_pos = real_length - 1; 32 | //fprintf(stderr, "real length: %d\n", real_length); 33 | total += real_length; 34 | //fprintf(stderr, "total: %d\n", total); 35 | 36 | /* 37 | int i; 38 | for (i=0;i= 0) { 44 | //fprintf(stderr, "%c", buffer[buf_pos]); 45 | //fprintf(stderr, "\t buf_pos=%d\n", buf_pos); 46 | line[line_pos++] = buffer[buf_pos--]; 47 | 48 | char line2[256]; 49 | int i,j; 50 | if (line[line_pos-1] == '\n') { 51 | for (i=line_pos-2,j=0;i>=0;--i,++j) { 52 | line2[j] = line[i]; 53 | } 54 | if (j != 0) { 55 | line2[j++] = '\n'; 56 | line2[j] = '\0'; 57 | //fprintf(stderr, "line2: %s\n", line2); 58 | fputs(line2, output_file); 59 | } 60 | line_pos = 0; 61 | } else if ((buf_pos < 0) && (total == input_file_size)) { 62 | for (i=line_pos-1,j=0;i>=0;--i,++j) { 63 | line2[j] = line[i]; 64 | } 65 | line2[j++] = '\n'; 66 | line2[j] = '\0'; 67 | //fprintf(stderr, "line2: %s\n", line2); 68 | fputs(line2, output_file); 69 | } 70 | } 71 | 72 | offset = offset - buf_size; 73 | if (offset+input_file_size < 0) { 74 | buf_size = buf_size + offset + input_file_size; 75 | offset = -input_file_size; 76 | } 77 | } 78 | 79 | fclose(input_file); 80 | fclose(output_file); 81 | return 0; 82 | 83 | } 84 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/stack.h: -------------------------------------------------------------------------------- 1 | #ifndef _STACK_H_ 2 | #define _STACK_H_ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #ifdef __APPLE__ 12 | #define MAP_ANONYMOUS MAP_ANON 13 | #endif 14 | #include 15 | 16 | 17 | typedef struct _snode 18 | { 19 | int e, s; 20 | struct _snode *next; 21 | }SNODE; 22 | 23 | typedef struct _stack 24 | { 25 | SNODE *head, *tail; 26 | int count; 27 | }STACK; 28 | 29 | inline void * 30 | alloc_node (int n) 31 | { 32 | void *p; 33 | 34 | p =(void *)mmap(0, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); 35 | if(p != (void *)-1) 36 | { 37 | memset(p,0,n); 38 | } 39 | else 40 | { 41 | printf("error: ac alloc failed\n"); 42 | return NULL; 43 | } 44 | return p; 45 | } 46 | 47 | inline void 48 | free_node (void *p) 49 | { 50 | int ret = munmap(p, sizeof(SNODE)); 51 | if ( ret == -1 ) { 52 | printf("Error: mumap for hash table element failed!\n"); 53 | abort(); 54 | } 55 | } 56 | 57 | /* stack_init - init stack */ 58 | void stack_init (STACK * s) 59 | { 60 | s->head = s->tail = 0; 61 | s->count = 0; 62 | } 63 | 64 | /* stack_push - add node to stack */ 65 | void stack_push (STACK * s, int e, int st) 66 | { 67 | SNODE * q; 68 | if (!s->head) 69 | { 70 | q = s->tail = s->head = (SNODE *) L_MALLOC (sizeof (SNODE)); 71 | assert (q != NULL); 72 | q->e = e; 73 | q->s = st; 74 | q->next = 0; 75 | } 76 | else 77 | { 78 | q = (SNODE *) L_MALLOC (sizeof (SNODE)); 79 | assert (q != NULL); 80 | q->e = e; 81 | q->s = st; 82 | q->next = s->head; 83 | s->head = q; 84 | } 85 | s->count++; 86 | } 87 | 88 | /* stack_remove - remove the 1st node */ 89 | void stack_toppop (STACK * s, int *e, int *st) 90 | { 91 | /* if no node, jus return two -1s */ 92 | *e = -1; 93 | *st = -1; 94 | SNODE * q; 95 | if (s->head) 96 | { 97 | q = s->head; 98 | *e = q->e; 99 | *st = q->s; 100 | 101 | s->head = s->head->next; 102 | s->count--; 103 | if (!s->head) 104 | { 105 | s->tail = 0; 106 | s->count = 0; 107 | } 108 | L_FREE (q); 109 | } 110 | } 111 | 112 | /* stack_count - return stack length */ 113 | int stack_count (STACK * s) 114 | { 115 | return s->count; 116 | } 117 | 118 | /* stack_free - free stack */ 119 | void stack_free (STACK * s) 120 | { 121 | while(stack_count(s)) 122 | { 123 | int e,st; 124 | stack_toppop(s, &e, &st); 125 | } 126 | } 127 | 128 | 129 | 130 | #endif /* _STACK_H_ */ 131 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/lru_cache.h: -------------------------------------------------------------------------------- 1 | /** 2 | * -- c++ -- 3 | * 4 | * By Pengcheng Li 5 | */ 6 | 7 | #ifndef _L_LRU_CACHE_H_ 8 | #define _L_LRU_CACHE_H_ 9 | 10 | #include "hash.h" /* doubly linked list, stack and hash table */ 11 | #include "dll.h" 12 | #include "attrs.h" 13 | #include "declarations.h" 14 | 15 | /** 16 | * Data structure of the software cache. 17 | */ 18 | struct _LLRUCache_t { 19 | struct list_head the_cache; 20 | size_t size; 21 | int32_t slab_class; 22 | } ATTR_ALIGN_TO_AVOID_FALSE_SHARING; 23 | 24 | /* item does not exist, but added to head now. */ 25 | void add_to_lru_cache( LLRUCache_t * lru_cache, LItem_t * item ) 26 | { 27 | // item->lease_or_lru = LRU; 28 | DLLAdd( &lru_cache->the_cache, &item->list ); 29 | lru_cache->size += 1; 30 | } 31 | 32 | /* item exists, move to head now. */ 33 | void update_in_lru_cache( LLRUCache_t * lru_cache, LItem_t * item ) 34 | { 35 | /* LRU algorithm: move the found node to the head */ 36 | DLLUpdateHead( &lru_cache->the_cache, &item->list ); 37 | 38 | /* no need for the change of hash table. */ 39 | } 40 | 41 | /* item exists, remove it from cache. */ 42 | void remove_from_lru_cache( LLRUCache_t * lru_cache, LItem_t * item ) 43 | { 44 | DLLRemove( &item->list ); 45 | lru_cache->size -= 1; 46 | } 47 | 48 | LItem_t * tail_of_lru_cache( LLRUCache_t * lru_cache ) 49 | { 50 | return DLLTail( &lru_cache->the_cache ); 51 | } 52 | 53 | LLRUCache_t * create_lru_cache( size_t size, int32_t slab_class) 54 | { 55 | LLRUCache_t * lru_cache = (LLRUCache_t *)malloc(sizeof(LLRUCache_t)); 56 | memset( lru_cache, 0, sizeof(LLRUCache_t) ); 57 | 58 | /* create the software cache */ 59 | INIT_LIST_HEAD(&lru_cache->the_cache); 60 | 61 | lru_cache->size = size; 62 | lru_cache->slab_class = slab_class; 63 | 64 | return lru_cache; 65 | } 66 | 67 | void print_lru_cache( LLRUCache_t * lru_cache ); 68 | /* destroy the software cache */ 69 | void destroy_lru_cache( LLRUCache_t * lru_cache ) 70 | { 71 | LItem_t * tmp; 72 | LItem_t * n; 73 | HashTableElem_t * m; 74 | list_for_each_entry_safe(tmp, n, &lru_cache->the_cache, list) { 75 | m = tmp->hash_node; 76 | hlist_del(&m->list); 77 | free(m); 78 | list_del(&tmp->list); 79 | free(tmp); 80 | } 81 | } 82 | 83 | int32_t lru_cache_empty( LLRUCache_t * lru_cache ) 84 | { 85 | return DLLEmpty( &lru_cache->the_cache ); 86 | } 87 | 88 | void print_lru_cache( LLRUCache_t * lru_cache ) 89 | { 90 | LItem_t * tmp; 91 | list_for_each_entry(tmp, &lru_cache->the_cache, list) { 92 | print_item( tmp ); 93 | } 94 | } 95 | 96 | /* export interface to report cache misses */ 97 | void stats_of_lru_cache( LLRUCache_t * lru_cache ) 98 | { 99 | } 100 | 101 | #endif /* _L_LRU_CACHE_H_ */ 102 | -------------------------------------------------------------------------------- /gem/lib/src/Footprint/makefile.rules: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # This file includes all the test targets as well as all the 4 | # non-default build rules and test recipes. 5 | # 6 | ############################################################## 7 | 8 | 9 | ############################################################## 10 | # 11 | # Test targets 12 | # 13 | ############################################################## 14 | 15 | ###### Place all generic definitions here ###### 16 | 17 | # This defines tests which run tools of the same name. This is simply for convenience to avoid 18 | # defining the test name twice (once in TOOL_ROOTS and again in TEST_ROOTS). 19 | # Tests defined here should not be defined in TOOL_ROOTS and TEST_ROOTS. 20 | TEST_TOOL_ROOTS := linear_fp dual_fp dual_fp_all 21 | 22 | # This defines the tests to be run that were not already defined in TEST_TOOL_ROOTS. 23 | TEST_ROOTS := 24 | 25 | # This defines the tools which will be run during the the tests, and were not already defined in 26 | # TEST_TOOL_ROOTS. 27 | TOOL_ROOTS := 28 | 29 | # This defines the static analysis tools which will be run during the the tests. They should not 30 | # be defined in TEST_TOOL_ROOTS. If a test with the same name exists, it should be defined in 31 | # TEST_ROOTS. 32 | # Note: Static analysis tools are in fact executables linked with the Pin Static Analysis Library. 33 | # This library provides a subset of the Pin APIs which allows the tool to perform static analysis 34 | # of an application or dll. Pin itself is not used when this tool runs. 35 | SA_TOOL_ROOTS := 36 | 37 | # This defines all the applications that will be run during the tests. 38 | APP_ROOTS := 39 | 40 | # This defines any additional object files that need to be compiled. 41 | OBJECT_ROOTS := 42 | 43 | # This defines any additional dlls (shared objects), other than the pintools, that need to be compiled. 44 | DLL_ROOTS := 45 | 46 | # This defines any static libraries (archives), that need to be built. 47 | LIB_ROOTS := 48 | 49 | ###### Define the sanity subset ###### 50 | 51 | # This defines the list of tests that should run in sanity. It should include all the tests listed in 52 | # TEST_TOOL_ROOTS and TEST_ROOTS excluding only unstable tests. 53 | SANITY_SUBSET := $(TEST_TOOL_ROOTS) $(TEST_ROOTS) 54 | 55 | 56 | ############################################################## 57 | # 58 | # Test recipes 59 | # 60 | ############################################################## 61 | 62 | # This section contains recipes for tests other than the default. 63 | # See makefile.default.rules for the default test rules. 64 | # All tests in this section should adhere to the naming convention: .test 65 | 66 | 67 | ############################################################## 68 | # 69 | # Build rules 70 | # 71 | ############################################################## 72 | 73 | # This section contains the build rules for all binaries that have special build rules. 74 | # See makefile.default.rules for the default build rules. 75 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/workload.h: -------------------------------------------------------------------------------- 1 | #ifndef _L_WORKLOAD_T_ 2 | #define _L_WORKLOAD_T_ 3 | 4 | /* workload_t */ 5 | struct _LWorkload_t { 6 | char name[1024]; 7 | int32_t M; /* number of keys */ 8 | int32_t N; /* trace length */ 9 | char key_slab_file[1024]; 10 | char key_lease_file[1024]; 11 | char trace_file[1024]; 12 | char item_num_file[1024]; 13 | char slab_mem_file[1024]; 14 | }; 15 | 16 | #endif 17 | 18 | /* LWorkload_t workloads[] = { */ 19 | /* { */ 20 | /* "fb3", */ 21 | /* 15000000, */ 22 | /* 50000010, */ 23 | /* "../../../traces/key_slab", */ 24 | /* "../../../traces/fb/trace3/key_lease", */ 25 | /* "../../../traces/fb/trace3/trace.tr", */ 26 | /* "../../../traces/item_num", */ 27 | /* }, */ 28 | /* { */ 29 | /* "fb4", */ 30 | /* 15000000, */ 31 | /* 50000010, */ 32 | /* "../../../traces/key_slab", */ 33 | /* "../../../traces/fb/trace4/key_lease", */ 34 | /* "../../../traces/fb/trace4/trace.tr", */ 35 | /* "../../../traces/item_num", */ 36 | /* }, */ 37 | /* { */ 38 | /* "fb5", */ 39 | /* 15000000, */ 40 | /* 50000010, */ 41 | /* "../../../traces/key_slab", */ 42 | /* "../../../traces/fb/trace5/key_lease", */ 43 | /* "../../../traces/fb/trace5/trace.tr", */ 44 | /* "../../../traces/item_num", */ 45 | /* }, */ 46 | /* { */ 47 | /* "twi2", */ 48 | /* 8000000, */ 49 | /* 50000000, */ 50 | /* "../../../traces/key_slab", */ 51 | /* "../../../traces/twi/trace2/key_lease", */ 52 | /* "../../../traces/twi/trace2/trace.tr", */ 53 | /* "../../../traces/item_num", */ 54 | /* }, */ 55 | /* { */ 56 | /* "twi3", */ 57 | /* 8000000, */ 58 | /* 50000000, */ 59 | /* "../../../traces/key_slab", */ 60 | /* "../../../traces/twi/trace3/key_lease", */ 61 | /* "../../../traces/twi/trace3/trace.tr", */ 62 | /* "../../../traces/item_num", */ 63 | /* }, */ 64 | /* { */ 65 | /* "hm_0", */ 66 | /* 8000000, */ 67 | /* 50000000, */ 68 | /* "../../../traces/key_slab", */ 69 | /* "../../../traces/msr/hm_0/key_lease", */ 70 | /* "../../../traces/msr/hm_0/trace.tr", */ 71 | /* "../../../traces/item_num", */ 72 | /* }, */ 73 | /* { */ 74 | /* "prn_0", */ 75 | /* 8000000, */ 76 | /* 50000000, */ 77 | /* "../../../traces/key_slab", */ 78 | /* "../../../traces/msr/prn_0/key_lease", */ 79 | /* "../../../traces/msr/prn_0/trace.tr", */ 80 | /* "../../../traces/item_num", */ 81 | /* }, */ 82 | /* { */ 83 | /* "prn_1", */ 84 | /* 8000000, */ 85 | /* 50000000, */ 86 | /* "../../../traces/key_slab", */ 87 | /* "../../../traces/msr/prn_1/key_lease", */ 88 | /* "../../../traces/msr/prn_1/trace.tr", */ 89 | /* "../../../traces/item_num", */ 90 | /* }, */ 91 | /* }; */ 92 | 93 | 94 | -------------------------------------------------------------------------------- /policies/lirs/lirs-sim/lirs.h: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "string.h" 3 | #include "stdlib.h" 4 | 5 | /********************** Two Parameters You may Want to Change ************/ 6 | /* if you want to limit the maximum LIRS stack size (e.g. 3 times of LRU stack * size, you can change the "2000" to "3" 7 | */ 8 | #define MAX_S_LEN (mem_size*2500) 9 | 10 | /* the size percentage of HIR blocks, default value is 1% of cache size */ 11 | #define HIR_RATE 1.0 12 | 13 | 14 | /* This specifies from what virtual time (reference event), the counter for 15 | * block miss starts to collect. You can test a warm cache by changin the "0" 16 | * to some virtual time you desire.*/ 17 | #define STAT_START_POINT 0 18 | 19 | /**************************************************************************/ 20 | 21 | #define LOWEST_HG_NUM 2 22 | 23 | #define TRUE 1 24 | #define FALSE 0 25 | 26 | /* used to mark comparison of recency and Smax */ 27 | #define S_STACK_IN 1 28 | #define S_STACK_OUT 0 29 | 30 | 31 | typedef struct pf_struct { 32 | unsigned long ref_times; 33 | unsigned long pf_times; 34 | 35 | unsigned long page_num; 36 | int isResident; 37 | int isHIR_block; 38 | 39 | struct pf_struct * LIRS_next; 40 | struct pf_struct * LIRS_prev; 41 | 42 | struct pf_struct * HIR_rsd_next; 43 | struct pf_struct * HIR_rsd_prev; 44 | 45 | unsigned int recency; 46 | } page_struct; 47 | 48 | page_struct * page_tbl; 49 | 50 | unsigned long total_pg_refs, warm_pg_refs; 51 | unsigned long no_dup_refs; /* counter excluding duplicate refs */ 52 | unsigned long num_pg_flt; 53 | 54 | long free_mem_size, mem_size, vm_size; 55 | 56 | struct pf_struct * LRU_list_head; 57 | struct pf_struct * LRU_list_tail; 58 | 59 | struct pf_struct * HIR_list_head; 60 | struct pf_struct * HIR_list_tail; 61 | 62 | struct pf_struct * LIR_LRU_block_ptr; /* LIR block with Rmax recency */ 63 | 64 | unsigned long HIR_block_portion_limit, HIR_block_activate_limit; 65 | 66 | extern page_struct *find_last_LIR_LRU(); 67 | extern void add_HIR_list_head(page_struct * new_rsd_HIR_ptr); 68 | extern void add_LRU_list_head(page_struct *new_ref_ptr); 69 | extern FILE *openReadFile(); 70 | extern void insert_LRU_list(page_struct *old_ref_ptr, page_struct *new_ref_ptr); 71 | extern page_struct *prune_LIRS_stack(); 72 | 73 | unsigned long cur_lir_S_len; 74 | 75 | /* get the range of accessed blocks [1:N] and the number of references */ 76 | int get_range(FILE *trc_fp, long *p_vm_size, long *p_trc_len) 77 | { 78 | long ref_blk; 79 | long count = 0; 80 | long min, max; 81 | 82 | fseek(trc_fp, 0, SEEK_SET); 83 | 84 | fscanf(trc_fp, "%ld", &ref_blk); 85 | max = min = ref_blk; 86 | 87 | while (!feof(trc_fp)){ 88 | if (ref_blk < 0) 89 | return FALSE; 90 | count++; 91 | if (ref_blk > max) 92 | max = ref_blk; 93 | if (ref_blk < min) 94 | min = ref_blk; 95 | fscanf(trc_fp, "%ld", &ref_blk); 96 | } 97 | 98 | printf(" [%d %d] for %lu refs in the trace\n", min, max, count); 99 | fseek(trc_fp, 0, SEEK_SET); 100 | *p_vm_size = max; 101 | *p_trc_len = count; 102 | return TRUE; 103 | } 104 | -------------------------------------------------------------------------------- /gem/lib/src/external.rb: -------------------------------------------------------------------------------- 1 | # Support for adding external tools such as Pin 2 | 3 | require 'os' 4 | 5 | module LabExternal 6 | PinTools = "source/tools/" 7 | FootprintCode = "src/Footprint" 8 | FootprintTool = "Footprint" 9 | #AnytasksetCode = "src/Anytaskset" 10 | #AnytasksetTool = "Anytaskset" 11 | 12 | def self.temp 13 | Labenv.env[Labenv::PinDir] = '/localdisk/cding/pin/pin-2.9-39599-gcc.3.4.6-ia32_intel64-linux/' 14 | end 15 | 16 | def self.add_footprint_analyzer 17 | require 'fileutils' 18 | tooldir = File.join(Labenv.env[Labenv::PinDir], PinTools) 19 | analyzer = File.join(LocaCmdDir, FootprintCode) 20 | # copy the files over 21 | Dir.chdir( tooldir ) 22 | begin 23 | FileUtils.cp_r(analyzer, tooldir) 24 | Dir.chdir( FootprintTool ) 25 | run_cmd 'make' 26 | raise "Fail to build the footprint analyzer" unless $?.success? 27 | rescue Exception => e 28 | msg = "Copying/making footprint analyzer directory failed" 29 | puts msg 30 | msg += e.backtrace.map{|k| k.to_s + "\n"}.to_s 31 | puts "Type ok to continue" 32 | is_ok = $stdin.gets.chomp 33 | raise msg unless is_ok.downcase == 'ok' 34 | Dir.chdir( FootprintTool ) 35 | end 36 | obj_dir = Dir.entries(".").find {|i| i.match /^obj/} 37 | raise "Object file directory not found" if obj_dir == nil 38 | 39 | if OS.mac? 40 | obj = File.join( tooldir, FootprintTool, obj_dir, "dual_fp_all.dylib" ) #.dylib for mac, .so for windows 41 | else 42 | obj = File.join( tooldir, FootprintTool, obj_dir, "dual_fp_all.so" ) 43 | end 44 | #obj = File.join( tooldir, FootprintTool, obj_dir, "linear_fp.dylib" ) 45 | raise "Object file #{obj} not found" unless File.file?(obj) 46 | Labenv.env[:footprint_obj] = obj 47 | Labenv.save_env 48 | end 49 | 50 | # following code is for experimental anytaskset 51 | =begin 52 | def self.add_anytaskset_analyzer 53 | require 'fileutils' 54 | tooldir = File.join(Labenv.env[Labenv::PinDir], PinTools) 55 | analyzer = File.join(LocaCmdDir, AnytasksetCode) 56 | # copy the files over 57 | Dir.chdir( tooldir ) 58 | begin 59 | FileUtils.cp_r(analyzer, tooldir) 60 | Dir.chdir( AnytasksetTool) 61 | run_cmd 'make' 62 | raise "Fail to build the anytaskset analyzer" unless $?.success? 63 | rescue Exception => e 64 | msg = "Copying/making anytaskset analyzer directory failed" 65 | puts msg 66 | msg += e.backtrace.map{|k| k.to_s + "\n"}.to_s 67 | puts "Type ok to continue" 68 | is_ok = $stdin.gets.chomp 69 | raise msg unless is_ok.downcase == 'ok' 70 | Dir.chdir( AnytasksetTool ) 71 | end 72 | obj_dir = Dir.entries(".").find {|i| i.match /^obj/} 73 | raise "Object file directory not found" if obj_dir == nil 74 | obj = File.join( tooldir, AnytasksetTool, obj_dir, "anytaskset-fp.so" ) 75 | raise "Object file #{obj} not found" unless File.file?(obj) 76 | Labenv.env[:anytaskset_obj] = obj 77 | Labenv.save_env 78 | end 79 | =end 80 | 81 | def self.remove_footprint_analyzer 82 | require 'fileutils' 83 | pin = File.join( Labenv.env[Labenv::PinDir], PinTools, FootprintTool) 84 | if not File.directory?(pin) 85 | warn "no footprint tool in #{pin}" 86 | return 87 | end 88 | FileUtils.rm_r pin 89 | end 90 | end 91 | 92 | -------------------------------------------------------------------------------- /policies/lirs/lirs/lirs.h: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "string.h" 3 | #include "stdlib.h" 4 | 5 | /********************** Three Parameters You may Want to Change ************/ 6 | /* if you want to limit the maximum LIRS stack size (e.g. 3 times of LRU stack * size, you can change the "2000" to "3" 7 | */ 8 | #define MAX_S_LEN (mem_size*2500) 9 | 10 | /* the size percentage of HIR blocks, default value is 1% of cache size */ 11 | #define HIR_RATE 1.0 12 | 13 | /* This specifies the size of Memory */ 14 | /* #define DEFAULT_MEMSIZE 32768 */ 15 | #define DEFAULT_MEMSIZE 16384 16 | 17 | 18 | /* This specifies from what virtual time (reference event), the counter for 19 | * block miss starts to collect. You can test a warm cache by changin the "0" 20 | * to some virtual time you desire.*/ 21 | #define STAT_START_POINT 0 22 | 23 | /**************************************************************************/ 24 | 25 | #define LOWEST_HG_NUM 2 26 | 27 | #define TRUE 1 28 | #define FALSE 0 29 | 30 | /* used to mark comparison of recency and Smax */ 31 | #define S_STACK_IN 1 32 | #define S_STACK_OUT 0 33 | 34 | #define EVICT_LIST_SIZE 10 35 | 36 | typedef struct pf_struct { 37 | unsigned long ref_times; 38 | unsigned long pf_times; 39 | 40 | unsigned long page_num; 41 | int isResident; 42 | int isHIR_block; 43 | 44 | struct pf_struct * LIRS_next; 45 | struct pf_struct * LIRS_prev; 46 | 47 | struct pf_struct * HIR_rsd_next; 48 | struct pf_struct * HIR_rsd_prev; 49 | 50 | unsigned int recency; 51 | } page_struct; 52 | 53 | page_struct * page_tbl; 54 | 55 | unsigned long total_pg_refs, warm_pg_refs; 56 | unsigned long no_dup_refs; /* counter excluding duplicate refs */ 57 | unsigned long num_pg_flt; 58 | 59 | long free_mem_size, mem_size, vm_size; 60 | 61 | struct pf_struct * LRU_list_head; 62 | struct pf_struct * LRU_list_tail; 63 | 64 | struct pf_struct * HIR_list_head; 65 | struct pf_struct * HIR_list_tail; 66 | 67 | struct pf_struct * LIR_LRU_block_ptr; /* LIR block with Rmax recency */ 68 | 69 | unsigned long HIR_block_portion_limit, HIR_block_activate_limit; 70 | 71 | unsigned long *evict_list, evict_cur_idx, evict_max_idx; 72 | 73 | extern page_struct *find_last_LIR_LRU(); 74 | extern void add_HIR_list_head(page_struct * new_rsd_HIR_ptr); 75 | extern void add_LRU_list_head(page_struct *new_ref_ptr); 76 | extern FILE *openReadFile(); 77 | extern void insert_LRU_list(page_struct *old_ref_ptr, page_struct *new_ref_ptr); 78 | extern page_struct *prune_LIRS_stack(); 79 | extern void LIRS_Repl(FILE *); 80 | extern void print_stack(int); 81 | extern void record_evict(unsigned long); 82 | 83 | unsigned long cur_lir_S_len; 84 | 85 | /* get the range of accessed blocks [1:N] and the number of references */ 86 | int get_range(FILE *trc_fp, long *p_vm_size, long *p_trc_len) 87 | { 88 | char ref_blk_str[128]; 89 | long ref_blk; 90 | long count = 0; 91 | long min, max; 92 | 93 | fseek(trc_fp, 0, SEEK_SET); 94 | 95 | do { 96 | fscanf(trc_fp, "%s", ref_blk_str); 97 | } while(strcmp(ref_blk_str, "*") == 0); 98 | 99 | ref_blk = atoi(ref_blk_str); 100 | max = min = ref_blk; 101 | 102 | while (!feof(trc_fp)){ 103 | if (ref_blk < 0) 104 | return FALSE; 105 | count++; 106 | if (ref_blk > max) 107 | max = ref_blk; 108 | if (ref_blk < min) 109 | min = ref_blk; 110 | 111 | fscanf(trc_fp, "%s", ref_blk_str); 112 | ref_blk = atoi(ref_blk_str); 113 | } 114 | 115 | // printf(" MIN page refs #: %lu, MAX page refs #: %lu for %lu refs in the trace\n", 116 | // min, max, count); 117 | fseek(trc_fp, 0, SEEK_SET); 118 | *p_vm_size = max; 119 | *p_trc_len = count; 120 | return TRUE; 121 | } 122 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/hash.h: -------------------------------------------------------------------------------- 1 | #ifndef _HASH_H_ 2 | #define _HASH_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "data_structures.h" 13 | #include "attrs.h" 14 | #include "declarations.h" 15 | 16 | #define DEFAULT_BUCKET_SIZE (15) /*hash table size */ 17 | 18 | 19 | struct _HashTableElem_t{ 20 | struct hlist_node list; 21 | int64_t key_id; 22 | LItem_t *points_to; /* T: LItem_t * or else */ 23 | } ATTR_ALIGN_TO_AVOID_FALSE_SHARING; 24 | 25 | struct _HashTable_t { 26 | struct hlist_head *bucket; 27 | uint64_t bucket_size; 28 | uint64_t bucket_mask; 29 | } ATTR_ALIGN_TO_AVOID_FALSE_SHARING; 30 | 31 | /* the seed of hash key */ 32 | uint32_t hash_rd = 0x20150707; 33 | 34 | /* calculate hash key, given a key_id */ 35 | uint64_t hashkey( HashTable_t * ht , int64_t key_id ) 36 | { 37 | return ((uint64_t) key_id) & ht->bucket_mask ; 38 | } 39 | 40 | /* create a hash table */ 41 | HashTable_t * create_hash_table() 42 | { 43 | HashTable_t * hash_table = (HashTable_t *)malloc(sizeof(HashTable_t)); 44 | hash_table->bucket_size = 1 << DEFAULT_BUCKET_SIZE; 45 | hash_table->bucket_mask = hash_table->bucket_size -1; 46 | hash_table->bucket = (struct hlist_head *) malloc 47 | (hash_table->bucket_size * sizeof(struct hlist_head)); 48 | size_t i; 49 | for ( i = 0; i < hash_table->bucket_size; i++ ) 50 | INIT_HLIST_HEAD(&hash_table->bucket[i]); 51 | 52 | return hash_table; 53 | } 54 | 55 | /** 56 | * destroy a hash table - 57 | * we assume that all hash_nodes in the hash table are freed already. 58 | */ 59 | void destroy_hash_table( HashTable_t * hash_table ) 60 | { 61 | free( hash_table->bucket ); 62 | free( hash_table ); 63 | } 64 | 65 | /* add an element to a hash table */ 66 | void HashTableAdd( HashTable_t * ht, HashTableElem_t * elem ) 67 | { 68 | uint64_t hash = hashkey(ht, elem->key_id); 69 | hlist_add_head( &elem->list, &ht->bucket[hash] ); 70 | } 71 | 72 | /* get an element in a hash table, given a key_id */ 73 | HashTableElem_t * HashTableGetElem( HashTable_t * ht, int64_t key_id ) 74 | { 75 | uint64_t hash = hashkey(ht, key_id); 76 | HashTableElem_t *elem; 77 | struct hlist_node *n; 78 | 79 | hlist_for_each_entry( elem, n, &ht->bucket[hash], list ) { 80 | if ( LIKELY(key_id == elem->key_id) ) { 81 | return elem; 82 | } 83 | } 84 | 85 | return NULL; 86 | } 87 | 88 | /* delete an element from a hash table, given a key_id */ 89 | HashTableElem_t * HashTableDel(HashTable_t * ht, intptr_t key_id ) 90 | { 91 | HashTableElem_t * elem = HashTableGetElem(ht, key_id); 92 | hlist_del(&elem->list); 93 | return elem; 94 | } 95 | 96 | /** 97 | * update a key_id entry with new cache line address. need to do : 98 | * 1. change the cache line address of the entry; 99 | * 2. get rid of the "key-value" pair from hash table due to change of key; 100 | * 3. add new hash element to the hash table. 101 | */ 102 | void HashTableUpdate(HashTable_t * ht, intptr_t old_key_id, intptr_t new_key_id ) 103 | { 104 | /* key changes, thus chang to another bucket. */ 105 | HashTableElem_t * elem = HashTableDel( ht, old_key_id ); 106 | 107 | /* update the new pointed cache line */ 108 | elem->key_id = new_key_id; 109 | 110 | /* NOTE: no need to change the pointed link node, because the linke node's address keeps the same*/ 111 | // elem->list_node = new_node; 112 | 113 | HashTableAdd(ht, elem); 114 | } 115 | 116 | /* get the node in the linked list of the software cache, given a key_id */ 117 | LItem_t * HashTableGet( HashTable_t * ht, intptr_t key_id ) 118 | { 119 | uint64_t hash = hashkey(ht, key_id); 120 | HashTableElem_t *elem; 121 | struct hlist_node *n; 122 | 123 | hlist_for_each_entry( elem, n, &ht->bucket[hash], list ) { 124 | if ( LIKELY(key_id == elem->key_id) ) { 125 | return elem->points_to; 126 | } 127 | } 128 | 129 | return 0; /* 0 works for both LItem_t * and int32_t */ 130 | } 131 | 132 | 133 | 134 | #endif /* _HASH_H_ */ 135 | -------------------------------------------------------------------------------- /doc/Site/installation_files/installation.css: -------------------------------------------------------------------------------- 1 | .style { 2 | padding: 4px; 3 | } 4 | .paragraph_style { 5 | color: rgb(88, 77, 77); 6 | font-family: 'ArialMT', 'Arial', sans-serif; 7 | font-size: 15px; 8 | font-stretch: normal; 9 | font-style: normal; 10 | font-variant: normal; 11 | font-weight: 400; 12 | letter-spacing: 0; 13 | line-height: 20px; 14 | margin-bottom: 0px; 15 | margin-left: 0px; 16 | margin-right: 0px; 17 | margin-top: 0px; 18 | opacity: 1.00; 19 | padding-bottom: 13px; 20 | padding-top: 0px; 21 | text-align: left; 22 | text-decoration: none; 23 | text-indent: 0px; 24 | text-transform: none; 25 | } 26 | .style_External_630_50 { 27 | position: relative; 28 | } 29 | .style_SkipStroke { 30 | background: transparent; 31 | opacity: 1.00; 32 | } 33 | .style_SkipStroke_1 { 34 | background: transparent; 35 | opacity: 1.00; 36 | } 37 | .Body { 38 | color: rgb(88, 77, 77); 39 | font-family: 'ArialMT', 'Arial', sans-serif; 40 | font-size: 15px; 41 | font-stretch: normal; 42 | font-style: normal; 43 | font-variant: normal; 44 | font-weight: 400; 45 | letter-spacing: 0; 46 | line-height: 20px; 47 | margin-bottom: 0px; 48 | margin-left: 0px; 49 | margin-right: 0px; 50 | margin-top: 0px; 51 | opacity: 1.00; 52 | padding-bottom: 0px; 53 | padding-top: 0px; 54 | text-align: left; 55 | text-decoration: none; 56 | text-indent: 0px; 57 | text-transform: none; 58 | } 59 | .Header { 60 | color: rgb(167, 167, 167); 61 | font-family: 'Arial-BoldMT', 'Arial', sans-serif; 62 | font-size: 36px; 63 | font-stretch: normal; 64 | font-style: normal; 65 | font-variant: normal; 66 | font-weight: 700; 67 | letter-spacing: 0; 68 | line-height: 42px; 69 | margin-bottom: 0px; 70 | margin-left: 0px; 71 | margin-right: 0px; 72 | margin-top: 0px; 73 | opacity: 1.00; 74 | padding-bottom: 0px; 75 | padding-top: 0px; 76 | text-align: center; 77 | text-decoration: none; 78 | text-indent: 0px; 79 | text-transform: none; 80 | } 81 | .Normal { 82 | padding: 4px; 83 | } 84 | .Normal_External_630_50 { 85 | position: relative; 86 | } 87 | .graphic_generic_header_textbox_style_default_SkipStroke { 88 | background: transparent; 89 | opacity: 1.00; 90 | } 91 | .graphic_textbox_layout_style_default { 92 | padding: 4px; 93 | } 94 | .graphic_textbox_layout_style_default_External_584_538 { 95 | position: relative; 96 | } 97 | .graphic_textbox_style_default_SkipStroke { 98 | background: transparent; 99 | opacity: 1.00; 100 | } 101 | a { 102 | color: rgb(88, 77, 77); 103 | text-decoration: underline; 104 | } 105 | a:visited { 106 | color: rgb(121, 121, 121); 107 | text-decoration: underline; 108 | } 109 | a:hover { 110 | color: rgb(0, 0, 0); 111 | text-decoration: underline; 112 | } 113 | ol { 114 | padding:0; 115 | margin:0; 116 | text-indent:0; 117 | list-style-type:none ; 118 | list-style-image:none 119 | } 120 | .Bullet { 121 | text-decoration:none ; 122 | text-transform:none ; 123 | border: none; 124 | } 125 | .bumper { 126 | font-size: 1px; 127 | line-height: 1px; 128 | } 129 | #widget0 a:hover { 130 | color: rgb(0, 0, 0); 131 | text-decoration: underline; 132 | } 133 | #widget0 a:visited { 134 | color: rgb(121, 121, 121); 135 | text-decoration: underline; 136 | } 137 | #widget0 a { 138 | color: rgb(88, 77, 77); 139 | text-decoration: underline; 140 | } 141 | .spacer { 142 | font-size: 1px; 143 | line-height: 1px; 144 | } 145 | body { 146 | -webkit-text-size-adjust: none; 147 | } 148 | div { 149 | overflow: visible; 150 | } 151 | img { 152 | border: none; 153 | } 154 | .InlineBlock { 155 | display: inline; 156 | } 157 | .InlineBlock { 158 | display: inline-block; 159 | } 160 | .inline-block { 161 | display: inline-block; 162 | vertical-align: baseline; 163 | margin-bottom:0.3em; 164 | } 165 | .inline-block.shape-with-text { 166 | vertical-align: bottom; 167 | } 168 | .vertical-align-middle-middlebox { 169 | display: table; 170 | } 171 | .vertical-align-middle-innerbox { 172 | display: table-cell; 173 | vertical-align: middle; 174 | } 175 | div.paragraph { 176 | position: relative; 177 | } 178 | li.full-width { 179 | width: 100; 180 | } 181 | -------------------------------------------------------------------------------- /doc/Site/external_software_files/external_software.css: -------------------------------------------------------------------------------- 1 | .style { 2 | padding: 4px; 3 | } 4 | .paragraph_style { 5 | color: rgb(88, 77, 77); 6 | font-family: 'ArialMT', 'Arial', sans-serif; 7 | font-size: 15px; 8 | font-stretch: normal; 9 | font-style: normal; 10 | font-variant: normal; 11 | font-weight: 400; 12 | letter-spacing: 0; 13 | line-height: 20px; 14 | margin-bottom: 0px; 15 | margin-left: 0px; 16 | margin-right: 0px; 17 | margin-top: 0px; 18 | opacity: 1.00; 19 | padding-bottom: 13px; 20 | padding-top: 0px; 21 | text-align: left; 22 | text-decoration: none; 23 | text-indent: 0px; 24 | text-transform: none; 25 | } 26 | .style_External_630_50 { 27 | position: relative; 28 | } 29 | .style_SkipStroke { 30 | background: transparent; 31 | opacity: 1.00; 32 | } 33 | .style_SkipStroke_1 { 34 | background: transparent; 35 | opacity: 1.00; 36 | } 37 | .Body { 38 | color: rgb(88, 77, 77); 39 | font-family: 'ArialMT', 'Arial', sans-serif; 40 | font-size: 15px; 41 | font-stretch: normal; 42 | font-style: normal; 43 | font-variant: normal; 44 | font-weight: 400; 45 | letter-spacing: 0; 46 | line-height: 20px; 47 | margin-bottom: 0px; 48 | margin-left: 0px; 49 | margin-right: 0px; 50 | margin-top: 0px; 51 | opacity: 1.00; 52 | padding-bottom: 0px; 53 | padding-top: 0px; 54 | text-align: left; 55 | text-decoration: none; 56 | text-indent: 0px; 57 | text-transform: none; 58 | } 59 | .Header { 60 | color: rgb(167, 167, 167); 61 | font-family: 'Arial-BoldMT', 'Arial', sans-serif; 62 | font-size: 36px; 63 | font-stretch: normal; 64 | font-style: normal; 65 | font-variant: normal; 66 | font-weight: 700; 67 | letter-spacing: 0; 68 | line-height: 42px; 69 | margin-bottom: 0px; 70 | margin-left: 0px; 71 | margin-right: 0px; 72 | margin-top: 0px; 73 | opacity: 1.00; 74 | padding-bottom: 0px; 75 | padding-top: 0px; 76 | text-align: center; 77 | text-decoration: none; 78 | text-indent: 0px; 79 | text-transform: none; 80 | } 81 | .Normal { 82 | padding: 4px; 83 | } 84 | .Normal_External_630_50 { 85 | position: relative; 86 | } 87 | .graphic_generic_header_textbox_style_default_SkipStroke { 88 | background: transparent; 89 | opacity: 1.00; 90 | } 91 | .graphic_textbox_layout_style_default { 92 | padding: 4px; 93 | } 94 | .graphic_textbox_layout_style_default_External_584_538 { 95 | position: relative; 96 | } 97 | .graphic_textbox_style_default_SkipStroke { 98 | background: transparent; 99 | opacity: 1.00; 100 | } 101 | a { 102 | color: rgb(88, 77, 77); 103 | text-decoration: underline; 104 | } 105 | a:visited { 106 | color: rgb(121, 121, 121); 107 | text-decoration: underline; 108 | } 109 | a:hover { 110 | color: rgb(0, 0, 0); 111 | text-decoration: underline; 112 | } 113 | ol { 114 | padding:0; 115 | margin:0; 116 | text-indent:0; 117 | list-style-type:none ; 118 | list-style-image:none 119 | } 120 | .Bullet { 121 | text-decoration:none ; 122 | text-transform:none ; 123 | border: none; 124 | } 125 | .bumper { 126 | font-size: 1px; 127 | line-height: 1px; 128 | } 129 | #widget0 a:hover { 130 | color: rgb(0, 0, 0); 131 | text-decoration: underline; 132 | } 133 | #widget0 a:visited { 134 | color: rgb(121, 121, 121); 135 | text-decoration: underline; 136 | } 137 | #widget0 a { 138 | color: rgb(88, 77, 77); 139 | text-decoration: underline; 140 | } 141 | .spacer { 142 | font-size: 1px; 143 | line-height: 1px; 144 | } 145 | body { 146 | -webkit-text-size-adjust: none; 147 | } 148 | div { 149 | overflow: visible; 150 | } 151 | img { 152 | border: none; 153 | } 154 | .InlineBlock { 155 | display: inline; 156 | } 157 | .InlineBlock { 158 | display: inline-block; 159 | } 160 | .inline-block { 161 | display: inline-block; 162 | vertical-align: baseline; 163 | margin-bottom:0.3em; 164 | } 165 | .inline-block.shape-with-text { 166 | vertical-align: bottom; 167 | } 168 | .vertical-align-middle-middlebox { 169 | display: table; 170 | } 171 | .vertical-align-middle-innerbox { 172 | display: table-cell; 173 | vertical-align: middle; 174 | } 175 | div.paragraph { 176 | position: relative; 177 | } 178 | li.full-width { 179 | width: 100; 180 | } 181 | -------------------------------------------------------------------------------- /gem/lib/src/Footprint/histo.H: -------------------------------------------------------------------------------- 1 | #ifndef _HISTO_HPP_ 2 | #define _HISTO_HPP_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | namespace histo 12 | { 13 | typedef uint32_t (*DOMAIN_VALUE_TO_INDEX_FN) (uint64_t); 14 | typedef uint64_t (*DOMAIN_INDEX_TO_VALUE_FN) (uint32_t); 15 | 16 | template 17 | struct histogram { 18 | uint64_t buckets[BUCKETS]; 19 | double cdf[BUCKETS]; 20 | uint64_t totcnt; 21 | 22 | // constructor 23 | histogram (void) { 24 | totcnt = 0; 25 | memset ((void *)buckets, 0, sizeof (buckets)); 26 | memset ((void *)cdf, 0, sizeof (cdf)); 27 | } 28 | 29 | inline uint32_t domain_value_to_index (uint64_t value) { 30 | return domain_value_to_index_fn (value); 31 | } 32 | 33 | inline uint64_t domain_index_to_value (uint32_t index) { 34 | return domain_index_to_value_fn (index); 35 | } 36 | 37 | inline void put_value (uint64_t value) { 38 | uint32_t index = domain_value_to_index_fn (value); 39 | buckets[index]++; 40 | } 41 | 42 | uint64_t calc_totcnt (void) { 43 | for (int32_t index = 0; index < BUCKETS; index++) 44 | totcnt += buckets[index]; 45 | return totcnt; 46 | } 47 | 48 | inline uint64_t& operator[](uint32_t index) { 49 | return buckets[index]; 50 | } 51 | 52 | inline double query_pdf (uint32_t index) { 53 | return (double)buckets[index]/(double)totcnt; 54 | } 55 | 56 | inline double query_cdf (uint32_t index) { 57 | return cdf[index]; 58 | } 59 | 60 | void build_cdf (bool reverse = false) { 61 | uint64_t count = 0; 62 | int32_t index; 63 | 64 | calc_totcnt (); 65 | 66 | if (reverse) { 67 | for (index = BUCKETS - 1; index >= 0; index--) { 68 | count += buckets[index]; 69 | cdf[index] = (double)count/(double)totcnt; 70 | } 71 | } else { 72 | for (index = 0; index < BUCKETS; index++) { 73 | count += buckets[index]; 74 | cdf[index] = (double)count/(double)totcnt; 75 | } 76 | } 77 | } 78 | 79 | void print (ofstream& os) { 80 | calc_totcnt(); 81 | os << "# HISTOGRAM TOTAL COUNT " << totcnt << endl; 82 | os << "# NUMBER OF BINS: " << BUCKETS << endl; 83 | for (unsigned i = 0; i <= domain_value_to_index(totcnt); i++) { 84 | os << "BIN: " << setw(5) << i << " "; 85 | os << "VAL: " << setw(12) << domain_index_to_value (i) << " "; 86 | os << "COUNT: " << buckets[i]; 87 | os << endl; 88 | } 89 | } 90 | }; 91 | 92 | template 93 | inline uint32_t sublog_value_to_index (uint64_t value) { 94 | if (value < (1<> 32; 102 | if (hi) { 103 | __asm__ ( 104 | "bsr %1, %0;" 105 | : "=r"(msb) 106 | : "m"(hi) 107 | : "eax" 108 | ); 109 | msb += 32; 110 | } else { 111 | UINT32 t = value; 112 | __asm__ ( 113 | "bsr %1, %0;" 114 | : "=r"(msb) 115 | : "m"(t) 116 | : "eax" 117 | ); 118 | } 119 | #elif defined (__x86_64__) && defined (__GNUC__) 120 | __asm__ ( 121 | "rex.w bsr %1, %0;" 122 | : "=r"(msb) 123 | : "m"(value) 124 | : "eax" 125 | ); 126 | #else 127 | cerr << "Wrong architecture or compiler!" << endl; 128 | assert(0); 129 | #endif 130 | */ 131 | msb = 63 - __builtin_clzll(value); 132 | shift = msb - SUBLOG_BITS; 133 | index = value >> shift; 134 | index &= (1< 140 | inline uint64_t sublog_index_to_value (uint32_t index) { 141 | uint32_t shift = index >> SUBLOG_BITS; 142 | uint32_t t = index & ((1<, sublog_index_to_value > 155 | // reuse_time_hist; 156 | 157 | } 158 | #endif 159 | -------------------------------------------------------------------------------- /gem/lib/src/env.rb: -------------------------------------------------------------------------------- 1 | require 'yaml' # for serialization 2 | 3 | module Labenv 4 | # paths for the files and directories 5 | LocaDir = ".loca" 6 | ConfigFile = "config.yaml" 7 | DataDir = "data" 8 | @@paths = nil # root directory of Locality Lab 9 | 10 | # commands: base and configured 11 | Commands = [:config, :run, :upload, :uninstall, :help] 12 | @@env = nil 13 | 14 | # user inputs 15 | PinDir = "pin directory" 16 | LocaServer = "loca server" 17 | UserInputs = [PinDir, LocaServer] 18 | 19 | # debugging 20 | Debug = true 21 | 22 | def self.env 23 | read_config if @@env == nil 24 | return @@env 25 | end 26 | 27 | def self.paths 28 | setup_paths if @@paths == nil 29 | return @@paths 30 | end 31 | 32 | def self.config( gui=true ) 33 | 34 | if Labenv.env == nil 35 | @@env = Hash.new # initial env 36 | Labenv.env[PinDir] = '/localdisk/cding/pin/pin-2.9-39599-gcc.3.4.6-ia32_intel64-linux' 37 | Labenv.env[LocaServer] = Labenv.paths[Labenv::DataDir] # 'cycle1.cs.rochester.edu:/p/compiler/loclab/data' 38 | end 39 | 40 | if gui 41 | inputs_gui( @@env ) 42 | else 43 | inputs_cmdln( @@env ) 44 | end 45 | 46 | save_env 47 | 48 | require 'src/external' 49 | LabExternal.add_footprint_analyzer # Pin tool and compile -- if this throws errors, use the following line 50 | #LabExternal.add_anytaskset_analyzer # Pin tool and compile 51 | 52 | Labenv.env["run"] = "#{File.join(Labenv.env[PinDir],"pin")} -t #{Labenv.env[:footprint_obj]}" 53 | #Labenv.env["prun"] = "#{File.join(Labenv.env[PinDir],"pin")} -t #{Labenv.env[:anytaskset_obj]}" 54 | #Labenv.env["pfp"] = "#{LocaCmdDir}/src/Anytaskset/anytaskset-sfp-compose.rb" 55 | #Labenv.env["pmr"] = "#{LocaCmdDir}/src/Anytaskset/anytaskset-mc.rb" 56 | Labenv.env["upload"] = "rsync -trv ~/.loca/data #{Labenv.env[LocaServer]}" 57 | 58 | # accepted = gui.verify( hash2arrlist(cmd) ) 59 | # cmd.each{ |k,v| Labenv.env[k] = v } 60 | 61 | save_env 62 | 63 | puts @@env.inspect if Debug 64 | return nil 65 | end 66 | 67 | private_methods 68 | 69 | def self.inputs_gui( hash ) 70 | # to build jar: javac *.java; jar cf hashTableGUI.jar *.class 71 | begin 72 | require 'src/hashTableGUI.jar' 73 | 74 | # inputs = Labenv.env.reject{ |key, _| !UserInputs.include? key } 75 | inputs = Hash.new 76 | UserInputs.each{ |k| 77 | inputs[k] = Labenv.env[k] || " " 78 | } 79 | input_list = hash2arrlist( inputs ) 80 | gui = Java::hashTableGUI.new 81 | puts inputs.inspect if $Debug 82 | input_list = gui.getInputs( input_list ) 83 | arrlist_update_hash( input_list, hash ) 84 | return hash 85 | rescue Exception # LoadError 86 | inputs_cmdln( hash ) 87 | return hash 88 | end 89 | end 90 | 91 | def self.inputs_cmdln( hash ) 92 | UserInputs.each do |q| 93 | puts "Enter the #{q} (default #{hash[q]}): " 94 | input = $stdin.gets.chomp 95 | hash[q] = input if input != "" 96 | end 97 | return hash 98 | end 99 | 100 | def self.setup_paths 101 | home = ENV[ ["HOME", "HOMEPATH"].detect {|h| ENV[h] != nil} ] 102 | raise "Could not find home directory" unless home != nil 103 | root = home + "/#{LocaDir}" 104 | if not File.directory? root 105 | Dir.mkdir( root, 0755 ) 106 | warn("Locality Lab: Directory created at #{root}") 107 | end 108 | depot = root + "/#{DataDir}" 109 | if not File.directory? depot 110 | Dir.mkdir( depot, 0755 ) 111 | warn("Locality Lab: Directory created at #{depot}") 112 | end 113 | @@paths = Hash.new 114 | @@paths[LocaDir] = root 115 | @@paths[ConfigFile] = root + "/" + ConfigFile 116 | @@paths[DataDir] = root + "/" + DataDir 117 | 118 | puts "paths = #{@@paths.inspect}" if Debug 119 | 120 | return @@paths 121 | end 122 | 123 | def self.save_env 124 | File.open(Labenv.paths[ConfigFile], 'w', 0600) do |file| 125 | file.puts Labenv.env.to_yaml 126 | end 127 | end 128 | 129 | def self.read_config 130 | config = Labenv.paths[ConfigFile] 131 | if File.exists?(config) 132 | @@env = YAML::load( File.read(config) ) 133 | end 134 | return @@env 135 | end # def 136 | 137 | def self.hash2arrlist( hash ) 138 | alist = Java::java.util.ArrayList.new 139 | hash.each{ |k,v| 140 | alist.add( Java::myEntry.new( k, v )) 141 | } 142 | return alist 143 | end 144 | 145 | def self.arrlist_update_hash( alist, hash ) 146 | (0...alist.size).each{ |i| 147 | hash[alist.get(i).getKey] = alist.get(i).getValue 148 | } 149 | return hash 150 | end 151 | end 152 | -------------------------------------------------------------------------------- /policies/lirs/lirs-sim/lru.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source lru.c simulate LRU replacement algorithm. 3 | * 4 | * Revised by : Song Jiang 5 | * sjiang@cs.wm.edu 6 | * Revised at Nov 15, 2002 7 | */ 8 | 9 | #include "sim.h" 10 | 11 | 12 | //main() 13 | main(int argc, char* argv[]) 14 | { 15 | FILE *trc_fp, *cuv_fp, *para_fp; 16 | unsigned long i; 17 | char trc_file_name[100]; 18 | char para_file_name[100]; 19 | char cuv_file_name[100]; 20 | 21 | 22 | /*int argc = 3; 23 | char argv[50][50]; 24 | strcpy(argv[1], "2"); 25 | strcpy(argv[2], "ps2"); 26 | */ 27 | 28 | if (argc != 2){ 29 | printf("%s: file_name_prefix[.trc] \n", argv[0]); 30 | return; 31 | } 32 | 33 | 34 | strcpy(para_file_name, argv[1]); 35 | strcat(para_file_name, ".par"); 36 | para_fp = openReadFile(para_file_name); 37 | 38 | 39 | strcpy(trc_file_name, argv[1]); 40 | strcat(trc_file_name, ".trc"); 41 | trc_fp = openReadFile(trc_file_name); 42 | 43 | strcpy(cuv_file_name, argv[1]); 44 | strcat(cuv_file_name, "_LRU.cuv"); 45 | cuv_fp = fopen(cuv_file_name, "w"); 46 | 47 | get_range(trc_fp, &vm_size, &total_ref_pg); 48 | 49 | page_tbl = (page_struct *)calloc(vm_size+1, sizeof(page_struct)); 50 | 51 | while (fscanf(para_fp, "%lu", &mem_size) != EOF){ 52 | if (mem_size <= 0) 53 | break; 54 | 55 | printf("\nmem_size = %ld", mem_size); 56 | 57 | total_ref_pg = 0; 58 | num_pg_flt = 0; 59 | 60 | fseek(trc_fp, 0, SEEK_SET); 61 | 62 | free_mem_size = mem_size; 63 | 64 | /* initialize the page table */ 65 | for (i = 0; i <= vm_size; i++){ 66 | page_tbl[i].ref_times = 0; 67 | page_tbl[i].pf_times = 0; 68 | 69 | page_tbl[i].page_num = i; 70 | page_tbl[i].isResident = 0; 71 | 72 | page_tbl[i].LRU_next = NULL; 73 | page_tbl[i].LRU_prev = NULL; 74 | 75 | page_tbl[i].recency = vm_size+10; 76 | } 77 | 78 | LRU_list_head = NULL; 79 | LRU_list_tail = NULL; 80 | 81 | LRU_Repl(trc_fp); 82 | 83 | 84 | printf("total_ref_pg = %d num_pg_flt = %d \npf ratio = %2.1f\%, mem shortage ratio = %2.1f\% \n", total_ref_pg, num_pg_flt, (float)num_pg_flt/total_ref_pg*100, (float)(vm_size-mem_size)/vm_size*100); 85 | 86 | fprintf(cuv_fp, "%5d %2.1f\n", mem_size, 100-(float)num_pg_flt/total_ref_pg*100); 87 | 88 | } 89 | 90 | return; 91 | } 92 | 93 | 94 | LRU_Repl(FILE *trc_fp) 95 | { 96 | unsigned long ref_page; 97 | long last_ref_pg = -1; 98 | long num = 0; 99 | 100 | page_struct *temp_LRU_ptr; 101 | 102 | fscanf(trc_fp, "%lu", &ref_page); 103 | 104 | while (!feof(trc_fp)){ 105 | page_tbl[ref_page].ref_times++; 106 | 107 | total_ref_pg++; 108 | 109 | if (ref_page > vm_size){ 110 | printf("Wrong ref page number found: %d.\n", ref_page); 111 | return FALSE; 112 | } 113 | 114 | if (ref_page == last_ref_pg){ 115 | fscanf(trc_fp, "%lu", &ref_page); 116 | continue; 117 | } 118 | else 119 | last_ref_pg = ref_page; 120 | 121 | if (!page_tbl[ref_page].isResident) { /* page fault */ 122 | page_tbl[ref_page].pf_times++; 123 | num_pg_flt++; 124 | if (free_mem_size == 0){ /* free the LRU page */ 125 | 126 | LRU_list_tail->isResident = 0; 127 | 128 | temp_LRU_ptr = LRU_list_tail; 129 | 130 | LRU_list_tail = LRU_list_tail->LRU_prev; 131 | LRU_list_tail->LRU_next = NULL; 132 | 133 | temp_LRU_ptr->LRU_prev = NULL; 134 | temp_LRU_ptr->LRU_next = NULL; 135 | free_mem_size++; 136 | 137 | } 138 | page_tbl[ref_page].isResident = 1; 139 | free_mem_size--; 140 | } 141 | else { /* hit in memroy */ 142 | if (page_tbl[ref_page].LRU_prev) 143 | page_tbl[ref_page].LRU_prev->LRU_next = page_tbl[ref_page].LRU_next; 144 | else /* hit at the stack top */ 145 | LRU_list_head = page_tbl[ref_page].LRU_next; 146 | 147 | 148 | if (page_tbl[ref_page].LRU_next) 149 | page_tbl[ref_page].LRU_next->LRU_prev = page_tbl[ref_page].LRU_prev; 150 | else /* hit at the stack bottom */ 151 | LRU_list_tail = page_tbl[ref_page].LRU_prev; 152 | } 153 | 154 | page_tbl[ref_page].LRU_next = LRU_list_head; /* place newly referenced page at head */ 155 | 156 | page_tbl[ref_page].LRU_prev = NULL; 157 | 158 | LRU_list_head = (page_struct *)&page_tbl[ref_page]; 159 | 160 | if (LRU_list_head->LRU_next) 161 | LRU_list_head->LRU_next->LRU_prev = LRU_list_head; 162 | 163 | if (!LRU_list_tail) 164 | LRU_list_tail = LRU_list_head; 165 | 166 | fscanf(trc_fp, "%lu", &ref_page); 167 | if (++num % 10000 == 0) 168 | fprintf(stderr, "%d samples processed\r", num); 169 | 170 | } 171 | 172 | printf("\n"); 173 | return; 174 | } 175 | 176 | 177 | -------------------------------------------------------------------------------- /policies/lru/lru.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A simple implementaion of lru cache. 3 | Every new accessed item will be put at the end of the linked list used in LRU cache. 4 | And when the cache is full, kick out the first item of the list. 5 | 6 | Please change line 84 to the correct directory in your machine. 7 | ''' 8 | 9 | import sys 10 | import os 11 | 12 | ''' 13 | LRU Cache 14 | ''' 15 | 16 | class LRU: 17 | def __init__(self, memory): 18 | self.capacity = memory 19 | self.list = LinkedList(0) 20 | self.hash = {} 21 | self.size = 0 22 | 23 | def access(self, key): 24 | if key in self.hash: 25 | # key existed 26 | key_node = self.hash[key] 27 | self.list.delete(key_node) 28 | self.list.append(key_node) 29 | return True 30 | else: 31 | key_node = KeyNode(key, self.list) 32 | self.hash[key] = key_node 33 | if self.size < self.capacity: 34 | # has room for a new item 35 | self.size += 1 36 | else: 37 | # the cache is full; an item should be kicked out 38 | head = self.list.head 39 | del self.hash[head.next.key] 40 | self.list.delete(head.next) 41 | self.list.append(key_node) 42 | return False 43 | 44 | ''' 45 | helper data structures: KeyNode and LinkedList 46 | ''' 47 | class KeyNode: 48 | def __init__(self, key, ll): 49 | self.key = key 50 | self.prev, self.next = None, None 51 | self.list = ll 52 | 53 | class LinkedList: 54 | def __init__(self, size): 55 | self.size = 0 56 | self.head = KeyNode(0, self) 57 | self.tail = self.head 58 | 59 | # delete a node 60 | def delete(self, node): 61 | if node == self.tail: 62 | self.tail = self.tail.prev 63 | self.tail.next = None 64 | node.next = None 65 | else: 66 | node.prev.next = node.next 67 | node.next.prev = node.prev 68 | node.prev, node.next = None, None 69 | 70 | # append a node at the end of the list 71 | def append(self, node): 72 | self.tail.next = node 73 | node.prev = self.tail 74 | self.tail = node 75 | 76 | 77 | 78 | ''' 79 | simulator part 80 | ''' 81 | ITEM_PER_MB = 256 # every item is 4kb 82 | MEM_UNIT = int(sys.argv[3]) * 16 # 83 | 84 | trace_dir = "../../traces/" 85 | trace_name = str(sys.argv[1]) 86 | mrc, hits, misses = [], [], [] 87 | 88 | # read trace file and get the miss ratio 89 | def run_cache_simulator(memory, trace_path): 90 | global mrc, hits, misses 91 | cache = LRU(memory) 92 | count, hit, miss = 0, 0, 0 93 | with open(trace_path) as trace: 94 | for key in trace: 95 | key = key.strip() #didnt previously get rid of new line character at end of line 96 | count += 1 97 | if cache.access(key) == True: 98 | hit += 1 99 | else: 100 | #print("Count:") 101 | #print(count) 102 | #print("Miss on:") 103 | #print(key) 104 | miss += 1 105 | trace.close() 106 | hits += [hit] 107 | misses += [miss] 108 | #print("Misses:") maybe uncomment if you want it to be scarily verbose 109 | #print(misses) 110 | #print("Hits:") 111 | #print(hits) 112 | mrc += [float(miss) / float(count)] 113 | print("Miss ratio:") 114 | print(mrc) 115 | 116 | 117 | def get_trace_path(): 118 | # return trace_dir + trace_name.split("_")[0] + "/" + trace_name.split("_")[1] + "/trace.tr" 119 | return trace_dir + trace_name + "/trace.tr" 120 | 121 | # write mrc into file 122 | def write_mrc(): 123 | if not os.path.exists("mrcs"): 124 | os.makedirs("mrcs") 125 | mrc_file = open("mrcs/" + "lru_" + trace_name.split("/")[0] + "_" + trace_name.split("/")[1] + "_mrc", "w") 126 | # mrc_file.write("memory accesses misses hits miss_ratio\n") 127 | mrc_file.write("memory miss_ratio\n") 128 | for i in range(0, len(mrc)): 129 | # mrc_file.write(str((i) * MEM_UNIT) + " " + str(misses[i] + hits[i]) + " " + str(misses[i]) + " " + str(hits[i]) + " " + str(mrc[i]) + "\n") 130 | mrc_file.write(str((i + 1) * MEM_UNIT) + " " + str(mrc[i]) + "\n") 131 | mrc_file.close() 132 | 133 | # run cache simulator several times 134 | def get_mrc(): 135 | trace_path = get_trace_path() 136 | for i in range (1, int(sys.argv[2])): 137 | mem = i * MEM_UNIT * ITEM_PER_MB 138 | print("\nMemory space for items: ") 139 | print(mem) 140 | run_cache_simulator(mem, trace_path) 141 | write_mrc() 142 | 143 | def main(): 144 | get_mrc() 145 | 146 | # entrance of the whole program 147 | main() 148 | 149 | -------------------------------------------------------------------------------- /gem/lib/src/hashTableGUI.java: -------------------------------------------------------------------------------- 1 | 2 | import java.awt.BorderLayout; 3 | 4 | import java.awt.Dimension; 5 | 6 | import java.awt.GridLayout; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.awt.event.WindowEvent; 10 | import java.awt.event.WindowListener; 11 | import java.util.ArrayList; 12 | import java.util.concurrent.CountDownLatch; 13 | 14 | import javax.swing.BoxLayout; 15 | import javax.swing.JButton; 16 | import javax.swing.JFrame; 17 | import javax.swing.JLabel; 18 | import javax.swing.JOptionPane; 19 | import javax.swing.JPanel; 20 | import javax.swing.JTextField; 21 | 22 | public class hashTableGUI implements ActionListener, WindowListener{ 23 | 24 | private JButton okButton; 25 | 26 | private JTextField[] tfArray; 27 | 28 | private JLabel[] labArray; 29 | 30 | private CountDownLatch latch; 31 | 32 | private JFrame f; 33 | 34 | public boolean verify(ArrayList> table){ 35 | String message = "Here is the data: \n"; 36 | for(myEntry e: table){ 37 | message += (e.getKey()+ ": " +e.getValue()+ "\n"); 38 | } 39 | String[] choices = {"OK", "MODIFY"}; 40 | int c = JOptionPane.showOptionDialog(null, message, 41 | "Results", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, 42 | null, choices, ""); 43 | if(c == 0){ 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | public ArrayList> getInputs(ArrayList> table){ 50 | instantiateGUI(table); 51 | latch = new CountDownLatch(1); 52 | try { 53 | latch.await(); 54 | } catch (InterruptedException e1) { 55 | // TODO Auto-generated catch block 56 | e1.printStackTrace(); 57 | } 58 | int idx = 0; 59 | for(myEntry e: table){ 60 | e.setValue(tfArray[idx].getText()); 61 | idx++; 62 | } 63 | f.dispose(); 64 | return table; 65 | } 66 | 67 | public void instantiateGUI(ArrayList> table){ 68 | f = new JFrame(); 69 | 70 | tfArray = new JTextField[table.size()]; 71 | labArray = new JLabel[table.size()]; 72 | 73 | int next = 0; 74 | for(myEntry e: table){ 75 | JTextField tf = new JTextField(e.getValue()); 76 | JLabel label = new JLabel(e.getKey()); 77 | tfArray[next] = tf; 78 | labArray[next] = label; 79 | next++; 80 | } 81 | 82 | okButton = new JButton("OK"); 83 | okButton.addActionListener(this); 84 | 85 | JPanel p1 = new JPanel(); 86 | p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS)); 87 | 88 | for(int i = 0; i < table.size(); i++){ 89 | JPanel panel = new JPanel(); 90 | panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); 91 | panel.add(labArray[i]); 92 | panel.add(tfArray[i]); 93 | p1.add(panel); 94 | } 95 | f.add(p1, BorderLayout.CENTER); 96 | f.add(okButton, BorderLayout.SOUTH); 97 | 98 | f.addWindowListener(this); 99 | 100 | f.setTitle("Modify Screen"); 101 | f.setLocationRelativeTo(null); 102 | f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 103 | f.setVisible(true); 104 | f.pack(); 105 | } 106 | 107 | public static void main(String[] args){ 108 | /* */ 109 | ArrayList> table = new ArrayList>(); 110 | table.add(new myEntry("First Name", "Alex simon")); 111 | table.add(new myEntry("Last Name", "")); 112 | table.add(new myEntry("Address", "ssh://p/compiler/hg-repos/loclab/iloveprogramming/doggy")); 113 | table.add(new myEntry("Fav. Color", "Orange")); 114 | table.add(new myEntry("Phone Number", "?")); 115 | 116 | hashTableGUI h = new hashTableGUI(); 117 | table = h.getInputs(table); 118 | table = h.getInputs(table); 119 | h.verify(table); 120 | table = h.getInputs(table); 121 | System.out.println(table.get(0).getValue()); 122 | } 123 | 124 | @Override 125 | public void actionPerformed(ActionEvent e) { 126 | if((e.getSource() == okButton) || (e.getSource() == f)){ 127 | f.dispose(); 128 | } 129 | } 130 | 131 | @Override 132 | public void windowActivated(WindowEvent e) { 133 | // TODO Auto-generated method stub 134 | 135 | } 136 | 137 | @Override 138 | public void windowClosed(WindowEvent e) { 139 | latch.countDown(); 140 | } 141 | 142 | @Override 143 | public void windowClosing(WindowEvent e) { 144 | // TODO Auto-generated method stub 145 | 146 | } 147 | 148 | @Override 149 | public void windowDeactivated(WindowEvent e) { 150 | // TODO Auto-generated method stub 151 | 152 | } 153 | 154 | @Override 155 | public void windowDeiconified(WindowEvent e) { 156 | // TODO Auto-generated method stub 157 | 158 | } 159 | 160 | @Override 161 | public void windowIconified(WindowEvent e) { 162 | // TODO Auto-generated method stub 163 | 164 | } 165 | 166 | @Override 167 | public void windowOpened(WindowEvent e) { 168 | // TODO Auto-generated method stub 169 | 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /policies/lc/lc_with_item_size/lease_bins.h: -------------------------------------------------------------------------------- 1 | #ifndef _L_ORDERED_LEASE_CACHE_H_ 2 | #define _L_ORDERED_LEASE_CACHE_H_ 3 | 4 | #include "hash.h" /* doubly linked list, stack and hash table */ 5 | #include "dll.h" 6 | #include "attrs.h" 7 | #include "declarations.h" 8 | 9 | struct _LOrderedLeaseCache_t { 10 | size_t size; 11 | int32_t max_lease_time; 12 | int32_t tail; /* points to timeout bin */ 13 | struct list_head * bins; 14 | int32_t *bin_size; 15 | 16 | int32_t slab_class; 17 | }; 18 | 19 | LOrderedLeaseCache_t * create_ordered_lease_cache( size_t size, 20 | int32_t max_lease_time, int32_t slab_class) 21 | { 22 | LOrderedLeaseCache_t * lease_cache = 23 | (LOrderedLeaseCache_t *)malloc(sizeof(LOrderedLeaseCache_t)); 24 | memset( lease_cache, 0, sizeof(LOrderedLeaseCache_t) ); 25 | 26 | lease_cache->size = size; 27 | lease_cache->max_lease_time = max_lease_time; 28 | lease_cache->slab_class = slab_class; 29 | lease_cache->bins = 30 | (struct list_head *)malloc(sizeof(struct list_head) * (max_lease_time+1)); 31 | memset(lease_cache->bins, 0, sizeof(struct list_head) * (max_lease_time+1)); 32 | int32_t i; 33 | for ( i =0; i<=max_lease_time; i++ ) { 34 | INIT_LIST_HEAD(&lease_cache->bins[i]); 35 | } 36 | lease_cache->bin_size = (int32_t *)malloc(sizeof(int32_t) * (max_lease_time+1)); 37 | memset( lease_cache->bin_size, 0, sizeof(int32_t) * (max_lease_time+1) ); 38 | 39 | lease_cache->tail = 0; 40 | 41 | return lease_cache; 42 | } 43 | 44 | void destroy_ordered_lease_cache( LOrderedLeaseCache_t * lease_cache ) 45 | { 46 | /* free each bin of bins. */ 47 | int32_t i; 48 | for ( i=0; i<=lease_cache->max_lease_time; i++ ) { 49 | LItem_t * tmp; 50 | LItem_t * n; 51 | HashTableElem_t * m; 52 | list_for_each_entry_safe(tmp, n, &lease_cache->bins[i], list) { 53 | m = tmp->hash_node; 54 | hlist_del(&m->list); 55 | free(m); 56 | list_del(&tmp->list); 57 | free(tmp); 58 | } 59 | } 60 | 61 | free(lease_cache->bins); 62 | free(lease_cache->bin_size); 63 | free(lease_cache); 64 | } 65 | 66 | void add_to_lease_cache( LOrderedLeaseCache_t * lease_cache, LItem_t * item ) 67 | { 68 | /* go to LRU if yes */ 69 | assert ( item->lease_time != 0 && item->lease_time <= lease_cache->max_lease_time ); 70 | 71 | item->lease_or_lru = LEASE; 72 | 73 | int slot; 74 | slot = ( lease_cache->tail + item->lease_time ) % (lease_cache->max_lease_time+1); 75 | 76 | DLLAdd( &lease_cache->bins[slot], &item->list ); 77 | lease_cache->size += 1; 78 | lease_cache->bin_size[slot] += 1; 79 | } 80 | 81 | void update_in_lease_cache( LOrderedLeaseCache_t * lease_cache, LItem_t * item ) 82 | { 83 | DLLRemove( &item->list ); 84 | 85 | int32_t prior_slot, passed_time, last_tail; 86 | passed_time = local_timers[lease_cache->slab_class] - item->last_access_time; 87 | last_tail = ( lease_cache->tail - passed_time + lease_cache->max_lease_time+1 ) % (lease_cache->max_lease_time+1); 88 | prior_slot = ( last_tail + item->lease_time ) % (lease_cache->max_lease_time+1); 89 | lease_cache->bin_size[prior_slot] -= 1; 90 | 91 | int slot; 92 | slot = ( lease_cache->tail + item->lease_time ) % (lease_cache->max_lease_time+1); 93 | 94 | DLLAdd( &lease_cache->bins[slot], &item->list ); 95 | lease_cache->bin_size[slot] += 1; 96 | } 97 | 98 | void remove_from_lease_cache( LOrderedLeaseCache_t * lease_cache, LItem_t * item ) 99 | { 100 | DLLRemove( &item->list ); 101 | 102 | int32_t prior_slot, passed_time, last_tail; 103 | passed_time = local_timers[lease_cache->slab_class] - item->last_access_time; 104 | last_tail = ( lease_cache->tail - passed_time + lease_cache->max_lease_time+1 ) % (lease_cache->max_lease_time+1); 105 | prior_slot = ( last_tail + item->lease_time ) % (lease_cache->max_lease_time+1); 106 | lease_cache->bin_size[prior_slot] -= 1; 107 | lease_cache->size -= 1; 108 | } 109 | 110 | void offload_timeout_bin_of_lease_cache( LOrderedLeaseCache_t * lease_cache, LLRUCache_t * lru_cache ) 111 | { 112 | struct list_head * timeout_bin_head = &lease_cache->bins[lease_cache->tail]; 113 | 114 | if ( DLLEmpty( timeout_bin_head ) ) goto UPDATE_TAIL; 115 | 116 | /* not empty, change lease_or_lru of the offloaded items to LRU */ 117 | LItem_t * tmp; 118 | list_for_each_entry(tmp, &lease_cache->bins[lease_cache->tail], list) { 119 | tmp->lease_or_lru = LRU; 120 | } 121 | 122 | struct list_head * timeout_bin_first_node = timeout_bin_head->next; 123 | struct list_head * timeout_bin_tail_node = timeout_bin_head->prev; 124 | /* clear this bin */ 125 | INIT_LIST_HEAD( timeout_bin_head ); 126 | 127 | /* link this bin to LRU cache */ 128 | struct list_head * lru_cache_head = &lru_cache->the_cache; 129 | struct list_head * lru_cache_first_node = lru_cache_head->next; 130 | 131 | lru_cache_first_node->prev = timeout_bin_tail_node; 132 | timeout_bin_tail_node->next = lru_cache_first_node; 133 | lru_cache_head->next = timeout_bin_first_node; 134 | timeout_bin_first_node->prev = lru_cache_head; 135 | 136 | /* change cache sizes */ 137 | lease_cache->size -= lease_cache->bin_size[lease_cache->tail]; 138 | lru_cache->size += lease_cache->bin_size[lease_cache->tail]; 139 | lease_cache->bin_size[lease_cache->tail] = 0; 140 | 141 | UPDATE_TAIL: 142 | /* update tail */ 143 | lease_cache->tail = ( lease_cache->tail + 1 ) % (lease_cache->max_lease_time+1); 144 | } 145 | 146 | #endif /*_L_ORDERED_LEASE_CACHE_H_*/ 147 | -------------------------------------------------------------------------------- /policies/2q/2q.py: -------------------------------------------------------------------------------- 1 | ''' 2 | An implementation of 2Q cache. 3 | In this implementation, the FIFO list and LRU list is the same length. 4 | ''' 5 | 6 | import os 7 | import sys 8 | 9 | MAX_ACCESS = 8000000 10 | 11 | 12 | class TwoQ: 13 | def __init__(self, capacity): 14 | self.capacity = capacity 15 | self.lru_list = LinkedList(int(capacity / 2)) 16 | self.fifo_list = LinkedList(int(capacity / 2)) 17 | self.lru_nodes = {} 18 | self.fifo_nodes = {} 19 | self.size = 0 20 | 21 | def access(self, key): 22 | # print(key) 23 | if key in self.fifo_nodes: 24 | # the node is in fifo; should put it in lru 25 | node = self.fifo_nodes[key] 26 | self.fifo_list.delete_node(node) # delete from fifo 27 | del self.fifo_nodes[key] 28 | if self.lru_list.size >= self.lru_list.capacity: 29 | del self.lru_nodes[self.lru_list.tail.key] 30 | self.lru_list.delete_tail() 31 | print("yo") 32 | self.lru_list.insert_front(node) 33 | self.lru_nodes[key] = node 34 | return True 35 | elif key in self.lru_nodes: 36 | # the node is in lru list; move it to the head of the list 37 | node = self.lru_nodes[key] 38 | self.lru_list.delete_node(node) 39 | self.lru_list.insert_front(node) 40 | #size remains same 41 | return True 42 | else: 43 | # miss 44 | node = Node(key) 45 | if self.fifo_list.size >= self.fifo_list.capacity: 46 | # FIFO is full 47 | del self.fifo_nodes[self.fifo_list.tail.key] 48 | self.fifo_list.delete_tail() 49 | self.fifo_list.insert_front(node) 50 | self.fifo_nodes[key] = node 51 | #size increases by 1 or stays the same size, if full 52 | return False 53 | 54 | 55 | class Node: 56 | def __init__(self, key): 57 | self.key = key 58 | self.prev, self.next = None, None 59 | 60 | class LinkedList: 61 | def __init__(self, capacity): 62 | self.capacity = capacity 63 | self.size = 0; 64 | self.head = Node(0) 65 | self.tail = self.head 66 | 67 | # insert a node at the head of the list 68 | def insert_front(self, node): 69 | node.next = self.head.next 70 | self.head.next = node 71 | node.prev = self.head 72 | if node.next is not None: 73 | node.next.prev = node 74 | else: 75 | self.tail = node 76 | self.size += 1 77 | 78 | def delete_node(self, node): 79 | if node == self.tail: 80 | self.tail = self.tail.prev 81 | self.tail.next = None 82 | node.prev = node.next = None 83 | else: 84 | node.prev.next = node.next 85 | node.next.prev = node.prev 86 | node.prev, node.next = None, None 87 | self.size -= 1 88 | 89 | def delete_tail(self): 90 | # self.delete_node(self.tail) 91 | self.tail = self.tail.prev 92 | self.tail.next.prev = None 93 | self.tail.next = None 94 | self.size -= 1 95 | 96 | # delete the first node of the linked list 97 | def delete_first(self): 98 | self.head.next = self.head.next.next 99 | if self.head.next is not None: 100 | self.head.next.prev = head 101 | else: 102 | # the deleted node is the only node in this linked list 103 | self.tail = head 104 | self.size -= 1 105 | 106 | ''' 107 | simulator part 108 | ''' 109 | 110 | #its 256 everywhere else so i changed this from 128 to 256 111 | ITEM_PER_MB = 256 112 | # MEM_UNIT = 256 113 | MEM_UNIT = int(sys.argv[3]) * 16 # set 256MB as one memory unit 114 | 115 | trace_dir = "../../traces/" 116 | # trace_name = input("input trace name: ") # e.g. facebook_trace3 117 | trace_name = str(sys.argv[1]) 118 | mrc, hits, misses = [], [], [] 119 | 120 | 121 | # read trace file and get the final miss ratio 122 | def run_cache_simulator(memory, trace_path): 123 | global mrc, hits, misses 124 | # print("given memory: " + str(memory)) 125 | cache = TwoQ(memory) 126 | count, hit, miss = 0, 0, 0 127 | real_size = 0 128 | with open(trace_path) as trace: 129 | for key in trace: 130 | key = key.strip() 131 | count += 1 132 | if cache.access(key) == True: 133 | hit += 1 134 | else: 135 | miss += 1 136 | trace.close() 137 | hits += [hit] 138 | misses += [miss] 139 | mrc += [float(miss) / float(count)] 140 | 141 | 142 | def get_trace_path(): 143 | # return trace_dir + trace_name.split("_")[0] + "/" + trace_name.split("_")[1] + "/trace.tr" 144 | return trace_dir + trace_name + "/trace.tr" 145 | 146 | # write mrc into file 147 | def write_mrc(): 148 | if not os.path.exists("mrcs"): 149 | os.makedirs("mrcs") 150 | mrc_file = open("mrcs/" + "2q_" + trace_name.split("/")[0] + "_" + trace_name.split("/")[1] + "_mrc", "w") 151 | # mrc_file.write("memory accesses misses hits miss_ratio\n") 152 | mrc_file.write("memory miss_ratio\n") 153 | for i in range(0, len(mrc)): 154 | # mrc_file.write(str((i + 1) * MEM_UNIT) + " " + str(misses[i] + hits[i]) + " " + str(misses[i]) + " " + str(hits[i]) + " " + str(mrc[i]) + "\n") 155 | mrc_file.write(str((i + 1) * MEM_UNIT) + " " + str(mrc[i]) + "\n") 156 | mrc_file.close() 157 | 158 | # run cache simulator several times 159 | def get_mrc(): 160 | trace_path = get_trace_path() 161 | for i in range (1, int(sys.argv[2])): 162 | mem = i * MEM_UNIT * ITEM_PER_MB 163 | print("Capacity:") 164 | print(mem) 165 | run_cache_simulator(mem, trace_path) 166 | write_mrc() 167 | 168 | def main(): 169 | get_mrc() 170 | 171 | # entrance of the whole program 172 | main() 173 | 174 | -------------------------------------------------------------------------------- /doc/Site/Scripts/Widgets/Navbar/navbar.js: -------------------------------------------------------------------------------- 1 | // 2 | // iWeb - navbar.js 3 | // Copyright (c) 2007-2008 Apple Inc. All rights reserved. 4 | // 5 | 6 | var NavBar=Class.create(Widget,{widgetIdentifier:"com-apple-iweb-widget-NavBar",initialize:function($super,instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp) 7 | {if(instanceID) 8 | {$super(instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp);if(!this.preferenceForKey("useStaticFeed")&&this.preferenceForKey("dotMacAccount")) 9 | {var depthPrefix=this.preferenceForKey("path-to-root");if(!depthPrefix||depthPrefix=="") 10 | depthPrefix="./";this.xml_feed=depthPrefix+"?webdav-method=truthget&depth=infinity&ns=iweb&filterby=in-navbar";} 11 | else 12 | {this.xml_feed="feed.xml";if(this.sitePath) 13 | {this.xml_feed=this.sitePath+"/"+this.xml_feed;}} 14 | this.changedPreferenceForKey("navbar-css");this.regenerate();}},regenerate:function() 15 | {new Ajax.Request(this.xml_feed,{method:'get',onSuccess:this.populateNavItems.bind(this)});return true;},getStyleElement:function(key) 16 | {if(!this.styleElement) 17 | {var head=document.getElementsByTagName("head")[0];if(head) 18 | {var newElement=document.createElement("style");newElement.type="text/css";head.appendChild(newElement);this.styleElement=newElement;}} 19 | return this.styleElement;},substWidgetPath:function(text) 20 | {var result=text.replace(/\$WIDGET_PATH/gm,this.widgetPath);return result;},addCSSSelectorPrefix:function(text) 21 | {var prefix="div#"+this.instanceID+" ";text=text.replace(/\/\*[^*]*\*+([^/][^*]*\*+)*\//gm,"");text=text.replace(/(^\s*|\}\s*)([^{]+)({[^}]*})/gm,function(match,beforeSelectorList,selectorList,propertyList){var result=beforeSelectorList;var selectors=selectorList.split(",");for(var i=0;i 2 | #include 3 | #include 4 | 5 | #include "pin.H" 6 | #include "xed-portability.h" 7 | #include "histo.H" 8 | 9 | using namespace std; 10 | using namespace histo; 11 | KNOB KnobResultFile(KNOB_MODE_WRITEONCE, "pintool", 12 | "o", "fp.out", "specify result file name"); 13 | 14 | #include 15 | #include 16 | #include 17 | #include "histo.H" 18 | //#include 19 | 20 | /* ===================================================================== */ 21 | /* Global Variables */ 22 | /* ===================================================================== */ 23 | std::ofstream ResultFile; 24 | 25 | #define MAP_SIZE 0x4000000 //todo: if long is 64bit, size should be larger 26 | //#define MAP_SIZE (1<<18) //around cache size: 8M = 2**23/(2**6) = 2**17 27 | #define WORDSHIFT 6 28 | #define Index(x) (x>>WORDSHIFT)%MAP_SIZE 29 | // #define MAX_WINDOW 225 //8*28+1 do not count the window size>1 billion 30 | typedef unsigned int stamp_t; 31 | typedef unsigned long stamp_addr; 32 | typedef unsigned long long stamp_tt; 33 | 34 | const uint32_t SUBLOG_BITS = 8; 35 | const uint32_t MAX_WINDOW = (65-SUBLOG_BITS)*(1< (N-prev_access); 74 | 75 | if(!prev_access){ 76 | M++; 77 | first_count_i[idx] += N - prev_access; 78 | first_my_count[idx] += 1; 79 | }else{ 80 | count_i[idx] += N - prev_access; 81 | my_count[idx] += 1; 82 | } 83 | 84 | // if(( N >= threshold) || (M >= cache_threshold)) 85 | // { 86 | // PIN_ExitApplication(0); 87 | // } 88 | 89 | } 90 | 91 | 92 | VOID Instruction(INS ins, VOID *v) { 93 | // Instruments loads using a predicated call, i.e. 94 | // the call happens iff the load will be actually executed. 95 | // The IA-64 architecture has explicitly predicated instructions. 96 | // On the IA-32 and Intel(R) 64 architectures conditional moves and REP 97 | // prefixed instructions appear as predicated instructions in Pin. 98 | if (INS_IsMemoryRead(ins)) { 99 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 100 | IARG_INST_PTR, IARG_MEMORYREAD_EA, 101 | IARG_END); 102 | } 103 | if (INS_HasMemoryRead2(ins)) { 104 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 105 | IARG_INST_PTR, IARG_MEMORYREAD2_EA, 106 | IARG_END); 107 | } 108 | if (INS_IsMemoryWrite(ins)) { 109 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 110 | IARG_INST_PTR, IARG_MEMORYWRITE_EA, 111 | IARG_END); 112 | } 113 | } 114 | 115 | 116 | 117 | /* ===================================================================== */ 118 | 119 | VOID Fini(INT32 code, VOID *v){ 120 | 121 | gettimeofday(&finish, 0); 122 | stamp_t time = (finish.tv_sec - start.tv_sec); 123 | stamp_t i, idx; 124 | stamp_tt ws, tmp; 125 | 126 | ResultFile.open(KnobResultFile.Value().c_str()); 127 | ResultFile << "N:" << N << " M:" << M << " total_time:" << time << endl; 128 | 129 | for(i=0;i(tmp); 134 | first_my_count[idx]+=1; 135 | first_count_i[idx]+=tmp; 136 | } 137 | 138 | double sum=0.0, sum_i=0.0, fp, mr=1.0; 139 | 140 | for(i=1;i<=sublog_value_to_index(N);i++){ 141 | ws = sublog_index_to_value(i); 142 | fp = (1.0*((N-sum)*ws+sum_i))/(N-ws+1); 143 | sum_i += count_i[i] + first_count_i[i]; 144 | sum += my_count[i] + first_my_count[i]; 145 | // ResultFile << i << "\t" << ws << "\t" << fp << "\t" << count_i[i] << "\t"; 146 | //ResultFile << my_count[i] << "\t" << first_count_i[i] << "\t" << first_my_count[i] << endl; 147 | mr -= my_count[i]*1.0/N; 148 | ResultFile << i << "\t" << ws << "\t" << fp << "\t" << my_count[i]*1.0/N << "\t" << mr << endl; 149 | } 150 | ResultFile.close(); 151 | 152 | } 153 | 154 | /* ===================================================================== */ 155 | 156 | int main(int argc, char *argv[]) 157 | { 158 | if( PIN_Init(argc,argv) ) 159 | { 160 | return Usage(); 161 | } 162 | 163 | memset (stamps, 0, MAP_SIZE*sizeof(stamp_t)); 164 | memset (my_count, 0, MAX_WINDOW*sizeof(stamp_tt)); 165 | memset (count_i, 0, MAX_WINDOW*sizeof(stamp_tt)); 166 | 167 | INS_AddInstrumentFunction(Instruction, 0); 168 | PIN_AddFiniFunction(Fini, 0); 169 | 170 | gettimeofday(&start, 0); 171 | 172 | // Never returns 173 | PIN_StartProgram(); 174 | 175 | return 0; 176 | } 177 | 178 | /* ===================================================================== */ 179 | /* eof */ 180 | /* ===================================================================== */ 181 | -------------------------------------------------------------------------------- /policies/lfu/lfu.py: -------------------------------------------------------------------------------- 1 | ''' 2 | An implementation of LFU cache. 3 | This implementation is not perfect; it can onlt deal with traces with no more than 8,000,000 accesses. 4 | ''' 5 | 6 | import os 7 | import sys 8 | 9 | MAX_ACCESS = 8000000 10 | BIN_NUM = 180000 # 1 + 2 + ... + 4000 > 8,000,000 11 | 12 | class LFU: 13 | def __init__(self, capacity): 14 | self.capacity = capacity 15 | self.list = LinkedList() # maintain nodes in frequency-decreasing order 16 | self.nodes = {} 17 | self.freqs = [] 18 | self.size = 0 19 | for i in range(BIN_NUM): 20 | self.freqs += [LinkedList()] 21 | 22 | # access a key 23 | def access(self, key): 24 | # print(key) 25 | if key in self.nodes: 26 | # hit 27 | node = self.nodes[key] 28 | node.freq += 1 29 | node.list.delete_node(node) # delete from original ll 30 | node.list = self.freqs[node.freq] 31 | node.list.insert_front(node) 32 | return True 33 | else: 34 | # miss 35 | new_node = Node(key, self.freqs[1]) # create a new node with frequency set to 1 36 | if self.size >= self.capacity: 37 | # need kick out an item 38 | target_ll = None 39 | for ll in self.freqs: 40 | if ll.size > 0: 41 | target_ll = ll 42 | break 43 | del self.nodes[target_ll.tail.key] # delete from hashtable 44 | target_ll.delete_tail() # delete from ll 45 | else: 46 | self.size += 1 47 | self.nodes[key] = new_node 48 | self.freqs[1].insert_front(new_node) # insert in the front of ll with frequency 1 49 | return False 50 | 51 | 52 | class Node: 53 | def __init__(self, key, ll): 54 | self.key = key 55 | self.list = ll 56 | self.prev, self.next = None, None 57 | self.freq = 1 58 | 59 | class LinkedList: 60 | def __init__(self): 61 | self.size = 0; 62 | self.head = Node(0, self) 63 | self.tail = self.head 64 | 65 | # insert a node at the head of the list 66 | def insert_front(self, node): 67 | node.next = self.head.next 68 | self.head.next = node 69 | node.prev = self.head 70 | if node.next is not None: 71 | node.next.prev = node 72 | else: 73 | self.tail = node 74 | self.size += 1 #increase size on hit? Has to go. 75 | # if self.tail == self.head: 76 | # print(str(node.key) + " " + str(self.size)) 77 | 78 | # append a node at the end of the linked list 79 | def append(self, node): 80 | self.tail.next = node 81 | node.prev = self.tail 82 | self.tail = node 83 | 84 | def delete_node(self, node): 85 | if node == self.tail: 86 | self.tail = self.tail.prev 87 | self.tail.next = None 88 | node.next = None 89 | else: 90 | node.prev.next = node.next 91 | node.next.prev = node.prev 92 | node.prev, node.next = None, None 93 | self.size -= 1 94 | 95 | # node.prev.next = node.next 96 | # if node.next is not None: 97 | # node.next.prev = node.prev 98 | # else: 99 | # # delete the tail 100 | # self.tail = self.head 101 | # node.prev = node.next = None # not neccessary 102 | # self.size -= 1 103 | 104 | def delete_tail(self): 105 | # self.delete_node(self.tail) 106 | self.tail = self.tail.prev 107 | self.tail.next.prev = None 108 | self.tail.next = None 109 | self.size -= 1 110 | 111 | # delete the first node of the linked list 112 | def delete_first(self): 113 | self.head.next = self.head.next.next 114 | if self.head.next is not None: 115 | self.head.next.prev = head 116 | else: 117 | # the deleted node is the only node in this linked list 118 | self.tail = head 119 | self.size -= 1 120 | 121 | 122 | ''' 123 | simulator part 124 | ''' 125 | 126 | #WHY IS IT 128 here and not 256 like it is everywhere else? 127 | ITEM_PER_MB = 256 128 | # MEM_UNIT = 256 129 | MEM_UNIT = int(sys.argv[3]) * 16 # set 256MB as one memory unit 130 | 131 | trace_dir = "../../traces/" 132 | # trace_name = input("input trace name: ") # e.g. facebook_trace3 133 | trace_name = str(sys.argv[1]) 134 | mrc, hits, misses = [], [], [] 135 | 136 | 137 | # read trace file and get the final miss ratio 138 | def run_cache_simulator(memory, trace_path): 139 | global mrc, hits, misses 140 | cache = LFU(memory) 141 | print("Capacity:") 142 | print(cache.capacity) 143 | count, hit, miss = 0, 0, 0 144 | with open(trace_path) as trace: 145 | for key in trace: 146 | key = key.strip() 147 | count += 1 148 | if cache.access(key) == True: 149 | hit += 1 150 | else: 151 | miss += 1 152 | trace.close() 153 | hits += [hit] 154 | misses += [miss] 155 | mrc += [float(miss) / float(count)] 156 | 157 | 158 | def get_trace_path(): 159 | # return trace_dir + trace_name.split("_")[0] + "/" + trace_name.split("_")[1] + "/trace.tr" 160 | return trace_dir + trace_name + "/trace.tr" 161 | 162 | # write mrc into file 163 | def write_mrc(): 164 | if not os.path.exists("mrcs"): 165 | os.makedirs("mrcs") 166 | mrc_file = open("mrcs/" + "lfu_" + trace_name.split("/")[0] + "_" + trace_name.split("/")[1] + "_mrc", "w") 167 | # mrc_file.write("memory accesses misses hits miss_ratio\n") 168 | mrc_file.write("memory miss_ratio\n") 169 | for i in range(0, len(mrc)): 170 | # mrc_file.write(str((i + 1) * MEM_UNIT) + " " + str(misses[i] + hits[i]) + " " + str(misses[i]) + " " + str(hits[i]) + " " + str(mrc[i]) + "\n") 171 | mrc_file.write(str((i + 1) * MEM_UNIT) + " " + str(mrc[i]) + "\n") 172 | mrc_file.close() 173 | # for i in range(1, len(mrc) + 1): 174 | # mrc_file.write(str(i) + " " + str(mrc[i - 1]) + "\n") 175 | # mrc_file.close() 176 | 177 | # run cache simulator several times 178 | def get_mrc(): 179 | trace_path = get_trace_path() 180 | for i in range (1, int(sys.argv[2])): 181 | mem = i * MEM_UNIT * ITEM_PER_MB 182 | run_cache_simulator(mem, trace_path) 183 | write_mrc() 184 | 185 | def main(): 186 | get_mrc() 187 | 188 | # entrance of the whole program 189 | main() 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /gem/lib/src/Footprint/dual_fp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "pin.H" 6 | #include "xed-portability.h" 7 | #include "histo.H" 8 | 9 | using namespace std; 10 | using namespace histo; 11 | KNOB KnobResultFile(KNOB_MODE_WRITEONCE, "pintool", 12 | "o", "dual_fp.out", "specify result file name"); 13 | 14 | #include 15 | #include 16 | #include 17 | #include "histo.H" 18 | //#include 19 | 20 | /* ===================================================================== */ 21 | /* Global Variables */ 22 | /* ===================================================================== */ 23 | std::ofstream ResultFile; 24 | 25 | #define MAP_SIZE 0x4000000 //todo: if long is 64bit, size should be larger 26 | //#define MAP_SIZE (1<<18) //around cache size: 8M = 2**23/(2**6) = 2**17 27 | #define WORDSHIFT1 6 28 | #define WORDSHIFT2 2 29 | #define Index1(x) (x>>WORDSHIFT1)%MAP_SIZE 30 | #define Index2(x) (x>>WORDSHIFT2)%MAP_SIZE 31 | // #define MAX_WINDOW 225 //8*28+1 do not count the window size>1 billion 32 | typedef unsigned int stamp_t; 33 | typedef unsigned long stamp_addr; 34 | typedef unsigned long long stamp_tt; 35 | 36 | const uint32_t SUBLOG_BITS = 8; 37 | const uint32_t MAX_WINDOW = (65-SUBLOG_BITS)*(1< (N-prev_access); 84 | 85 | if(!prev_access){ 86 | M[i] ++; 87 | first_count_i[idx][i] += N - prev_access; 88 | first_count[idx][i] += 1; 89 | }else{ 90 | count_i[idx][i] += N - prev_access; 91 | lcount[idx][i] += 1; 92 | } 93 | } 94 | 95 | // if(( N >= threshold) || (M >= cache_threshold)) 96 | // { 97 | // PIN_ExitApplication(0); 98 | // } 99 | 100 | } 101 | 102 | 103 | VOID Instruction(INS ins, VOID *v) { 104 | // Instruments loads using a predicated call, i.e. 105 | // the call happens iff the load will be actually executed. 106 | // The IA-64 architecture has explicitly predicated instructions. 107 | // On the IA-32 and Intel(R) 64 architectures conditional moves and REP 108 | // prefixed instructions appear as predicated instructions in Pin. 109 | if (INS_IsMemoryRead(ins)) { 110 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 111 | IARG_INST_PTR, IARG_MEMORYREAD_EA, 112 | IARG_END); 113 | } 114 | if (INS_HasMemoryRead2(ins)) { 115 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 116 | IARG_INST_PTR, IARG_MEMORYREAD2_EA, 117 | IARG_END); 118 | } 119 | if (INS_IsMemoryWrite(ins)) { 120 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 121 | IARG_INST_PTR, IARG_MEMORYWRITE_EA, 122 | IARG_END); 123 | } 124 | } 125 | 126 | 127 | 128 | /* ===================================================================== */ 129 | 130 | VOID Fini(INT32 code, VOID *v){ 131 | 132 | gettimeofday(&finish, 0); 133 | stamp_t time = (finish.tv_sec - start.tv_sec); 134 | stamp_t i, idx, k; 135 | stamp_tt ws, tmp; 136 | 137 | ResultFile.open(KnobResultFile.Value().c_str()); 138 | ResultFile << "N:" << N << " M1:" << M[0] << " M2:" << M[1] << " total_time:" << time << endl; 139 | 140 | for(k = 0; k < 2; k++) { 141 | for(i = 0; i < MAP_SIZE; i++){ 142 | if(!stamps[i][k]) 143 | continue; 144 | tmp = N-stamps[i][k] + 1; 145 | idx = sublog_value_to_index(tmp); 146 | first_count[idx][k] += 1; 147 | first_count_i[idx][k] += tmp; 148 | } 149 | } 150 | 151 | double sum=0.0, sum_i=0.0, fp, mr=1.0; 152 | double sum2=0.0, sum_i2=0.0, fp2, mr2=1.0; 153 | 154 | for(i=1;i<=sublog_value_to_index(N);i++){ 155 | ws = sublog_index_to_value(i); 156 | fp = ( 1.0 * (( N - sum ) * ws + sum_i)) / ( N - ws + 1 ); 157 | sum_i += count_i[i][0] + first_count_i[i][0]; 158 | sum += lcount[i][0] + first_count[i][0]; 159 | mr -= lcount[i][0] * 1.0 / N; 160 | ResultFile << i << "\t" << ws << "\t" << fp*(1< 62 | req = request.path # req looks like /program.dat or foldername 63 | fullreq = File.join(HomeDir, req) # fullreq is path/req 64 | ext = File.extname(req) 65 | currentDir = File.join("#{LocaServerDir}/", File.dirname(req)) #{}"./" 66 | 67 | ## Create list of items in directory. 68 | if File.directory?(fullreq) 69 | if req == "/" 70 | currentDir = "#{LocaServerDir}/" 71 | else 72 | currentDir = File.join("#{LocaServerDir}/", req) 73 | end 74 | 75 | files, dirs = Server.browse(currentDir) 76 | htmlString = Server.headMatter(currentDir) 77 | htmlString += Server.tableSection(currentDir, files, dirs) 78 | htmlString += Server.footMatter() 79 | 80 | htmlFile = File.new(".current.html", "w") 81 | htmlFile.write(htmlString) 82 | htmlFile.close 83 | 84 | contents = File.open(".current.html", 'r') { |f| f.read } 85 | headers = { 86 | 'Content-Type' => 'text/html', 87 | 'Content-Length' => contents.bytesize.to_s, 88 | } 89 | ## Create contents of the plotting page. 90 | elsif ext =~ /[a|i|d|dat]$/ or ext == ".fp" 91 | program = File.basename(req, ext) # strips .dat or .fp from req. 92 | ## Create HTML files to display dynamic picture. 93 | if ext =~ /[a|i|d|dat]$/ 94 | ["fp", "lf", "mr", "rd"].each do |metric| 95 | File.open("#{LocaServerDir}/#{program}.#{metric}.html", "w") do |imageHTML| 96 | imageHTML.puts Server.imagePage(currentDir, "#{program}", "#{metric}", false) 97 | end 98 | end 99 | else 100 | ["fp", "lf"].each do |metric| 101 | File.open("#{LocaServerDir}/#{program}.#{metric}.html", "w") do |imageHTML| 102 | imageHTML.puts Server.imagePage(currentDir, "#{program}", "#{metric}", true) 103 | end 104 | end 105 | end 106 | 107 | ## Plot the graphs. 108 | # If .png file doesn't exist, make it. 109 | # .fp file may update, so re-plot anyway 110 | if !File.file?(File.join("./data/", "#{program}.fp.png")) or ext == ".fp" 111 | if ext =~ /[a|i|d|dat]$/ 112 | Plot.default(currentDir, program, ext) 113 | else 114 | Plot_p.default(currentDir, program, ext) 115 | end 116 | end 117 | 118 | ## If the request is a post, read form data and plot 119 | # the zoomed images. 120 | if (request.post?) 121 | ## If the range form has been submitted, 122 | # plot that range and go to the same plot. 123 | # Else If the plot type form has been submitted, go to that plot. 124 | if (request.params["whichForm"] == "rangeForm") 125 | program = request.params["program"] 126 | metric = request.params["metric"] 127 | xmin = request.params["xmin"].to_f 128 | xmax = request.params["xmax"].to_f 129 | if ext =~ /[a|i|d|dat]$/ 130 | Plot.zoom(currentDir, program, ext, xmin, xmax, metric) 131 | else 132 | Plot_p.zoom(currentDir, program, ext, xmin, xmax, metric) 133 | end 134 | 135 | plothtml = "#{LocaServerDir}/#{program}.#{metric}.html" 136 | contents = File.open(plothtml, 'r') { |f| f.read } 137 | elsif (request.params["whichForm"] == "typeForm") 138 | goToMetric = request.params["goToMetric"] 139 | contents = File.open("#{LocaServerDir}/#{program}.#{goToMetric}.html", 'r') { |f| f.read } 140 | end 141 | else 142 | contents = File.open("#{LocaServerDir}/#{program}.fp.html", 'r') { |f| f.read } 143 | end 144 | 145 | ## Create headers. 146 | headers = { 147 | 'Content-Type' => 'text/html', 148 | 'Content-Length' => contents.bytesize.to_s, 149 | } 150 | 151 | else 152 | req = (req == '/') ? '.current.html' : ".#{req}" 153 | type = case req 154 | when /\.html$/ then 155 | 'text/html' 156 | when /\.gif$/ then 157 | 'image/gif' 158 | when /\.ico$/ then 159 | 'image/x-icon' 160 | when /\.pdf$/ then 161 | 'image/png' 162 | else 163 | 'text/plain' 164 | end 165 | 166 | return unless File.file?(req) 167 | contents = File.open(req, 'r') { |file| file.read } 168 | headers = { 169 | 'Content-Type' => type, 170 | 'Content-Length' => contents.bytesize.to_s, 171 | } 172 | end 173 | response = [200, headers, [contents]] 174 | end 175 | end 176 | class UpServer 177 | def call(env) 178 | 179 | request = Rack::Request.new(env) 180 | name = '' 181 | if (request.path == '/upload') 182 | name = request.params["upload"][:filename] 183 | puts name 184 | if (name =~ /.dat([.][a|i|d])?$/ or name =~ /.info$/ or name =~ /.fp$/) #check file type 185 | basename = "#{HomeDir}/#{name}" 186 | FileUtils.cp(basename, "#{LocaServerDir}/data/") 187 | res = File.open(basename, "wb") 188 | res.puts request.params["upload"][:tempfile].readlines 189 | res.close 190 | end 191 | end 192 | contents = '' 193 | if name =~ /.dat([.][a|i|d])?$/ or name =~ /.fp$/ 194 | contents = "data/#{name}" 195 | end 196 | headers = { 197 | 'Content-Length' => contents.bytesize.to_s, 198 | } 199 | response = [200, headers, [contents]] 200 | end 201 | end 202 | 203 | s = CServer.new 204 | up = UpServer.new 205 | 206 | app = Rack::Builder.new do 207 | map('/') { run s } 208 | map('/upload') { run up } 209 | end 210 | 211 | Rack::Handler::WEBrick.run(app, :Port => 3000) 212 | -------------------------------------------------------------------------------- /gem/lib/src/Footprint/dual_fp_all.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "pin.H" 6 | #include "xed-portability.h" 7 | #include "histo.H" 8 | 9 | using namespace std; 10 | using namespace histo; 11 | KNOB KnobResultFile(KNOB_MODE_WRITEONCE, "pintool", 12 | "o", "dual_fp.out", "specify result file name"); 13 | KNOB KnobProfileMode(KNOB_MODE_WRITEONCE, "pintool", 14 | "m","1", "instruction or/and data: data(1), inst(2), both(3)"); 15 | 16 | #include 17 | #include 18 | #include 19 | #include "histo.H" 20 | //#include 21 | 22 | /* ===================================================================== */ 23 | /* Global Variables */ 24 | /* ===================================================================== */ 25 | std::ofstream ResultFile; 26 | 27 | #define MAP_SIZE 0x4000000 //todo: if long is 64bit, size should be larger 28 | //#define MAP_SIZE (1<<18) //around cache size: 8M = 2**23/(2**6) = 2**17 29 | #define WORDSHIFT1 6 30 | #define WORDSHIFT2 2 31 | #define Index1(x) (x>>WORDSHIFT1)%MAP_SIZE 32 | #define Index2(x) (x>>WORDSHIFT2)%MAP_SIZE 33 | // #define MAX_WINDOW 225 //8*28+1 do not count the window size>1 billion 34 | typedef unsigned int stamp_t; 35 | typedef unsigned long stamp_addr; 36 | typedef unsigned long long stamp_tt; 37 | 38 | const uint32_t SUBLOG_BITS = 8; 39 | const uint32_t MAX_WINDOW = (65-SUBLOG_BITS)*(1< (N-prev_access); 86 | 87 | if(!prev_access){ 88 | M[i] ++; 89 | first_count_i[idx][i] += N - prev_access; 90 | first_count[idx][i] += 1; 91 | }else{ 92 | count_i[idx][i] += N - prev_access; 93 | lcount[idx][i] += 1; 94 | } 95 | } 96 | 97 | // if(( N >= threshold) || (M >= cache_threshold)) 98 | // { 99 | // PIN_ExitApplication(0); 100 | // } 101 | 102 | } 103 | 104 | 105 | VOID RecordMem(VOID * ip, VOID * addr) 106 | { 107 | Record((ADDRINT)addr); 108 | } 109 | 110 | VOID RecordInst(VOID *ip) 111 | { 112 | Record((ADDRINT)ip); 113 | } 114 | 115 | 116 | VOID Instruction(INS ins, VOID *v) { 117 | // Instruments loads using a predicated call, i.e. 118 | // the call happens iff the load will be actually executed. 119 | // The IA-64 architecture has explicitly predicated instructions. 120 | // On the IA-32 and Intel(R) 64 architectures conditional moves and REP 121 | // prefixed instructions appear as predicated instructions in Pin. 122 | if(profile_data){ 123 | if (INS_IsMemoryRead(ins)) { 124 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 125 | IARG_INST_PTR, IARG_MEMORYREAD_EA, 126 | IARG_END); 127 | } 128 | if (INS_HasMemoryRead2(ins)) { 129 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 130 | IARG_INST_PTR, IARG_MEMORYREAD2_EA, 131 | IARG_END); 132 | } 133 | if (INS_IsMemoryWrite(ins)) { 134 | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordMem, 135 | IARG_INST_PTR, IARG_MEMORYWRITE_EA, 136 | IARG_END); 137 | } 138 | } 139 | 140 | if(profile_inst){ 141 | // Insert a call to printip before every instruction, and pass it the IP 142 | INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)RecordInst, IARG_INST_PTR, IARG_END); 143 | } 144 | } 145 | 146 | 147 | 148 | /* ===================================================================== */ 149 | 150 | VOID Fini(INT32 code, VOID *v){ 151 | 152 | gettimeofday(&finish, 0); 153 | stamp_t time = (finish.tv_sec - start.tv_sec); 154 | stamp_t i, idx, k; 155 | stamp_tt ws, tmp; 156 | 157 | char fname[512]; //[50]; //need to support long filename 158 | char mode = 'd'; 159 | if(profile_inst){ 160 | if(profile_data) mode = 'a'; 161 | else mode = 'i'; 162 | } 163 | sprintf(fname, "%s.%c", KnobResultFile.Value().c_str(), mode); 164 | 165 | ResultFile.open(fname); 166 | ResultFile << "N:" << N << " M1:" << M[0] << " M2:" << M[1] << " total_time:" << time << endl; 167 | 168 | for(k = 0; k < 2; k++) { 169 | for(i = 0; i < MAP_SIZE; i++){ 170 | if(!stamps[i][k]) 171 | continue; 172 | tmp = N-stamps[i][k] + 1; 173 | idx = sublog_value_to_index(tmp); 174 | first_count[idx][k] += 1; 175 | first_count_i[idx][k] += tmp; 176 | } 177 | } 178 | 179 | double sum=0.0, sum_i=0.0, fp, mr=1.0; 180 | double sum2=0.0, sum_i2=0.0, fp2, mr2=1.0; 181 | 182 | for(i=1;i<=sublog_value_to_index(N);i++){ 183 | ws = sublog_index_to_value(i); 184 | fp = ( 1.0 * (( N - sum ) * ws + sum_i)) / ( N - ws + 1 ); 185 | sum_i += count_i[i][0] + first_count_i[i][0]; 186 | sum += lcount[i][0] + first_count[i][0]; 187 | mr -= lcount[i][0] * 1.0 / N; 188 | ResultFile << i << "\t" << ws << "\t" << fp*(1<