     commandEncoder.setBuffer(sumBuffer, offset: 0, atIndex: 2);
 
     // 3. Call the dispatchThreadgroups(_:threadsPerThreadgroup:) method to encode the compute function with a specified number of threadgroups for the grid and the number of threads per threadgroup.
-    let threadsPerThreadgroup: MTLSize = MTLSizeMake(256, 1, 1); // a decent guess
-    commandEncoder.dispatchThreadgroups(MTLSizeMake(N / threadsPerThreadgroup.width, 1, 1), threadsPerThreadgroup: threadsPerThreadgroup)
+    let threadsPerThreadgroup: MTLSize = MTLSizeMake(256, 1, 1) // a decent guess
+    let threadGroups: MTLSize = MTLSizeMake(N / threadsPerThreadgroup.width, 1, 1)
+    commandEncoder.dispatchThreadgroups(threadGroups, threadsPerThreadgroup: threadsPerThreadgroup)
     
     // 4. Call endEncoding() to finish encoding the compute commands onto the command buffer.
     commandEncoder.endEncoding();

    
    sumArray = Array(UnsafeBufferPointer(start: output, count: N));
    
    
}

// create an array of random floats

var N : Int = 1024 * 1024 * 10;

print("Running test with N = ", N);


    }
}

func generateLibrary(device: MTLDevice) -> MTLLibrary {
    let library : MTLLibrary?;
    do {
        let source : String = try String(contentsOfFile: "./addFunction.metal" )
        library = try device.newLibraryWithSource(source, options: nil) // do we need compile options?
    }
    catch _ {
        print("error creating library ...");
        library = nil
    }
    return library!
}

func computeSumMetal(array1 array1 : [Float], array2 : [Float], inout sumArray : [Float], N : Int) {
    
    let devices: [MTLDevice] = MTLCopyAllDevices();
