/ src / optmized / SConscript
SConscript
 1  # Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved.
 2  #
 3  # Redistribution and use in source and binary forms, with or without modification,
 4  # are permitted provided that the following conditions are met:
 5  # 1. Redistributions of source code must retain the above copyright notice,
 6  #    this list of conditions and the following disclaimer.
 7  # 2. Redistributions in binary form must reproduce the above copyright notice,
 8  #    this list of conditions and the following disclaimer in the documentation
 9  #    and/or other materials provided with the distribution.
10  # 3. Neither the name of the copyright holder nor the names of its contributors
11  #    may be used to endorse or promote products derived from this software without
12  #    specific prior written permission.
13  #
14  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18  # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21  # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23  # POSSIBILITY OF SUCH DAMAGE.
24  
25  # Inherit global environment
26  Import('env')
27  from os.path import join as joinpath
28  
29  builddir = joinpath(env['BUILDROOT'], 'src', 'optmized')
30  
31  e = env.Clone()
32  
33  # These rearrangements are not value-safe:
34  #	 (a ⊕ b) ⊕ c ⇒ a ⊕ (b ⊕ c)
35  #	 a ⊗ (b ⊕ c) ⇒ (a ⊗ b) ⊕ (a ⊕ c)
36  #
37  # To Disallow these changes in gcc remove -ffast-math
38  if '-ffast-math' in e['CFLAGS']:
39      e['CFLAGS'].remove('-ffast-math')
40  
41  e.Append(
42      CFLAGS = ['-fPIC']
43  )
44  
45  try:
46      dbg_mode=env['debug_mode']
47  except KeyError as err:
48      print("Keyerror, debug_mode not found, setting to none", err)
49      dbg_mode='none'
50  
51  if dbg_mode == 'libs' or dbg_mode == 'all':
52      e.Append(
53          CCFLAGS = ['-g']
54         )
55      # remove all optimizations on command line
56      opt_list=["-O%s"%x for x in range(1, 10)]
57      opt_list.append('-Os')
58      for opt in opt_list:
59          try:
60              e['CFLAGS'].remove(opt)
61          except ValueError as err:
62              pass
63  else:
64      e.Append(
65          CCFLAGS = ['-O3'],
66      )
67  
68  experiment_src=[
69  	'expm1f.c',
70  	]
71  
72  source = Glob('*.c', exclude=experiment_src)
73  source += Glob('data/*.c')
74  
75  vec_objs   = SConscript('vec/SConscript',
76                          exports    = {'env' : e},
77                          duplicate  = 0,
78                          src_dir    = '#src/optmized/vec',
79  			variant_dir= joinpath(builddir, 'vec'))
80  
81  objs = e.StaticObject(source) + vec_objs
82  
83  Return('objs')