+def add_base_stage(name: str,
+ input_args,
+ output_stages: typing.MutableMapping[str, hpccm.Stage]):
+ """Establish dependencies that are shared by multiple parallel stages."""
+ # Building blocks are chunks of container-builder instructions that can be
+ # copied to any build stage with the addition operator.
+ building_blocks = collections.OrderedDict()
+ building_blocks['base_packages'] = hpccm.building_blocks.packages(
+ ospackages=_common_packages)
+
+ # These are the most expensive and most reusable layers, so we put them first.
+ building_blocks['compiler'] = get_compiler(input_args, compiler_build_stage=output_stages.get('compiler_build'))
+ building_blocks['gdrcopy'] = get_gdrcopy(input_args, building_blocks['compiler'])
+ building_blocks['ucx'] = get_ucx(input_args, building_blocks['compiler'], building_blocks['gdrcopy'])
+ building_blocks['mpi'] = get_mpi(input_args, building_blocks['compiler'], building_blocks['ucx'])
+
+ # Create the stage from which the targeted image will be tagged.
+ output_stages[name] = hpccm.Stage()
+
+ output_stages[name] += hpccm.primitives.baseimage(image=base_image_tag(input_args),
+ _distro=hpccm_distro_name(input_args),
+ _as=name)
+ for bb in building_blocks.values():
+ if bb is not None:
+ output_stages[name] += bb
+
+