4949from easybuild .easyblocks .generic .cmakemake import setup_cmake_env
5050from easybuild .framework .easyblock import EasyBlock
5151from easybuild .framework .easyconfig import CUSTOM
52+ from easybuild .toolchains .compiler .fujitsu import TC_CONSTANT_FUJITSU
5253from easybuild .tools .build_log import EasyBuildError
5354from easybuild .tools .filetools import adjust_permissions , apply_regex_substitutions , mkdir , write_file
5455from easybuild .tools .modules import get_software_root , get_software_version
@@ -65,6 +66,7 @@ def extra_options():
6566 extra_vars = EasyBlock .extra_options ()
6667 extra_vars .update ({
6768 'sanity_check_motorbike' : [True , "Should the motorbike sanity check run?" , CUSTOM ],
69+ 'sanity_check_oversubscribe' : [True , "Should the motorbike sanity check use oversubscription?" , CUSTOM ],
6870 })
6971 return extra_vars
7072
@@ -552,6 +554,17 @@ def sanity_check_step(self):
552554 # only for recent (>= v6.0) versions of openfoam.org variant
553555 # could be turned off by set 'sanity_check_motorbike' to False (default True)
554556 if self .is_dot_org and self .looseversion >= LooseVersion ('6' ) and self .cfg ['sanity_check_motorbike' ]:
557+
558+ if (self .cfg ['sanity_check_oversubscribe' ] and
559+ self .toolchain .mpi_family () == toolchain .OPENMPI and
560+ self .toolchain .comp_family () != TC_CONSTANT_FUJITSU ):
561+ # allow oversubscription of number of processes over number of available cores with OpenMPI 3.0 & newer,
562+ # to avoid that motorBike fails if only a handful of cores are available
563+ pre_cmds = [
564+ "export OMPI_MCA_rmaps_base_oversubscribe=true" ,
565+ "export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe" ,
566+ ]
567+
555568 openfoamdir_path = os .path .join (self .installdir , self .openfoamdir )
556569 if self .looseversion <= LooseVersion ('10' ):
557570 motorbike_path = os .path .join (
@@ -572,47 +585,47 @@ def sanity_check_step(self):
572585
573586 if self .looseversion <= LooseVersion ('10' ):
574587 cmds = [
575- "cp -dR --preserve=timestamps %s %s" % (motorbike_path , test_dir ),
576- # Make sure the tmpdir for tests ir writeable if read-only-installdir is used
577- "chmod -R +w %s" % test_dir ,
578- "cd %s" % os .path .join (test_dir , os .path .basename (motorbike_path )),
579- "source $FOAM_BASH" ,
580- ". $WM_PROJECT_DIR/bin/tools/RunFunctions" ,
581- "cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir ,
582- "runApplication surfaceFeatures" ,
583- "runApplication blockMesh" ,
584- "runApplication decomposePar -copyZero" ,
585- "runParallel snappyHexMesh -overwrite" ,
586- "runParallel patchSummary" ,
587- "runParallel potentialFoam" ,
588- "runParallel simpleFoam" ,
589- "runApplication reconstructParMesh -constant" ,
590- "runApplication reconstructPar -latestTime" ,
591- "cd %s" % self .builddir ,
592- "rm -r %s" % test_dir ,
588+ "cp -dR --preserve=timestamps %s %s" % (motorbike_path , test_dir ),
589+ # Make sure the tmpdir for tests ir writeable if read-only-installdir is used
590+ "chmod -R +w %s" % test_dir ,
591+ "cd %s" % os .path .join (test_dir , os .path .basename (motorbike_path )),
592+ "source $FOAM_BASH" ,
593+ ". $WM_PROJECT_DIR/bin/tools/RunFunctions" ,
594+ "cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir ,
595+ "runApplication surfaceFeatures" ,
596+ "runApplication blockMesh" ,
597+ "runApplication decomposePar -copyZero" ,
598+ "runParallel snappyHexMesh -overwrite" ,
599+ "runParallel patchSummary" ,
600+ "runParallel potentialFoam" ,
601+ "runParallel simpleFoam" ,
602+ "runApplication reconstructParMesh -constant" ,
603+ "runApplication reconstructPar -latestTime" ,
604+ "cd %s" % self .builddir ,
605+ "rm -r %s" % test_dir ,
593606 ]
594607 # v11 and above run the motorBike example differently
595608 else :
596609 cmds = [
597- "cp -dR --preserve=timestamps %s %s" % (motorbike_path , test_dir ),
598- # Make sure the tmpdir for tests ir writeable if read-only-installdir is used
599- "chmod -R +w %s" % os .path .join (test_dir , os .path .basename (motorbike_path )),
600- "cd %s" % os .path .join (test_dir , os .path .basename (motorbike_path )),
601- "source $FOAM_BASH" ,
602- ". $WM_PROJECT_DIR/bin/tools/RunFunctions" ,
603- "cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir ,
604- "runApplication blockMesh" ,
605- "runApplication decomposePar -copyZero" ,
606- "find . -type f -iname '*level*' -exec rm {} \\ ;" ,
607- "runParallel renumberMesh -overwrite" ,
608- "runParallel potentialFoam -initialiseUBCs" ,
609- "runParallel simpleFoam" ,
610- "cd %s" % self .builddir ,
611- "rm -r %s" % test_dir ,
610+ "cp -dR --preserve=timestamps %s %s" % (motorbike_path , test_dir ),
611+ # Make sure the tmpdir for tests ir writeable if read-only-installdir is used
612+ "chmod -R +w %s" % os .path .join (test_dir , os .path .basename (motorbike_path )),
613+ "cd %s" % os .path .join (test_dir , os .path .basename (motorbike_path )),
614+ "source $FOAM_BASH" ,
615+ ". $WM_PROJECT_DIR/bin/tools/RunFunctions" ,
616+ "cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir ,
617+ "runApplication blockMesh" ,
618+ "runApplication decomposePar -copyZero" ,
619+ "find . -type f -iname '*level*' -exec rm {} \\ ;" ,
620+ "runParallel renumberMesh -overwrite" ,
621+ "runParallel potentialFoam -initialiseUBCs" ,
622+ "runParallel simpleFoam" ,
623+ "cd %s" % self .builddir ,
624+ "rm -r %s" % test_dir ,
612625 ]
613626 # all commands need to be run in a single shell command,
614627 # because sourcing $FOAM_BASH sets up environment
615- custom_commands .append (' && ' .join (cmds ))
628+ custom_commands .append (' && ' .join (pre_cmds + cmds ))
616629
617630 super ().sanity_check_step (custom_paths = custom_paths , custom_commands = custom_commands )
618631
0 commit comments