@@ -1,5 +1,7 @@
11{ stdenv, fetchurl, gfortran, tolerateCpuTimingInaccuracy ? true, shared ? false
2−, cpuConfig ? if stdenv.isi686 then "-b 32 -A 18 -V 1" else "-b 64 -A 31 -V 384"
2+, cpuConfig ? if stdenv.isi686 then "-b 32 -A 12 -V 1" else "-b 64 -A 14 -V 384"
3+, cacheEdge ? "262144"
4+, threads ? "0"
35}:
46
57# Atlas detects the CPU and optimizes its build accordingly. This is great when
@@ -9,27 +11,40 @@
911# cannot execute.
1012#
1113# To avoid these issues, the build is configured using the 'cpuConfig'
12−# parameter as follows:
14+# parameter. Upstream recommends these defaults for distributions:
1315#
1416# | x86 CPU | x86_64 CPU |
1517# |---------------------------------------------+------------------------|
1618# | -b 32 | -b 64 |
17−# | -A 18 (Pentium II) | -A 31 (Athlon K7) |
18−# | -V 1 (No SIMD: Pentium II doesn't have SSE) | -V 384 (SSE1 and SSE2) |
19+# | -A 12 (x86x87) | -A 14 (x86SSE2) |
20+# | -V 1 (No SIMD) | -V 384 (SSE1 and SSE2) |
1921#
20−# Users who want to compile a highly optimized version of ATLAS that's suitable
21−# for their local machine can override these settings accordingly.
22+# These defaults should give consistent performance across machines.
23+# Performance will be substantially lower than an optimized build, but a build
24+# optimized for one machine will give even worse performance on others. If you
25+# are a serious user of Atlas (e.g., you write code that uses it) you should
26+# compile an optimized version for each of your machines.
27+#
28+# The parameter 'cacheEdge' sets the L2 cache per core (in bytes). Setting this
29+# parameter reduces build time because some tests to detect the L2 cache size
30+# will not be run. It will also reduce impurity; different build nodes on Hydra
31+# may have different L2 cache sizes, but fixing the L2 cache size should
32+# account for that. This also makes the performance of binary substitutes more
33+# consistent.
2234#
2335# The -V flags can change with each release as new instruction sets are added
2436# because upstream thinks it's a good idea to add entries at the start of an
2537# enum, rather than the end. If the build suddenly fails with messages about
2638# missing instruction sets, you may need to poke around in the source a bit.
39+#
40+# Upstream recommends the x86x87/x86SSE2 architectures for generic x86/x86_64
41+# for distribution builds. Additionally, we set 'cacheEdge' to reduce impurity.
42+# Otherwise, the cache parameters will be detected by timing which will be
43+# highly variable on Hydra.
2744
2845let
46+ inherit (stdenv.lib) optional optionalString;
2947 version = "3.10.2";
30−
31− optionalString = stdenv.lib.optionalString;
32− optional = stdenv.lib.optional;
3348in
3449
3550stdenv.mkDerivation {
@@ -50,27 +65,50 @@ stdenv.mkDerivation {
5065 patches = optional tolerateCpuTimingInaccuracy ./disable-timing-accuracy-check.patch;
5166
5267 # Configure outside of the source directory.
53− preConfigure = '' mkdir build; cd build; configureScript=../configure; '';
68+ preConfigure = ''
69+ mkdir build
70+ cd build
71+ configureScript=../configure
72+ '';
5473
5574 # * -fPIC is passed even in non-shared builds so that the ATLAS code can be
5675 # used to inside of shared libraries, like Octave does.
5776 #
5877 # * -t 0 disables use of multi-threading. It's not quite clear what the
5978 # consequences of that setting are and whether it's necessary or not.
60− configureFlags = "-Fa alg -fPIC -t 0 ${cpuConfig}" + optionalString shared " --shared";
79+ configureFlags = [
80+ "-Fa alg"
81+ "-fPIC"
82+ "-t ${threads}"
83+ cpuConfig
84+ ] ++ optional shared "--shared";
85+
86+ postConfigure = ''
87+ if [[ -n "${cacheEdge}" ]]; then
88+ echo '#define CacheEdge ${cacheEdge}' >> include/atlas_cacheedge.h
89+ echo '#define CacheEdge ${cacheEdge}' >> include/atlas_tcacheedge.h
90+ fi
91+ '';
6192
6293 doCheck = true;
6394
95+ postInstall = ''
96+ # Avoid name collision with the real lapack (ATLAS only builds a partial
97+ # lapack).
98+ mv $out/lib/liblapack.a $out/lib/liblapack_atlas.a
99+ '';
100+
64101 meta = {
65102 homepage = "http://math-atlas.sourceforge.net/";
66103 description = "Automatically Tuned Linear Algebra Software (ATLAS)";
67104 license = stdenv.lib.licenses.bsd3;
68105
69106 longDescription = ''
70− The ATLAS (Automatically Tuned Linear Algebra Software) project is an ongoing
71− research effort focusing on applying empirical techniques in order to provide
72− portable performance. At present, it provides C and Fortran77 interfaces to a
73− portably efficient BLAS implementation, as well as a few routines from LAPACK.
107+ The ATLAS (Automatically Tuned Linear Algebra Software) project is an
108+ ongoing research effort focusing on applying empirical techniques in
109+ order to provide portable performance. At present, it provides C and
110+ Fortran77 interfaces to a portably efficient BLAS implementation, as well
111+ as a few routines from LAPACK.
74112 '';
75113
76114 maintainers = with stdenv.lib.maintainers; [ ttuegel ];