Exemplo n.º 1
0
    def get_defaults():
        (system, node, release, version, machine, processor) = platform.uname()

        if sys.platform.startswith('linux'):
            try:
                from numpy.distutils import cpuinfo
            except ImportError:
                cpu = ''
            else:
                info = cpuinfo.cpuinfo().info
                cpu = "{0} ({1} cores)".format(
                    info[0]['model name'], len(info))
        else:
            # TODO: Get this on a Mac
            cpu = ''

        try:
            import psutil
        except ImportError:
            ram = ''
        else:
            ram = util.human_file_size(psutil.phymem_usage().total)

        return {
            'machine': node,
            'os': "{0} {1}".format(system, release),
            'arch': platform.machine(),
            'cpu': cpu,
            'ram': ram
            }
Exemplo n.º 2
0
    def generate_machine_file(self, path):
        from numpy.distutils import cpuinfo
        import psutil

        if not sys.stdout.isatty():
            raise RuntimeError(
                "No ASV machine info file found at '{0}'.\n"
                "Run asv at the console the first time to generate "
                "one.".format(path))

        print("No ASV machine info file found.")
        print("I will now ask you some questions about this machine to "
              "identify it in the benchmarks.")
        print()

        (system, node, release, version, machine, processor) = platform.uname()

        print(
            "1. NAME: A unique name to identify this machine in the results.")
        name = util.get_answer_default("NAME", node)

        print("2. OS: The OS type and version of this machine.")
        operating_system = util.get_answer_default(
            "OS", "{0} {1}".format(system, release))

        print("3. ARCH: The architecture of the machine, e.g. i386")
        arch = util.get_answer_default("ARCH", platform.machine())

        print("4. CPU: A human-readable description of the CPU.")
        if sys.platform.startswith('linux'):
            info = cpuinfo.cpuinfo().info
            cpu = "{0} ({1} cores)".format(info[0]['model name'], len(info))
        else:
            # TODO: Get this on a Mac
            cpu = ''
        cpu = util.get_answer_default("CPU", cpu)

        print("4. RAM: The amount of physical RAM in the system.")
        ram = util.human_file_size(psutil.phymem_usage().total)
        ram = util.get_answer_default("RAM", ram)

        util.write_json(
            path, {
                "machine": name,
                "os": operating_system,
                "arch": arch,
                "cpu": cpu,
                "ram": ram
            })
Exemplo n.º 3
0
    def generate_machine_file(self, path):
        from numpy.distutils import cpuinfo
        import psutil

        if not sys.stdout.isatty():
            raise RuntimeError(
                "No ASV machine info file found at '{0}'.\n"
                "Run asv at the console the first time to generate "
                "one.".format(path))

        print("No ASV machine info file found.")
        print("I will now ask you some questions about this machine to "
              "identify it in the benchmarks.")
        print()

        (system, node, release, version, machine, processor) = platform.uname()

        print(
            "1. NAME: A unique name to identify this machine in the results.")
        name = util.get_answer_default("NAME", node)

        print("2. OS: The OS type and version of this machine.")
        operating_system = util.get_answer_default(
            "OS", "{0} {1}".format(system, release))

        print("3. ARCH: The architecture of the machine, e.g. i386")
        arch = util.get_answer_default("ARCH", platform.machine())

        print("4. CPU: A human-readable description of the CPU.")
        if sys.platform.startswith('linux'):
            info = cpuinfo.cpuinfo().info
            cpu = "{0} ({1} cores)".format(info[0]['model name'], len(info))
        else:
            # TODO: Get this on a Mac
            cpu = ''
        cpu = util.get_answer_default("CPU", cpu)

        print("4. RAM: The amount of physical RAM in the system.")
        ram = util.human_file_size(psutil.phymem_usage().total)
        ram = util.get_answer_default("RAM", ram)

        util.write_json(path, {
            "machine": name,
            "os": operating_system,
            "arch": arch,
            "cpu": cpu,
            "ram": ram
        })
