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)
Beispiel #2
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)
Beispiel #3
0
 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)
Beispiel #4
0
    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)
Beispiel #5
0
    def get_user_depot_path(self):
        user_depot_path = ''

        hostname = socket.gethostname()
        hostname_short = ''.join(c for c in hostname if not c.isdigit())

        optarch = build_option('optarch') or None
        if optarch:
            user_depot_path = os.path.join('~', '.julia', self.version, self.get_environment_folder())
        else:
            arch = systemtools.get_cpu_architecture()
            cpu_family = systemtools.get_cpu_family()
            user_depot_path = os.path.join('~', '.julia', self.version, self.get_environment_folder())
        return user_depot_path
    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 #7
0
    def get_environment_folder(self):
        env_path = ''

        hostname = socket.gethostname()
        hostname_short = ''.join(c for c in hostname if not c.isdigit())

        if self.cfg['arch_name']:
            env_path = '-'.join([hostname_short, self.cfg['arch_name']])
            return env_path

        optarch = build_option('optarch') or None
        if optarch:
            env_path = '-'.join([hostname_short, optarch])
        else:
            arch = systemtools.get_cpu_architecture()
            cpu_family = systemtools.get_cpu_family()
            env_path = '-'.join([hostname_short, cpu_family, arch])
        return env_path
    def _get_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(
                "_get_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:
            self.log.raiseException(
                "_get_optimal_architecture: don't know how to set optarch for %s."
                % self.arch)
Beispiel #9
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)
Beispiel #10
0
 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
     run_cmd.clear_cache()
     self.assertEqual(get_cpu_family(), INTEL)
Beispiel #11
0
 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)
 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)