📄 buildiface
字号:
'greq' => 'request', 'preq' => 'request' );%altname = ( 'comm-Sendrecv_repl' => 'Sendrecv_replace', 'comm-Get_topology' => 'Topo_test', 'comm-Get_rank' => 'Comm_rank', 'comm-Get_size' => 'Comm_size', 'comm-Get_group' => 'Comm_group', 'dtype-Create_contiguous' => 'Type_contiguous', 'dtype-Create_vector' => 'Type_vector', 'dtype-Create_indexed' => 'Type_indexed', 'dtype-Commit' => 'Type_commit', 'dtype-Pack' => 'Pack', 'dtype-Unpack' => 'Unpack', 'dtype-Pack_size' => 'Pack_size', 'dtype-Free' => 'Type_free', 'dtype-Get_size' => 'Type_size', 'dtype-Get_name' => 'Type_get_name', 'dtype-Set_name' => 'Type_set_name', 'group-Get_size' => 'Group_size', 'group-Get_rank' => 'Group_rank', 'group-Intersect' => 'Group_intersection', 'intra-Create_intercomm' => 'Intercomm_create', 'inter-Get_remote_group' => 'Comm_remote_group', 'inter-Get_remote_size' => 'Comm_remote_size', 'inter-Dup' => 'Comm_dup', 'intra-Create' => 'Comm_create', 'intra-Dup' => 'Comm_dup', 'intra-Split' => 'Comm_split', 'intra-Create_cart' => 'Cart_create', 'intra-Create_graph' => 'Graph_create', 'st-Is_cancelled' => 'Test_cancelled', 'cart-Get_cart_rank' => 'Cart_rank', 'cart-Map' => 'Cart_map', 'cart-Get_topo' => 'Topo_test', 'cart-Shift' => 'Cart_shift', 'cart-Sub' => 'Cart_sub', 'cart-Dup' => 'Comm_dup', 'cart-Get_dim' => 'Cartdim_get', 'graph-Map' => 'Graph_map', 'graph-Get_topo' => 'Topo_test', 'graph-Get_neighbors' => 'Graph_neighbors', 'graph-Get_neighbors_count' => 'Graph_neighbors_count', 'graph-Get_dims' => 'Graphdims_get' );# These routines must be defered%defer_definition = ( 'Pack' => Datatype, 'Pack_size' => Datatype, 'Unpack' => Datatype );# These classes (in the binding name) do not have a compare operation.%class_has_no_compare = ( 'Status' => 1);# These classes do not have a default intialization%class_has_no_default = ( 'Status' => 1 );# If we aren't building separate files, create the master fileif (!$build_sep_files) { $filename = "mpicxx.h"; $OUTFD = OUTFILEHANDLE; open ( $OUTFD, ">$filename" ) || die "Could not open $filename\n"; $files[$#files+1] = $filename; &print_header; print $OUTFD "namespace MPI {\n"; print $OUTFD "#ifdef HAVE_CXX_EXCEPTIONS#define MPIX_CALL( fnc ) \\{int err; err = fnc ; if (err) throw Exception(err);}#else#define MPIX_CALL( fnc ) (void)fnc#endif\n";print $OUTFD "// Typedefs for basic int typestypedef long MPI::Offset;typedef long MPI::Aint;typedef int MPI::Fint;\n";}# Build the routines by classforeach $class (@classes) { $Class = $fullclassname{$class}; $mpi_type = $class_type{$class}; if ($class eq "file" && !$build_io) { next; } if ($build_sep_files) { $filename = "${mpiclass}-cpp.h"; open ( $OUTFD, ">$filename" ) || die "Could not open $filename\n"; $files[$#files+1] = $filename; &print_header; print $OUTFD "namespace MPI {\n"; } else { # Here is where we add (some) of the code to write the # class definition, including the destructor, assignment, # and compare operations. $shortclass = $class; &PrintClassHead( $OUTFD, $Class, $mpi_type, $class_friends{$class} ); } foreach $mpilevel (@mpilevels) { $mpiclass = "$mpilevel$class"; $class_hash = "class_$mpiclass"; foreach $routine (keys(%$class_hash)) { $info = $$class_hash{$routine}; print STDERR "processing $routine\n" if $debug; # Find the corresponding args. Some C++ routines don't use the # natural names, so we check for that here $args = ""; if (defined($mpi_routine{$routine})) { $args = $mpi_routine{$routine}; } $mpi_routine_name = $routine; if ($args eq "") { # Check for an alternate name print STDERR "Checking for $class-$routine\n" if $debug; # Check for $Class_$routine $trial_name = "${Class}_" . lc($routine); print STDERR "Trial = $trial_name\n" if $debug; if (defined($mpi_routine{$trial_name})) { $mpi_routine_name = $trial_name; $args = $mpi_routine{$mpi_routine_name}; } elsif (defined($altname{"$class-$routine"})) { $mpi_routine_name = $altname{"$class-$routine"}; $args = $mpi_routine{$mpi_routine_name}; } else { print STDERR "Name $routine has no known MPI routine\n"; } } # Process info for finding the return value info. &FindReturnInfo( $info, $args ); $real_return_type = $return_type; if ($return_type =~ /MPI_/) { $real_return_type =~ s/MPI_//; } print $OUTFD "${indent}$real_return_type $routine"; # OUTFD, C declaration, C datatype for Class, output info &print_args( $OUTFD, $args, $class_type{$class}, $info ); if (!defined($defer_definition{$routine})) { # Some routines must be defined after another class is # defined. print $OUTFD "${indent}{\n"; # If there is a return type, declare it here $finalcast = ""; if ($return_parm_pos > 0) { if ($return_type =~ /MPI_/) { print $OUTFD "$indent $real_return_type *v$return_parm_pos = new $real_return_type;\n"; $finalcast = "*"; } else { print $OUTFD "$indent $return_type v$return_parm_pos;\n"; } } print $OUTFD "$indent MPIX_CALL( MPI_$mpi_routine_name"; &print_call_args( $OUTFD, $args, $class_type{$class}, $info ); print $OUTFD ");\n"; if ($return_parm_pos > 0) { print $OUTFD "$indent return ${finalcast}v$return_parm_pos;\n"; } print $OUTFD "$indent}\n"; } else { print $OUTFD ";\n"; } } } if ($build_sep_files) { print $OUTFD "} // namespace MPI\n"; close( $OUTFD ); } else { &PrintClassTail( $OUTFD ); }}%short_from_long_class = ( 'Datatype' => 'dtype' );if (!$build_sep_files) { if (0) { # The defered functions are now in the initcpp file. # First, add the deferred definition foreach $routine (keys(%defer_definition)) { $mpiclass = $defer_definition{$routine}; $class = "$short_from_long_class{$mpiclass}"; foreach $mpilevel (@mpilevels) { $mpiclass = "$mpilevel$class"; print STDERR "$mpiclass\n" if $debug; $class_hash = "class_$mpiclass"; $Class = $fullclassname{$class}; $info = $$class_hash{$routine}; $args = $mpi_routine{$routine}; # Process info for finding the return value info. &FindReturnInfo( $info, $args ); # If thies routine isn't a member of this MPI level, # then skip it if ($return_type eq "") { next; } $real_return_type = $return_type; print $OUTFD "$real_return_type $defer_definition{$routine}::$routine"; &print_args( $OUTFD, $args, $defer_definition{$routine}, $info ); print $OUTFD "{\n"; if ($return_parm_pos > 0) { $finalcast = ""; if ($return_type =~ /MPI_/) { print $OUTFD "$indent $real_return_type *v$return_parm_pos = new $real_return_type;\n"; $finalcast = "*"; } else { print $OUTFD "$indent $return_type v$return_parm_pos;\n"; } } print $OUTFD "$indent MPIX_CALL( MPI_$routine"; &print_call_args( $OUTFD, $args, $defer_definition{$routine}, $info ); print $OUTFD ");"; if ($return_parm_pos > 0) { print $OUTFD "$indent return ${finalcast}v$return_parm_pos;\n"; } print $OUTFD "\n}\n"; } }} foreach $dtype (@dtypes) { print $OUTFD "extern Datatype MPI::$dtype;\n"; } print $OUTFD "extern Datatype MPI::TWOINT;\n"; # Initialize the operations foreach $op (@ops) { print $OUTFD "extern const Op MPI::$op;\n"; } # Predefined communicators and groups print $OUTFD "extern Intracomm MPI::COMM_WORLD;\n"; print $OUTFD "extern Intracomm MPI::COMM_SELF;\n"; print $OUTFD "extern const Comm MPI::COMM_NULL;\n"; print $OUTFD "extern const Group MPI::GROUP_EMPTY;\n"; print $OUTFD "extern void Init(void);\n"; print $OUTFD "extern void Finalize(void);\n"; print $OUTFD "} // namespace MPI\n"; close ( $OUTFD );}# Build the special routines&build_specials;## This block can be used to create the Makefile## This isn't quite right. mpicxx.h isn't a regular kind of source file.open ( MAKEFD, ">Makefile.sm" ) || die "Cannot create Makefile.sm";print MAKEFD "# DO NOT EDIT\n# This file created by buildiface $arg_string\n";# This line is unfortunately necessary to ensure that a working# autoconf is used.#print MAKEFD "smvar_autoconf = /home/gropp/bin/linux/autoconf\n";#print MAKEFD "smvar_debug = 1\n";print MAKEFD "smvar_do_dependencies = 0\n";&print_line( MAKEFD, "mpi_sources = ", 80, "\\\n\t", 8 );for ($i=0; $i<=$#files; $i++) { $name = $files[$i]; &print_line( MAKEFD, "$name ", 80, "\\\n\t", 8 );}&print_endline( MAKEFD );# No profile library for C++. All routines call the MPI, not PMPI, routines.print MAKEFD "lib\${MPILIBNAME}_a_SOURCES = \${mpi_sources}\\INCLUDES = -I../../include -I\${top_srcdir}/src/include\maintainerclean-local:\\trm -f \${mpi_sources}\n";close( MAKEFD );## ------------------------------------------------------------------------# Procedures# print_line( FD, line, count, continue, continuelen )# Print line to FD; if line size > count, output continue string and# continue. Use print_endline to finish a linesub print_line { my $FD = $_[0]; my $line = $_[1]; my $count = $_[2]; my $continue = $_[3]; my $continue_len = $_[4]; $linelen = length( $line ); #print "linelen = $linelen, print_line_len = $print_line_len\n"; if ($print_line_len + $linelen > $count) { print $FD $continue; $print_line_len = $continue_len; } print $FD $line; $print_line_len += $linelen;}sub print_endline { my $FD = $_[0]; print $FD "\n"; $print_line_len = 0;}# Print the header of the file, containing the definitions etc.sub print_header { print $OUTFD "/* -*- Mode: C++; c-basic-offset:4 ; -*- */\/* \ * (C) 2001 by Argonne National Laboratory.\ * See COPYRIGHT in top-level directory.\ *\ * This file is automatically generated by buildiface $arg_string\ * DO NOT EDIT\ *//* style: c++ header */\\n";}# Print the arguments for the routine DEFINITION.# TODO : Remove any output parameters. This is stored in info by position # if an integer or type (if a string). If 0, there is no return objectsub print_args { my @parms = split(/\s*,\s*/, $_[1] ); my $OUTFD = $_[0]; my $class_type = $_[2]; # ?? my $info = $_[3]; # Value of <class>_hash{routine)} my $count = 1; my $last_args = ""; my $first = 1; my $args_printed = 0; # Special case: if the only parm is "void", remove it from the list print STDERR "Nparms = $#parms, parms = " . join(',',@parms) . "\n" if $debug; if ($#parms == 0 && $parms[0] eq "void") { $#parms = -1; } # class_pos is the position of the class variable in the argument list. # If specified by parm type, we must find it $class_pos = ""; if ($class_pos eq "") { $class_pos = 1; foreach $parm (@parms) { if ($parm =~ /$class_type/) { last; } $class_pos++; } } # Output the list print $OUTFD "( "; foreach $parm (@parms) { print "parm = :$parm:\n" if $debug; # Match type to replacement if ($count == $class_pos || $count == $return_parm_pos) { # Skip this arg in the definition ; } else { $args_printed ++; if ($first) { $first = 0; } else { print $OUTFD ", "; } if ($parm =~/\[/) { # Argument type is array, so we need to # a) place parameter correctly # Split into raw type and [] $parm =~ /\s*([^\s]*)\s*(\[\s*\])/; $basetype = $1; $foundbrack = $2; print $OUTFD "$basetype v$count\[\]"; } else { # Convert C to C++ types $cxxtype = $parm; if ($cxxtype =~ /MPI_/) { $cxxtype =~ s/\*/\&/; } $cxxtype =~ s/MPI_//; print $OUTFD "${cxxtype} v$count"; } } $count++; } if ($args_printed == 0) { print $OUTFD "void"; } print $OUTFD " )\n";}# Print the arguments for the routine CALL. # Handle the special argumentssub print_call_args { my @parms = split(/\s*,\s*/, $_[1] ); my $OUTFD = $_[0]; my $class_type = $_[2]; # ?? my $info = $_[3]; # Value of <class>_hash{routine)} my $count = 1; my $first = 1; print $OUTFD "( "; # Special case: if the only parm is "void", remove it from the list if ($#parms == 0 && $parms[0] eq "void") { $#parms = -1; } # class_pos is the position of the class variable in the argument list. # If specified by parm type, we must find it $class_pos = ""; if ($class_pos eq "") { $class_pos = 1; foreach $parm (@parms) { if ($parm =~ /$class_type/) { last; } $class_pos++; } } my $lcclass = lc($fullclassname{$class});; my $lctopclass = $lcclass; # For derived classes, we sometimes need to know the name of the # top-most class, particularly for the "the_real_xxx" name. if (defined($mytopclass{$lcclass})) { $lctopclass = $mytopclass{$lcclass}; } foreach $parm (@parms) { if (!$first) { print $OUTFD ", "; } else { $first = 0; } if ($count == $return_parm_pos) { # We may need to pass the address of a temporary object # We'll unilateraly assume this for now # This must be first, so that it has a priority over the # class pos location. if ($parm =~ /MPI_/) { my $lctype = $real_return_type; # Convert class_type to the appropriate name $lctype = lc($lctype); if (defined($mytopclass{$lctype})) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -