示例#1
0
    def configure_step(self):
        """Custom configuration procedure for numexpr."""
        super(EB_numexpr, self).configure_step()

        # if Intel MKL is available, set up site.cfg such that the right VML library is used;
        # this makes a *big* difference in terms of performance;
        # see also https://github.com/pydata/numexpr/blob/master/site.cfg.example
        if self.imkl_root:

            # figure out which VML library to link to
            cpu_features = get_cpu_features()
            if 'avx512f' in cpu_features:
                mkl_vml_lib = 'mkl_vml_avx512'
            elif 'avx2' in cpu_features:
                mkl_vml_lib = 'mkl_vml_avx2'
            elif 'avx' in cpu_features:
                mkl_vml_lib = 'mkl_vml_avx'
            else:
                # use default kernels as fallback for non-AVX systems
                mkl_vml_lib = 'mkl_vml_def'

            mkl_libs = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'mkl_def', mkl_vml_lib, 'mkl_rt', 'iomp5']

            mkl_lib_dirs = [
                os.path.join(self.imkl_root, 'mkl', 'lib', 'intel64'),
                os.path.join(self.imkl_root, 'lib', 'intel64'),
            ]

            site_cfg_txt = '\n'.join([
                "[mkl]",
                "include_dirs = %s" % os.path.join(self.imkl_root, 'mkl', 'include'),
                "library_dirs = %s" % ':'.join(mkl_lib_dirs),
                "mkl_libs = %s" % ', '.join(mkl_libs),
            ])
            write_file('site.cfg', site_cfg_txt)
示例#2
0
    def __init__(self, *args, **kwargs):
        """Initialisation of custom class variables for FFTW."""
        super(EB_FFTW, self).__init__(*args, **kwargs)

        # do not enable MPI if the toolchain does not support it
        if not self.toolchain.mpi_family():
            self.log.info("Disabling MPI support because the toolchain used does not support it.")
            self.cfg['with_mpi'] = False

        for flag in FFTW_CPU_FEATURE_FLAGS:
            # fail-safe: make sure we're not overwriting an existing attribute (could lead to weird bugs if we do)
            if hasattr(self, flag):
                raise EasyBuildError("EasyBlock attribute '%s' already exists")
            setattr(self, flag, self.cfg['use_%s' % flag])

            # backwards compatibility: use use_fma setting if use_fma4 is not set
            if flag == 'fma4' and self.cfg['use_fma4'] is None and self.cfg['use_fma'] is not None:
                self.log.deprecated("Use 'use_fma4' instead of 'use_fma' easyconfig parameter", '4.0')
                self.fma4 = self.cfg['use_fma']

        # auto-detect CPU features that can be used and are not enabled/disabled explicitly,
        # but only if --optarch=GENERIC is not being used
        cpu_arch = get_cpu_architecture()
        if self.cfg['auto_detect_cpu_features']:

            # if --optarch=GENERIC is used, limit which CPU features we consider for auto-detection
            if build_option('optarch') == OPTARCH_GENERIC:
                if cpu_arch == X86_64:
                    # SSE(2) is supported on all x86_64 architectures
                    cpu_features = ['sse', 'sse2']
                elif cpu_arch == AARCH64:
                    # NEON is supported on all AARCH64 architectures (indicated with 'asimd')
                    cpu_features = ['asimd']
                else:
                    cpu_features = []
            else:
                cpu_features = FFTW_CPU_FEATURE_FLAGS
            self.log.info("CPU features considered for auto-detection: %s", cpu_features)

            # get list of available CPU features, so we can check which ones to retain
            avail_cpu_features = get_cpu_features()

            # on macOS, AVX is indicated with 'avx1.0' rather than 'avx'
            if 'avx1.0' in avail_cpu_features:
                avail_cpu_features.append('avx')

            self.log.info("List of available CPU features: %s", avail_cpu_features)

            for flag in cpu_features:
                # only enable use of a particular CPU feature if it's still undecided (i.e. None)
                if getattr(self, flag) is None and flag in avail_cpu_features:
                    self.log.info("Enabling use of %s (should be supported based on CPU features)", flag.upper())
                    setattr(self, flag, True)

        # Auto-disable quad-precision on ARM and POWER, as it is unsupported
        if self.cfg['with_quad_prec'] and cpu_arch in [AARCH32, AARCH64, POWER]:
            self.cfg['with_quad_prec'] = False
            self.log.debug("Quad-precision automatically disabled; not supported on %s.", cpu_arch)
