| 63 | return my_rows, img |
| 64 | |
| 65 | def main(): |
| 66 | imax = 255 |
| 67 | N = 35_000 |
| 68 | T_s = time.time() |
| 69 | nR, nC = N, N |
| 70 | Re_limits = np.array([-0.7440, -0.7433]) |
| 71 | Im_limits = np.array([ 0.1315, 0.1322]) |
| 72 | n_groups = 16 |
| 73 | n_jobs_per_group = 18 |
| 74 | n_jobs = n_jobs_per_group*n_groups |
| 75 | #client = Client('127.0.0.1:8786') |
| 76 | client = Client('143.198.155.245:8786') |
| 77 | results = [] |
| 78 | for c in range(n_groups): |
| 79 | tasks = [] |
| 80 | Tcs = time.time() |
| 81 | for i in range(n_jobs_per_group): |
| 82 | job = dask.delayed(MB)(nC, Re_limits, nR, Im_limits, 255, |
| 83 | c*n_jobs_per_group+i, n_jobs) |
| 84 | tasks.append(job) |
| 85 | results.extend( dask.compute(*tasks) ) |
| 86 | Tce = time.time() - Tcs |
| 87 | print(f'group {c:2d} took {Tce:.3f} sec') |
| 88 | client.close() |
| 89 | |
| 90 | # reassemble the image |
| 91 | img = np.empty((N,N), dtype=np.uint8) |
| 92 | for i in range(len(results)): |
| 93 | my_rows, img_rows = results[i] |
| 94 | img[my_rows,:] = img_rows |
| 95 | |
| 96 | print(f'{time.time() - T_s:.3f} {N:5d}') |
| 97 | return |
| 98 | plt.imshow(img) |
| 99 | plt.show() |
| 100 | if __name__ == '__main__': main() |