forked from lloda/ra-ra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
82 lines (67 loc) · 3.09 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- mode: Python -*-
# -*- coding: utf-8 -*-
# (c) Daniel Llorens - 2015-2016
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version.
# SConstruct for ra/bench
# FIXME Shared pieces with {examples,test,doc}/SConstruct
import os, string, atexit
from colorama import Fore, Back, Style
from os.path import join, abspath
import imp
ra = imp.load_source('ra', '../ra.py')
# FIXME pick BLAS flags from here.
try:
Import('top')
except:
top = {}
vars = Variables()
vars.AddVariables(PathVariable('variant_dir', 'build directory', '.', PathVariable.PathIsDirCreate))
env = Environment(options=vars,
ENV=dict([(k, os.environ[k] if k in os.environ else '')
for k in ['PATH', 'HOME', 'TERM', 'LD_RUN_PATH', 'DYLD_LIBRARY_PATH',
'RPATH', 'LIBRARY_PATH', 'TEXINPUTS', 'GCC_COLORS', 'BOOST_ROOT',
'RA_USE_BLAS']]))
variant_dir = env['variant_dir']
for var, default in [('CC', 'gcc'), ('CXX', 'g++'), ('FORTRAN', 'gfortran')]:
ra.take_from_environ(env, var, default=default)
for var in ['FORTRANFLAGS', 'LINKFLAGS', 'CCFLAGS', 'CXXFLAGS']:
ra.take_from_environ(env, var, wrapper=string.split)
for var in ['RPATH', 'LIBPATH']:
ra.take_from_environ(env, var, wrapper=lambda x: [x])
arch = os.popen('../config.guess').read()
if arch.find('86-apple-darwin') >= 0:
archflags=['-march=native', '-Wa,-q']
ld_blas = {'LINKFLAGS': ' -framework Accelerate ', 'LIBS': []}
else:
archflags=['-march=native']
ld_blas = {'LINKFLAGS': '', 'LIBS': ['blas']}
env.Prepend(CPPPATH=['..', '.'],
CCFLAGS=archflags if str(env['CCFLAGS']).strip()=='' else '',
CXXFLAGS=['-std=c++1z', '-Wall', '-Werror', '-fdiagnostics-color=always', '-Wno-unknown-pragmas',
'-finput-charset=UTF-8', '-fextended-identifiers',
'-Wno-error=strict-overflow', '-Werror=zero-as-null-pointer-constant',
#'-Wconversion',
# '-funsafe-math-optimizations', # TODO Test with this.
])
env_blas = env.Clone()
if 'RA_USE_BLAS' in env['ENV'] and env['ENV']['RA_USE_BLAS']=='1':
print("[%s] BLAS will be used." % Dir('.').path)
env_blas.Append(CPPDEFINES={'RA_USE_BLAS': 1})
env_blas.Append(LINKFLAGS=ld_blas['LINKFLAGS'])
env_blas.Append(LIBS=ld_blas['LIBS'])
else:
print("[%s] BLAS won't be used." % Dir('.').path)
if 'skip_summary' not in top:
atexit.register(lambda: ra.print_summary(GetBuildFailures, 'ra/bench'))
[ra.to_test_ra(env, variant_dir)(bench)
for bench in ['bench-dot', 'bench-reduce-sqrm',
'bench-gemv', 'bench-sum-rows', 'bench-sum-cols',
'bench-pack', 'bench-from',
'bench-stencil1', 'bench-stencil2', 'bench-stencil3',
'bench-optimize'
]]
[ra.to_test_ra(env_blas, variant_dir)(bench)
for bench in ['bench-gemm']]