|
| 1 | +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other |
| 2 | +# Spack Project Developers. See the top-level COPYRIGHT file for details. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: (Apache-2.0 OR MIT) |
| 5 | + |
| 6 | +from spack import * |
| 7 | +from spack.pkg.builtin.fftw import FftwBase |
| 8 | +from spack.error import SpackError |
| 9 | + |
| 10 | + |
| 11 | +def target_check(spec): |
| 12 | + if spec.target != "a64fx": |
| 13 | + error_msg = ("It can only be built on an A64FX machine.\n") |
| 14 | + raise SpackError(error_msg) |
| 15 | + |
| 16 | + |
| 17 | +class FujitsuFftw(FftwBase): |
| 18 | + """FFTW (Fujitsu Optimized version) is a comprehensive collection of |
| 19 | + fast C routines for computing the Discrete Fourier Transform (DFT) |
| 20 | + and various special cases thereof. |
| 21 | +
|
| 22 | + It is an open-source implementation of the Fast Fourier transform |
| 23 | + algorithm. It can compute transforms of real and complex-values |
| 24 | + arrays of arbitrary size and dimension. |
| 25 | + Fujitsu Optimized FFTW is the optimized FFTW implementation targeted |
| 26 | + for A64FX CPUs. |
| 27 | +
|
| 28 | + For single precision build, please use precision value as float. |
| 29 | + Example : spack install fujitsufftw precision=float |
| 30 | + """ |
| 31 | + |
| 32 | + _name = 'fujitsu-fftw' |
| 33 | + homepage = "https://github.com/fujitsu/fftw3" |
| 34 | + |
| 35 | + version('master', branch='fj_master', git='https://github.com/fujitsu/fftw3.git') |
| 36 | + |
| 37 | + variant('shared', default=True, description='Builds a shared version of the library') |
| 38 | + variant('openmp', default=True, description="Enable OpenMP support") |
| 39 | + variant('debug', default=False, description='Builds a debug version of the library') |
| 40 | + |
| 41 | + depends_on('texinfo') |
| 42 | + |
| 43 | + provides('fftw-api@3', when='@2:') |
| 44 | + |
| 45 | + conflicts('precision=quad', when='%fj', msg="Fujitsu Compiler doesn't support quad precision") |
| 46 | + conflicts('precision=long_double', when='%fj', msg="ARM-SVE vector instructions only works in single or double precision") |
| 47 | + conflicts('%arm') |
| 48 | + conflicts('%cce') |
| 49 | + conflicts('%apple-clang') |
| 50 | + conflicts('%clang') |
| 51 | + conflicts('%gcc') |
| 52 | + conflicts('%intel') |
| 53 | + conflicts('%nag') |
| 54 | + conflicts('%pgi') |
| 55 | + conflicts('%xl') |
| 56 | + conflicts('%xl_r') |
| 57 | + |
| 58 | + def autoreconf(self, spec, prefix): |
| 59 | + if spec.target != "a64fx": |
| 60 | + target_check(spec) |
| 61 | + |
| 62 | + touch = which('touch') |
| 63 | + touch('ChangeLog') |
| 64 | + autoreconf = which('autoreconf') |
| 65 | + autoreconf('-ifv') |
| 66 | + |
| 67 | + def configure(self, spec, prefix): |
| 68 | + """Configure function""" |
| 69 | + # Base options |
| 70 | + options = [ |
| 71 | + 'CFLAGS=-Ofast', |
| 72 | + 'FFLAGS=-Kfast', |
| 73 | + '--enable-sve', |
| 74 | + '--enable-armv8-cntvct-el0', |
| 75 | + '--enable-fma', |
| 76 | + '--enable-fortran', |
| 77 | + '--prefix={0}'.format(prefix), |
| 78 | + 'ac_cv_prog_f77_v=-###' |
| 79 | + ] |
| 80 | + |
| 81 | + if '+shared' in spec: |
| 82 | + options.append('--enable-shared') |
| 83 | + else: |
| 84 | + options.append('--disable-shared') |
| 85 | + |
| 86 | + if '+openmp' in spec: |
| 87 | + options.append('--enable-openmp') |
| 88 | + options.append('OPENMP_CFLAGS=-Kopenmp') |
| 89 | + else: |
| 90 | + options.append('--disable-openmp') |
| 91 | + |
| 92 | + if '+mpi' in spec: |
| 93 | + options.append('--enable-mpi') |
| 94 | + else: |
| 95 | + options.append('--disable-mpi') |
| 96 | + |
| 97 | + # Double is the default precision, for all the others we need |
| 98 | + # to enable the corresponding option. |
| 99 | + enable_precision = { |
| 100 | + 'float': ['--enable-float'], |
| 101 | + 'double': None, |
| 102 | + 'long_double': ['--enable-long-double'], |
| 103 | + 'quad': ['--enable-quad-precision'] |
| 104 | + } |
| 105 | + |
| 106 | + # Different precisions must be configured and compiled one at a time |
| 107 | + configure = Executable('../configure') |
| 108 | + for precision in self.selected_precisions: |
| 109 | + |
| 110 | + opts = (enable_precision[precision] or []) + options[:] |
| 111 | + with working_dir(precision, create=True): |
| 112 | + configure(*opts) |
0 commit comments