Changeset 5200 in /cluster/svnroot


Ignore:
Timestamp:
Jul 3, 2015 10:51:50 AM (5 years ago)
Author:
amweeden06
Message:

HPCU Fractal OpenMP - Adding solution and refactoring starter code

Location:
bccd-ng/hpcu-weekly-challenge/fractal-openmp
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • bccd-ng/hpcu-weekly-challenge/fractal-openmp/starter/fractal.js

    r5188 r5200  
    1111  var step = 0.00625;
    1212  var depth = 100.0;
    13   var depthOver16 = 0.0625 * depth;
    14   var depthOver8 = 0.125 * depth;
    15   var depthOver4 = 0.25 * depth;
    16   var depthOver2 = 0.5 * depth;
    17   var depthPlus1 = depth + 1;
    1813  var pixels = [];
    19   var outputStr = "";
     14  var row;
     15  var col;
     16  var myX;
     17  var myY;
     18  var i;
     19  var x;
     20  var y;
     21  var tmp;
     22  var outputStr;
    2023
    21   // Converts a value in the range [low..high] to the range [0..255]
    22   var mapToColor = function(val, low, high) {
    23     return Math.floor(255 * (val - low) / (high - low));
    24   };
    25 
    26   // Loop over each pixel
     24  /* Loop over each pixel */
    2725  for (var row = 0; row < nRows; row++) {
     26    pixels[row] = [];
    2827    for (var col = 0; col < nCols; col++) {
    2928
    30       // Set the (x,y) coordinate for each pixel
    31       var myX = (col - middleCol) * step;
    32       var myY = (row - middleRow) * step;
     29      /* Set the (x,y) coordinate for each pixel */
     30      myX = (col - middleCol) * step;
     31      myY = (row - middleRow) * step;
    3332
    34       // Calculate the number of iterations for each pixel
    35       var i = 0;
    36       var x = 0;
    37       var y = 0;
     33      /* Calculate the number of iterations for each pixel */
     34      i = 0;
     35      x = 0;
     36      y = 0;
    3837      while ((x*x + y*y < 4) && (i < depth)) {
    39         var tmp = x*x - y*y + myX;
     38        tmp = x*x - y*y + myX;
    4039        y = 2*x*y + myY;
    4140        x = tmp;
     
    4342      }
    4443
    45       // Build output string
    46       outputStr += i + ",";
     44      /* Build array */
     45      pixels[row][col] = i;
    4746    }
    48 
    49     // Build output string
    50     outputStr += "<br/>";
    5147  }
    5248
    53   // Display output string
     49  /* Display array */
     50  outputStr = "";
     51  for (row = 0; row < nRows; row++) {
     52    for (col = 0; col < nCols; col++) {
     53      outputStr += pixels[row][col] + ",";
     54    }
     55    outputStr += "\n";
     56  }
    5457  document.getElementById('output-box').innerHTML = outputStr;
    5558};
  • bccd-ng/hpcu-weekly-challenge/fractal-openmp/starter/index.html

    r5188 r5200  
    33  <head>
    44    <title>HPCU Bi-Weekly Challenge: Fractal OpenMP</title>
    5     <script type="text/javascript" src="fractal-openmp.js"></script>
     5    <script type="text/javascript" src="fractal.js"></script>
    66  </head>
    77  <body>
Note: See TracChangeset for help on using the changeset viewer.