示例#3
0
    def __init__(self, *args, **kwargs):
        """Constructor for custom Mesa easyblock: figure out which values to pass to swr-arches configuration option."""

        super(EB_Mesa, self).__init__(*args, **kwargs)

        self.gallium_configopts = []

        # Mesa fails to build with libunwind on aarch64
        # See https://github.com/easybuilders/easybuild-easyblocks/issues/2150
        if get_cpu_architecture() == AARCH64:
            given_config_opts = self.cfg.get('configopts')
            if "-Dlibunwind=true" in given_config_opts:
                self.log.warning('libunwind not supported on aarch64, stripping from configopts!')
                configopts_libunwind_stripped = given_config_opts.replace('-Dlibunwind=true', '-Dlibunwind=false')
                self.cfg.set_keys({'configopts': configopts_libunwind_stripped})
                self.log.warning('New configopts after stripping: ' + self.cfg.get('configopts'))

        # Check user-defined Gallium drivers
        gallium_drivers = self.get_configopt_value('gallium-drivers')

        if not gallium_drivers:
            # Add appropriate Gallium drivers for current architecture
            arch = get_cpu_architecture()
            arch_gallium_drivers = {
                X86_64: ['swrast', 'swr'],
                POWER: ['swrast'],
                AARCH64: ['swrast'],
            }
            if arch in arch_gallium_drivers:
                gallium_drivers = arch_gallium_drivers[arch]
                # Add configopt for additional Gallium drivers
                self.gallium_configopts.append('-Dgallium-drivers=' + ','.join(gallium_drivers))

        self.log.debug('Gallium driver(s) included in the installation: %s' % ', '.join(gallium_drivers))

        self.swr_arches = []

        if 'swr' in gallium_drivers:
            # Check user-defined SWR arches
            self.swr_arches = self.get_configopt_value('swr-arches')

            if not self.swr_arches:
                # Set cpu features of SWR for current micro-architecture
                feat_to_swrarch = {
                    'avx': 'avx',
                    'avx1.0': 'avx',  # on macOS, AVX is indicated with 'avx1.0' rather than 'avx'
                    'avx2': 'avx2',
                    'avx512f': 'skx',  # AVX-512 Foundation - introduced in Skylake
                    'avx512er': 'knl',  # AVX-512 Exponential and Reciprocal Instructions implemented in Knights Landing
                }
                # Determine list of values to pass to swr-arches configuration option
                cpu_features = get_cpu_features()
                self.swr_arches = sorted([swrarch for feat, swrarch in feat_to_swrarch.items() if feat in cpu_features])
                # Add configopt for additional SWR arches
                self.gallium_configopts.append('-Dswr-arches=' + ','.join(self.swr_arches))

            self.log.debug('SWR Gallium driver will support: %s' % ', '.join(self.swr_arches))
示例#4
0
    def __init__(self, *args, **kwargs):
        """Constructor for custom Mesa easyblock: figure out which values to pass to swr-arches configuration option."""

        super(EB_Mesa, self).__init__(*args, **kwargs)

        self.gallium_configopts = []

        # Check user-defined Gallium drivers
        gallium_drivers = self.get_configopt_value('gallium-drivers')

        if not gallium_drivers:
            # Add appropriate Gallium drivers for current architecture
            arch = get_cpu_architecture()
            arch_gallium_drivers = {
                'x86_64': ['swrast', 'swr'],
                'POWER': ['swrast'],
            }
            if arch in arch_gallium_drivers:
                gallium_drivers = arch_gallium_drivers[arch]
                # Add configopt for additional Gallium drivers
                self.gallium_configopts.append('-Dgallium-drivers=' +
                                               ','.join(gallium_drivers))

        self.log.debug('Gallium driver(s) included in the installation: %s' %
                       ', '.join(gallium_drivers))

        self.swr_arches = []

        if 'swr' in gallium_drivers:
            # Check user-defined SWR arches
            self.swr_arches = self.get_configopt_value('swr-arches')

            if not self.swr_arches:
                # Set cpu features of SWR for current micro-architecture
                feat_to_swrarch = {
                    'avx': 'avx',
                    'avx1.0':
                    'avx',  # on macOS, AVX is indicated with 'avx1.0' rather than 'avx'
                    'avx2': 'avx2',
                    'avx512f':
                    'skx',  # AVX-512 Foundation - introduced in Skylake
                    'avx512er':
                    'knl',  # AVX-512 Exponential and Reciprocal Instructions implemented in Knights Landing
                }
                # Determine list of values to pass to swr-arches configuration option
                cpu_features = get_cpu_features()
                self.swr_arches = sorted([
                    swrarch for feat, swrarch in feat_to_swrarch.items()
                    if feat in cpu_features
                ])
                # Add configopt for additional SWR arches
                self.gallium_configopts.append('-Dswr-arches=' +
                                               ','.join(self.swr_arches))

            self.log.debug('SWR Gallium driver will support: %s' %
                           ', '.join(self.swr_arches))
