35
35
# FIXME: and DOLFIN wrappers.
37
37
import os, sys, shutil, difflib
38
from numpy import array, shape, abs, max
38
from numpy import array, shape, abs, max, isnan
39
39
from ffc.log import begin, end, info, info_red, info_green, info_blue
40
40
from ufctest import generate_test_code
41
41
from instant.output import get_status_output
176
176
ufc_cflags = get_status_output("pkg-config --cflags ufc-1")[1].strip()
178
# Get Boost dir (code copied from ufc/src/utils/python/ufc_utils/build.py)
179
# Set a default directory for the boost installation
180
if sys.platform == "darwin":
181
# Use MacPorts as default
182
default = os.path.join(os.path.sep, "opt", "local")
184
default = os.path.join(os.path.sep, "usr")
186
# If BOOST_DIR is not set use default directory
189
boost_dir = os.getenv("BOOST_DIR", default)
190
boost_is_found = False
191
for inc_dir in ["", "include"]:
192
if os.path.isfile(os.path.join(boost_dir, inc_dir, "boost", "version.hpp")):
193
boost_inc_dir = os.path.join(boost_dir, inc_dir)
195
for lib_dir in ["", "lib"]:
196
if os.path.isfile(os.path.join(boost_dir, lib_dir, "libboost_math_tr1.so")) or\
197
os.path.isfile(os.path.join(boost_dir, lib_dir, "libboost_math_tr1.dylib")):
198
boost_lib_dir = os.path.join(boost_dir, lib_dir)
200
if boost_inc_dir != "" and boost_lib_dir != "":
201
boost_is_found = True
203
if not boost_is_found:
204
raise OSError, """The Boost library was not found.
205
If Boost is installed in a nonstandard location,
206
set the environment variable BOOST_DIR.
209
ufc_cflags += " -I%s -L%s" % (boost_inc_dir, boost_lib_dir)
178
211
# Set compiler options
180
213
info("Benchmarking activated")
194
227
# Compile test code
195
228
prefix = f.split(".h")[0]
196
command = "g++ %s -o %s.bin %s.cpp" % (compiler_options, prefix, prefix)
229
command = "g++ %s -o %s.bin %s.cpp -lboost_math_tr1" % (compiler_options, prefix, prefix)
197
230
ok = run_command(command)
284
317
# Check that values match to within tolerance
285
318
diff = max(abs(old_values - new_values))
319
if diff > tolerance or isnan(diff):
287
320
if ok: log_error("\n" + header + "\n" + len(header)*"-")
288
321
log_error("%s: values differ, error = %g (tolerance = %g)" % (key, diff, tolerance))
289
322
log_error(" old = " + " ".join("%.16g" % v for v in old_values))