CMS 3D CMS Logo

functions.py
Go to the documentation of this file.
1 def makeSerialClone(module, **kwargs):
2  type = module._TypedParameterizable__type
3  if type.endswith('@alpaka'):
4  # alpaka module with automatic backend selection
5  base = type.removesuffix('@alpaka')
6  elif type.startswith('alpaka_serial_sync::'):
7  # alpaka module with explicit serial_sync backend
8  base = type.removeprefix('alpaka_serial_sync::')
9  elif type.startswith('alpaka_cuda_async::'):
10  # alpaka module with explicit cuda_async backend
11  base = type.removeprefix('alpaka_cuda_async::')
12  elif type.startswith('alpaka_rocm_async::'):
13  # alpaka module with explicit rocm_async backend
14  base = type.removeprefix('alpaka_rocm_async::')
15  else:
16  # non-alpaka module
17  raise TypeError('%s is not an alpaka-based module, and cannot be used with makeSerialClone()' % str(module))
18 
19  copy = module.clone(**kwargs)
20  copy._TypedParameterizable__type = 'alpaka_serial_sync::' + base
21  if 'alpaka' in copy.parameterNames_():
22  del copy.alpaka
23  return copy
def makeSerialClone(module, kwargs)
Definition: functions.py:1
#define str(s)