1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/parallel/math-fcns.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +// |jit-test| slow; 1.5 +load(libdir + "parallelarray-helpers.js"); 1.6 + 1.7 +// The MathCache has 4096 entries, so ensure we overwrite at least one 1.8 +// entry by using > 4096 distinct inputs. 1.9 + 1.10 +var len = 5000; 1.11 +var iters = 100; 1.12 + 1.13 +// The problem we are trying to expose (Bugzilla 901000) is 1.14 +// a data-race on the MathCache; such a bug is inherently 1.15 +// non-deterministic. On a 4 core Mac laptop: 1.16 +// 1.17 +// len == 10000 iters==1 replicates the problem on 2/10 runs, 1.18 +// len == 10000 iters==2 replicates the problem on 3/10 runs, 1.19 +// len == 10000 iters==5 replicates the problem on 6/10 runs, 1.20 +// len == 10000 iters==10 replicates the problem on 9/10 runs. 1.21 +// 1.22 +// len == 5000 iters==1 replicates the problem on 1/10 runs, 1.23 +// len == 5000 iters==2 replicates the problem on 4/10 runs, 1.24 +// len == 5000 iters==5 replicates the problem on 5/10 runs, 1.25 +// len == 5000 iters==10 replicates the problem on 9/10 runs. 1.26 +// 1.27 +// len == 2000 iters==1 replicates the problem on 0/10 runs, 1.28 +// len == 2000 iters==2 replicates the problem on 0/10 runs, 1.29 +// len == 2000 iters==5 replicates the problem on 0/10 runs, 1.30 +// len == 2000 iters==10 replicates the problem on 3/10 runs 1.31 + 1.32 +function check(fill) { 1.33 + var seq = Array.build(len, fill); 1.34 + for (var i = 0; i < iters; i++) { 1.35 + var par = Array.buildPar(len, fill); 1.36 + assertStructuralEq(par, seq); 1.37 + } 1.38 +} 1.39 + 1.40 +function checkAbs(a) { check(function (i) { return Math.abs(a[i]); }); } 1.41 +function checkAcos(a) { check(function (i) { return Math.acos(a[i]); }); } 1.42 +function checkAsin(a) { check(function (i) { return Math.asin(a[i]); }); } 1.43 +function checkAtan(a) { check(function (i) { return Math.atan(a[i]); }); } 1.44 +function checkAtan2(a) { check(function (i) { return Math.atan2(a[i]); }); } 1.45 +function checkCeil(a) { check(function (i) { return Math.ceil(a[i]); }); } 1.46 +function checkCos(a) { check(function (i) { return Math.cos(a[i]); }); } 1.47 +function checkExp(a) { check(function (i) { return Math.exp(a[i]); }); } 1.48 +function checkFloor(a) { check(function (i) { return Math.floor(a[i]); }); } 1.49 +function checkLog(a) { check(function (i) { return Math.log(a[i]); }); } 1.50 +function checkRound(a) { check(function (i) { return Math.round(a[i]); }); } 1.51 +function checkSin(a) { check(function (i) { return Math.sin(a[i]); }); } 1.52 +function checkSqrt(a) { check(function (i) { return Math.sqrt(a[i]); }); } 1.53 +function checkTan(a) { check(function (i) { return Math.tan(a[i]); }); } 1.54 + 1.55 +function callVariousUnaryMathFunctions() { 1.56 + // We might want to consider making this test adopt seedrandom.js 1.57 + // and call Math.seedrandom("seed") here ... 1.58 + // function fill(i) { return (2*Math.random())-1; } 1.59 + // function fill(i) { return (20*Math.random())-10; } 1.60 + // 1.61 + // ... but its easiest to just drop the pseudo-random input entirely. 1.62 + function fill(i) { return 10/i; } 1.63 + var input = Array.build(len, fill); 1.64 + 1.65 + checkAbs(input); //print("abs"); 1.66 + checkAcos(input); //print("acos"); 1.67 + checkAsin(input); //print("asin"); 1.68 + checkAtan(input); //print("atan"); 1.69 + 1.70 + checkAtan2(input); //print("atan2"); 1.71 + checkCeil(input); //print("ceil"); 1.72 + checkCos(input); //print("cos"); 1.73 + checkExp(input); //print("exp"); 1.74 + 1.75 + checkFloor(input); //print("floor"); 1.76 + checkLog(input); //print("log"); 1.77 + checkRound(input); //print("round"); 1.78 + checkSin(input); //print("sin"); 1.79 + 1.80 + checkSqrt(input); //print("sqrt"); 1.81 + checkTan(input); //print("tan"); 1.82 +} 1.83 + 1.84 +if (getBuildConfiguration().parallelJS) 1.85 + callVariousUnaryMathFunctions();