On 11/04/2016 01:12 PM, Andrei Alexandrescu wrote:
So I'm working on the checkedint pull request (really need to get that
in...) and was trying to get some benchmarks going with ldc. The stock
ldc on mint is outdated and it can't compile the code, so I needed to do
a self-installation. I've put it in ~/bin/ldc2-1.1.0-beta3-linux-x86. Then:

$ PATH=~/bin/ldc2-1.1.0-beta3-linux-x86/bin:$PATH

Found the problem, sorry for the distraction. I'd downloaded the 32-bit version not the 64-bit one. I got it working with the right download.

BTW the benchmark results have been pretty good:

======================================
Running trialPrimes() benchmark...
                                     int: 37 ms, 789 μs, and 8 hnsecs
                     Checked!(int, void): 25 ms and 398 μs
                     Checked!(int, Warn): 64 ms, 653 μs, and 9 hnsecs
                                    uint: 42 ms, 361 μs, and 1 hnsec
                    Checked!(uint, void): 42 ms, 49 μs, and 5 hnsecs
                    Checked!(uint, Warn): 72 ms, 322 μs, and 7 hnsecs
                                    long: 67 ms and 893 μs
                    Checked!(long, void): 54 ms, 512 μs, and 3 hnsecs
                    Checked!(long, Warn): 91 ms and 932 μs
                                   ulong: 69 ms and 567 μs
                   Checked!(ulong, void): 69 ms, 136 μs, and 4 hnsecs
                   Checked!(ulong, Warn): 95 ms, 196 μs, and 7 hnsecs
DONE

Running collatzSort() benchmark...
                                     int: 43 ms, 967 μs, and 9 hnsecs
                     Checked!(int, void): 44 ms, 104 μs, and 8 hnsecs
                     Checked!(int, Warn): 81 ms, 833 μs, and 1 hnsec
                                    uint: 43 ms, 398 μs, and 3 hnsecs
                    Checked!(uint, void): 43 ms, 560 μs, and 6 hnsecs
                    Checked!(uint, Warn): 82 ms, 727 μs, and 7 hnsecs
                                    long: 43 ms, 208 μs, and 4 hnsecs
                    Checked!(long, void): 43 ms, 734 μs, and 5 hnsecs
                    Checked!(long, Warn): 83 ms, 868 μs, and 5 hnsecs
                                   ulong: 43 ms, 459 μs, and 4 hnsecs
                   Checked!(ulong, void): 43 ms, 544 μs, and 5 hnsecs
                   Checked!(ulong, Warn): 84 ms, 567 μs, and 7 hnsecs
DONE
======================================

The Checked!(int, void) type is a checkedint that just "goes through" the framework (it's a wrapper struct that doesn't insert any checks) and to ldc's credit it gets optimized to pretty much a built-in int.

The Checked!(int, Warn) type inserts all checks necessary to print a warning to stderr in case anything wrong happens. We're looking at a 2x speed reduction, which is up to par with Thomas' library (https://code.dlang.org/packages/checkedint). I've tried to run the corresponding test for that and ran into a snag. It does work with dmd but not with my locally-installed ldc. Any idea on what could be happening? Here's the trace:

$dub run checkedint:tests --build=release --verbose --compiler=$HOME/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2

Using dub registry url 'http://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/andrei/.dub/packages/local-packages.json
No package found in current working directory.
Building package checkedint:tests in /home/andrei/.dub/packages/checkedint-0.5.3/tests/
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/andrei/.dub/packages/local-packages.json
Found dependency checkedint 0.5.3
Checking for missing dependencies.
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/andrei/.dub/packages/local-packages.json
Found dependency checkedint 0.5.3
Checking for upgrades.
Using cached upgrade results...
Generating using build
Generate target checkedint:tests (executable /home/andrei/.dub/packages/checkedint-0.5.3/tests checkedint_tests) Generate target checkedint (staticLibrary /home/andrei/.dub/packages/checkedint-0.5.3 checkedint) Performing "release" build using /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 for x86_64. Target '/home/andrei/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a' doesn't exist, need rebuild.
checkedint 0.5.3: building configuration "library"...
/home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 -lib -of.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a -release -enable-inlining -O -ignore -w -oq -od=.dub/obj -d-version=Have_checkedint -I.dub/packages/checkedint-0.5.3/source/ .dub/packages/checkedint-0.5.3/source/checkedint/asserts.d .dub/packages/checkedint-0.5.3/source/checkedint/flags.d .dub/packages/checkedint-0.5.3/source/checkedint/noex.d .dub/packages/checkedint-0.5.3/source/checkedint/package.d .dub/packages/checkedint-0.5.3/source/checkedint/throws.d .dub/packages/checkedint-0.5.3/source/checkedint/traits.d .dub/packages/checkedint-0.5.3/source/future/bitop.d .dub/packages/checkedint-0.5.3/source/future/math.d .dub/packages/checkedint-0.5.3/source/future/traits0.d Error: failed to create path to file: .dub/obj/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a
No such file or directory
FAIL .dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/ checkedint staticLibrary /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 failed with exit code 1.


Andrei

Reply via email to