|
8 | 8 | from firedrake.cython import mgimpl as impl |
9 | 9 |
|
10 | 10 |
|
11 | | -def get_or_set_mg_hierarchy_map_cache(cache_dict, entity_dofs_key, |
12 | | - create_map_on_cpu): |
| 11 | +def get_or_set_mg_hierarchy_map_cache(cache_dict, entity_dofs_key, create_map_on_cpu): |
13 | 12 | """ |
14 | 13 | :arg cache_dict: An instance of :class:`dict` that maps from tuple |
15 | 14 | ``(entity_dofs_key, compute_backend)`` to the corresponding map. |
16 | | - :arg create_host_map: A callable that takes no argument and returns the map |
| 15 | + :arg create_map_on_cpu: A callable that takes no argument and returns the map |
17 | 16 | on the CPU backend. |
18 | 17 | :returns map: An instance of :class:`pyop2.base.Map`. |
19 | 18 | """ |
20 | 19 | try: |
21 | 20 | return cache_dict[(entity_dofs_key, op2.compute_backend)] |
22 | 21 | except KeyError: |
| 22 | + |
23 | 23 | from pyop2.sequential import cpu_backend |
24 | | - host_map = cache_dict.setdefault((entity_dofs_key, |
25 | | - cpu_backend), create_map_on_cpu()) |
26 | | - return cache_dict.setdefault((entity_dofs_key, op2.compute_backend), |
27 | | - op2.compute_backend.Map(host_map)) |
| 24 | + if (entity_dofs_key, cpu_backend) not in cache_dict: |
| 25 | + cache_dict[(entity_dofs_key, cpu_backend)] = create_map_on_cpu() |
| 26 | + |
| 27 | + map_on_cpu = cache_dict[(entity_dofs_key, cpu_backend)] |
| 28 | + |
| 29 | + if (entity_dofs_key, op2.compute_backend) not in cache_dict: |
| 30 | + cache_dict[(entity_dofs_key, op2.compute_backend)] = op2.compute_backend.Map(map_on_cpu) |
| 31 | + |
| 32 | + return cache_dict[(entity_dofs_key, op2.compute_backend)] |
28 | 33 |
|
29 | 34 |
|
30 | 35 | def fine_node_to_coarse_node_map(Vf, Vc): |
|
0 commit comments