📄 mpi.jam
字号:
.mpirun_flags = -n ; } else if $(.debug-configuration) { ECHO "Did not find Microsoft Compute Cluster Pack in $(cluster_pack_path_native)." ; } } if ! $(options) { # Try to auto-detect options based on the wrapper compiler local command = [ common.get-invocation-command mpi : mpic++ : $(mpicxx) ] ; if ! $(mpicxx) && ! $(command) { # Try "mpiCC", which is used by MPICH command = [ common.get-invocation-command mpi : mpiCC ] ; } if ! $(mpicxx) && ! $(command) { # Try "mpicxx", which is used by OpenMPI and MPICH2 command = [ common.get-invocation-command mpi : mpicxx ] ; } local result ; local compile_flags ; local link_flags ; if ! $(command) { # Do nothing: we'll complain later } # OpenMPI and newer versions of LAM-MPI have -showme:compile and # -showme:link. else if [ safe-shell-command "$(command) -showme:compile" ] && [ safe-shell-command "$(command) -showme:link" ] { if $(.debug-configuration) { ECHO "Found recent LAM-MPI or Open MPI wrapper compiler: $(command)" ; } compile_flags = [ SHELL "$(command) -showme:compile" ] ; link_flags = [ SHELL "$(command) -showme:link" ] ; # Prepend COMPILER as the executable name, to match the format of # other compilation commands. compile_flags = "COMPILER $(compile_flags)" ; link_flags = "COMPILER $(link_flags)" ; } # Look for LAM-MPI's -showme else if [ safe-shell-command "$(command) -showme" ] { if $(.debug-configuration) { ECHO "Found older LAM-MPI wrapper compiler: $(command)" ; } result = [ SHELL "$(command) -showme" ] ; } # Look for MPICH else if [ safe-shell-command "$(command) -show" ] { if $(.debug-configuration) { ECHO "Found MPICH wrapper compiler: $(command)" ; } compile_flags = [ SHELL "$(command) -compile_info" ] ; link_flags = [ SHELL "$(command) -link_info" ] ; } if $(result) || $(compile_flags) && $(link_flags) { if $(result) { result = [ strip-eol $(result) ] ; options = [ cmdline_to_features $(result) ] ; } else { compile_flags = [ strip-eol $(compile_flags) ] ; link_flags = [ strip-eol $(link_flags) ] ; # Separately process compilation and link features, then combine # them at the end. local compile_features = [ cmdline_to_features $(compile_flags) : "<cxxflags>" ] ; local link_features = [ cmdline_to_features $(link_flags) : "<linkflags>" ] ; options = $(compile_features) $(link_features) ; } # If requested, display MPI configuration information. if $(.debug-configuration) { if $(result) { ECHO " Wrapper compiler command line: $(result)" ; } else { local match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" : $(compile_flags) ] ; ECHO "MPI compilation flags: $(match[2])" ; local match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" : $(link_flags) ] ; ECHO "MPI link flags: $(match[2])" ; } } } else { if $(command) { ECHO "MPI auto-detection failed: unknown wrapper compiler $(command)" ; ECHO "Please report this error to the Boost mailing list: http://www.boost.org" ; } else if $(mpicxx) { ECHO "MPI auto-detection failed: unable to find wrapper compiler $(mpicxx)" ; } else { ECHO "MPI auto-detection failed: unable to find wrapper compiler `mpic++' or `mpiCC'" ; } ECHO "You will need to manually configure MPI support." ; } } # Find mpirun (or its equivalent) and its flags if ! $(.mpirun) { .mpirun = [ common.get-invocation-command mpi : mpirun : $(mpirun-with-options[1]) ] ; .mpirun_flags = $(mpirun-with-options[2-]) ; .mpirun_flags ?= -np ; } if $(.debug-configuration) { if $(options) { echo "MPI build features: " ; ECHO $(options) ; } if $(.mpirun) { echo "MPI launcher: $(.mpirun) $(.mpirun_flags)" ; } ECHO "====================================================" ; } if $(options) { .configured = true ; # Set up the "mpi" alias alias mpi : : : : $(options) ; }}# States whether MPI has bee configuredrule configured ( ){ return $(.configured) ;}# Returs the "extra" requirements needed to build MPI. These requirements are# part of the /mpi//mpi library target, but they need to be added to anything# that uses MPI directly to work around bugs in BBv2's propagation of# requirements.rule extra-requirements ( ){ return $(MPI_EXTRA_REQUIREMENTS) ;}# Support for testing; borrowed from Pythontype.register RUN_MPI_OUTPUT ;type.register RUN_MPI : : TEST ;class mpi-test-generator : generator{ import property-set ; rule __init__ ( * : * ) { generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; self.composing = true ; } rule run ( project name ? : property-set : sources * : multiple ? ) { # Generate an executable from the sources. This is the executable we will run. local executable = [ generators.construct $(project) $(name) : EXE : $(property-set) : $(sources) ] ; result = [ construct-result $(executable[2-]) : $(project) $(name)-run : $(property-set) ] ; }}# Use mpi-test-generator to generate MPI tests from sourcesgenerators.register [ new mpi-test-generator mpi.capture-output : : RUN_MPI_OUTPUT ] ;generators.register-standard testing.expect-success : RUN_MPI_OUTPUT : RUN_MPI ;# The number of processes to spawn when executing an MPI test.feature mpi:processes : : free incidental ;# The flag settings on testing.capture-output do not# apply to mpi.capture output at the moment.# Redo this explicitly.toolset.flags mpi.capture-output ARGS <testing.arg> ;rule capture-output ( target : sources * : properties * ){ # Use the standard capture-output rule to run the tests testing.capture-output $(target) : $(sources[1]) : $(properties) ; # Determine the number of processes we should run on. local num_processes = [ property.select <mpi:processes> : $(properties) ] ; num_processes = $(num_processes:G=) ; # We launch MPI processes using the "mpirun" equivalent specified by the user. LAUNCHER on $(target) = [ on $(target) return $(.mpirun) $(.mpirun_flags) $(num_processes) ] ;}# Creates a set of test cases to be run through the MPI launcher. The name, sources, # and requirements are the same as for any other test generator. However, schedule is # a list of numbers, which indicates how many processes each test run will use. For # example, passing 1 2 7 will run the test with 1 process, then 2 processes, then 7# 7 processes. The name provided is just the base name: the actual tests will be # the name followed by a hypen, then the number of processes. rule mpi-test ( name : sources * : requirements * : schedule * ){ sources ?= $(name).cpp ; schedule ?= 1 2 3 4 7 8 13 17 ; local result ; for processes in $(schedule) { result += [ testing.make-test run-mpi : $(sources) /boost/mpi//boost_mpi : $(requirements) <toolset>msvc:<link>static <mpi:processes>$(processes) : $(name)-$(processes) ] ; } return $(result) ;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -