?? mpi.jam
字號:
# Support for the Message Passing Interface (MPI)## (C) Copyright 2005, 2006 Trustees of Indiana University# (C) Copyright 2005 Douglas Gregor## Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)## Authors: Douglas Gregor# Andrew Lumsdaine## ==== MPI Configuration ====# # For many users, MPI support can be enabled simply by adding the following # line to your user-config.jam file:## using mpi ;## This should auto-detect MPI settings based on the MPI wrapper compiler in # your path, e.g., "mpic++". If the wrapper compiler is not in your path, or# has a different name, you can pass the name of the wrapper compiler as the# first argument to the mpi module:## using mpi : /opt/mpich2-1.0.4/bin/mpiCC ;## If your MPI implementation does not have a wrapper compiler, or the MPI # auto-detection code does not work with your MPI's wrapper compiler,# you can pass MPI-related options explicitly via the second parameter to the # mpi module:## using mpi : : <find-shared-library>lammpio <find-shared-library>lammpi++# <find-shared-library>mpi <find-shared-library>lam # <find-shared-library>dl ;## To see the results of MPI auto-detection, pass "--debug-configuration" on# the bjam command line.## The (optional) fourth argument configures Boost.MPI for running# regression tests. These parameters specify the executable used to# launch jobs (default: "mpirun") followed by any necessary arguments# to this to run tests and tell the program to expect the number of# processors to follow (default: "-np"). With the default parameters,# for instance, the test harness will execute, e.g.,# # mpirun -np 4 all_gather_test## ==== Linking Against the MPI Libraries ===## To link against the MPI libraries, import the "mpi" module and add the # following requirement to your target:# # <library>/mpi//mpi ## Since MPI support is not always available, you should check # "mpi.configured" before trying to link against the MPI libraries.import "class" : new ;import common ;import feature : feature ;import generators ;import os ;import project ;import property ;import testing ;import toolset ;import type ;# Make this module a projectproject.initialize $(__name__) ;project mpi ;if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]{ .debug-configuration = true ;}# Assuming the first part of the command line is the given prefix# followed by some non-empty value, remove the first argument. Returns# either nothing (if there was no prefix or no value) or a pair## <name>value rest-of-cmdline## This is a subroutine of cmdline_to_featuresrule add_feature ( prefix name cmdline ) { local match = [ MATCH "^$(prefix)([^\" ]+|\"[^\"]+\") *(.*)$" : $(cmdline) ] ; # If there was no value associated with the prefix, abort if ! $(match) { return ; } local value = $(match[1]) ; if [ MATCH " +" : $(value) ] { value = "\"$(value)\"" ; } return "<$(name)>$(value)" $(match[2]) ;}# Strip any end-of-line characters off the given string and return the# result.rule strip-eol ( string ){ local match = [ MATCH "^(([A-Za-z0-9~`\.!@#$%^&*()_+={};:'\",.<>/?\\| -]|[|])*).*$" : $(string) ] ; if $(match) { return $(match[1]) ; } else { return $(string) ; }}# Split a command-line into a set of features. Certain kinds of# compiler flags are recognized (e.g., -I, -D, -L, -l) and replaced# with their Boost.Build equivalents (e.g., <include>, <define>,# <library-path>, <find-library>). All other arguments are introduced# using the features in the unknown-features parameter, because we# don't know how to deal with them. For instance, if your compile and# correct. The incoming command line should be a string starting with# an executable (e.g., g++ -I/include/path") and may contain any# number of command-line arguments thereafter. The result is a list of# features corresponding to the given command line, ignoring the# executable.rule cmdline_to_features ( cmdline : unknown-features ? ){ local executable ; local features ; local otherflags ; local result ; unknown-features ?= <cxxflags> <linkflags> ; # Pull the executable out of the command line. At this point, the # executable is just thrown away. local match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" : $(cmdline) ] ; executable = $(match[1]) ; cmdline = $(match[2]) ; # List the prefix/feature pairs that we will be able to transform. # Every kind of parameter not mentioned here will be placed in both # cxxflags and linkflags, because we don't know where they should go. local feature_kinds-D = "define" ; local feature_kinds-I = "include" ; local feature_kinds-L = "library-path" ; local feature_kinds-l = "find-shared-library" ; while $(cmdline) { # Check for one of the feature prefixes we know about. If we # find one (and the associated value is nonempty), convert it # into a feature. local match = [ MATCH "^(-.)(.*)" : $(cmdline) ] ; local matched ; if $(match) && $(match[2]) { local prefix = $(match[1]) ; if $(feature_kinds$(prefix)) { local name = $(feature_kinds$(prefix)) ; local add = [ add_feature $(prefix) $(name) $(cmdline) ] ; if $(add) { result += $(add[1]) ; cmdline = $(add[2]) ; matched = yes ; } } } # If we haven't matched a feature prefix, just grab the command-line # argument itself. If we can map this argument to a feature # (e.g., -pthread -> <threading>multi), then do so; otherwise, # and add it to the list of "other" flags that we don't # understand. if ! $(matched) { match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" : $(cmdline) ] ; local value = $(match[1]) ; cmdline = $(match[2]) ; # Check for multithreading support if $(value) = "-pthread" || $(value) = "-pthreads" { result += "<threading>multi" ; # DPG: This is a hack intended to work around a BBv2 bug where # requirements propagated from libraries are not checked for # conflicts when BBv2 determines which "common" properties to # apply to a target. In our case, the <threading>single property # gets propagated from the common properties to Boost.MPI # targets, even though <threading>multi is in the usage # requirements of <library>/mpi//mpi. MPI_EXTRA_REQUIREMENTS += "<threading>multi" ; } else if [ MATCH "(.*[a-zA-Z0-9<>?-].*)" : $(value) ] { otherflags += $(value) ; } } } # If there are other flags that we don't understand, add them to the # result as both <cxxflags> and <linkflags> if $(otherflags) { for unknown in $(unknown-features) { result += "$(unknown)$(otherflags)" ; } } return $(result) ;}# Determine if it is safe to execute the given shell command by trying# to execute it and determining whether the exit code is zero or# not. Returns true for an exit code of zero, false otherwise.local rule safe-shell-command ( cmdline ){ local result = [ SHELL "$(cmdline) > /dev/null 2>/dev/null; if [ "$?" -eq "0" ]; then echo SSCOK; fi" ] ; return [ MATCH ".*(SSCOK).*" : $(result) ] ;}# Initialize the MPI module. rule init ( mpicxx ? : options * : mpirun-with-options * ){ if ! $(options) && $(.debug-configuration) { ECHO "===============MPI Auto-configuration===============" ; } if ! $(mpicxx) && [ os.on-windows ] { # Try to auto-configure to the Microsoft Compute Cluster Pack local cluster_pack_path_native = "C:\\Program Files\\Microsoft Compute Cluster Pack" ; local cluster_pack_path = [ path.make $(cluster_pack_path_native) ] ; if [ GLOB $(cluster_pack_path_native)\\Include : mpi.h ] { if $(.debug-configuration) { ECHO "Found Microsoft Compute Cluster Pack: $(cluster_pack_path_native)" ; } # Pick up either the 32-bit or 64-bit library, depending on which address # model the user has selected. Default to 32-bit. options = <include>$(cluster_pack_path)/Include <address-model>64:<library-path>$(cluster_pack_path)/Lib/amd64 <library-path>$(cluster_pack_path)/Lib/i386 <find-static-library>msmpi <toolset>msvc:<define>_SECURE_SCL=0 ; # Setup the "mpirun" equivalent (mpiexec) .mpirun = "\"$(cluster_pack_path_native)\\Bin\\mpiexec.exe"\" ;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -