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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Bug 977853 -- Pared down version of script exhibiting negative
michael@0 2 // interaction with convert to doubles optimization. See bug for gory
michael@0 3 // details.
michael@0 4
michael@0 5 if (!getBuildConfiguration().parallelJS)
michael@0 6 quit();
michael@0 7
michael@0 8 load(libdir + "parallelarray-helpers.js")
michael@0 9
michael@0 10 var numIters = 5;
michael@0 11 var golden_output;
michael@0 12
michael@0 13 function PJS_div4(v, s)
michael@0 14 {
michael@0 15 return [ v[0]/s, v[1]/s, v[2]/s, v[3]/s ];
michael@0 16 }
michael@0 17
michael@0 18 function PJS_normalized(v)
michael@0 19 {
michael@0 20 var d = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
michael@0 21 d = d > 0.0 ? d : 1.0;
michael@0 22 var result = [ v[0]/d, v[1]/d, v[2]/d, 1.0 ];
michael@0 23 return result;
michael@0 24 }
michael@0 25
michael@0 26 // This is the elemental function passed to mapPar
michael@0 27 function PJS_displace(p)
michael@0 28 {
michael@0 29 var position = [p[0], p[1], p[2], 1.0];
michael@0 30 var normal = position;
michael@0 31 var roughness = 0.025 / 0.35;
michael@0 32 normal = PJS_normalized(PJS_div4(normal, roughness));
michael@0 33 return null;
michael@0 34 }
michael@0 35 var NUM_VERTEX_COMPONENTS = 3;
michael@0 36 var initPos, nVertices;
michael@0 37 var userData = {
michael@0 38 nVertices : 25, //2880,
michael@0 39 initPos : [],
michael@0 40 };
michael@0 41 function setup() {
michael@0 42 for(var k = 0; k < NUM_VERTEX_COMPONENTS*userData.nVertices; k++) {
michael@0 43 userData.initPos[k] = k/1000;
michael@0 44 }
michael@0 45 nVertices = userData.nVertices;
michael@0 46 initPos = new Array(nVertices);
michael@0 47 for(var i=0, j=0; i<nVertices; i++, j+=NUM_VERTEX_COMPONENTS) {
michael@0 48 initPos[i] = [userData.initPos[j],
michael@0 49 userData.initPos[j+1],
michael@0 50 userData.initPos[j+2]];
michael@0 51 }
michael@0 52 }
michael@0 53 function SimulatePJS() {
michael@0 54 var curPosAndNor;
michael@0 55
michael@0 56 // Measure Parallel Execution
michael@0 57 assertParallelExecSucceeds(
michael@0 58 function(m) { return initPos.mapPar(PJS_displace, m); },
michael@0 59 function() { });
michael@0 60 }
michael@0 61 var start_time, elapsed_parallel = 0, elapsed_sequential = 0;
michael@0 62 setup();
michael@0 63 SimulatePJS();

mercurial