예제 #1
0
    def test_cpu_speed_linux(self):
        """Test getting CPU speed (mocked for Linux)."""
        # test for particular type of system by mocking used functions
        st.get_os_type = lambda: st.LINUX
        st.read_file = mocked_read_file
        st.is_readable = lambda fp: mocked_is_readable(PROC_CPUINFO_FP, fp)

        # tweak global constant used by mocked_read_file
        global PROC_CPUINFO_TXT

        # /proc/cpuinfo on Linux x86 (no cpufreq)
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_INTEL
        self.assertEqual(get_cpu_speed(), 2600.075)

        # /proc/cpuinfo on Linux POWER
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER
        self.assertEqual(get_cpu_speed(), 3550.0)

        # Linux (x86) with cpufreq
        st.is_readable = lambda fp: mocked_is_readable(MAX_FREQ_FP, fp)
        self.assertEqual(get_cpu_speed(), 2850.0)
예제 #2
0
    def test_cpu_speed_linux(self):
        """Test getting CPU speed (mocked for Linux)."""
        # test for particular type of system by mocking used functions
        st.get_os_type = lambda: st.LINUX
        st.read_file = mocked_read_file
        st.os.path.exists = lambda fp: mocked_os_path_exists(PROC_CPUINFO_FP, fp)

        # tweak global constant used by mocked_read_file
        global PROC_CPUINFO_TXT

        # /proc/cpuinfo on Linux x86 (no cpufreq)
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_X86
        self.assertEqual(get_cpu_speed(), 2600.075)

        # /proc/cpuinfo on Linux POWER
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER
        self.assertEqual(get_cpu_speed(), 3550.0)

        # Linux (x86) with cpufreq
        st.os.path.exists = lambda fp: mocked_os_path_exists(MAX_FREQ_FP, fp)
        self.assertEqual(get_cpu_speed(), 2850.0)
예제 #3
0
 def test_cpu_speed(self):
     """Test getting CPU speed."""
     cpu_speed = get_cpu_speed()
     self.assertTrue(isinstance(cpu_speed, float))
     self.assertTrue(cpu_speed > 0.0)
예제 #4
0
 def test_cpu_speed_darwin(self):
     """Test getting CPU speed (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = mocked_run_cmd
     self.assertEqual(get_cpu_speed(), 2400.0)
예제 #5
0
 def test_cpu_speed_native(self):
     """Test getting CPU speed."""
     cpu_speed = get_cpu_speed()
     self.assertTrue(isinstance(cpu_speed, float) or cpu_speed is None)
     self.assertTrue(cpu_speed > 0.0 or cpu_speed is None)
예제 #6
0
    def configure_step(self):

        # configure for 64-bit build
        self.cfg.update('configopts', "-b 64")

        if self.cfg['ignorethrottling']:
            # ignore CPU throttling check
            # this is not recommended, it will disturb the measurements done by ATLAS
            # used for the EasyBuild demo, to avoid requiring root privileges
            if LooseVersion(self.version) < LooseVersion('3.10.0'):
                self.cfg.update('configopts', '-Si cputhrchk 0')
            else:
                self.log.warning(
                    "Ignore CPU throttling check is not possible via command line."
                )
                # apply patch to ignore CPU throttling: make ProbeCPUThrottle always return 0
                # see http://sourceforge.net/p/math-atlas/support-requests/857/
                cfg_file = os.path.join('CONFIG', 'src', 'config.c')
                for line in fileinput.input(cfg_file,
                                            inplace=1,
                                            backup='.orig.eb'):
                    line = re.sub(r"^(\s*iret)\s*=\s*.*CPU THROTTLE.*$",
                                  r"\1 = 0;", line)
                    sys.stdout.write(line)
            self.log.warning('CPU throttling check ignored: NOT recommended!')

        if get_cpu_vendor() in [AMD, INTEL]:
            # use cycle accurate timer for timings
            # see http://math-atlas.sourceforge.net/atlas_install/node23.html
            # this should work on Linux with both GCC and Intel compilers
            cpu_freq = int(get_cpu_speed())
            self.cfg.update('configopts', "-D c -DPentiumCPS=%s" % cpu_freq)
        else:
            # use -DWALL for non-x86, see http://math-atlas.sourceforge.net/atlas_install/node25.html
            self.cfg.update('configopts', "-D c -DWALL")

        # if LAPACK is found, instruct ATLAS to provide a full LAPACK library
        # ATLAS only provides a few LAPACK routines natively
        if self.cfg['full_lapack']:
            lapack_lib_version = LooseVersion('3.9')
            if LooseVersion(self.version) < lapack_lib_version:
                # pass built LAPACK library
                lapack = get_software_root('LAPACK')
                if lapack:
                    self.cfg.update(
                        'configopts',
                        ' --with-netlib-lapack=%s/lib/liblapack.a' % lapack)
                else:
                    raise EasyBuildError(
                        "netlib's LAPACK library not available, required to build ATLAS "
                        "with a full LAPACK library.")
            else:
                # pass LAPACK source tarball
                lapack_src = None
                for src in self.src:
                    if src['name'].startswith('lapack'):
                        lapack_src = src['path']
                if lapack_src is not None:
                    self.cfg.update(
                        'configopts',
                        ' --with-netlib-lapack-tarfile=%s' % lapack_src)
                else:
                    raise EasyBuildError(
                        "LAPACK source tarball not available, but required.")

        # enable building of shared libraries (requires -fPIC)
        if self.cfg['sharedlibs'] or self.toolchain.options['pic']:
            self.log.debug(
                "Enabling -fPIC because we're building shared ATLAS libs, or just because."
            )
            self.cfg.update('configopts', '-Fa alg -fPIC')

        # ATLAS only wants to be configured/built in a separate dir'
        try:
            objdir = "obj"
            os.makedirs(objdir)
            os.chdir(objdir)
        except OSError as err:
            raise EasyBuildError(
                "Failed to create obj directory to build in: %s", err)

        # specify compilers
        self.cfg.update(
            'configopts', '-C ic %(cc)s -C if %(f77)s' % {
                'cc': os.getenv('CC'),
                'f77': os.getenv('F77')
            })

        # call configure in parent dir
        cmd = "%s %s/configure --prefix=%s %s" % (
            self.cfg['preconfigopts'], self.cfg['start_dir'], self.installdir,
            self.cfg['configopts'])
        (out, exitcode) = run_cmd(cmd,
                                  log_all=False,
                                  log_ok=False,
                                  simple=False)

        if exitcode != 0:
            throttling_regexp = re.compile("cpu throttling [a-zA-Z]* enabled",
                                           re.IGNORECASE)
            if throttling_regexp.search(out):
                errormsg = (
                    "Configure failed, possible because CPU throttling is enabled; ATLAS doesn't like that. "
                    "You can either disable CPU throttling, or set 'ignorethrottling' to True in the ATLAS .eb file. "
                    "Also see http://math-atlas.sourceforge.net/errata.html#cputhrottle . "
                    "Configure output: %s") % out
            else:
                errormsg = "configure output: %s\nConfigure failed, not sure why (see output above)." % out
            raise EasyBuildError(errormsg)
예제 #7
0
    def configure_step(self):

        # configure for 64-bit build
        self.cfg.update('configopts', "-b 64")

        if self.cfg['ignorethrottling']:
            # ignore CPU throttling check
            # this is not recommended, it will disturb the measurements done by ATLAS
            # used for the EasyBuild demo, to avoid requiring root privileges
            if LooseVersion(self.version) < LooseVersion('3.10.0'):
                self.cfg.update('configopts', '-Si cputhrchk 0')
            else:
                self.log.warning("Ignore CPU throttling check is not possible via command line.")
                # apply patch to ignore CPU throttling: make ProbeCPUThrottle always return 0
                # see http://sourceforge.net/p/math-atlas/support-requests/857/
                cfg_file = os.path.join('CONFIG', 'src', 'config.c')
                for line in fileinput.input(cfg_file, inplace=1, backup='.orig.eb'):
                    line = re.sub(r"^(\s*iret)\s*=\s*.*CPU THROTTLE.*$", r"\1 = 0;", line)
                    sys.stdout.write(line)
            self.log.warning('CPU throttling check ignored: NOT recommended!')

        # use cycle accurate timer for timings
        # see http://math-atlas.sourceforge.net/atlas_install/node23.html
        # this should work on Linux with both GCC and Intel compilers
        cpu_freq = int(get_cpu_speed())
        self.cfg.update('configopts', "-D c -DPentiumCPS=%s" % cpu_freq)


        # if LAPACK is found, instruct ATLAS to provide a full LAPACK library
        # ATLAS only provides a few LAPACK routines natively
        if self.cfg['full_lapack']:
            lapack_lib_version = LooseVersion('3.9')
            if LooseVersion(self.version) < lapack_lib_version:
                # pass built LAPACK library
                lapack = get_software_root('LAPACK')
                if lapack:
                    self.cfg.update('configopts', ' --with-netlib-lapack=%s/lib/liblapack.a' % lapack)
                else:
                    self.log.error("netlib's LAPACK library not available,"\
                                   " required to build ATLAS with a full LAPACK library.")
            else:
                # pass LAPACK source tarball
                lapack_src = None
                for src in self.src:
                    if src['name'].startswith('lapack'):
                        lapack_src = src['path']
                if lapack_src is not None:
                    self.cfg.update('configopts', ' --with-netlib-lapack-tarfile=%s' % lapack_src)
                else:
                    self.log.error("LAPACK source tarball not available, but required.")

        # enable building of shared libraries (requires -fPIC)
        if self.cfg['sharedlibs'] or self.toolchain.options['pic']:
            self.log.debug("Enabling -fPIC because we're building shared ATLAS libs, or just because.")
            self.cfg.update('configopts', '-Fa alg -fPIC')

        # ATLAS only wants to be configured/built in a separate dir'
        try:
            objdir = "obj"
            os.makedirs(objdir)
            os.chdir(objdir)
        except OSError, err:
            self.log.error("Failed to create obj directory to build in: %s" % err)
예제 #8
0
 def test_cpu_speed_darwin(self):
     """Test getting CPU speed (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = mocked_run_cmd
     self.assertEqual(get_cpu_speed(), 2400.0)
예제 #9
0
 def test_cpu_speed_native(self):
     """Test getting CPU speed."""
     cpu_speed = get_cpu_speed()
     self.assertTrue(isinstance(cpu_speed, float) or cpu_speed is None)
     self.assertTrue(cpu_speed > 0.0 or cpu_speed is None)
예제 #10
0
    def configure_step(self):

        # configure for 64-bit build
        self.cfg.update('configopts', "-b 64")

        if self.cfg['ignorethrottling']:
            # ignore CPU throttling check
            # this is not recommended, it will disturb the measurements done by ATLAS
            # used for the EasyBuild demo, to avoid requiring root privileges
            if LooseVersion(self.version) < LooseVersion('3.10.0'):
                self.cfg.update('configopts', '-Si cputhrchk 0')
            else:
                self.log.warning(
                    "Ignore CPU throttling check is not possible via command line."
                )
                # apply patch to ignore CPU throttling: make ProbeCPUThrottle always return 0
                # see http://sourceforge.net/p/math-atlas/support-requests/857/
                cfg_file = os.path.join('CONFIG', 'src', 'config.c')
                for line in fileinput.input(cfg_file,
                                            inplace=1,
                                            backup='.orig.eb'):
                    line = re.sub(r"^(\s*iret)\s*=\s*.*CPU THROTTLE.*$",
                                  r"\1 = 0;", line)
                    sys.stdout.write(line)
            self.log.warning('CPU throttling check ignored: NOT recommended!')

        if get_cpu_vendor() in [AMD, INTEL]:
            # use cycle accurate timer for timings
            # see http://math-atlas.sourceforge.net/atlas_install/node23.html
            # this should work on Linux with both GCC and Intel compilers
            cpu_freq = int(get_cpu_speed())
            self.cfg.update('configopts', "-D c -DPentiumCPS=%s" % cpu_freq)
        else:
            # use -DWALL for non-x86, see http://math-atlas.sourceforge.net/atlas_install/node25.html
            self.cfg.update('configopts', "-D c -DWALL")

        # if LAPACK is found, instruct ATLAS to provide a full LAPACK library
        # ATLAS only provides a few LAPACK routines natively
        if self.cfg['full_lapack']:
            lapack_lib_version = LooseVersion('3.9')
            if LooseVersion(self.version) < lapack_lib_version:
                # pass built LAPACK library
                lapack = get_software_root('LAPACK')
                if lapack:
                    self.cfg.update(
                        'configopts',
                        ' --with-netlib-lapack=%s/lib/liblapack.a' % lapack)
                else:
                    raise EasyBuildError(
                        "netlib's LAPACK library not available, required to build ATLAS "
                        "with a full LAPACK library.")
            else:
                # pass LAPACK source tarball
                lapack_src = None
                for src in self.src:
                    if src['name'].startswith('lapack'):
                        lapack_src = src['path']
                if lapack_src is not None:
                    self.cfg.update(
                        'configopts',
                        ' --with-netlib-lapack-tarfile=%s' % lapack_src)
                else:
                    raise EasyBuildError(
                        "LAPACK source tarball not available, but required.")

        # enable building of shared libraries (requires -fPIC)
        if self.cfg['sharedlibs'] or self.toolchain.options['pic']:
            self.log.debug(
                "Enabling -fPIC because we're building shared ATLAS libs, or just because."
            )
            self.cfg.update('configopts', '-Fa alg -fPIC')

        # ATLAS only wants to be configured/built in a separate dir'
        try:
            objdir = "obj"
            os.makedirs(objdir)
            os.chdir(objdir)
        except OSError, err:
            raise EasyBuildError(
                "Failed to create obj directory to build in: %s", err)
예제 #11
0
 def test_cpu_speed(self):
     """Test getting CPU speed."""
     cpu_speed = get_cpu_speed()
     self.assertTrue(isinstance(cpu_speed, float))
     self.assertTrue(cpu_speed > 0.0)
예제 #12
0
    def configure_step(self):

        # configure for 64-bit build
        self.cfg.update('configopts', "-b 64")

        if self.cfg['ignorethrottling']:
            # ignore CPU throttling check
            # this is not recommended, it will disturb the measurements done by ATLAS
            # used for the EasyBuild demo, to avoid requiring root privileges
            if LooseVersion(self.version) < LooseVersion('3.10.0'):
                self.cfg.update('configopts', '-Si cputhrchk 0')
            else:
                self.log.warning("Ignore CPU throttling check is not possible via command line.")
                # apply patch to ignore CPU throttling: make ProbeCPUThrottle always return 0
                # see http://sourceforge.net/p/math-atlas/support-requests/857/
                cfg_file = os.path.join('CONFIG', 'src', 'config.c')
                for line in fileinput.input(cfg_file, inplace=1, backup='.orig.eb'):
                    line = re.sub(r"^(\s*iret)\s*=\s*.*CPU THROTTLE.*$", r"\1 = 0;", line)
                    sys.stdout.write(line)
            self.log.warning('CPU throttling check ignored: NOT recommended!')

        if get_cpu_vendor() in [AMD, INTEL]:
            # use cycle accurate timer for timings
            # see http://math-atlas.sourceforge.net/atlas_install/node23.html
            # this should work on Linux with both GCC and Intel compilers
            cpu_freq = int(get_cpu_speed())
            self.cfg.update('configopts', "-D c -DPentiumCPS=%s" % cpu_freq)
        else:
            # use -DWALL for non-x86, see http://math-atlas.sourceforge.net/atlas_install/node25.html
            self.cfg.update('configopts', "-D c -DWALL")

        # if LAPACK is found, instruct ATLAS to provide a full LAPACK library
        # ATLAS only provides a few LAPACK routines natively
        if self.cfg['full_lapack']:
            lapack_lib_version = LooseVersion('3.9')
            if LooseVersion(self.version) < lapack_lib_version:
                # pass built LAPACK library
                lapack = get_software_root('LAPACK')
                if lapack:
                    self.cfg.update('configopts', ' --with-netlib-lapack=%s/lib/liblapack.a' % lapack)
                else:
                    raise EasyBuildError("netlib's LAPACK library not available, required to build ATLAS "
                                         "with a full LAPACK library.")
            else:
                # pass LAPACK source tarball
                lapack_src = None
                for src in self.src:
                    if src['name'].startswith('lapack'):
                        lapack_src = src['path']
                if lapack_src is not None:
                    self.cfg.update('configopts', ' --with-netlib-lapack-tarfile=%s' % lapack_src)
                else:
                    raise EasyBuildError("LAPACK source tarball not available, but required.")

        # enable building of shared libraries (requires -fPIC)
        if self.cfg['sharedlibs'] or self.toolchain.options['pic']:
            self.log.debug("Enabling -fPIC because we're building shared ATLAS libs, or just because.")
            self.cfg.update('configopts', '-Fa alg -fPIC')

        # ATLAS only wants to be configured/built in a separate dir'
        try:
            objdir = "obj"
            os.makedirs(objdir)
            os.chdir(objdir)
        except OSError as err:
            raise EasyBuildError("Failed to create obj directory to build in: %s", err)

        # specify compilers
        self.cfg.update('configopts', '-C ic %(cc)s -C if %(f77)s' % {
                                                                     'cc':os.getenv('CC'),
                                                                     'f77':os.getenv('F77')
                                                                    })

        # call configure in parent dir
        cmd = "%s %s/configure --prefix=%s %s" % (self.cfg['preconfigopts'], self.cfg['start_dir'],
                                                 self.installdir, self.cfg['configopts'])
        (out, exitcode) = run_cmd(cmd, log_all=False, log_ok=False, simple=False)

        if exitcode != 0:
            throttling_regexp = re.compile("cpu throttling [a-zA-Z]* enabled", re.IGNORECASE)
            if throttling_regexp.search(out):
                errormsg = ' '.join([
                    "Configure failed, possible because CPU throttling is enabled; ATLAS doesn't like that. ",
                    "You can either disable CPU throttling, or set 'ignorethrottling' to True in the ATLAS .eb spec file.",
                    "Also see http://math-atlas.sourceforge.net/errata.html#cputhrottle .",
                    "Configure output: %s",
                ]) % out
            else:
                errormsg = "configure output: %s\nConfigure failed, not sure why (see output above)." % out
            raise EasyBuildError(errormsg)