I have the following code structure which I want to take advantage of multi-threading to speed up results, as every computation is independent. For every point in a 2D grid, I call a compute_at_point() function and get the result.
How can I parallelize this with threads? I know the computers that will be used have at least 4 cores. Code below:
for i in range(0, grid_rows):
for j in range(0, grid_cols):
grid_point = input_grid[i, j]
res_at_point = compute_at_point(input_grid, grid_point)
output_grid[i, j] = res_at_point
Where input_grid and output_grid have the same shape, and every computation is independent.