📄 buildiface
字号:
#! /usr/bin/perl ## This file builds candidate interface files from the descriptions in # mpi.h## Here are the steps:# 1) Find the prototypes in mpi.h.in (Look for *Begin Prototypes*)# 2) For each function, match the name and args:# int MPI_xxxx( ... )# 3) By groups, create a new file with the name {catname}.h containing # Copyright# For each function in the group, the expansion of the method## Each MPI routine is assigned to a group. Within each group,# a particular argument is (usually) eliminated from the C++ call.# E.g., in MPI::Send, the communicator argument is removed from the# call sequence.# Routines that have out parameters (e.g., the request in MPI_Isend)# remove them as well. Other routines return void.## The replacement text will look something like# void Name( args ) const {# MPIX_CALL( MPI_Name( args, with (cast)((class).the_real_(class)) ); }## If coverage analysis is desired, consider using the -coverage# switch. This (will, once done) allow generating crude coverage data.# We'd prefer to use gcov, but gcov aborts (!) when used on the data # generated by the g++. The coverage switch changes the replacement text# to something like# void Name( args ) const {# COVERAGE_ENTER(Name,argcount);# MPIX_Call ....# COVERAGE_EXIT(Name,argcount); }# The COVERAGE_ENTER and EXIT can be used as macros to invoke code to keep# track of each entry and exit. The argcount is the number of parameters,# and can be used to distinquish between routines with the same name but# different number of arguments.## (const applies only if the function does not modify its object (e.g., # get_name may be const but set_name must not be.)## A capability of this approach is that a stripped-down interface that # implements only the required routines can be created.## Data structures# %<class>_members (e.g., mpi1comm): keys are names of routines.# Values are string indicating processing:# returnvalue-arg (0 if void, type if unique, position if not)# Pass by reference to process routine# # TODO:# The derived classes (such as Intracomm) must *not* have their own# protected the_real_intracomm; instead, the must refer to the # parent class's private storage. - DONE## The pack, unpack, packsize, init, and finalize routines must be # placed in initcpp.cpp. - DONE## externs for the predefined objects need to be added to the# end of mpicxx.h - DONE## The optional no-status versions need to be created for # methods such as Recv, Test, and Sendrecv . - DONE## Setup global variables$build_io = 1; # If false, exclude the MPI-IO routines$indent = " ";$print_line_len = 0;$gDebug = 0;$gDebugRoutine = "NONE";@mpilevels = ( 'mpi1' , 'mpi2' );#feature variables$do_subdecls = 1;$doCoverage = 0;$doFuncspec = 1;# Process environment variables# CXX_COVERAGE - yes : turn on coverage codeif (defined($ENV{"CXX_COVERAGE"}) && $ENV{"CXX_COVERAGE"} eq "yes") { setCoverage(1);}# Process arguments## Args# -feature={logical,fint,subdecls,weak,bufptr}, separated by :, value given # by =on or =off, eg# -feature=logical=on:fint=off# The feature names mean:# subdecls - Declarations for PC-C++ compilers added# -routines=name - provide a list of routines or a file that# lists the routines to use. The names must be in the same form as the # the class_xxx variables. E.g., comm-Send, dtype-Commit.$routine_list = "";foreach $_ (@ARGV) { if (/-feature=(.*)/) { foreach $feature (split(/:/,$1)) { print STDERR "Processing feature $feature\n" if $gDebug; # Feature values are foo=on,off ($name,$value) = split(/=/,$feature); if ($value eq "on") { $value = 1; } elsif ($value eq "off") { $value = 0; } # Set the variable based on the string $varname = "do_$name"; $$varname = $value; } } elsif (/-nosep/ || /-sep/) { ; } # Old argument; ignore elsif (/-noromio/) { $build_io = 0; } elsif (/-debug=(.*)/) { $gDebug = 0; $gDebugRoutine = $1; } elsif (/-debug/) { $gDebug = 1; } elsif (/-routines=(.*)/) { $routine_list = $1; } elsif (/-coverage/) { &setCoverage( 1 ); } elsif (/-nocoverage/) { &setCoverage( 0 ); } else { print STDERR "Unrecognized argument $_\n"; }}if (! -d "../../mpi/romio") { $build_io = 0; }# ----------------------------------------------------------------------------# # The following hashes define each of the methods that belongs to each class.# To allow us to differentiate between MPI-1 and MPI-2, the methods for# are separated. The hash names have the form# class_mpi<1 or 2><short classname># The value of each key is the POSITION (from 1) of the return argument # if an integer is used or the MPI-1 type (e.g., MPI_Request) if a string is# used. The position form is normally used to return an int or other value# whose type does not give an unambiguous argument. A value of 0 indicates# that the routine does not return a value.# Value of the hash is the argument of the routine that returns a value# ToDo:# Add to the value of each routine any special instructions on # processing the arguments. See the Fortran version of buildiface.# Needed are:# in:array, out:array - Convert array of class members to/from# arrays of the_real_xxx. Question: for# simplicity, should we have just in:reqarray,# inout:reqarray, out:reqarray? Answer: the # current approach uses separate routines for# each array type.# in:const - Add const in the C++ declaration (e.g., # in send, make the buf const void * instead# of just void *)# in:bool,out:bool - Convert value from bool to/from int# # We'll indicate these with to fields returnvalue:argnum:... # For each method with special processing for an arg, there is # methodname-argnum.# Eg, Isend is# Isend => 'MPI_Request:1', Isend-1 => 'in:const'# and Send is# Send => '0:1', Send-1 => 'in:const'# The mappings for the arguments are kept in a # separate hash, %funcArgMap.#%class_mpi1comm = ( Send => '0:1', Recv => 0, Bsend => '0:1', Ssend => '0:1', Rsend => '0:1', Isend => 'MPI_Request:1', Irsend => 'MPI_Request:1', Issend => 'MPI_Request:1', Ibsend => 'MPI_Request:1', Irecv => MPI_Request, Iprobe => 'int;bool', Probe => 0, Send_init => 'MPI_Request:1', Ssend_init => 'MPI_Request:1', Bsend_init => 'MPI_Request:1', Rsend_init => 'MPI_Request:1', Recv_init => MPI_Request, Sendrecv => 0, Sendrecv_replace => 0, Get_size => 'int', Get_rank => 'int', Free => 0, Get_topology => 2, Get_group => MPI_Group, Compare => 'static:int', Abort => 0, Set_errhandler => 0, Get_errhandler => MPI_Errhandler, Is_inter => '2;bool', );%funcArgMap = ( 'Send-1' => 'in:const', 'Bsend-1' => 'in:const', 'Rsend-1' => 'in:const', 'Ssend-1' => 'in:const', 'Irsend-1' => 'in:const', 'Isend-1' => 'in:const', 'Ibsend-1' => 'in:const', 'Issend-1' => 'in:const', 'Send_init-1' => 'in:const', 'Ssend_init-1' => 'in:const', 'Bsend_init-1' => 'in:const', 'Rsend_init-1' => 'in:const', 'Free_keyval-1' => 'in:refint', 'Waitany-2' => 'inout:reqarray:1', 'Waitsome-2' => 'inout:reqarray:1', 'Waitsome-5' => 'out:statusarray:1', # or 4? 'Waitall-2' => 'inout:reqarray:1', 'Waitall-3' => 'out:statusarray:1', 'Testany-2' => 'inout:reqarray:1', 'Testany-3' => 'in:refint', 'Testsome-2' => 'inout:reqarray:1', 'Testsome-5' => 'out:statusarray:1', # or 4? 'Testall-2' => 'inout:reqarray:1', 'Testall-4' => 'out:statusarray:1', 'Startall-2' => 'inout:preqarray:1', 'Pack-1' => 'in:const', 'Unpack-1' => 'in:const', 'Pack-6' => 'in:refint', 'Unpack-5' => 'in:refint', 'Get_error_string-3' => 'in:refint', 'Create_struct-4' => 'in:dtypearray:1', 'Merge-2' => 'in:bool', 'Create_cart-4' => 'in:boolarray:2', 'Create_cart-5' => 'in:bool', 'Create_graph-5' => 'in:bool', 'cart-Get_topo-4' => 'out:boolarray:2', 'Sub-2' => 'in:boolarray:-10', # Use -10 for immediate number 'Shift-4' => 'in:refint', 'Shift-5' => 'in:refint', # Bug - there are cartcomm map and graphcomm map. The # call routine will find this 'cart-Map-4' => 'in:boolarray:2', 'Get_processor_name-2' => 'in:refint', 'info-Set-2' => 'in:const', 'info-Set-3' => 'in:const', 'info-Get-2' => 'in:const', 'Get_valuelen-2' => 'in:const', 'file-Open-2' => 'in:const', 'file-Delete-1' => 'in:const', 'Set_view-4' => 'in:const', 'Write-2' => 'in:const', 'Write_all-2' => 'in:const', 'Iwrite_at-2' => 'in:const', 'Iwrite-2' => 'in:const', 'Write_at-3' => 'in:const', 'Write_at_all-3' => 'in:const', 'Write_at_all_begin-3' => 'in:const', 'Write_at_all_end-2' => 'in:const', 'Write_all_begin-2' => 'in:const', 'Write_all_end-2' => 'in:const', 'Write_ordered_begin-2' => 'in:const', 'Write_ordered_end-2' => 'in:const', 'Write_ordered-2' => 'in:const', 'Write_shared-2' => 'in:const', 'Set_atomicity-2' => 'in:bool', 'Put-1' => 'in:const', 'Accumulate-1' => 'in:const', 'Alloc_mem-2' => 'in:constref:Info', 'Detach_buffer-1' => 'inout:ptrref', 'Get_version-1' => 'in:refint', 'Get_version-2' => 'in:refint', 'Get_name-3' => 'in:refint', 'Set_name-2' => 'in:const', 'Add_error_string-2' => 'in:const', );%class_mpi1cart = ( 'Dup' => MPI_Comm, 'Get_dim' => 'int', 'Get_topo' => '0:4', 'Get_cart_rank' => '3', 'Get_coords' => 0, 'Shift' => '0:4:5', 'Sub' => 'MPI_Comm:2', 'Map' => '5:4',);$specialReturnType{"cart-Dup"} = "Cartcomm";$specialReturnType{"cart-Sub"} = "Cartcomm";$specialReturnType{"cart-Split"} = "Cartcomm";%class_mpi1dtype = ( 'Create_contiguous' => 'MPI_Datatype', 'Create_vector' => 'MPI_Datatype', 'Create_indexed' => 'MPI_Datatype', 'Create_struct' => 'static:5:4', 'Get_size' => 2, 'Commit' => 0, 'Free' => 0, # 'Pack' => '0:1:6', # 'Unpack' => '0:1:5', 'Pack_size' => 4, );%class_mpi1errh = ( 'Free' => 0, # Init missing );%class_mpi1graph = ( 'Get_dims' => 0, 'Get_topo' => 0, 'Get_neighbors_count' => 'int', 'Get_neighbors' => 0, 'Map' => 5, );$specialReturnType{"graph-Dup"} = "Graphcomm";$specialReturnType{"graph-Split"} = "Graphcomm";# Range routines will require special handling# The Translate_ranks, Union, Intersect, Difference, and Compare routines are # static and don't work on an instance of a group%class_mpi1group = ( 'Get_size' => 'int', 'Get_rank' => 'int', 'Translate_ranks' => 'static:0', 'Compare' => 'static:int', 'Union' => 'static:MPI_Group', 'Intersect' => 'static:MPI_Group', 'Difference' => 'static:MPI_Group', 'Incl', MPI_Group, 'Excl', MPI_Group, 'Range_incl', MPI_Group, 'Range_excl', MPI_Group, 'Free' => 0,);%class_mpi1inter = ( 'Dup' => MPI_Comm, 'Get_remote_size' => 'int', 'Get_remote_group' => MPI_Group, 'Merge' => 'MPI_Comm:2', );$specialReturnType{"inter-Dup"} = "Intercomm";$specialReturnType{"inter-Split"} = "Intercomm";%class_mpi1intra = ( #'Barrier' => 0, #'Bcast' => 0, #'Gather' => 0, #'Gatherv' => 0, #'Scatter' => 0, #'Scatterv' => 0, #'Allgather' => 0, #'Allgatherv' => 0, #'Alltoall' => 0, #'Alltoallv' => 0, #'Reduce' => 0, #'Allreduce' => 0, #'Reduce_scatter' => 0, 'Scan' => 0, 'Dup' => MPI_Comm, 'Create' => MPI_Comm, 'Split' => MPI_Comm, 'Create_intercomm' => MPI_Comm, 'Create_cart' => 'MPI_Comm:4:5', 'Create_graph' => 'MPI_Comm:5' );$specialReturnType{"intra-Split"} = "Intracomm";$specialReturnType{"intra-Create"} = "Intracomm";$specialReturnType{"intra-Dup"} = "Intracomm";%class_mpi1op = ( 'Free' => 0);%class_mpi1preq = ( 'Start' => 0, 'Startall' => 'static:0:2' );%class_mpi1req = ( 'Wait' => 0, 'Test' => 'int;bool', 'Free' => 0, 'Cancel' => 0, 'Waitall' => 'static:0:2:3', 'Waitany' => 'static:int:2', 'Waitsome' => 'static:3:2:5', 'Testall' => 'static:int;bool:2:4', 'Testany' => 'static:4;bool:2:3:4', 'Testsome' => 'static:3:2:5',);%class_mpi1st = ( 'Get_count' => 'int', 'Is_cancelled' => 'int;bool', 'Get_elements' => 'int', # get/set source, tag, error have no C binding );# These are the routines that are in no class, minus the few that require# special handling (Init, Wtime, and Wtick).%class_mpi1base = ( 'Get_processor_name' => '0:2', 'Get_error_string' => '0:3', 'Get_error_class', => '2', 'Compute_dims' => 0, 'Finalize' => 0, 'Is_initialized', => '1;bool', 'Attach_buffer' => 0, 'Detach_buffer' => '2:1', 'Pcontrol' => '0', 'Get_version' => '0:1:2', # MPI 1.2 );## Here are the MPI-2 methods# WARNING: These are incomplete. They primarily define only the# MPI-2 routines implemented by MPICH2.%class_mpi2base = ( 'Alloc_mem' => '3;void *:2', 'Free_mem' => '0', 'Open_port' => '1', 'Close_port' => '0',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -