title: unexpected results while writing to buffer in compute shader
body: <p>Here is a simple metal compute shader:</p>
  
  <pre><code>kernel void test(uint k [[ thread_position_in_grid ]],
                           device float* a [[buffer(1)]]){
      a[k] = 2;
  };
  </code></pre>
  
  <p>On the CPU I access the data like so:</p>
  
  <pre><code>let size = floatArray.count * MemoryLayout.size(ofValue: floatArray[0])
  metalBuffer = device.makeBuffer(bytes: floatArray, length: size, options: [])
  data = metalBuffer.contents().assumingMemoryBound(to: Float.self)
  </code></pre>
  
  <p><code>floatArray</code> is all zeros. I dispatch with</p>
  
  <pre><code>encoder.dispatchThreadgroups(MTLSize(width:32, height:1, depth:1),
  threadsPerThreadgroup: MTLSize(width:32, height:1, depth:1))
  </code></pre>
  
  <p>When the shader has finished I print the contents:</p>
  
  <pre><code>print(data[0])
  </code></pre>
  
  <p>Now <code>data[0]</code> and <code>data[1]</code> both give a value of <code>2</code> as expected, but the rest are not <code>2</code>. For example <code>data[2]</code> is about <code>1.477</code>. I feel like I must be making a simple mistake.</p>