js/src/jit-test/tests/parallel/bug977853-convert-doubles.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/parallel/bug977853-convert-doubles.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +// Bug 977853 -- Pared down version of script exhibiting negative
     1.5 +// interaction with convert to doubles optimization. See bug for gory
     1.6 +// details.
     1.7 +
     1.8 +if (!getBuildConfiguration().parallelJS)
     1.9 +  quit();
    1.10 +
    1.11 +load(libdir + "parallelarray-helpers.js")
    1.12 +
    1.13 +var numIters = 5;
    1.14 +var golden_output;
    1.15 +
    1.16 +function PJS_div4(v, s)
    1.17 +{
    1.18 +  return [ v[0]/s, v[1]/s, v[2]/s, v[3]/s ];
    1.19 +}
    1.20 +
    1.21 +function PJS_normalized(v)
    1.22 +{
    1.23 +  var d = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
    1.24 +  d = d > 0.0 ? d : 1.0;
    1.25 +  var result = [ v[0]/d, v[1]/d, v[2]/d, 1.0 ];
    1.26 +  return result;
    1.27 +}
    1.28 +
    1.29 +// This is the elemental function passed to mapPar
    1.30 +function PJS_displace(p)
    1.31 +{
    1.32 +  var position = [p[0], p[1], p[2], 1.0];
    1.33 +  var normal = position;
    1.34 +  var roughness = 0.025 / 0.35;
    1.35 +  normal = PJS_normalized(PJS_div4(normal, roughness));
    1.36 +  return null;
    1.37 +}
    1.38 +var NUM_VERTEX_COMPONENTS = 3;
    1.39 +var initPos, nVertices;
    1.40 +var userData = {
    1.41 +  nVertices : 25, //2880,
    1.42 +  initPos : [],
    1.43 +};
    1.44 +function setup() {
    1.45 +  for(var k = 0; k < NUM_VERTEX_COMPONENTS*userData.nVertices; k++) {
    1.46 +    userData.initPos[k] = k/1000;
    1.47 +  }
    1.48 +  nVertices	= userData.nVertices;
    1.49 +  initPos		= new Array(nVertices);
    1.50 +  for(var i=0, j=0; i<nVertices; i++, j+=NUM_VERTEX_COMPONENTS) {
    1.51 +	initPos[i] = [userData.initPos[j],
    1.52 +				  userData.initPos[j+1],
    1.53 +				  userData.initPos[j+2]];
    1.54 +  }
    1.55 +}
    1.56 +function SimulatePJS() {
    1.57 +  var curPosAndNor;
    1.58 +
    1.59 +  // Measure Parallel Execution
    1.60 +  assertParallelExecSucceeds(
    1.61 +    function(m) { return initPos.mapPar(PJS_displace, m); },
    1.62 +    function() { });
    1.63 +}
    1.64 +var start_time, elapsed_parallel = 0, elapsed_sequential = 0;
    1.65 +setup();
    1.66 +SimulatePJS();

mercurial