kerncraft/likwid_bench_auto.py
def measure_bw(type_, total_size, threads_per_core, max_threads_per_core, cores_per_socket,
               sockets):
    """*size* is given in kilo bytes"""
    groups = []
    for s in range(sockets):
        groups += [
            '-w',
            'S' + str(s) + ':' + str(total_size) + 'kB:' +
            str(threads_per_core * cores_per_socket) +
            ':1:' + str(int(max_threads_per_core / threads_per_core))]
    # for older likwid versions add ['-g', str(sockets), '-i', str(iterations)] to cmd
    cmd = ['likwid-bench', '-t', type_] + groups
    sys.stderr.write(' '.join(cmd))
    output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
    if not output:
        print(' '.join(cmd) + ' returned no output, possibly wrong version installed '
                              '(requires 4.0 or later)', file=sys.stderr)
        sys.exit(1)
    bw = float(get_match_or_break(r'^MByte/s:\s+([0-9]+(?:\.[0-9]+)?)\s*$', output)[0])
    print(' ', PrefixedUnit(bw, 'MB/s'), file=sys.stderr)
    return PrefixedUnit(bw, 'MB/s')
def measure_bw(type_, total_size, threads_per_core, max_threads_per_core, cores_per_socket,
               sockets):
    """*size* is given in kilo bytes"""
    groups = []
    for s in range(sockets):
        groups += [
            '-w',
            'S' + str(s) + ':' + str(total_size) + 'kB:' +
            str(threads_per_core * cores_per_socket) +
            ':1:' + str(int(max_threads_per_core / threads_per_core))]
    # for older likwid versions add ['-g', str(sockets), '-i', str(iterations)] to cmd
    cmd = ['likwid-bench', '-t', type_] + groups
    sys.stderr.write(' '.join(cmd))
    output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
    if not output:
        print(' '.join(cmd) + ' returned no output, possibly wrong version installed '
                              '(requires 4.0 or later)', file=sys.stderr)
        sys.exit(1)
    bw = float(get_match_or_break(r'^MByte/s:\s+([0-9]+(?:\.[0-9]+)?)\s*$', output)[0])
    print(' ', PrefixedUnit(bw, 'MB/s'), file=sys.stderr)
    return PrefixedUnit(bw, 'MB/s')
def measure_bw ( type_ , total_size , threads_per_core , max_threads_per_core , cores_per_socket , sockets ) : groups = [ ] for s in range ( sockets ) : groups += [ '-w' , 'S' + str ( s ) + ':' + str ( total_size ) + 'kB:' + str ( threads_per_core * cores_per_socket ) + ':1:' + str ( int ( max_threads_per_core / threads_per_core ) ) ] # for older likwid versions add ['-g', str(sockets), '-i', str(iterations)] to cmd cmd = [ 'likwid-bench' , '-t' , type_ ] + groups sys . stderr . write ( ' ' . join ( cmd ) ) output = subprocess . Popen ( cmd , stdout = subprocess . PIPE ) . communicate ( ) [ 0 ] . decode ( 'utf-8' ) if not output : print ( ' ' . join ( cmd ) + ' returned no output, possibly wrong version installed ' '(requires 4.0 or later)' , file = sys . stderr ) sys . exit ( 1 ) bw = float ( get_match_or_break ( r'^MByte/s:\s+([0-9]+(?:\.[0-9]+)?)\s*$' , output ) [ 0 ] ) print ( ' ' , PrefixedUnit ( bw , 'MB/s' ) , file = sys . stderr ) return PrefixedUnit ( bw , 'MB/s' )
*size* is given in kilo bytes
* size * is given in kilo bytes