def test_cpu_family_linux(self):
        """Test get_cpu_family function (mocked for Linux)."""
        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)
        global PROC_CPUINFO_TXT

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_X86
        self.assertEqual(get_cpu_family(), INTEL)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_ARM
        self.assertEqual(get_cpu_family(), ARM)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER
        self.assertEqual(get_cpu_family(), POWER)
 def __init__(self, *args, **kwargs):
     """Compiler constructor."""
     Toolchain.base_init(self)
     self.arch = systemtools.get_cpu_architecture()
     self.cpu_family = systemtools.get_cpu_family()
     # list of compiler prefixes
     self.prefixes = []
     super(Compiler, self).__init__(*args, **kwargs)
    def test_cpu_family_linux(self):
        """Test get_cpu_family function (mocked for Linux)."""
        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)
        st.platform.uname = mocked_uname
        global MACHINE_NAME
        global PROC_CPUINFO_TXT

        MACHINE_NAME = 'x86_64'
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_INTEL
        self.assertEqual(get_cpu_family(), INTEL)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_AMD
        self.assertEqual(get_cpu_family(), AMD)

        MACHINE_NAME = 'armv7l'
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_RASPI2
        self.assertEqual(get_cpu_family(), ARM)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_ODROID_XU3
        self.assertEqual(get_cpu_family(), ARM)

        MACHINE_NAME = 'aarch64'
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_XGENE2
        self.assertEqual(get_cpu_family(), ARM)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_THUNDERX
        self.assertEqual(get_cpu_family(), ARM)

        MACHINE_NAME = 'ppc64'
        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER
        self.assertEqual(get_cpu_family(), POWER)
    def _set_optimal_architecture(self):
        """ Get options for the current architecture """
        if self.arch is None:
            self.arch = systemtools.get_cpu_family()

        optarch = None
        if build_option('optarch') is not None:
            optarch = build_option('optarch')
        elif self.arch in (self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION or []):
            optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[self.arch]

        if optarch is not None:
            self.log.info("_set_optimal_architecture: using %s as optarch for %s." % (optarch, self.arch))
            self.options.options_map['optarch'] = optarch

        if 'optarch' in self.options.options_map and self.options.options_map.get('optarch', None) is None:
            raise EasyBuildError("_set_optimal_architecture: don't know how to set optarch for %s", self.arch)
Beispiel #5
0
    def _set_optimal_architecture(self):
        """ Get options for the current architecture """
        if self.arch is None:
            self.arch = systemtools.get_cpu_family()

        optarch = None
        # --optarch is specified with flags to use
        if build_option('optarch') is not None and build_option('optarch') != OPTARCH_GENERIC:
            optarch = build_option('optarch')
        # --optarch=GENERIC
        elif build_option('optarch') == OPTARCH_GENERIC:
            if self.arch in (self.COMPILER_GENERIC_OPTION or []):
                optarch = self.COMPILER_GENERIC_OPTION[self.arch]
        # no --optarch specified
        elif self.arch in (self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION or []):
            optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[self.arch]

        if optarch is not None:
            self.log.info("_set_optimal_architecture: using %s as optarch for %s." % (optarch, self.arch))
            self.options.options_map['optarch'] = optarch

        if 'optarch' in self.options.options_map and self.options.options_map.get('optarch', None) is None:
            raise EasyBuildError("_set_optimal_architecture: don't know how to set optarch for %s", self.arch)
 def test_cpu_family_darwin(self):
     """Test get_cpu_family function (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = mocked_run_cmd
     self.assertEqual(get_cpu_family(), INTEL)
 def test_cpu_family_native(self):
     """Test get_cpu_family function."""
     cpu_family = get_cpu_family()
     self.assertTrue(cpu_family in CPU_FAMILIES or cpu_family == UNKNOWN)
 def test_cpu_family_native(self):
     """Test get_cpu_family function."""
     run_cmd.clear_cache()
     cpu_family = get_cpu_family()
     self.assertTrue(cpu_family in CPU_FAMILIES or cpu_family == UNKNOWN)