mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
09aaf83332
---------------------- ./INSTALL Added warning that enabling debugging code can adversely affect performance even when the debugging isn't turned on at run-time. Performance testing shows that under certain circumstances (like data type conversions of compound types) the H5_timer functions, although only a few lines each, contribute a fairly large percent to the execution time. ./src/H5T.c ./src/H5Tpkg.h ./src/H5Tpublic.h Improved the H5Tunregister() function to make unregistering more flexible. It takes the same arguments as H5Tregister() but also accepts wild cards. All conversion functions that match the H5Tunregister() search criteria are removed from the global type conversion table. The H5Tregister_hard() and H5Tregister_soft() were combined into a single function called H5Tregister() which is the counterpart to H5Tunregister(). A new `persistence' argument was added to differentiate between the two types of conversion functions. The application is allowed to register a hard conversion function for the no-op conversion path although the library isn't obligated to call it (it usually does). This is mostly for completeness, but the application might use it to help determine if the raw data pipeline was able to use the optimized path for the case when no type conversion is necessary. The library doesn't allow this path to be unregistered although the application can redefine it as often as it likes. Fixed the type conversion tables in preparation for MT-safety and to fix previosly-known design bugs wrt. unregistering conversion functions or changing the C function associated with a conversion path. The MT-safety stuff is documented in a separate white paper. Increased the conversion function debugging name from 9 characters to 31 characters so the output can be more descriptive. Moved conversion path statistics from the H5T_cdata_t member into the conversion path itself. This makes H5T_cdata_t contain only application-visible data structures. ./src/H5A.c ./src/H5D.c ./src/H5Ofill.c ./src/H5P.c ./src/H5T.c Improved the way type conversion functions are called so the caller doesn't have to check for data type debugging and increment type conversion timers and statistics. Changed check for no-op conversion since it is now application-definable and there may even be more than one definition at a time in a multi-threaded application (one thread might be using the no-op conversion path when some other thread changes its definition -- the first thread still sees the original defintion until it's done with the operation). ./doc/html/Datatypes.html Updated the user guide to reflect the changes to data type conversion registration functions. ./bin/trace ./src/H5.c Added tracing support for the new H5T_pers_t data type. ./test/dtypes.c Added printf to display alignment value if non-aligned data types are being tested. ./test/h5test.c Modified the H5Tunregister() calls to use the new arguments. All 94 of those calls can be replaced by a single call to the new H5Tunregister() function. ./src/H5.c Added HAVE_GETTIMEOFDAY around an auto variable and initialized the elapsed time to zero when gettimeofday() is not available. ./src/H5F.c ./src/H5Fprivate.h ./src/H5P.c Added an H5*_init() functions which do the same thing as H5*_init_interface() but can be called from other packages and don't do anything if the interface is already initialized. This fixes a couple memory leaks in applications that repeatedly close and open the library with H5close(). ./src/H5Tconv.c Optimized some data alignment code in the hardware conversion functions. Hardware conversions accumulate statistics about source and destination data alignment and print that information when the conversion function is unregistered (usually when the application exits) if data type debugging is compiled into the library and enabled at run-time. The conversion caching was cleaned up for the compound data type conversion function. It now caches conversion paths in a manner that will be MT-safe and is much simpler than the old method. Also cleaned up some array index maps. ./src/H5detect.c Fixd mispelling of alingemnt. ./src/H5private.h Changed `TRUE' to `1' in assignment to interface_initialize_g in FUNC_ENTER macro definition. ./tools/testh5dump.sh Completely rewritten to make it shorter, better documented, and conforming to most of the other test outputs. The comparison of the actual output with the expected output is insensitive to differences in white space. The test now passes for the first time on Linux where the output width wasn't as expected but the output was otherwise correct. ./tools/testfiles/tall-1.ddl ./tools/testfiles/tall-2.ddl ./tools/testfiles/tall-3.ddl ./tools/testfiles/tattr-1.ddl ./tools/testfiles/tattr-2.ddl ./tools/testfiles/tattr-3.ddl ./tools/testfiles/tattr-4.ddl ./tools/testfiles/tcomp-1.ddl ./tools/testfiles/tcomp-2.ddl ./tools/testfiles/tcomp-3.ddl ./tools/testfiles/tcomp-4.ddl ./tools/testfiles/tdset-1.ddl ./tools/testfiles/tdset-2.ddl ./tools/testfiles/tdset-3.ddl ./tools/testfiles/tdset-4.ddl ./tools/testfiles/tgroup-1.ddl ./tools/testfiles/tgroup-2.ddl ./tools/testfiles/tgroup-3.ddl ./tools/testfiles/tlink-1.ddl ./tools/testfiles/tlink-2.ddl ./tools/testfiles/tlink-3.ddl ./tools/testfiles/tlink-4.ddl ./tools/testfiles/tlink-5.ddl ./tools/testfiles/tslink-1.ddl ./tools/testfiles/tslink-2.ddl Changed `../h5dump' to just `h5dump'. ./config/alpha-dec-osf4.0 Added more warning and optimization switches to the native compiler.
245 lines
8.2 KiB
Perl
Executable File
245 lines
8.2 KiB
Perl
Executable File
#!/usr/bin/perl -w
|
|
require 5.003;
|
|
$Source = "";
|
|
|
|
##############################################################################
|
|
# A map from type name to type letter. We use this map for two reasons:
|
|
# 1. We want the debugging stuff in the source code to be as unobtrusive as
|
|
# possible, which means as compact as possible.
|
|
# 2. It's easier (faster) to parse these one and two-letter types in the C
|
|
# functions that display debugging results.
|
|
#
|
|
# All type strings are one or two characters. One-character strings
|
|
# are always lower case and should be used for common types.
|
|
# Two-character strings begin with an upper-case letter which is
|
|
# usually the same as the package name.
|
|
#
|
|
%TypeString = ("hbool_t" => "b",
|
|
"htri_t" => "b",
|
|
"double" => "d",
|
|
"H5D_layout_t" => "Dl",
|
|
"H5D_transfer_t" => "Dt",
|
|
"herr_t" => "e",
|
|
"H5E_direction_t" => "Ed",
|
|
"H5E_error_t*" => "Ee",
|
|
"H5F_driver_t" => "Fd",
|
|
"H5F_scope_t" => "Fs",
|
|
"H5G_link_t" => "Gl",
|
|
"H5G_stat_t*" => "Gs",
|
|
"hsize_t" => "h",
|
|
"hssize_t" => "Hs",
|
|
"hid_t" => "i",
|
|
"int" => "Is",
|
|
"unsigned" => "Iu",
|
|
"unsigned int" => "Iu",
|
|
"H5I_type_t" => "It",
|
|
"MPI_Comm" => "Mc",
|
|
"MPI_Info" => "Mi",
|
|
"off_t" => "o",
|
|
"H5P_class_t" => "p",
|
|
"href_t" => "r",
|
|
"H5R_type_t" => "Rt",
|
|
"char*" => "s",
|
|
"H5S_class_t" => "Sc",
|
|
"H5S_seloper_t" => "Ss",
|
|
"H5T_cset_t", => "Tc",
|
|
"H5T_norm_t" => "Tn",
|
|
"H5T_order_t" => "To",
|
|
"H5T_pad_t" => "Tp",
|
|
"H5T_pers_t" => "Te",
|
|
"H5T_sign_t" => "Ts",
|
|
"H5T_class_t" => "Tt",
|
|
"H5T_str_t" => "Tz",
|
|
"void*" => "x",
|
|
"FILE*" => "x",
|
|
"H5A_operator_t" => "x",
|
|
"H5E_auto_t" => "x",
|
|
"H5E_walk_t" => "x",
|
|
"H5G_iterate_t" => "x",
|
|
"H5T_cdata_t**" => "x",
|
|
"H5T_conv_t" => "x",
|
|
"H5T_overflow_t" => "x",
|
|
"H5Z_func_t" => "x",
|
|
"size_t" => "z",
|
|
"H5Z_filter_t" => "Zf",
|
|
"ssize_t" => "Zs",
|
|
);
|
|
|
|
##############################################################################
|
|
# Print an error message.
|
|
#
|
|
sub errmesg ($$@) {
|
|
my ($file, $func, @mesg) = @_;
|
|
my ($mesg) = join "", @mesg;
|
|
my ($lineno) = 1;
|
|
if ($Source =~ /(.*?\n)($func)/s) {
|
|
local $_ = $1;
|
|
$lineno = tr/\n/\n/;
|
|
}
|
|
|
|
print "$file: in function \`$func\':\n";
|
|
print "$file:$lineno: $mesg\n";
|
|
}
|
|
|
|
##############################################################################
|
|
# Given a C data type return the type string that goes with it.
|
|
#
|
|
sub argstring ($$$) {
|
|
my ($file, $func, $atype) = @_;
|
|
my ($ptr, $tstr, $array) = (0, "!", "");
|
|
my ($fq_atype);
|
|
|
|
# Normalize the data type by removing redundant white space,
|
|
# certain type qualifiers, and indirection.
|
|
$atype =~ s/^\bconst\b//;
|
|
$atype =~ s/\b__unused__\b//g;
|
|
$atype =~ s/\s+/ /g;
|
|
$ptr = length $1 if $atype =~ s/(\*+)//;
|
|
$atype =~ s/^\s+//;
|
|
$atype =~ s/\s+$//;
|
|
if ($atype =~ /(.*)\[(.*)\]$/) {
|
|
($array, $atype) = ($2, $1);
|
|
$atype =~ s/\s+$//;
|
|
}
|
|
$fq_atype = $atype . ('*' x $ptr);
|
|
|
|
if ($ptr>0 && exists $TypeString{$fq_atype}) {
|
|
$ptr = 0;
|
|
$tstr = $TypeString{$fq_atype};
|
|
} elsif ($ptr>0 && exists $TypeString{"$atype*"}) {
|
|
--$ptr;
|
|
$tstr = $TypeString{"$atype*"};
|
|
} elsif (!exists $TypeString{$atype}) {
|
|
errmesg $file, $func, "unknown type \`$atype", '*'x$ptr, "\'";
|
|
} else {
|
|
$tstr = $TypeString{$atype};
|
|
}
|
|
return ("*" x $ptr) . ($array?"[$array]":"") . $tstr;
|
|
}
|
|
|
|
##############################################################################
|
|
# Given information about an API function, rewrite that function with
|
|
# updated tracing information.
|
|
#
|
|
sub rewrite_func ($$$$$) {
|
|
my ($file, $type, $name, $args, $body) = @_;
|
|
my ($arg,$trace);
|
|
my (@arg_name, @arg_str);
|
|
local $_;
|
|
|
|
# Parse return value
|
|
my $rettype = argstring $file, $name, $type;
|
|
goto error if $rettype =~ /!/;
|
|
|
|
# Parse arguments
|
|
if ($args eq "void") {
|
|
$trace = "H5TRACE0(\"$rettype\",\"\");\n";
|
|
} else {
|
|
# Split arguments. First convert `/*in,out*/' to get rid of the
|
|
# comma, then split the arguments on commas.
|
|
$args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g;
|
|
my @args = split /,[\s\n]*/, $args;
|
|
my $argno = 0;
|
|
my %names;
|
|
|
|
for $arg (@args) {
|
|
unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**)
|
|
([a-z_A-Z]\w*)(\[.*?\])?
|
|
(\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) {
|
|
errmesg $file, $name, "unable to parse \`$arg\'";
|
|
goto error;
|
|
} else {
|
|
my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6);
|
|
$names{$aname} = $argno++;
|
|
$adir ||= "in";
|
|
$atype =~ s/\s+$//;
|
|
push @arg_name, $aname;
|
|
|
|
if ($adir eq "out") {
|
|
push @arg_str, "x";
|
|
} else {
|
|
if (defined $array) {
|
|
$atype .= "*";
|
|
if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) {
|
|
my $asize = $1;
|
|
if (exists $names{$asize}) {
|
|
$atype .= '[a' . $names{$asize} . ']';
|
|
} else {
|
|
warn "bad array size: $asize";
|
|
$atype .= "*";
|
|
}
|
|
}
|
|
}
|
|
push @arg_str, argstring $file, $name, $atype;
|
|
}
|
|
}
|
|
}
|
|
$trace = "H5TRACE" . scalar(@arg_str) . "(\"$rettype\",\"";
|
|
$trace .= join("", @arg_str) . "\"";
|
|
my $len = 4 + length $trace;
|
|
for (@arg_name) {
|
|
if ($len + length >= 77) {
|
|
$trace .= ",\n $_";
|
|
$len = 13 + length;
|
|
} else {
|
|
$trace .= ",$_";
|
|
$len += 1 + length;
|
|
}
|
|
}
|
|
$trace .= ");\n";
|
|
}
|
|
goto error if grep {/!/} @arg_str;
|
|
|
|
# The H5TRACE() statement
|
|
if ($body =~ /\/\*[ \t]*NO[ \t]*TRACE[ \t]*\*\//) {
|
|
if ($body =~ /\s*H5TRACE\d+\s*\(/) {
|
|
errmesg $file, $name, "warning: trace info was not updated";
|
|
} else {
|
|
errmesg $file, $name, "warning: trace info was not inserted";
|
|
}
|
|
} elsif ($body =~ s/((\n[ \t]*)H5TRACE\d+\s*\(.*?\);)\n/"$2$trace"/es) {
|
|
# Replaced an H5TRACE macro
|
|
} elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\s*\(.*?\);)\n/"$1$2$trace"/es) {
|
|
# Added an H5TRACE macro after a FUNC_ENTER macro.
|
|
} else {
|
|
errmesg $file, $name, "unable to insert tracing information";
|
|
print "body=\n>>>>>", $body, "<<<<<\n";
|
|
goto error;
|
|
}
|
|
|
|
|
|
error:
|
|
return "\n$type\n$name($args)\n$body";
|
|
}
|
|
|
|
##############################################################################
|
|
# Process each source file, rewriting API functions with updated
|
|
# tracing information.
|
|
#
|
|
my $total_api = 0;
|
|
for $file (@ARGV) {
|
|
# Snarf up the entire file
|
|
open SOURCE, $file or die "$file: $!\n";
|
|
$Source = join "", <SOURCE>;
|
|
close SOURCE;
|
|
|
|
# Make modifications
|
|
my $original = $Source;
|
|
my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[a-z]\w*)*)\s*\n #type
|
|
(H5[A-Z]{1,2}[^_A-Z]\w*) #name
|
|
\s*\((.*?)\)\s* #args
|
|
(\{.*?\n\}[^\n]*) #body
|
|
/rewrite_func($file,$1,$3,$4,$5)/segx;
|
|
$total_api += $napi;
|
|
|
|
# If the source changed then print out the new version
|
|
if ($original ne $Source) {
|
|
printf "%s: instrumented %d API function%s\n",
|
|
$file, $napi, 1==$napi?"":"s";
|
|
rename $file, "$file~" or die "unable to make backup";
|
|
open SOURCE, ">$file" or die "unable to modify source";
|
|
print SOURCE $Source;
|
|
close SOURCE;
|
|
}
|
|
}
|