Skip to content
Snippets Groups Projects
Select Git revision
  • 7fbad72b6c02aea86537cc1a426e6554f882dc21
  • master default
  • zs2021
  • zs1920
4 results

prvocisla-else.py

Blame
  • graph.pl 6.00 KiB
    #!/usr/bin/perl
    
    my $min_mem = 8;	# Minimum memory block size (KB)
    my $max_mem = 262144;	# Maximum memory block size (KB), must fit in physical memory
    my @item_sizes = (16,64,128,1024,4096);	# Sizes of items
    my @randomized = (0,1);	# Try randomized accesses?
    my @modify = (0,1);	# Try read-write accesses?
    my $measure_ms = 1000;	# Duration of measurement in ms
    my $array = 1;		# Items are accessed as an array instead of a list
    my $huge = 0;		# Use huge pages (hugetlbfs required)
    
    # If you want to include profiling information (cache misses etc.) in detailed
    # graphs, ask for specific events here. You must have the "perf" utility installed,
    # with a recent enough kernel. The set of available events depends on the exact
    # cpu type, see "man perf-list" for further details. Also, it might be necessary
    # to increase $measure_ms in order to gather enough samples.
    
    # Events and their names
    my %perf_events = (
    	# 'cpu-cycles' => 'CPU cycles',
    	# 'cache-misses' => 'Cache misses',
    	'L1-dcache-load-misses' => 'L1D load misses',
    	'LLC-loads' => 'LLC loads',
    	# 'dTLB-load-misses' => 'DTLB load misses',
    	'mem-loads' => 'Memory loads',
    	'r412E' => 'LLC misses',
    );
    my @perf_events = sort keys %perf_events;
    
    # How to call "perf"
    my $perf_tool = "perf_3.16";
    
    # Use --graph to disable all calculations and just re-use the log files
    my $graph_only = 0;
    if (@ARGV && $ARGV[0] eq "--graph") {
    	$graph_only = 1;
    	shift @ARGV;
    }
    
    # Use ./graph.pl <directory> to store results in a given directory.
    # Otherwise, "out" is used.
    my $dir = $ARGV[0] // 'out';
    -d $dir or mkdir $dir or die "Cannot create $dir";
    chdir $dir or die;
    for my $f ("access.c", "Makefile") {
    	-f $f or symlink "../$f", $f or die;
    }
    
    ### Get machine description, including layout of caches ###
    
    my $hostname = `hostname`;
    chomp $hostname;
    
    my $cpu = `grep -m1 '^model name[[:space:]]\\+:' /proc/cpuinfo`;
    chomp $cpu;
    $cpu =~ s{^model name\s+:\s*}{};
    $cpu = " $cpu ";
    $cpu =~ s{\(tm\)|\(r\)}{}gi;
    $cpu =~ s{ (Intel|AMD|CPU|Processor) }{ }g;
    $cpu =~ s{ @.*}{};
    $cpu =~ s{\s+}{ }g;
    $cpu =~ s{^\s+|\s+$}{}g;
    
    my @options = ();
    push @options, ($array ? "Array" : "List");
    push @options, "HugePages" if $huge;
    $machine = '(' . join(" ", @options) . ')';
    
    our $c;
    my @caches = ();