summaryrefslogtreecommitdiff
path: root/libraries/integer-gmp
Commit message (Collapse)AuthorAgeFilesLines
* integer-gmp: Make minusInteger more efficientAlan Mock2016-06-042-3/+41
| | | | | | | | | | | | | | | | Give `minusInteger` its own implementation. Previously `minusInteger` used `plusInteger` and `negateInteger`, which meant it always allocated. Now it works more like `plusInteger`. Reviewers: goldfire, hvr, bgamari, austin Reviewed By: hvr, bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2278 GHC Trac Issues: #12129
* Make integer-gmp operations more strictHerbert Valerio Riedel2016-03-111-9/+9
| | | | | | | | | | | | Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1984 GHC Trac Issues: #10691
* Build system: Correctly pass `TARGETPLATFORM` as hostNicolas Trangez2016-02-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | When building the bundled GMP sources, the `HOSTPLATFORM` value was passed to the `--host` flag of the `./configure` call. This is incorrect: when building a cross-compiler, e.g. a compiler targeting ARM but running on X86, the host on which GMP will run is ARM, i.e. the target platform of the compiler, and the host platform (i.e. the platform on which the compiler will run) is X86. See e.g. [1] for more information about the meaning of and relation between build, host and target. [1] https://www.gnu.org/software/autoconf/manual/ autoconf-2.65/html_node/Specifying-Target-Triplets.html Test Plan: Building ARM cross-compiler with `integer-gmp` Reviewers: thomie, gracjan, austin, erikd, Phyx, hvr, bgamari Reviewed By: erikd, bgamari Subscribers: erikd, gracjan Differential Revision: https://phabricator.haskell.org/D1960
* Switch from -this-package-key to -this-unit-id.Edward Z. Yang2016-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A small cosmetic change, but we have to do a bit of work to actually support it: - Cabal submodule update, so that Cabal passes us -this-unit-id when we ask for it. This includes a Cabal renaming to be consistent with Unit ID, which makes ghc-pkg a bit more scrutable. - Build system is updated to use -this-unit-id rather than -this-package-key, to avoid deprecation warnings. Needs a version test so I resurrected the old test we had (sorry rwbarton!) - I've *undeprecated* -package-name, so that we are in the same state as GHC 7.10, since the "correct" flag will have only entered circulation in GHC 8.0. - I removed -package-key. Since we didn't deprecate -package-id I think this should not cause any problems for users; they can just change their code to use -package-id. - The package database is indexed by UNIT IDs, not component IDs. I updated the naming here. - I dropped the signatures field from ExposedModule; nothing was using it, and instantiatedWith from the package database field. - ghc-pkg was updated to use unit ID nomenclature, I removed the -package-key flags but I decided not to add any new flags for now. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: 23Skidoo, thomie, erikd Differential Revision: https://phabricator.haskell.org/D1780
* Patch-level increment integer-gmp to 1.0.0.1Herbert Valerio Riedel2015-12-282-1/+11
| | | | and update changelog.md
* integer-gmp: Fix #11296Ben Gamari2015-12-271-2/+2
| | | | | | | | | | | | | | | | | | | This was introduced by a mental fumble in 9e8562ae02701270e2c1dfcee3279d862dc5b7b6 wherein I replaced `getSizeofMutableByteArray` with `getSizeofMutBigNat`. This was noticed by invalid integers being produced on 32-bit machines in #11296. Test Plan: Validate Reviewers: hvr, goldfire, austin Reviewed By: hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1707 GHC Trac Issues: #11296
* Use idiomatic way to tell Autoconf the c compilerHerbert Valerio Riedel2015-12-141-4/+1
| | | | | | | | | | | | | | | | | | | | The non-idiomatic `--with-cc` flag was added via 5c789e424c1461c1dadfd38c44fcb9e8f38bf755 However, `--with-cc` seems rather fragile and support for `--with-cc` needs to be added explicitly to autoconf-based Cabal packages. The `CC=` flag, however, is supported natively by GNU Autoconf, so let's use the standard facility for that. Relatedly, Cabal prior to version 1.24 used a similiar flag `--with-gcc=...`, but starting with Cabal-1.24 this has been changed to use `CC=...` instead as well (see https://github.com/haskell/cabal/pull/2946) This also updates a few submodules removing the now obsolete `--with-cc` flag support. Reviewed By: trofi, thomie, erikd Differential Revision: https://phabricator.haskell.org/D1608
* Tweak use of AC_USE_SYSTEM_EXTENSIONSHerbert Valerio Riedel2015-12-061-1/+3
| | | | | | | | | | | | | This makes sure that `AC_USE_SYSTEM_EXTENSIONS` (which implies `AC_PROG_CC`) is called after the `AC_ARG_WITH([cc],,)` invocation, so that the proper CC setting is in scope. Otherwise this can break cross-compilation. This also needs to pull in a submodule update for `unix` This is a follow-up commit to 7af29da05d2e5a5e311a5f73f20d0f232035973b which hopefully fixes #11168
* New magic function for applying realWorld#Ben Gamari2015-11-121-2/+1
| | | | | | | | | | | | | | Test Plan: validate Reviewers: goldfire, erikd, rwbarton, simonpj, austin, simonmar, hvr Reviewed By: simonpj Subscribers: simonmar, thomie Differential Revision: https://phabricator.haskell.org/D1103 GHC Trac Issues: #10678
* Add subWordC# on x86ishNikita Karetnikov2015-10-311-7/+0
| | | | | | | | | | | | | | | This adds a subWordC# primop which implements subtraction with overflow reporting. Reviewers: tibbe, goldfire, rwbarton, bgamari, austin, hvr Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1334 GHC Trac Issues: #10962
* integer-gmp: optimise bitBigNatHerbert Valerio Riedel2015-08-291-1/+18
| | | | | | | | | | | | | This is a somewhat minor optimisation exploiting the static knowledge of the operands involved allowing to save a few allocations. Reviewers: austin, rwbarton, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1179
* Implement getSizeofMutableByteArrayOp primopBen Gamari2015-08-211-28/+35
| | | | | | | | | | | | | | | Now since ByteArrays are mutable we need to be more explicit about when the size is queried. Test Plan: Add testcase and validate Reviewers: goldfire, hvr, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1139 GHC Trac Issues: #9447
* Build system: delete half-baked Cygwin supportThomas Miedema2015-08-201-5/+0
| | | | | | | | | | | | | | | | | | | We only support building GHC on mys2 nowadays, see https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Windows. This (partially) reverts various commits from a few years ago, among which: * 5775d5142da227d65fb86994d363eb16841ee642 "Add OSTYPE build-system variable, and use it" * 3fb8c431824aa2f3bd979e35d1a283546fcfbe74 "Fix building libgmp on cygwin" * cdbb4720c424500adb57cbbef69721d0b039fa46 "Fix cmd invocation by libffi cuild system on Windows 7 cygwin" * e8121501ee3549a35e954726ccfd871ac9d51f83 "Fix dblatex and xml* tool detection on Windows" Reviewed by: austin, Phyx Differential Revision: https://phabricator.haskell.org/D1155
* Add missing parentheses in eqBigNatWord#Reid Barton2015-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I'm pretty sure that parentheses were intended here. But oddly, they make very little difference. The presumably intended expression (sizeofBigNat# bn ==# 1#) `andI#` (bigNatToWord bn `eqWord#` w#) is 1# exactly when bn consists of a single limb equal to w#, clearly. In the original expression sizeofBigNat# bn ==# 1# `andI#` (bigNatToWord bn `eqWord#` w#) the right-hand side of ==# is always 0# or 1#. So it is 1# when bn consists of a single limb equal to w#. It is also 1# when bn has zero limbs and the word past the end of bn does not happen to be equal to w#. So in practice the difference is that nullBigNat was eqBigNatWord# to almost everything, but eqBigNatWord# is never supposed to be called on nullBigNat anyways. Note that even the corrected version might perform an out-of-bounds memory access if passed nullBigNat, because `andI#` is not guaranteed to short-circuit, though in fact GHC does convert isZeroBigNat to a series of branches in my local build. Test Plan: validate Reviewers: hvr, bgamari, goldfire, austin Reviewed By: hvr, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1095
* Use isTrue# around primitive comparisons in integer-gmpReid Barton2015-07-251-30/+30
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The form case na# ==# nb# of 0# -> ... _ -> ... sometimes generates convoluted assembly, see #10676. timesInt2Integer was the most spectacular offender, especially as it is a rather cheap function overall (no calls to gmp). I checked a few instances and some of the old generated assembly was fine already, but I changed them all for consistency. The new form is also more consistent with use of these primops in general. Test Plan: validate Reviewers: hvr, bgamari, goldfire, austin Reviewed By: hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1094
* Build: ./boot && ./configure && make sdist (#8723)Thomas Miedema2015-06-041-1/+4
| | | | | | | | | | | | | | | | | Make it possible to run `make sdist` right after configure, without completing a complete build first. Test Plan: I compared the contents of the created `.tar.bz2` files in the `sdistprep` directory, after running `make sdist` both before and after completing a full build, using `diff -r`. There weren't any differences (after applying the patches from D914). Note that the `.tar.bz2` files were not exactly the same size, but they aren't either when tarring and bzipping the same directory twice. It seems tarring and bzipping is not deterministic (on my system). Differential Revision: https://phabricator.haskell.org/D917
* Build system: prevent "--version: Command not found"Thomas Miedema2015-05-301-1/+4
| | | | | | | This would happen when running `make clean` before running `./configure`. [skip ci]
* Build system: check $CLEANING instead of $MAKECMDGOALSThomas Miedema2015-05-301-1/+1
| | | | | | | To check if we're cleaning, always check the $CLEANING variable, instead of sometimes $CLEANING, sometimes $MAKECMDGOALS. [skip ci]
* Drop old integer-gmp-0.5 from GHC source treeHerbert Valerio Riedel2015-03-3130-3332/+3589
| | | | | | | | | | | | | | | | | | This completes what c774b28f76ee4c220f7c1c9fd81585e0e3af0e8a (#9281) started. `integer-gmp-1.0` was added as an additional `libraries/integer-gmp2` folder while retaining the ability to configure GHC w/ the old `integer-gmp-0.5` to have a way back, and or the ability to easily switch between old/new `integer-gmp` for benchmark/debugging purposes. This commit removes the old `libraries/integer-gmp` folder and moves `libraries/integer-gmp2` into its place, while removing any mentions of "gmp2" as well as the to support two different `integer-gmp` packages in GHC's source-tree. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D769
* Bump ghc-prim to 0.4.0.0Herbert Valerio Riedel2015-03-201-1/+1
| | | | | | | | | | | | This major version bump was made necessary by f44333eae7bc7dc7b6003b75874a02445f6b633b which changed the type signatures of prefetch primops, as well as other changes such as 051d694fc978ad28ac3043d296cafddd3c2a7050 turning `Any` into an abstract closed type family. Reviewed By: ekmett Differential Revision: https://phabricator.haskell.org/D743
* Update in-tree GMP to version 5.0.4Herbert Valerio Riedel2014-11-231-0/+1584
| | | | | | | This is mostly a proof of concept for updating the in-tree GMP via patch files (and therefore w/o introducing new blobs into the Git history). NOTE: The updated GMP 5.0.4 version is only used by the integer-gmp2 backend.
* Revert "Rename _closure to _static_closure, apply naming consistently."Edward Z. Yang2014-10-201-2/+2
| | | | | | | This reverts commit 35672072b4091d6f0031417bc160c568f22d0469. Conflicts: compiler/main/DriverPipeline.hs
* Rename _closure to _static_closure, apply naming consistently.Edward Z. Yang2014-10-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In preparation for indirecting all references to closures, we rename _closure to _static_closure to ensure any old code will get an undefined symbol error. In order to reference a closure foobar_closure (which is now undefined), you should instead use STATIC_CLOSURE(foobar). For convenience, a number of these old identifiers are macro'd. Across C-- and C (Windows and otherwise), there were differing conventions on whether or not foobar_closure or &foobar_closure was the address of the closure. Now, all foobar_closure references are addresses, and no & is necessary. CHARLIKE/INTLIKE were not changed, simply alpha-renamed. Part of remove HEAP_ALLOCED patch set (#8199) Depends on D265 Signed-off-by: Edward Z. Yang <ezyang@mit.edu> Test Plan: validate Reviewers: simonmar, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D267 GHC Trac Issues: #8199
* Update config.{guess,sub} to GNU automake 1.14.1Herbert Valerio Riedel2014-09-162-175/+40
| | | | | | | | | | | | | The new versions should work better under MSYS2 A few submodules' `config.{guess,sub}` files were updated as well With this commit, all config.{guess,sub} files in the GHC tree have the md5sums 0fb81517303511f05a01b14f41cec2cf config.guess d2a165dceaa5ac1edba3c512f6ca7bd1 config.sub This addresses #9597
* Package keys (for linking/type equality) separated from package IDs.Edward Z. Yang2014-08-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch set makes us no longer assume that a package key is a human readable string, leaving Cabal free to "do whatever it wants" to allocate keys; we'll look up the PackageId in the database to display to the user. This also means we have a new level of qualifier decisions to make at the package level, and rewriting some Safe Haskell error reporting code to DTRT. Additionally, we adjust the build system to use a new ghc-cabal output Make variable PACKAGE_KEY to determine library names and other things, rather than concatenating PACKAGE/VERSION as before. Adds a new `-this-package-key` flag to subsume the old, erroneously named `-package-name` flag, and `-package-key` to select packages by package key. RFC: The md5 hashes are pretty tough on the eye, as far as the file system is concerned :( ToDo: safePkg01 test had its output updated, but the fix is not really right: the rest of the dependencies are truncated due to the fact the we're only grepping a single line, but ghc-pkg is wrapping its output. ToDo: In a later commit, update all submodules to stop using -package-name and use -this-package-key. For now, we don't do it to avoid submodule explosion. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D80
* integer-gmp: tweak gitignore.Austin Seipp2014-07-121-0/+3
| | | | | | Auditors: hvr Signed-off-by: Austin Seipp <austin@well-typed.com>
* integer-gmp: do not confuse ./configure (#8783)Christian Maeder2014-05-181-1/+1
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Update integer-gmp's .gitignore fileHerbert Valerio Riedel2014-04-221-12/+13
| | | | | | Note: the .gitignore pattern rules are not that obvious Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Update Cabal source-repository entries (re #8545)Herbert Valerio Riedel2014-04-191-6/+2
| | | | | | | | This adapts the source-repository entries to match the new situation of base.git, ghc-prim.git, integer-gmp.git, integer-simple.git, and template-haskell.git being folded into ghc.git Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Normalize GHC Trac URLsHerbert Valerio Riedel2014-04-193-6/+6
| | | | | | | | | | | | | | Update several old http://hackage.haskell.org/trac/ghc URLs references to the current http://ghc.haskell.org/trac/ghc URLs. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Fix GMP v4 compatibility.Austin Seipp2014-02-268-3/+39
| | | | | | | | | | | | | | | | | | We had started relying on GMP 5.x (for usage of mpz_powm_sec), but this is pretty painful on RHEL-esque targets, which still use GMP 4.x. In the mean time while we're still supporting this, it's easier to just fallback to mpz_powm when _sec is unavailable, and emit a WARNING for using the primitive. This also installs a header, HsIntegerGmp.h, which clients could use for a fallback. As a side note, this will probably also help Debian oldstable users who might have outdated GMP versions (which I believe is the cause for #8666.) Reviewed-by: Herbert Valerio Riedel <hvr@gnu.org> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix negation of `divMod`/`quotRem` results (fixes #8726)Herbert Valerio Riedel2014-02-021-7/+7
| | | | | | | | | | | | | | | | | | | | | | | High-level pseudo code of what the code was supposed to implement: quotRem' :: Integer -> Integer -> (Integer,Integer) quotRem' a b@(S# _) | b < 0 = negFst . uncurry quotRem' . negSnd $ (a,b) | otherwise = quotRemUI a (fromIntegral (abs b)) divMod' :: Integer -> Integer -> (Integer,Integer) divMod' a b@(S# _) | b < 0 = negSnd . uncurry divMod' . negBoth $ (a,b) | otherwise = divModUI a (fromIntegral b) negFst (q,r) = (-q,r) negSnd (q,r) = ( q,-r) negBoth (q,r) = (-q,-r) -- quotRemUI and divModUI represent GMP's `mpz_{f,t}div_qr_ui()` quotRemUI, divModUI :: Integer -> Word -> (Integer,Integer) Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Fix a popular typoGabor Greif2014-02-011-1/+1
| | | | Herbert, this is a merge candidate to the 7.8 branch
* Add Hackage-supported `changelog.md`Herbert Valerio Riedel2014-02-012-0/+45
| | | | Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Improve documentation of `integer-gmp`Herbert Valerio Riedel2014-01-314-32/+115
| | | | | | | | Among other things, this unhides `GHC.Integer` and re-groups the export list. Moreover, the internal representation of `Integer` is explained a bit more, and `/Since: 0.5.1.0/` annotations have been added. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Dont use big/small-int primops on IL32P64 (i.e. Win/x86_64) for nowHerbert Valerio Riedel2014-01-171-9/+78
| | | | | | | | | | | | | | This is due to `mpz_*()` functions having @long@ arguments which are 32bit on IL32P64, whereas `Int#` and `Word#` are 64bit wide, causing all sorts of malfunction due to truncation. This affects mostly the new big/small-int primops introduced in the course of #8647, so when `SIZEOF_W != SIZEOF_LONG` we simply fall back to using the big/big-int primops. big/small primops implemented via the low-level `mpn_*()` GMP operations are not affected, as those use `mp_limb_t` arguments. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Introduce new SIZEOF_MP_LIMB_T derived constantHerbert Valerio Riedel2014-01-163-9/+7
| | | | | | | | This allows to simplify code in `float.c` and to encode the "sizeof(mp_limb_t) != sizeof(W_)" assumption as a compile-time assertion. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Use correct package id for `stg_INTLIKE_closure` importHerbert Valerio Riedel2014-01-141-1/+1
| | | | | | | | I'm a bit surprised though this didn't cause linkage errors (the incorrect import statement was introduced in 7bdcadda7e) Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Fix in-tree GMP build (#8497) on OS X MavericksKazu Yamamoto2014-01-141-1/+9
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Wrap `gmpz_fdiv_{q,r,qr}_ui` to optimize `div`/`mod`Herbert Valerio Riedel2014-01-133-10/+41
| | | | | | | | | | | | | | This is similiar to what has been done in [af2ba9c8/integer-gmp] for `gmpz_tdiv_{q,r,qr}_ui` (re #8647); However, the gain is more modest here, as performance-conscious code tends to use `quot`/`rem` rather than `div`/`mod`: Program Size Allocs Runtime Elapsed TotalMem ------------------------------------------------------------- primetest +0.3% -2.4% 0.06 0.06 +0.0% rsa +0.2% -3.3% 0.02 0.02 +0.0% Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Allocate initial 1-limb mpz_t on the Stack and introduce MPZ# typeHerbert Valerio Riedel2014-01-133-187/+306
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now allocate a 1-limb mpz_t on the stack instead of doing a more expensive heap-allocation (especially if the heap-allocated copy becomes garbage right away); this addresses #8647. In order to delay heap allocations of 1-limb `ByteArray#`s instead of the previous `(# Int#, ByteArray# #)` pair, a 3-tuple `(# Int#, ByteArray#, Word# #)` is returned now. This tuple is given the type-synonym `MPZ#`. This 3-tuple representation uses either the 1st and the 2nd element, or the 1st and the 3rd element to represent the limb(s) (NB: undefined `ByteArray#` elements must not be accessed as they don't point to a proper `ByteArray#`, see also `DUMMY_BYTE_ARR`); more specifically, the following encoding is used (where `⊥` means undefined/unused): - (# 0#, ⊥, 0## #) -> value = 0 - (# 1#, ⊥, w #) -> value = w - (# -1#, ⊥, w #) -> value = -w - (# s#, d, 0## #) -> value = J# s d The `mpzToInteger` helper takes care of converting `MPZ#` into an `Integer`, and allocating a 1-limb `ByteArray#` in case the value (`w`/`-w`) doesn't fit the `S# Int#` representation). The following nofib benchmarks benefit from this optimization: Program Size Allocs Runtime Elapsed TotalMem ------------------------------------------------------------------ bernouilli +0.2% -5.2% 0.12 0.12 +0.0% gamteb +0.2% -1.7% 0.03 0.03 +0.0% kahan +0.3% -13.2% 0.17 0.17 +0.0% mandel +0.2% -24.6% 0.04 0.04 +0.0% power +0.2% -2.6% -2.0% -2.0% -8.3% primetest +0.1% -17.3% 0.06 0.06 +0.0% rsa +0.2% -18.5% 0.02 0.02 +0.0% scs +0.1% -2.9% -0.1% -0.1% +0.0% sphere +0.3% -0.8% 0.03 0.03 +0.0% symalg +0.2% -3.1% 0.01 0.01 +0.0% ------------------------------------------------------------------ Min +0.1% -24.6% -4.6% -4.6% -8.3% Max +0.3% +0.0% +5.9% +5.9% +4.5% Geometric Mean +0.2% -1.0% +0.2% +0.2% -0.0% Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Drop redundant formal parameter from TAKE1_UL1_RET2Herbert Valerio Riedel2014-01-112-10/+2
| | | | | | | | | | | This fixes the actual cause for #8661, i.e. a mismatch between the actual arity of the Cmm implementation and the arity declared in the foreign import statement. This also reverts [a3878d17/integer-gmp] as the workaround isn't needed anymore. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Follow-up to a3878d17Herbert Valerio Riedel2014-01-101-1/+4
| | | | | | Forgot to add this chunk to the commit [a3878d17/integer-gmp] Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Temporary disable `mpz_gmpz_tdiv_qr_ui` to workaround #8661Herbert Valerio Riedel2014-01-101-1/+6
| | | | | | | | | | | I still need to investigated, but for some reason not yet obvious to me, commit [af2ba9c8/integer-gmp] (re #8647) seems to have triggered #8661 on linux/32 This commit disables the use of the `quotRemIntegerWord#` primop on 32bit (which seems to trigger the issue). Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Manually float out `int2Integer# INT_MINBOUND`Herbert Valerio Riedel2014-01-081-9/+13
| | | | | | | This avoids allocating this special value over and over again every time it's needed, and therefore this addresses #8647. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Wrap `gmpz_tdiv_{q,r,qr}_ui` to optimize `quot`/`rem`Herbert Valerio Riedel2014-01-083-7/+71
| | | | | | | | | | | | | | | | | This is useful as `quot`/`rem` are often used with small-int divisors, like when computing the digits of an `Integer`. This optimization reduces allocations in the following `nofib` benchmarks: Program Size Allocs Runtime Elapsed TotalMem ----------------------------------------------------------------- power +0.3% -0.8% -1.2% -1.2% +0.0% primetest +0.3% -3.9% 0.07 0.07 +0.0% rsa +0.3% -4.0% 0.02 0.02 +0.0% symalg +0.2% -1.4% 0.01 0.01 +0.0% This addresses #8647 Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Hackishly fix parallel build failure with in-tree GMPAustin Seipp2014-01-071-1/+8
| | | | | | | | | | | | | | See the comments and #8102. The basic gist of it seems to be that the build system follows an implied rule from somewhere to directly build a C file, which doesn't have a dependency on the in-tree gmp.h that we build. As a result, the C file compilation races against the GMP build, causing an error. This is a pretty unsatisfactory hack, but for Windows and OS X machines where we more often build in-tree GMPs, it's quite important. Authored-by: Kazu Yamamoto <kazu@iij.ad.jp> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add new `mpz_{sub,add}_ui`-based primop (re #8647)Herbert Valerio Riedel2014-01-043-10/+66
| | | | | | | | | | | | | | | | | | | | | | | | | This adds `{plus,minus}IntegerInt#` which help to reduce temporary allocations in `plusInteger` and `minusInteger`. This and the previous commit introducing `timesIntegerInt#` (i.e. baeeef7af6e) result in reduced allocations for the following nofib benchmarks on Linux/amd64: Program Size Allocs Runtime Elapsed TotalMem ------------------------------------------------------------------ bernouilli +0.0% -4.2% 0.12 0.12 +0.0% kahan +0.1% -12.6% 0.17 0.17 +0.0% pidigits +0.0% -0.5% -4.7% -4.5% +0.0% power +0.0% -2.7% +3.1% +3.1% +9.1% primetest +0.0% -4.2% 0.07 0.07 +0.0% rsa +0.0% -4.1% 0.02 0.02 +0.0% scs +0.0% -2.6% -0.8% -0.7% +0.0% ------------------------------------------------------------------ Min +0.0% -12.6% -4.7% -4.5% -5.0% Max +0.1% +0.2% +3.1% +3.1% +9.1% Geometric Mean +0.1% -0.3% -0.0% +0.0% +0.1% ------------------------------------------------------------------ Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Add new `mpz_mul_si`-based primop (re #8647)Herbert Valerio Riedel2014-01-043-4/+15
| | | | | | | | | | | This primop helps reducing allocation by being able to pass one `S#` argument directly to the GMP multiplication primitive without needing to promote (and thus allocate a `ByteArray#` as well) the `J#` first. This benefits a few nofib benchmarks wrt to allocations (having most impact on `kahan` resulting in about 10% less allocations) Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Refactor C-- wrappers to use macros for mpz_t accessHerbert Valerio Riedel2014-01-041-90/+43
| | | | | | | This factors out the recurring task of converting mpz_t structures to/from Int#/ByteArrays# pairs and makes the code more readable. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>