1 | |
---|
2 | |
---|
3 | def get_allowed_number_of_cores_for_grid(self, grid, min_procs, max_procs): |
---|
4 | |
---|
5 | nx = grid.nx - 1 |
---|
6 | ny = grid.ny - 1 |
---|
7 | nz = grid.nz - 1 |
---|
8 | |
---|
9 | anc = list() |
---|
10 | for np_used in range(min_procs, max_procs+1): |
---|
11 | |
---|
12 | for npex in range(1, np_used+1): |
---|
13 | |
---|
14 | allowed = True |
---|
15 | |
---|
16 | # strict matching in nodes (all nodes are used completely) |
---|
17 | if self.tasks_per_node != 0: |
---|
18 | if np_used % self.tasks_per_node != 0: |
---|
19 | allowed = False |
---|
20 | |
---|
21 | if np_used % npex != 0: |
---|
22 | allowed = False |
---|
23 | |
---|
24 | npey = int(np_used / npex) |
---|
25 | |
---|
26 | # if fixed ratio is requested |
---|
27 | if self.npex_d_npey != 0.0 and npex / npey != self.npex_d_npey: |
---|
28 | allowed = False |
---|
29 | |
---|
30 | # nx restlos teilbar auf npex |
---|
31 | if (nx + 1) % npex != 0: |
---|
32 | allowed = False |
---|
33 | # ny restlos teilbar auf npey |
---|
34 | if (ny + 1) % npey != 0: |
---|
35 | allowed = False |
---|
36 | |
---|
37 | if self.nx_d_ny != 0.0 and float(nx) / float(ny) != float(self.nx_d_ny): |
---|
38 | allowed = False |
---|
39 | |
---|
40 | if self.multi_grid is True and (nx + 1) % 2 != 0: |
---|
41 | allowed = False |
---|
42 | if self.multi_grid is True and (ny + 1) % 2 != 0: |
---|
43 | allowed = False |
---|
44 | if self.multi_grid is True and nz % 2 != 0: |
---|
45 | allowed = False |
---|
46 | |
---|
47 | if self.switch is True and (nx + 1) % npey != 0: |
---|
48 | allowed = False |
---|
49 | if self.switch is True and (ny + 1) % npex != 0: |
---|
50 | allowed = False |
---|
51 | |
---|
52 | if self.poisfft is True and nz % npex != 0: |
---|
53 | allowed = False |
---|
54 | |
---|
55 | if npex > nx: |
---|
56 | allowed = False |
---|
57 | if npey > ny: |
---|
58 | allowed = False |
---|
59 | |
---|
60 | if self.spectra is True and nz % npey != 0: |
---|
61 | allowed = False |
---|
62 | |
---|
63 | if self.tempterton is True and nx > 1 and ny > 1 and self.temperton_check(nx, ny) == 0: |
---|
64 | allowed = False |
---|
65 | |
---|
66 | npxnpy = format(float(npex) / float(npey), '.2f') |
---|
67 | nxpex = float(nx + 1) / float(npex) |
---|
68 | nypey = float(ny + 1) / float(npey) |
---|
69 | |
---|
70 | if allowed: |
---|
71 | anc.append((nx, ny, nz, npex, npey, npxnpy, (npex * npey), (nx * ny * nz), nxpex, nypey)) |
---|
72 | return anc |
---|