<commit_before>
config const size : uint = 200;

proc main()
{
  const bytesRequired : uint = (size + 7) / 8;
  const byteRange = 0..#bytesRequired:int(64);
  const sizeRange = 0..#size:int(64);

  var bytes : [sizeRange, byteRange] uint(8);

  const limit : real = 4.0;
  const maxIter : int = 50;

  forall y in sizeRange do
    {
      for bytex in byteRange {
        var byte_acc : uint(8) = 0;

        for x in (bytex*8)..#8 do
          {
            var Zr : real = 0.0;
            var Zi : real = 0.0;
            var Tr : real = 0.0;
            var Ti : real = 0.0;
            const Cr : real = (2.0*x/size - 1.5);
            const Ci : real = (2.0*y/size - 1.0);

            {
              var iterNo : int = maxIter;
              while (iterNo > 0 && (Tr+Ti <= limit))
                {
                  Zi = 2.0*Zr*Zi + Ci;
                  Zr = Tr - Ti + Cr;
                  Tr = Zr * Zr;
                  Ti = Zi * Zi;
                  iterNo -= 1;
                }
            }

            byte_acc <<= 1;
            if(Tr+Ti <= limit) then
              byte_acc |= 0x01;
          }

        bytes(y, bytex) = byte_acc;
      }
    }

  var f = openfd(1);
  var w = f.writer(kind=iokind.native, locking=false);
  w.writef("P4\n%i %i\n", size, size);

  
  for (x,y) in bytes.domain do {
    w.write(bytes(x,y));
  }
}
<commit_msg>The difference between no-local and local timings was a result of iterating through the bytes array to print each individual byte instead of a single array print.  Updating my fastest version to reflect this.<commit_after>
config const size : uint = 200;

proc main()
{
  const bytesRequired : uint = (size + 7) / 8;
  const byteRange = 0..#bytesRequired:int(64);
  const sizeRange = 0..#size:int(64);

  var bytes : [sizeRange, byteRange] uint(8);

  const limit : real = 4.0;
  const maxIter : int = 50;

  forall y in sizeRange do
    {
      for bytex in byteRange {
        var byte_acc : uint(8) = 0;

        for x in (bytex*8)..#8 do
          {
            var Zr : real = 0.0;
            var Zi : real = 0.0;
            var Tr : real = 0.0;
            var Ti : real = 0.0;
            const Cr : real = (2.0*x/size - 1.5);
            const Ci : real = (2.0*y/size - 1.0);

            {
              var iterNo : int = maxIter;
              while (iterNo > 0 && (Tr+Ti <= limit))
                {
                  Zi = 2.0*Zr*Zi + Ci;
                  Zr = Tr - Ti + Cr;
                  Tr = Zr * Zr;
                  Ti = Zi * Zi;
                  iterNo -= 1;
                }
            }

            byte_acc <<= 1;
            if(Tr+Ti <= limit) then
              byte_acc |= 0x01;
          }

        bytes(y, bytex) = byte_acc;
      }
    }

  var f = openfd(1);
  var w = f.writer(kind=iokind.native, locking=false);
  w.writef("P4\n%i %i\n", size, size);

  
  w.write(bytes);
}

{'fraction_non_alphanumeric': 0.13041970169961845, 'fraction_numerical': 0.03191120360735345, 'mean_word_length': 1.3146067415730338, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5562833', 'n_tokens_mistral': 1070, 'n_tokens_neox': 979, 'n_words': 284}