Exemplo n.º 4
0
def run():
    _path = os.getcwd()
    os.chdir(tempfile.gettempdir())
    print('------')
    print('os.name=%r' % (os.name))
    print('------')
    print('sys.platform=%r' % (sys.platform))
    print('------')
    print('sys.version:')
    print(sys.version)
    print('------')
    print('sys.prefix:')
    print(sys.prefix)
    print('------')
    print('sys.path=%r' % (':'.join(sys.path)))
    print('------')

    try:
        import numpy
        has_newnumpy = 1
    except ImportError:
        print('Failed to import new numpy:', sys.exc_info()[1])
        has_newnumpy = 0

    try:
        from numpy.f2py import f2py2e
        has_f2py2e = 1
    except ImportError:
        print('Failed to import f2py2e:', sys.exc_info()[1])
        has_f2py2e = 0

    try:
        import numpy.distutils
        has_numpy_distutils = 2
    except ImportError:
        try:
            import numpy_distutils
            has_numpy_distutils = 1
        except ImportError:
            print('Failed to import numpy_distutils:', sys.exc_info()[1])
            has_numpy_distutils = 0

    if has_newnumpy:
        try:
            print('Found new numpy version %r in %s' %
                  (numpy.__version__, numpy.__file__))
        except Exception as msg:
            print('error:', msg)
            print('------')

    if has_f2py2e:
        try:
            print('Found f2py2e version %r in %s' %
                  (f2py2e.__version__.version, f2py2e.__file__))
        except Exception as msg:
            print('error:', msg)
            print('------')

    if has_numpy_distutils:
        try:
            if has_numpy_distutils == 2:
                print('Found numpy.distutils version %r in %r' %
                      (numpy.distutils.__version__, numpy.distutils.__file__))
            else:
                print('Found numpy_distutils version %r in %r' %
                      (numpy_distutils.numpy_distutils_version.
                       numpy_distutils_version, numpy_distutils.__file__))
            print('------')
        except Exception as msg:
            print('error:', msg)
            print('------')
        try:
            if has_numpy_distutils == 1:
                print('Importing numpy_distutils.command.build_flib ...',
                      end=' ')
                import numpy_distutils.command.build_flib as build_flib
                print('ok')
                print('------')
                try:
                    print(
                        'Checking availability of supported Fortran compilers:'
                    )
                    for compiler_class in build_flib.all_compilers:
                        compiler_class(verbose=1).is_available()
                        print('------')
                except Exception as msg:
                    print('error:', msg)
                    print('------')
        except Exception as msg:
            print(
                'error:', msg,
                '(ignore it, build_flib is obsolute for numpy.distutils 0.2.2 and up)'
            )
            print('------')
        try:
            if has_numpy_distutils == 2:
                print('Importing numpy.distutils.fcompiler ...', end=' ')
                import numpy.distutils.fcompiler as fcompiler
            else:
                print('Importing numpy_distutils.fcompiler ...', end=' ')
                import numpy_distutils.fcompiler as fcompiler
            print('ok')
            print('------')
            try:
                print('Checking availability of supported Fortran compilers:')
                fcompiler.show_fcompilers()
                print('------')
            except Exception as msg:
                print('error:', msg)
                print('------')
        except Exception as msg:
            print('error:', msg)
            print('------')
        try:
            if has_numpy_distutils == 2:
                print('Importing numpy.distutils.cpuinfo ...', end=' ')
                from numpy.distutils.cpuinfo import cpuinfo
                print('ok')
                print('------')
            else:
                try:
                    print('Importing numpy_distutils.command.cpuinfo ...',
                          end=' ')
                    from numpy_distutils.command.cpuinfo import cpuinfo
                    print('ok')
                    print('------')
                except Exception as msg:
                    print('error:', msg, '(ignore it)')
                    print('Importing numpy_distutils.cpuinfo ...', end=' ')
                    from numpy_distutils.cpuinfo import cpuinfo
                    print('ok')
                    print('------')
            cpu = cpuinfo()
            print('CPU information:', end=' ')
            for name in dir(cpuinfo):
                if name[0] == '_' and name[1] != '_' and getattr(
                        cpu, name[1:])():
                    print(name[1:], end=' ')
            print('------')
        except Exception as msg:
            print('error:', msg)
            print('------')
    os.chdir(_path)
Exemplo n.º 5
0
        try:
            if has_numpy_distutils == 2:
                print 'Importing numpy.distutils.cpuinfo ...',
                from numpy.distutils.cpuinfo import cpuinfo
                print 'ok'
                print '------'
            else:
                try:
                    print 'Importing numpy_distutils.command.cpuinfo ...',
                    from numpy_distutils.command.cpuinfo import cpuinfo
                    print 'ok'
                    print '------'
                except Exception,msg:
                    print 'error:',msg,'(ignore it)'
                    print 'Importing numpy_distutils.cpuinfo ...',
                    from numpy_distutils.cpuinfo import cpuinfo
                    print 'ok'
                    print '------'
            cpu = cpuinfo()
            print 'CPU information:',
            for name in dir(cpuinfo):
                if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():
                    print name[1:],
            print '------'
        except Exception,msg:
            print 'error:',msg
            print '------'
    os.chdir(_path)
if __name__ == "__main__":
    run()
Exemplo n.º 6
0
def run():
    _path = os.getcwd()
    os.chdir(tempfile.gettempdir())
    print '------'
    print 'os.name=%r' % (os.name)
    print '------'
    print 'sys.platform=%r' % (sys.platform)
    print '------'
    print 'sys.version:'
    print sys.version
    print '------'
    print 'sys.prefix:'
    print sys.prefix
    print '------'
    print 'sys.path=%r' % (':'.join(sys.path))
    print '------'

    try:
        import numpy
        has_newnumpy = 1
    except ImportError:
        print 'Failed to import new numpy:', sys.exc_info()[1]
        has_newnumpy = 0

    try:
        from numpy.f2py import f2py2e
        has_f2py2e = 1
    except ImportError:
        print 'Failed to import f2py2e:',sys.exc_info()[1]
        has_f2py2e = 0

    try:
        import numpy.distutils
        has_numpy_distutils = 2
    except ImportError:
        try:
            import numpy_distutils
            has_numpy_distutils = 1
        except ImportError:
            print 'Failed to import numpy_distutils:',sys.exc_info()[1]
            has_numpy_distutils = 0

    if has_newnumpy:
        try:
            print 'Found new numpy version %r in %s' % \
                  (numpy.__version__, numpy.__file__)
        except Exception as msg:
            print 'error:', msg
            print '------'

    if has_f2py2e:
        try:
            print 'Found f2py2e version %r in %s' % \
                  (f2py2e.__version__.version,f2py2e.__file__)
        except Exception as msg:
            print 'error:',msg
            print '------'

    if has_numpy_distutils:
        try:
            if has_numpy_distutils == 2:
                print 'Found numpy.distutils version %r in %r' % (\
            numpy.distutils.__version__,
            numpy.distutils.__file__)
            else:
                print 'Found numpy_distutils version %r in %r' % (\
            numpy_distutils.numpy_distutils_version.numpy_distutils_version,
            numpy_distutils.__file__)
            print '------'
        except Exception as msg:
            print 'error:',msg
            print '------'
        try:
            if has_numpy_distutils == 1:
                print 'Importing numpy_distutils.command.build_flib ...',
                import numpy_distutils.command.build_flib as build_flib
                print 'ok'
                print '------'
                try:
                    print 'Checking availability of supported Fortran compilers:'
                    for compiler_class in build_flib.all_compilers:
                        compiler_class(verbose=1).is_available()
                        print '------'
                except Exception as msg:
                    print 'error:',msg
                    print '------'
        except Exception as msg:
            print 'error:',msg,'(ignore it, build_flib is obsolute for numpy.distutils 0.2.2 and up)'
            print '------'
        try:
            if has_numpy_distutils == 2:
                print 'Importing numpy.distutils.fcompiler ...',
                import numpy.distutils.fcompiler as fcompiler
            else:
                print 'Importing numpy_distutils.fcompiler ...',
                import numpy_distutils.fcompiler as fcompiler
            print 'ok'
            print '------'
            try:
                print 'Checking availability of supported Fortran compilers:'
                fcompiler.show_fcompilers()
                print '------'
            except Exception as msg:
                print 'error:',msg
                print '------'
        except Exception as msg:
            print 'error:',msg
            print '------'
        try:
            if has_numpy_distutils == 2:
                print 'Importing numpy.distutils.cpuinfo ...',
                from numpy.distutils.cpuinfo import cpuinfo
                print 'ok'
                print '------'
            else:
                try:
                    print 'Importing numpy_distutils.command.cpuinfo ...',
                    from numpy_distutils.command.cpuinfo import cpuinfo
                    print 'ok'
                    print '------'
                except Exception as msg:
                    print 'error:',msg,'(ignore it)'
                    print 'Importing numpy_distutils.cpuinfo ...',
                    from numpy_distutils.cpuinfo import cpuinfo
                    print 'ok'
                    print '------'
            cpu = cpuinfo()
            print 'CPU information:',
            for name in dir(cpuinfo):
                if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():
                    print name[1:],
            print '------'
        except Exception as msg:
            print 'error:',msg
            print '------'
    os.chdir(_path)
Exemplo n.º 7
0
    for d, dnames, fnames in os.walk( bmark_dir ):
        for fname in fnames:
            if fname == benchmark + ".orig":
                matches.append( os.path.join( d, fname ) )
    if len( matches ) != 1:
        raise Exception( "couldn't find golden binary for " + benchmark )
    return matches[ 0 ]

def coin( p_heads = 0.5 ):
    return random.random() < p_heads

prefix = []

if options.annotate:
    ann_out = mktemp()
    if cpuinfo.cpuinfo().is_AMD():
        prefix = ["perf", "record", "-e", "cycles,instructions,r533f00,cache-references,cache-misses", "-o", ann_out, "--"]
    else:
        prefix = ["perf", "record", "-e", "cycles,instructions,r532010,r538010,cache-references,cache-misses", "-o", ann_out, "--"]
elif options.limit:
    prefix = [ options.limit ]

def save_output( fname, bmark, i ):
    if not os.path.exists( options.save_failing ):
        os.makedirs( options.save_failing )
    savename = os.path.join( options.save_failing, bmark + ".output.%d" % i )
    shutil.move( fname, savename )

class GoldenFailure( StandardError ):
    pass
Exemplo n.º 8
0
import os
import sys
import socket
import platform
import resource
from numpy.distutils.cpuinfo import cpuinfo
from zmq import zmq_version

CPU       = cpuinfo()
PLATFORM  = platform.system()
ARCH      = platform.architecture()
MAX_PROCS = resource.getrlimit(resource.RLIMIT_NPROC)[1]
MAX_FDS   = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
PAGESIZE  = resource.getpagesize()
HOSTNAME  = socket.gethostname()
PYPY      = hasattr(sys, 'pypy_version_info')
CPYTHON   = not PYPY
ZMQ       = zmq_version()
SSE2      = CPU._has_sse2()

try:
    socket.socket(socket.AF_TIPC, socket.SOCK_RDM)
    TIPC = True
except:
    TIPC = False

try:
    os.stat('/usr/include/pthread.h')
    PTHREADS = True
except:
    PTHREADS = False
Exemplo n.º 9
0
                    result[bmark][line[1]] = line[0].replace(",", "")
                    if not line[1] in allkeys:
                        allkeys.append(line[1])
        os.remove(fname)
    return result


def merge(d1, d2):
    for key in d2:
        if key in d1 and type(d1[key]) is dict:
            merge(d1[key], d2[key])
        else:
            d1[key] = d2[key]


if cpuinfo.cpuinfo().is_AMD():
    flop_regs = ["r533f00"]
else:
    flop_regs = ["r532010", "r538010"]

wattsup = os.path.join(root, "wu.py")
with open("benchmarks.csv", 'w') as fh:
    writer = None
    for i in range(n):
        for bmark, runcmd in benchmarks:
            run = runcmd(bmark, options.test)

            data = dict()
            merge(data, runWU(bmark, i, run, "time", "kwh", "watts"))
            merge(data,
                  runPerf(bmark, i, run, "cycles", "instructions", *flop_regs))
Exemplo n.º 10
0
                from numpy.distutils.cpuinfo import cpuinfo
                print 'ok'
                print '------'
            else:
                try:
                    print 'Importing numpy_distutils.command.cpuinfo ...',
                    from numpy_distutils.command.cpuinfo import cpuinfo
                    print 'ok'
                    print '------'
                except Exception, msg:
                    print 'error:', msg, '(ignore it)'
                    print 'Importing numpy_distutils.cpuinfo ...',
                    from numpy_distutils.cpuinfo import cpuinfo
                    print 'ok'
                    print '------'
            cpu = cpuinfo()
            print 'CPU information:',
            for name in dir(cpuinfo):
                if name[0] == '_' and name[1] != '_' and getattr(
                        cpu, name[1:])():
                    print name[1:],
            print '------'
        except Exception, msg:
            print 'error:', msg
            print '------'
    os.chdir(_path)


if __name__ == "__main__":
    run()