Repository: spack/spack

Issue:
unable to detect Perlmutter system architecture
cc: @sleak 

### Steps to reproduce

We are unable to detect perlmutter architecture in spack. For more details see https://spackpm.slack.com/archives/C5W7NKZJT/p1631284957272400. 

I have debugged this with e4s branch `e4s-21.08` and `develop` branch and still getting same issue
```
siddiq90@login11> spack -d arch
==> [2021-09-13-09:11:21.597439] '/bin/bash' '--norc' '--noprofile' '-lc' 'echo $CRAY_CPU_TARGET'
==> [2021-09-13-09:11:21.608167] NoPlatformError: Could not determine a platform for this machine.
==> [2021-09-13-09:11:21.608378] Error: Could not determine a platform for this machine.
Traceback (most recent call last):
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/main.py", line 774, in main
    setup_main_options(args)
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/main.py", line 478, in setup_main_options
    spack.config.set('config:debug', True, scope='command_line')
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/config.py", line 915, in set
    return config.set(path, value, scope)
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/llnl/util/lang.py", line 786, in __getattr__
    return getattr(self.instance, name)
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/llnl/util/lang.py", line 776, in instance
    self._instance = self.factory()
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/config.py", line 814, in _config
    _add_platform_scope(cfg, ConfigScope, name, path)
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/config.py", line 767, in _add_platform_scope
    platform = spack.architecture.platform().name
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/llnl/util/lang.py", line 190, in _memoized_function
    func.cache[args] = func(*args)
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/architecture.py", line 523, in _platform
    return platform_cls()
  File "/global/common/software/spackecp/perlmutter/e4s-21.08/spack/lib/spack/spack/platforms/cray.py", line 61, in __init__
    raise NoPlatformError()
spack.architecture.NoPlatformError: Could not determine a platform for this machine.
```

### Error message

_No response_

### Information on your system

```
siddiq90@login11> spack debug report
* **Spack:** 0.16.2-4211-d54a692e09
* **Python:** 3.6.12
==> Error: Could not determine a platform for this machine.
```

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:
@bvanessen I am also experiencing this.

Resolving patch:
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -24,6 +24,7 @@
     'x86-cascadelake': 'cascadelake',
     'x86-naples': 'zen',
     'x86-rome': 'zen2',
+    'x86-milan': 'zen3',
     'x86-skylake': 'skylake_avx512',
     'mic-knl': 'mic_knl',
     'interlagos': 'bulldozer',
@@ -143,19 +144,25 @@ def _default_target_from_env(self):
                 env={'TERM': os.environ.get('TERM', '')},
                 output=str, error=os.devnull
             )
+
             default_from_module = ''.join(output.split())  # rm all whitespace
             if default_from_module:
                 tty.debug("Found default module:%s" % default_from_module)
                 return default_from_module
             else:
-                front_end = archspec.cpu.host().name
-                if front_end in list(
-                        map(lambda x: _target_name_from_craype_target_name(x),
-                            self._avail_targets())
-                ):
-                    tty.debug("default to front-end architecture")
-                    return archspec.cpu.host().name
+                front_end = archspec.cpu.host()
+                # Look for the frontend architecture or closest ancestor
+                # available in cray target modules
+                avail = [
+                    _target_name_from_craype_target_name(x)
+                    for x in self._avail_targets()
+                ]
+                for front_end_possibility in [front_end] + front_end.ancestors:
+                    if front_end_possibility.name in avail:
+                        tty.debug("using front-end architecture or available ancestor")
+                        return front_end_possibility.name
                 else:
+                    tty.debug("using platform.machine as default")
                     return platform.machine()
 
     def _avail_targets(self):


Test patch: