using System.Diagnostics; float[,] image = new float[10000, 10000]; var rng = new Random(); for (int i = 0; i < image.GetLength(0); i += 1) { for (int j = 0; j < image.GetLength(1); j += 1) { image[i, j] = ((float)rng.Next()) / Int32.MaxValue; } } float[,] accum = new float[image.GetLength(0) - 2, image.GetLength(1) - 2]; Stopwatch timer = new Stopwatch(); timer.Start(); // for (int i = 0; i < accum.GetLength(0); i += 1) // { // for (int j = 0; j < accum.GetLength(1); j += 1) // { // accum[i, j] = 1; // for (int k1 = 0; k1 < 3; k1 += 1) // { // for (int k2 = 0; k2 < 3; k2 += 1) // { // accum[i, j] += (float)Math.Exp(image[i + k1, j + k2]); // } // } // } // } ParallelOptions options = new ParallelOptions(); options.MaxDegreeOfParallelism = 2; Parallel.For(0, accum.GetLength(0), options, (i, state) => { for (int j = 0; j < accum.GetLength(1); j += 1) { accum[i, j] = 1; for (int k1 = 0; k1 < 3; k1 += 1) { for (int k2 = 0; k2 < 3; k2 += 1) { accum[i, j] += (float)Math.Exp(image[i + k1, j + k2]); } } } }); timer.Stop(); Console.WriteLine(timer.Elapsed);