示例#5
0
 def test_cpu_features_darwin(self):
     """Test getting CPU features (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = mocked_run_cmd
     expected = ['1gbpage', 'acpi', 'aes', 'apic', 'avx1.0', 'avx2', 'bmi1', 'bmi2', 'clfsh', 'cmov', 'cx16',
                 'cx8', 'de', 'ds', 'dscpl', 'dtes64', 'em64t', 'erms', 'est', 'f16c', 'fma', 'fpu', 'fpu_csds',
                 'fxsr', 'htt', 'invpcid', 'lahf', 'lzcnt', 'mca', 'mce', 'mmx', 'mon', 'movbe', 'msr', 'mtrr',
                 'osxsave', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pge', 'popcnt', 'pse', 'pse36',
                 'rdrand', 'rdtscp', 'rdwrfsgs', 'seglim64', 'sep', 'smep', 'ss', 'sse', 'sse2', 'sse3', 'sse4.1',
                 'sse4.2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr', 'tsc', 'tsc_thread_offset', 'tsci', 'tsctmr',
                 'vme', 'vmx', 'x2apic', 'xd', 'xsave']
     self.assertEqual(get_cpu_features(), expected)
 def test_cpu_features_darwin(self):
     """Test getting CPU features (mocked for Darwin)."""
     st.get_os_type = lambda: st.DARWIN
     st.run_cmd = mocked_run_cmd
     expected = ['1gbpage', 'acpi', 'aes', 'apic', 'avx1.0', 'avx2', 'bmi1', 'bmi2', 'clfsh', 'cmov', 'cx16',
                 'cx8', 'de', 'ds', 'dscpl', 'dtes64', 'em64t', 'erms', 'est', 'f16c', 'fma', 'fpu', 'fpu_csds',
                 'fxsr', 'htt', 'invpcid', 'lahf', 'lzcnt', 'mca', 'mce', 'mmx', 'mon', 'movbe', 'msr', 'mtrr',
                 'osxsave', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pge', 'popcnt', 'pse', 'pse36',
                 'rdrand', 'rdtscp', 'rdwrfsgs', 'seglim64', 'sep', 'smep', 'ss', 'sse', 'sse2', 'sse3', 'sse4.1',
                 'sse4.2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr', 'tsc', 'tsc_thread_offset', 'tsci', 'tsctmr',
                 'vme', 'vmx', 'x2apic', 'xd', 'xsave']
     self.assertEqual(get_cpu_features(), expected)
示例#7
0
    def configure_step(self):
        """Custom configuration procedure for numexpr."""
        super(EB_numexpr, self).configure_step()

        self.imkl_root = get_software_root('imkl')

        # if Intel MKL is available, set up site.cfg such that the right VML library is used;
        # this makes a *big* difference in terms of performance;
        # see also https://github.com/pydata/numexpr/blob/master/site.cfg.example
        if self.imkl_root:

            # figure out which VML library to link to
            cpu_features = get_cpu_features()
            if 'avx512f' in cpu_features:
                mkl_vml_lib = 'mkl_vml_avx512'
            elif 'avx2' in cpu_features:
                mkl_vml_lib = 'mkl_vml_avx2'
            elif 'avx' in cpu_features:
                mkl_vml_lib = 'mkl_vml_avx'
            else:
                # use default kernels as fallback for non-AVX systems
                mkl_vml_lib = 'mkl_vml_def'

            mkl_ver = get_software_version('imkl')

            if LooseVersion(mkl_ver) >= LooseVersion('2021'):
                mkl_lib_dirs = [
                    os.path.join(self.imkl_root, 'mkl', 'latest', 'lib', 'intel64'),
                ]
                mkl_include_dirs = os.path.join(self.imkl_root, 'mkl', 'latest', 'include')
                mkl_libs = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5']
            else:
                mkl_lib_dirs = [
                    os.path.join(self.imkl_root, 'mkl', 'lib', 'intel64'),
                    os.path.join(self.imkl_root, 'lib', 'intel64'),
                ]
                mkl_include_dirs = os.path.join(self.imkl_root, 'mkl', 'include')
                mkl_libs = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'mkl_def', mkl_vml_lib, 'iomp5']

            site_cfg_lines = [
                "[mkl]",
                "include_dirs = %s" % mkl_include_dirs,
                "library_dirs = %s" % os.pathsep.join(mkl_lib_dirs + self.toolchain.get_variable('LDFLAGS', typ=list)),
            ]

            if LooseVersion(self.version) >= LooseVersion("2.8.0"):
                site_cfg_lines.append("libraries = %s" % os.pathsep.join(mkl_libs))
            else:
                site_cfg_lines.append("mkl_libs = %s" % ', '.join(mkl_libs))

            write_file('site.cfg', '\n'.join(site_cfg_lines))
示例#8
0
文件: elpa.py 项目: jotelha/JSC
    def __init__(self, *args, **kwargs):
        """Initialisation of custom class variables for ELPA."""
        super(EB_ELPA, self).__init__(*args, **kwargs)

        # do not enable MPI if the toolchain does not support it
        if not self.toolchain.mpi_family():
            self.log.info(
                "Disabling MPI support because the toolchain used does not support it."
            )
            self.cfg['with_mpi'] = False

        for flag in ELPA_CPU_FEATURE_FLAGS:
            # fail-safe: make sure we're not overwriting an existing attribute (could lead to weird bugs if we do)
            if hasattr(self, flag):
                raise EasyBuildError("EasyBlock attribute '%s' already exists")
            setattr(self, flag, self.cfg['use_%s' % flag])

        # auto-detect CPU features that can be used and are not enabled/disabled explicitly,
        # but only if --optarch=GENERIC is not being used
        if self.cfg['auto_detect_cpu_features']:

            # if --optarch=GENERIC is used, we will not use no CPU feature
            if build_option('optarch') == OPTARCH_GENERIC:
                cpu_features = []
            else:
                cpu_features = ELPA_CPU_FEATURE_FLAGS
            self.log.info("CPU features considered for auto-detection: %s",
                          cpu_features)

            # get list of available CPU features, so we can check which ones to retain
            avail_cpu_features = get_cpu_features()

            # on macOS, AVX is indicated with 'avx1.0' rather than 'avx'
            if 'avx1.0' in avail_cpu_features:
                avail_cpu_features.append('avx')

            # The AVX512 foundation instruction set is actually called avx512f, not avx512. Account for that here
            if 'avx512f' in avail_cpu_features:
                avail_cpu_features.append('avx512')

            self.log.info("List of available CPU features: %s",
                          avail_cpu_features)

            for flag in cpu_features:
                # only enable use of a particular CPU feature if it's still undecided (i.e. None)
                if getattr(self, flag) is None and flag in avail_cpu_features:
                    self.log.info(
                        "Enabling use of %s (should be supported based on CPU features)",
                        flag.upper())
                    setattr(self, flag, True)
示例#9
0
    def __init__(self, *args, **kwargs):
        """Initialisation of custom class variables for FFTW."""
        super(EB_FFTW, self).__init__(*args, **kwargs)

        for flag in FFTW_CPU_FEATURE_FLAGS:
            # fail-safe: make sure we're not overwriting an existing attribute (could lead to weird bugs if we do)
            if hasattr(self, flag):
                raise EasyBuildError("EasyBlock attribute '%s' already exists")
            setattr(self, flag, self.cfg['use_%s' % flag])

        # auto-detect CPU features that can be used and are not enabled/disabled explicitly,
        # but only if --optarch=GENERIC is not being used
        if self.cfg['auto_detect_cpu_features']:

            # if --optarch=GENERIC is used, limit which CPU features we consider for auto-detection
            if build_option('optarch') == OPTARCH_GENERIC:
                cpu_arch = get_cpu_architecture()
                if cpu_arch == X86_64:
                    # SSE(2) is supported on all x86_64 architectures
                    cpu_features = ['sse', 'sse2']
                elif cpu_arch == AARCH64:
                    # NEON is supported on all AARCH64 architectures (indicated with 'asimd')
                    cpu_features = ['asimd']
                else:
                    cpu_features = []
            else:
                cpu_features = FFTW_CPU_FEATURE_FLAGS
            self.log.info("CPU features considered for auto-detection: %s",
                          cpu_features)

            # get list of available CPU features, so we can check which ones to retain
            avail_cpu_features = get_cpu_features()

            # on macOS, AVX is indicated with 'avx1.0' rather than 'avx'
            if 'avx1.0' in avail_cpu_features:
                avail_cpu_features.append('avx')

            self.log.info("List of available CPU features: %s",
                          avail_cpu_features)

            for flag in cpu_features:
                # only enable use of a particular CPU feature if it's still undecided (i.e. None)
                if getattr(self, flag) is None and flag in avail_cpu_features:
                    self.log.info(
                        "Enabling use of %s (should be supported based on CPU features)",
                        flag.upper())
                    setattr(self, flag, True)
示例#10
0
    def test_cpu_features_linux(self):
        """Test getting CPU features (mocked for Linux)."""
        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_TXT = PROC_CPUINFO_TXT_INTEL
        expected = [
            'acpi', 'aes', 'aperfmperf', 'apic', 'arat', 'arch_perfmon', 'avx',
            'bts', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'dca',
            'de', 'ds_cpl', 'dtes64', 'dts', 'dts', 'ept', 'est',
            'flexpriority', 'fpu', 'fxsr', 'ht', 'ida', 'lahf_lm', 'lm', 'mca',
            'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nonstop_tsc', 'nx', 'pae',
            'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pdpe1gb', 'pebs',
            'pge', 'pln', 'pni', 'popcnt', 'pse', 'pse36', 'pts', 'rdtscp',
            'rep_good', 'sep', 'smx', 'ss', 'sse', 'sse2', 'sse4_1', 'sse4_2',
            'ssse3', 'syscall', 'tm', 'tm2', 'tpr_shadow', 'tsc',
            'tsc_deadline_timer', 'vme', 'vmx', 'vnmi', 'vpid', 'x2apic',
            'xsave', 'xsaveopt', 'xtopology', 'xtpr'
        ]
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_RASPI2
        expected = [
            'edsp', 'evtstrm', 'fastmult', 'half', 'idiva', 'idivt', 'lpae',
            'neon', 'thumb', 'tls', 'vfp', 'vfpd32', 'vfpv3', 'vfpv4'
        ]
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_ODROID_XU3
        expected = [
            'edsp', 'fastmult', 'half', 'idiva', 'idivt', 'neon', 'swp',
            'thumb', 'tls', 'vfp', 'vfpv3', 'vfpv4'
        ]
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_XGENE2
        expected = [
            'aes', 'asimd', 'crc32', 'evtstrm', 'fp', 'pmull', 'sha1', 'sha2'
        ]
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_THUNDERX
        expected = [
            'aes', 'asimd', 'crc32', 'evtstrm', 'fp', 'pmull', 'sha1', 'sha2'
        ]
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER
        st.get_cpu_architecture = lambda: POWER
        self.assertEqual(get_cpu_features(), ['altivec', 'vsx'])
示例#11
0
    def prepare_step(self, *args, **kwargs):
        """Custom prepare step for GROMACS."""

        # With the intel toolchain the -ftz build flag is automatically added, causing
        # denormal results being flushed to zero. This will cause errors for very small
        # arguments without FMA support since some intermediate results might be denormal.
        # [https://redmine.gromacs.org/issues/2335]
        # Set -fp-model precise on non-FMA CPUs to produce correct results.
        if self.toolchain.comp_family() == toolchain.INTELCOMP:
            cpu_features = get_cpu_features()
            if 'fma' not in cpu_features:
                self.log.info("FMA instruction not supported by this CPU: %s", cpu_features)
                self.log.info("Setting precise=True intel toolchain option to remove -ftz build flag")
                self.toolchain.options['precise'] = True

        # This must be called after enforcing the precise option otherwise the
        # change will be ignored.
        super(EB_GROMACS, self).prepare_step(*args, **kwargs)
示例#12
0
    def test_cpu_features_linux(self):
        """Test getting CPU features (mocked for Linux)."""
        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_TXT = PROC_CPUINFO_TXT_INTEL
        expected = ['acpi', 'aes', 'aperfmperf', 'apic', 'arat', 'arch_perfmon', 'avx', 'bts', 'clflush', 'cmov',
                    'constant_tsc', 'cx16', 'cx8', 'dca', 'de', 'ds_cpl', 'dtes64', 'dts', 'dts', 'ept', 'est',
                    'flexpriority', 'fpu', 'fxsr', 'ht', 'ida', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'monitor',
                    'msr', 'mtrr', 'nonstop_tsc', 'nx', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pdpe1gb',
                    'pebs', 'pge', 'pln', 'pni', 'popcnt', 'pse', 'pse36', 'pts', 'rdtscp', 'rep_good', 'sep', 'smx',
                    'ss', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr_shadow', 'tsc',
                    'tsc_deadline_timer', 'vme', 'vmx', 'vnmi', 'vpid', 'x2apic', 'xsave', 'xsaveopt', 'xtopology',
                    'xtpr']
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_RASPI2
        expected = ['edsp', 'evtstrm', 'fastmult', 'half', 'idiva', 'idivt', 'lpae', 'neon',
                    'thumb', 'tls', 'vfp', 'vfpd32', 'vfpv3', 'vfpv4']
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_ODROID_XU3
        expected = ['edsp', 'fastmult', 'half', 'idiva', 'idivt', 'neon', 'swp', 'thumb',
                    'tls', 'vfp', 'vfpv3', 'vfpv4']
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_XGENE2
        expected = ['aes', 'asimd', 'crc32', 'evtstrm', 'fp', 'pmull', 'sha1', 'sha2']
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_THUNDERX
        expected = ['aes', 'asimd', 'crc32', 'evtstrm', 'fp', 'pmull', 'sha1', 'sha2']
        self.assertEqual(get_cpu_features(), expected)

        PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER
        st.get_cpu_architecture = lambda: POWER
        self.assertEqual(get_cpu_features(), ['altivec', 'vsx'])
示例#13
0
 def test_cpu_features_native(self):
     """Test getting CPU features."""
     cpu_feat = get_cpu_features()
     self.assertTrue(isinstance(cpu_feat, list))
     self.assertTrue(len(cpu_feat) > 0)
     self.assertTrue(all([isinstance(x, basestring) for x in cpu_feat]))
示例#14
0
    def configure_step(self):
        """Custom configuration procedure for OpenCV."""

        # enable Python support if unspecified and Python is a dependency
        if 'BUILD_PYTHON_SUPPORT' not in self.cfg['configopts']:
            if get_software_root('Python'):
                self.cfg.update(
                    'configopts',
                    "-DBUILD_PYTHON_SUPPORT=ON -DBUILD_NEW_PYTHON_SUPPORT=ON")

                # recent OpenCV 3.x versions (and newer) use an alternative configure option to specify the location
                # where the OpenCV Python bindings should be installed
                py_pkgs_path = os.path.join(self.installdir, self.pylibdir)
                if LooseVersion(self.version) >= LooseVersion('3.4.4'):
                    self.cfg.update(
                        'configopts',
                        '-DOPENCV_PYTHON_INSTALL_PATH=%s' % py_pkgs_path)
                else:
                    self.cfg.update('configopts',
                                    '-DPYTHON_PACKAGES_PATH=%s' % py_pkgs_path)
            else:
                self.cfg.update(
                    'configopts',
                    "-DBUILD_PYTHON_SUPPORT=OFF -DBUILD_NEW_PYTHON_SUPPORT=OFF"
                )

        # enable CUDA support if CUDA is a dependency
        if 'WITH_CUDA' not in self.cfg['configopts']:
            if get_software_root('CUDA'):
                self.cfg.update('configopts', '-DWITH_CUDA=ON')
            else:
                self.cfg.update('configopts', '-DWITH_CUDA=OFF')

        # disable bundled protobuf if it is a dependency
        if 'BUILD_PROTOBUF' not in self.cfg['configopts']:
            if get_software_root('protobuf'):
                self.cfg.update('configopts', '-DBUILD_PROTOBUF=OFF')
            else:
                self.cfg.update('configopts', '-DBUILD_PROTOBUF=ON')

        # configure for dependency libraries
        for dep in [
                'JasPer', 'libjpeg-turbo', 'libpng', 'LibTIFF', 'libwebp',
                'OpenEXR', 'zlib'
        ]:
            if dep in ['libpng', 'LibTIFF', 'libwebp']:
                # strip off 'lib'
                opt_name = dep[3:].upper()
            elif dep == 'libjpeg-turbo':
                opt_name = 'JPEG'
            else:
                opt_name = dep.upper()

            shlib_ext = get_shared_lib_ext()
            if dep == 'zlib':
                lib_file = 'libz.%s' % shlib_ext
            else:
                lib_file = 'lib%s.%s' % (opt_name.lower(), shlib_ext)

            dep_root = get_software_root(dep)
            if dep_root:
                if dep == 'OpenEXR':
                    self.cfg.update('configopts',
                                    '-D%s_ROOT=%s' % (opt_name, dep_root))
                else:
                    inc_path = os.path.join(dep_root, 'include')
                    self.cfg.update(
                        'configopts',
                        '-D%s_INCLUDE_DIR=%s' % (opt_name, inc_path))
                    libdir = get_software_libdir(dep, only_one=True)
                    lib_path = os.path.join(dep_root, libdir, lib_file)
                    self.cfg.update('configopts',
                                    '-D%s_LIBRARY=%s' % (opt_name, lib_path))

        # GTK+3 is used by default, use GTK+2 or none explicitely to avoid picking up a system GTK
        if get_software_root('GTK+'):
            if LooseVersion(
                    get_software_version('GTK+')) < LooseVersion('3.0'):
                self.cfg.update('configopts', '-DWITH_GTK_2_X=ON')
        elif get_software_root('GTK3'):
            pass
        elif get_software_root('GTK2'):
            self.cfg.update('configopts', '-DWITH_GTK_2_X=ON')
        else:
            self.cfg.update('configopts', '-DWITH_GTK=OFF')

        # configure optimisation for CPU architecture
        # see https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options
        if self.toolchain.options.get(
                'optarch') and 'CPU_BASELINE' not in self.cfg['configopts']:
            optarch = build_option('optarch')
            if optarch is None:
                # optimize for host arch (let OpenCV detect it)
                self.cfg.update('configopts', '-DCPU_BASELINE=DETECT')
            elif optarch == OPTARCH_GENERIC:
                # optimize for generic x86 architecture (lowest supported by OpenCV is SSE3)
                self.cfg.update('configopts', '-DCPU_BASELINE=SSE3')
            else:
                raise EasyBuildError(
                    "Don't know how to configure OpenCV in accordance with --optarch='%s'",
                    optarch)

        if self.cfg['cpu_dispatch']:
            # using 'NONE' as value is equivalent with disabling the build of fat binaries (which is done by default)
            self.cfg.update('configopts',
                            '-DCPU_DISPATCH=%s' % self.cfg['cpu_dispatch'])

        # make sure that host CPU supports FP16 (unless -DCPU_BASELINE_DISABLE is already specified)
        # Intel Sandy Bridge does not support FP16!
        if 'CPU_BASELINE_DISABLE' not in self.cfg['configopts']:
            avail_cpu_features = get_cpu_features()
            if 'f16c' not in avail_cpu_features:
                self.cfg.update('configopts', '-DCPU_BASELINE_DISABLE=FP16')

        super(EB_OpenCV, self).configure_step()
示例#15
0
 def test_cpu_features_native(self):
     """Test getting CPU features."""
     cpu_feat = get_cpu_features()
     self.assertTrue(isinstance(cpu_feat, list))
     self.assertTrue(len(cpu_feat) > 0)
     self.assertTrue(all([isinstance(x, basestring) for x in cpu_feat]))
示例#16
0
    def configure_step(self):
        """Custom configuration procedure for OpenCV."""

        if 'CMAKE_BUILD_TYPE' not in self.cfg['configopts']:
            self.cfg.update('configopts', '-DCMAKE_BUILD_TYPE=Release')

        # enable Python support if unspecified and Python is a dependency
        if 'BUILD_PYTHON_SUPPORT' not in self.cfg['configopts']:
            if get_software_root('Python'):
                self.cfg.update(
                    'configopts',
                    "-DBUILD_PYTHON_SUPPORT=ON -DBUILD_NEW_PYTHON_SUPPORT=ON")
                py_pkgs_path = os.path.join(self.installdir, self.pylibdir)
                self.cfg.update('configopts',
                                '-DPYTHON_PACKAGES_PATH=%s' % py_pkgs_path)
            else:
                self.cfg.update(
                    'configopts',
                    "-DBUILD_PYTHON_SUPPORT=OFF -DBUILD_NEW_PYTHON_SUPPORT=OFF"
                )

        # enable CUDA support if CUDA is a dependency
        if 'WITH_CUDA' not in self.cfg['configopts']:
            if get_software_root('CUDA'):
                self.cfg.update('configopts', '-DWITH_CUDA=ON')
            else:
                self.cfg.update('configopts', '-DWITH_CUDA=OFF')

        # configure for dependency libraries
        for dep in ['JasPer', 'libjpeg-turbo', 'libpng', 'LibTIFF', 'zlib']:
            if dep in ['libpng', 'LibTIFF']:
                # strip off 'lib'
                opt_name = dep[3:].upper()
            elif dep == 'libjpeg-turbo':
                opt_name = 'JPEG'
            else:
                opt_name = dep.upper()

            shlib_ext = get_shared_lib_ext()
            if dep == 'zlib':
                lib_file = 'libz.%s' % shlib_ext
            else:
                lib_file = 'lib%s.%s' % (opt_name.lower(), shlib_ext)

            dep_root = get_software_root(dep)
            if dep_root:
                self.cfg.update(
                    'configopts', '-D%s_INCLUDE_DIR=%s' %
                    (opt_name, os.path.join(dep_root, 'include')))
                libdir = get_software_libdir(dep, only_one=True)
                self.cfg.update(
                    'configopts', '-D%s_LIBRARY=%s' %
                    (opt_name, os.path.join(dep_root, libdir, lib_file)))

        # configure optimisation for CPU architecture
        # see https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options
        if self.toolchain.options.get(
                'optarch') and 'CPU_BASELINE' not in self.cfg['configopts']:
            optarch = build_option('optarch')
            if optarch is None:
                # optimize for host arch (let OpenCV detect it)
                self.cfg.update('configopts', '-DCPU_BASELINE=DETECT')
            elif optarch == OPTARCH_GENERIC:
                # optimize for generic x86 architecture (lowest supported by OpenCV is SSE3)
                self.cfg.update('configopts', '-DCPU_BASELINE=SSE3')
            else:
                raise EasyBuildError(
                    "Don't know how to configure OpenCV in accordance with --optarch='%s'",
                    optarch)

        if self.cfg['cpu_dispatch']:
            # using 'NONE' as value is equivalent with disabling the build of fat binaries (which is done by default)
            self.cfg.update('configopts',
                            '-DCPU_DISPATCH=%s' % self.cfg['cpu_dispatch'])

        # make sure that host CPU supports FP16 (unless -DCPU_BASELINE_DISABLE is already specified)
        # Intel Sandy Bridge does not support FP16!
        if 'CPU_BASELINE_DISABLE' not in self.cfg['configopts']:
            avail_cpu_features = get_cpu_features()
            if 'f16c' not in avail_cpu_features:
                self.cfg.update('configopts', '-DCPU_BASELINE_DISABLE=FP16')

        super(EB_OpenCV, self).configure_step()
    def configure_step(self):
        """Custom configuration procedure for OpenCV."""

        if 'CMAKE_BUILD_TYPE' not in self.cfg['configopts']:
            self.cfg.update('configopts', '-DCMAKE_BUILD_TYPE=Release')

        # enable Python support if unspecified and Python is a dependency
        if 'BUILD_PYTHON_SUPPORT' not in self.cfg['configopts']:
            if get_software_root('Python'):
                self.cfg.update('configopts', "-DBUILD_PYTHON_SUPPORT=ON -DBUILD_NEW_PYTHON_SUPPORT=ON")
                py_pkgs_path = os.path.join(self.installdir, self.pylibdir)
                self.cfg.update('configopts', '-DPYTHON_PACKAGES_PATH=%s' % py_pkgs_path)
            else:
                self.cfg.update('configopts', "-DBUILD_PYTHON_SUPPORT=OFF -DBUILD_NEW_PYTHON_SUPPORT=OFF")

        # enable CUDA support if CUDA is a dependency
        if 'WITH_CUDA' not in self.cfg['configopts']:
            if get_software_root('CUDA'):
                self.cfg.update('configopts', '-DWITH_CUDA=ON')
            else:
                self.cfg.update('configopts', '-DWITH_CUDA=OFF')

        # configure for dependency libraries
        for dep in ['JasPer', 'libjpeg-turbo', 'libpng', 'LibTIFF', 'zlib']:
            if dep in ['libpng', 'LibTIFF']:
                # strip off 'lib'
                opt_name = dep[3:].upper()
            elif dep == 'libjpeg-turbo':
                opt_name = 'JPEG'
            else:
                opt_name = dep.upper()

            shlib_ext = get_shared_lib_ext()
            if dep == 'zlib':
                lib_file = 'libz.%s' % shlib_ext
            else:
                lib_file = 'lib%s.%s' % (opt_name.lower(), shlib_ext)

            dep_root = get_software_root(dep)
            if dep_root:
                self.cfg.update('configopts', '-D%s_INCLUDE_DIR=%s' % (opt_name, os.path.join(dep_root, 'include')))
                libdir = get_software_libdir(dep, only_one=True)
                self.cfg.update('configopts', '-D%s_LIBRARY=%s' % (opt_name, os.path.join(dep_root, libdir, lib_file)))

        # configure optimisation for CPU architecture
        # see https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options
        if self.toolchain.options.get('optarch') and 'CPU_BASELINE' not in self.cfg['configopts']:
            optarch = build_option('optarch')
            if optarch is None:
                # optimize for host arch (let OpenCV detect it)
                self.cfg.update('configopts', '-DCPU_BASELINE=DETECT')
            elif optarch == OPTARCH_GENERIC:
                # optimize for generic x86 architecture (lowest supported by OpenCV is SSE3)
                self.cfg.update('configopts', '-DCPU_BASELINE=SSE3')
            else:
                raise EasyBuildError("Don't know how to configure OpenCV in accordance with --optarch='%s'", optarch)

        if self.cfg['cpu_dispatch']:
            # using 'NONE' as value is equivalent with disabling the build of fat binaries (which is done by default)
            self.cfg.update('configopts', '-DCPU_DISPATCH=%s' % self.cfg['cpu_dispatch'])

        # make sure that host CPU supports FP16 (unless -DCPU_BASELINE_DISABLE is already specified)
        # Intel Sandy Bridge does not support FP16!
        if 'CPU_BASELINE_DISABLE' not in self.cfg['configopts']:
            avail_cpu_features = get_cpu_features()
            if 'f16c' not in avail_cpu_features:
                self.cfg.update('configopts', '-DCPU_BASELINE_DISABLE=FP16')

        super(EB_OpenCV, self).configure_step()