summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--btl/COPYING340
-rw-r--r--btl/README3
-rw-r--r--btl/accuracy/lapack/diff.hh47
-rw-r--r--btl/accuracy/lapack/lapack_LU.hh74
-rw-r--r--btl/accuracy/lapack/lapack_QR.hh74
-rw-r--r--btl/accuracy/lapack/lapack_STEV.hh52
-rw-r--r--btl/accuracy/lapack/lapack_SVD.hh57
-rw-r--r--btl/accuracy/lapack/lapack_SYEV.hh60
-rw-r--r--btl/accuracy/lapack/lapack_cholesky.hh54
-rw-r--r--btl/accuracy/lapack/main_lapack.cpp120
-rw-r--r--btl/accuracy/lapack/timer.hh67
-rw-r--r--btl/accuracy/main_blas.cpp253
-rw-r--r--btl/accuracy/sizes.hh59
-rw-r--r--btl/actions/action_aat_product.hh145
-rw-r--r--btl/actions/action_ata_product.hh145
-rw-r--r--btl/actions/action_atv_product.hh134
-rw-r--r--btl/actions/action_axpby.hh127
-rw-r--r--btl/actions/action_axpy.hh139
-rw-r--r--btl/actions/action_cholesky.hh129
-rw-r--r--btl/actions/action_fftw_1d.hh128
-rw-r--r--btl/actions/action_fftw_2d.hh128
-rw-r--r--btl/actions/action_fftw_3d.hh129
-rw-r--r--btl/actions/action_general_solve.hh137
-rw-r--r--btl/actions/action_ger.hh128
-rw-r--r--btl/actions/action_hessenberg.hh233
-rw-r--r--btl/actions/action_least_squares.hh137
-rw-r--r--btl/actions/action_lu_decomp.hh109
-rw-r--r--btl/actions/action_lu_solve.hh136
-rw-r--r--btl/actions/action_matrix_matrix_product.hh150
-rw-r--r--btl/actions/action_matrix_matrix_product_bis.hh152
-rw-r--r--btl/actions/action_matrix_vector_product.hh153
-rw-r--r--btl/actions/action_parallel_axpy.hh158
-rw-r--r--btl/actions/action_parallel_cholesky.hh130
-rw-r--r--btl/actions/action_parallel_lu_decomp.hh142
-rw-r--r--btl/actions/action_parallel_matrix_vector_product.hh159
-rw-r--r--btl/actions/action_parallel_qr_decomp.hh116
-rw-r--r--btl/actions/action_parallel_svd_decomp.hh151
-rw-r--r--btl/actions/action_parallel_symm_ev.hh138
-rw-r--r--btl/actions/action_partial_lu.hh125
-rw-r--r--btl/actions/action_qr_decomp.hh112
-rw-r--r--btl/actions/action_rot.hh116
-rw-r--r--btl/actions/action_stev.hh119
-rw-r--r--btl/actions/action_svd_decomp.hh115
-rw-r--r--btl/actions/action_syev.hh113
-rw-r--r--btl/actions/action_symm_ev.hh104
-rw-r--r--btl/actions/action_symv.hh139
-rw-r--r--btl/actions/action_syr2.hh133
-rw-r--r--btl/actions/action_trisolve.hh137
-rw-r--r--btl/actions/action_trisolve_matrix.hh165
-rw-r--r--btl/actions/action_trmm.hh165
-rw-r--r--btl/actions/base_action_fftw.hh86
-rw-r--r--btl/actions/basic_actions.hh21
-rw-r--r--btl/actions/fftw_actions.hh26
-rw-r--r--btl/data/action_settings.txt18
-rw-r--r--btl/data/gnuplot_common_settings.hh87
-rwxr-xr-xbtl/data/go_mean57
-rw-r--r--btl/data/mean.cxx182
-rw-r--r--btl/data/mk_gnuplot_script.sh68
-rw-r--r--btl/data/mk_mean_script.sh52
-rwxr-xr-xbtl/data/mk_new_gnuplot.sh54
-rw-r--r--btl/data/perlib_plot_settings.txt16
-rw-r--r--btl/data/regularize.cxx131
-rw-r--r--btl/data/smooth.cxx198
-rwxr-xr-xbtl/data/smooth_all.sh68
-rw-r--r--btl/generic_bench/bench.hh103
-rw-r--r--btl/generic_bench/bench_parameter.hh53
-rw-r--r--btl/generic_bench/btl.hh247
-rw-r--r--btl/generic_bench/init/init_function.hh54
-rw-r--r--btl/generic_bench/init/init_matrix.hh93
-rw-r--r--btl/generic_bench/init/init_vector.hh37
-rw-r--r--btl/generic_bench/static/bench_static.hh80
-rw-r--r--btl/generic_bench/static/intel_bench_fixed_size.hh66
-rw-r--r--btl/generic_bench/static/static_size_generator.hh57
-rw-r--r--btl/generic_bench/timers/STL_perf_analyzer.hh82
-rw-r--r--btl/generic_bench/timers/STL_timer.hh78
-rw-r--r--btl/generic_bench/timers/distributed_perf_analyzer_node.hh95
-rw-r--r--btl/generic_bench/timers/distributed_perf_analyzer_root.hh116
-rw-r--r--btl/generic_bench/timers/mixed_perf_analyzer.hh73
-rw-r--r--btl/generic_bench/timers/portable_perf_analyzer.hh110
-rw-r--r--btl/generic_bench/timers/portable_perf_analyzer_old.hh134
-rwxr-xr-xbtl/generic_bench/timers/portable_timer.hh145
-rw-r--r--btl/generic_bench/timers/x86_perf_analyzer.hh108
-rw-r--r--btl/generic_bench/timers/x86_timer.hh246
-rw-r--r--btl/generic_bench/utils/LinearCongruential.hh83
-rw-r--r--btl/generic_bench/utils/size_lin_log.hh70
-rw-r--r--btl/generic_bench/utils/size_log.hh54
-rw-r--r--btl/generic_bench/utils/utilities.h90
-rw-r--r--btl/generic_bench/utils/xy_file.hh75
-rw-r--r--btl/libs/BLACS/blacs.h50
-rw-r--r--btl/libs/BLACS/blacs_interface.hh153
-rw-r--r--btl/libs/BLACS/blacsinit.hh38
-rw-r--r--btl/libs/BLACS/gather.h49
-rw-r--r--btl/libs/BLACS/gather_impl.h126
-rw-r--r--btl/libs/BLACS/scatter.h61
-rw-r--r--btl/libs/BLACS/scatter_impl.h121
-rw-r--r--btl/libs/BLAS/CMakeLists.txt60
-rw-r--r--btl/libs/BLAS/blas.h681
-rw-r--r--btl/libs/BLAS/blas_interface.hh77
-rw-r--r--btl/libs/BLAS/blas_interface_impl.hh96
-rw-r--r--btl/libs/BLAS/c_interface_base.h89
-rw-r--r--btl/libs/BLAS/cblas_interface_impl.hh96
-rw-r--r--btl/libs/BLAS/main.cpp116
-rw-r--r--btl/libs/FFTW/fftw_interface.hh87
-rw-r--r--btl/libs/FFTW/main.cpp107
-rw-r--r--btl/libs/LAPACK/lapack.hh33
-rw-r--r--btl/libs/LAPACK/lapack_.hh38
-rw-r--r--btl/libs/LAPACK/lapack_interface.hh78
-rw-r--r--btl/libs/LAPACK/lapack_interface_impl.hh139
-rw-r--r--btl/libs/LAPACK/main.cpp95
-rw-r--r--btl/libs/PBLAS/main.cpp103
-rw-r--r--btl/libs/PBLAS/pblas.h106
-rw-r--r--btl/libs/PBLAS/pblas_interface.hh57
-rw-r--r--btl/libs/PBLAS/pblas_interface_impl.hh246
-rw-r--r--btl/libs/STL/CMakeLists.txt2
-rw-r--r--btl/libs/STL/STL_interface.hh255
-rw-r--r--btl/libs/STL/main.cpp42
-rw-r--r--numbench/benchconfig.py2
-rw-r--r--setup.py22
118 files changed, 12971 insertions, 3 deletions
diff --git a/btl/COPYING b/btl/COPYING
new file mode 100644
index 0000000..486449c
--- /dev/null
+++ b/btl/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/btl/README b/btl/README
new file mode 100644
index 0000000..90db5b4
--- /dev/null
+++ b/btl/README
@@ -0,0 +1,3 @@
+This project contains a modified copy of the Bench Template Library. It has
+been adapted in order to fit the needs of the project in which it has been used
+and is in a "work in progress" state. \ No newline at end of file
diff --git a/btl/accuracy/lapack/diff.hh b/btl/accuracy/lapack/diff.hh
new file mode 100644
index 0000000..6679655
--- /dev/null
+++ b/btl/accuracy/lapack/diff.hh
@@ -0,0 +1,47 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef DIFF_HH
+#define DIFF_HH
+
+#include <vector>
+
+double diff(const int& N, const double* x, const double* test)
+{
+ std::vector<double> d(x, x+N);
+ const int iONE = 1;
+ const double alpha = -1.;
+ daxpy_(&N, &alpha, test, &iONE, &d[0], &iONE);
+ return dnrm2_(&N, &d[0], &iONE)/dnrm2_(&N, x, &iONE);
+}
+
+template<typename T>
+T diff(const std::vector<T> x, const std::vector<T> test)
+{
+ return diff(static_cast<const int&>(x.size()), &x[0], &test[0]);
+}
+
+//float diff(const int& N, const float* x, const float* test)
+//{
+// std::vector<float> d(x, x+N);
+// const int iONE = 1;
+// const float alpha = -1.;
+// saxpy_(&N, &alpha, test, &iONE, &d[0], &iONE);
+// return snrm2_(&N, &d[0], &iONE)/snrm2_(&N, x, &iONE);
+//}
+
+#endif /* DIFF_HH */
diff --git a/btl/accuracy/lapack/lapack_LU.hh b/btl/accuracy/lapack/lapack_LU.hh
new file mode 100644
index 0000000..686a97f
--- /dev/null
+++ b/btl/accuracy/lapack/lapack_LU.hh
@@ -0,0 +1,74 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_LU_HH
+#define LAPACK_LU_HH
+
+#include "LinearCongruential.hh"
+#include "diff.hh"
+
+vector<int> get_piv(const vector<int>& ipiv)
+{
+ const int size = ipiv.size();
+ vector<int> ret(size);
+ for (int i = 0; i < size; ++i)
+ ret[i] = i;
+
+ int ii, jj, tmp;
+ for (int i = 1; i <= size; ++i) {
+ ii = i-1;
+ jj = ipiv[ii]-1;
+ tmp = ret[ii];
+ ret[ii] = ret[jj];
+ ret[jj] = tmp;
+ }
+
+ return ret;
+}
+
+double test_LU(const int& N, const unsigned& seed = 0)
+{
+ LinearCongruential lc(seed);
+
+ vector<double> A(N*N), Acopy, P(N*N);
+
+ /* Fill A and Acopy */
+ for (int i = 0; i < N*N; ++i)
+ A[i] = lc.get_01();
+ Acopy = A;
+
+ /* Compute decomposition */
+ vector<int> ipiv(N);
+ int info;
+ dgetrf_(&N, &N, &A[0], &N, &ipiv[0], &info);
+ vector<int> piv = get_piv(ipiv);
+
+ /* Construct P */
+ for (int r = 0; r < N; ++r) {
+ int c = piv[r];
+ P[c+N*r] = 1;
+ }
+
+ /* Test */
+ const double alpha = 1.;
+ dtrmm_("R", "L", "N", "U", &N, &N, &alpha, &A[0], &N, &P[0], &N);
+ dtrmm_("R", "U", "N", "N", &N, &N, &alpha, &A[0], &N, &P[0], &N);
+
+ return diff(Acopy, P);
+}
+
+#endif /* LAPACK_LU_HH */
diff --git a/btl/accuracy/lapack/lapack_QR.hh b/btl/accuracy/lapack/lapack_QR.hh
new file mode 100644
index 0000000..8b9ba82
--- /dev/null
+++ b/btl/accuracy/lapack/lapack_QR.hh
@@ -0,0 +1,74 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_QR_HH
+#define LAPACK_QR_HH
+
+#include "LinearCongruential.hh"
+#include "diff.hh"
+
+double test_QR(const int& N, const unsigned& seed = 0)
+{
+ LinearCongruential lc(seed);
+ vector<double> A(N*N), Acopy, tau(N), work(1), Q(N*N), H(N*N), tmp;
+
+ /* Fill A and Acopy */
+ for (int i = 0; i < N*N; ++i)
+ A[i] = lc.get_01();
+ Acopy = A;
+
+ /* Retrieve lwork */
+ int lwork = -1, info;
+ dgeqrf_(&N, &N, &A[0], &N, &tau[0], &work[0], &lwork, &info);
+ lwork = work[0];
+ work.resize(lwork);
+
+ /* Compute decomposition */
+ dgeqrf_(&N, &N, &A[0], &N, &tau[0], &work[0], &lwork, &info);
+
+ /* Compute Q */
+ for (int i = 0; i < N; ++i)
+ Q[i+i*N] = 1.;
+
+ double alpha, t;
+ const double dZERO = 0., dONE = 1.;
+ const int iONE = 1, N2 = N*N;
+ work.resize(N2);
+ for (int i = 0; i < N; ++i) {
+ /* Generate H_i */
+ for (int r = 0; r < N; ++r)
+ for (int c = r; c < N; ++c)
+ H[r+c*N] = (r == c);
+ dcopy_(&N, &A[i*N], &iONE, &work[0], &iONE);
+ for (int j = 0; j < i; ++j)
+ work[j] = 0.;
+ work[i] = 1.;
+ t = -tau[i];
+ dsyr_("U", &N, &t, &work[0], &iONE, &H[0], &N);
+
+ /* Multiply Q = Q*H_i */
+ dsymm_("R", "U", &N, &N, &dONE, &H[0], &N, &Q[0], &N, &dZERO, &work[0], &N);
+ dcopy_(&N2, &work[0], &iONE, &Q[0], &iONE);
+ }
+
+ /* Multiply */
+ dtrmm_("R", "U", "N", "N", &N, &N, &dONE, &A[0], &N, &Q[0], &N);
+
+ return diff(Acopy, Q);
+}
+
+#endif /* LAPACK_QR_HH */
diff --git a/btl/accuracy/lapack/lapack_STEV.hh b/btl/accuracy/lapack/lapack_STEV.hh
new file mode 100644
index 0000000..3fc9147
--- /dev/null
+++ b/btl/accuracy/lapack/lapack_STEV.hh
@@ -0,0 +1,52 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_STEV_HH
+#define LAPACK_STEV_HH
+
+#include "LinearCongruential.hh"
+#include "diff.hh"
+
+double test_STEV(const int& N, const unsigned& seed = 0)
+{
+ LinearCongruential lc(seed);
+ vector<double> A(N*N), D(N), E(N-1), Z(N*N), DD(N*N), work(max(1, 2*N-2)), tmp(N*N);
+
+ /* Fill D, E and A */
+ for (int i = 0; i < N-1; ++i) {
+ D[i] = lc.get_01(); A[i+i*N] = D[i];
+ E[i] = lc.get_01(); A[(i+1)+i*N] = E[i]; A[i+(i+1)*N] = E[i];
+ }
+ D[N-1] = lc.get_01(); A[N*N-1] = D[N-1];
+
+ /* Perform computation */
+ int info;
+ dstev_("V", &N, &D[0], &E[0], &Z[0], &N, &work[0], &info);
+
+ /* Construct DD */
+ for (int i = 0; i < N; ++i)
+ DD[i+i*N] = D[i];
+
+ /* A = V*D*V' */
+ const double dONE = 1., dZERO = 0.;
+ dgemm_("N", "N", &N, &N, &N, &dONE, &Z[0], &N, &DD[0], &N, &dZERO, &tmp[0], &N);
+ dgemm_("N", "T", &N, &N, &N, &dONE, &tmp[0], &N, &Z[0], &N, &dZERO, &DD[0], &N);
+
+ return diff(A, DD);
+}
+
+#endif /* LAPACK_STEV_HH */
diff --git a/btl/accuracy/lapack/lapack_SVD.hh b/btl/accuracy/lapack/lapack_SVD.hh
new file mode 100644
index 0000000..7dc2ab1
--- /dev/null
+++ b/btl/accuracy/lapack/lapack_SVD.hh
@@ -0,0 +1,57 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_SVD_HH
+#define LAPACK_SVD_HH
+
+#include "LinearCongruential.hh"
+#include "diff.hh"
+
+double test_SVD(const int& N, const unsigned& seed = 0)
+{
+ LinearCongruential lc(seed);
+
+ vector<double> A(N*N), Acopy, U(N*N), VT(N*N), S_(N), S(N*N);
+ vector<double> work(1);
+
+ /* Fill A and Acopy */
+ for (int i = 0; i < N*N; ++i)
+ A[i] = lc.get_01();
+ Acopy = A;
+
+ /* Retrieve lwork */
+ int lwork = -1, info;
+ dgesvd_("A", "A", &N, &N, &A[0], &N, &S_[0], &U[0], &N, &VT[0], &N, &work[0], &lwork, &info);
+ lwork = work[0];
+ work.resize(lwork);
+
+ /* Compute decomposition */
+ dgesvd_("A", "A", &N, &N, &A[0], &N, &S_[0], &U[0], &N, &VT[0], &N, &work[0], &lwork, &info);
+
+ /* Construct S */
+ for (int r = 0; r < N; ++r)
+ S[r+r*N] = S_[r];
+
+ /* Test */
+ const double dONE = 1., dZERO = 0.;
+ dgemm_("N", "N", &N, &N, &N, &dONE, &U[0], &N, &S[0], &N, &dZERO, &A[0], &N);
+ dgemm_("N", "N", &N, &N, &N, &dONE, &A[0], &N, &VT[0], &N, &dZERO, &S[0], &N);
+
+ return diff(Acopy, S);
+}
+
+#endif /* LAPACK_SVD_HH */
diff --git a/btl/accuracy/lapack/lapack_SYEV.hh b/btl/accuracy/lapack/lapack_SYEV.hh
new file mode 100644
index 0000000..dc6b733
--- /dev/null
+++ b/btl/accuracy/lapack/lapack_SYEV.hh
@@ -0,0 +1,60 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_SYEV_HH
+#define LAPACK_SYEV_HH
+
+#include "LinearCongruential.hh"
+#include "diff.hh"
+
+double test_SYEV(const int& N, const unsigned& seed = 0)
+{
+ LinearCongruential lc(seed);
+ vector<double> A(N*N), Acopy, W(N), D(N*N), work(1), tmp(N*N);
+
+ /* Fill A (symmetric) and Acopy */
+ for (int r = 0; r < N; ++r) {
+ A[r+r*N] = lc.get_01();
+ for (int c = r+1; c < N; ++c) {
+ A[r+c*N] = lc.get_01();
+ A[c+r*N] = A[r+c*N];
+ }
+ }
+ Acopy = A;
+
+ /* Retrieve lwork */
+ int lwork = -1, info;
+ dsyev_("V", "U", &N, &A[0], &N, &W[0], &work[0], &lwork, &info);
+ lwork = work[0];
+ work.resize(lwork);
+
+ /* Perform computation */
+ dsyev_("V", "U", &N, &A[0], &N, &W[0], &work[0], &lwork, &info);
+
+ /* Construct D */
+ for (int i = 0; i < N; ++i)
+ D[i+i*N] = W[i];
+
+ /* A = V*D*V' */
+ const double dONE = 1., dZERO = 0.;
+ dgemm_("N", "N", &N, &N, &N, &dONE, &A[0], &N, &D[0], &N, &dZERO, &tmp[0], &N);
+ dgemm_("N", "T", &N, &N, &N, &dONE, &tmp[0], &N, &A[0], &N, &dZERO, &D[0], &N);
+
+ return diff(Acopy, D);
+}
+
+#endif /* LAPACK_SYEV_HH */
diff --git a/btl/accuracy/lapack/lapack_cholesky.hh b/btl/accuracy/lapack/lapack_cholesky.hh
new file mode 100644
index 0000000..c398c0a
--- /dev/null
+++ b/btl/accuracy/lapack/lapack_cholesky.hh
@@ -0,0 +1,54 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_CHOLESKY_HH
+#define LAPACK_CHOLESKY_HH
+
+#include "LinearCongruential.hh"
+#include "diff.hh"
+
+double test_cholesky(const int& N, const unsigned& seed = 0)
+{
+ LinearCongruential lc(seed);
+
+ vector<double> A(N*N), Acopy, test(N*N);
+
+ /* Fill A (SPD), Acopy and test (identity) */
+ for (int r = 0; r < N; ++r) {
+ A[r+r*N] = N;
+ test[r+r*N] = 1.;
+ for (int c = r; c < N; ++c) {
+ A[r+c*N] += lc.get_01();
+ A[c+r*N] = A[r+c*N];
+ }
+ }
+ Acopy = A;
+
+ /* Compute decomposition */
+ int info;
+ dpotrf_("L", &N, &A[0], &N, &info);
+
+ /* Test */
+ const double alpha = 1.;
+ dtrmm_("L", "L", "N", "N", &N, &N, &alpha, &A[0], &N, &test[0], &N);
+ dtrmm_("R", "L", "T", "N", &N, &N, &alpha, &A[0], &N, &test[0], &N);
+
+ return diff(Acopy, test);
+
+}
+
+#endif /* LAPACK_CHOLESKY_HH */
diff --git a/btl/accuracy/lapack/main_lapack.cpp b/btl/accuracy/lapack/main_lapack.cpp
new file mode 100644
index 0000000..bd5db21
--- /dev/null
+++ b/btl/accuracy/lapack/main_lapack.cpp
@@ -0,0 +1,120 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "lapack.hh"
+#include "LinearCongruential.hh"
+#include "timer.hh"
+#include "sizes.hh"
+
+#include <iostream>
+#include <iomanip>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <string>
+
+using namespace std;
+
+extern "C" {
+ void daxpy_(const int*, const double*, const double*, const int*, double*, const int*);
+ void dcopy_(const int*, const double*, const int*, double*, const int*);
+ double dnrm2_(const int*, const double*, const int*);
+ void dsyr_(const char*, const int*, const double*, const double*, const int*, double*, const int*);
+ void dger_(const int*, const int*, const double*, const double*, const int*, const double*, const int*, double*, const int*);
+ void dgemm_(const char*, const char*, const int*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
+ void dsymm_(const char*, const char*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
+ void dtrmm_(const char*, const char*, const char*, const char*, const int*, const int*, const double*, const double*, const int*, double*, const int*);
+}
+#include "lapack_LU.hh"
+#include "lapack_cholesky.hh"
+#include "lapack_SVD.hh"
+#include "lapack_QR.hh"
+#include "lapack_SYEV.hh"
+#include "lapack_STEV.hh"
+
+template<typename exec_t>
+void test(exec_t exec, const std::string& testname, const int& max = 3000, const int& N = 100)
+{
+ vector<int> sizes = logsizes(1, max, N);
+ Timer timer;
+
+ ostringstream fname;
+ fname << "accuracy_" << testname << "_lapack.dat";
+ cout << "Testing " << testname << " --> " << fname.str() << endl;
+ ofstream fs(fname.str().c_str());
+
+ for (vector<int>::const_iterator i = sizes.begin(), end = sizes.end(); i != end; ++i) {
+ const int size = *i;
+ double error = 0;
+ timer.start();
+ int times = 0;
+ do
+ error += exec(size, times++);
+ while (timer.elapsed() < 1. || times < 16);
+ cout << " size: " << setw(4) << right << size;
+ cout << setw(15) << right << error/times << " ";
+ cout << "[" << setw(6) << times << " samples] ";
+ cout << "(" << setw(3) << right << (i-sizes.begin()+1) << "/" << N << ")" << endl;
+ fs << size << " " << error/times << "\n";
+ }
+
+ fs.close();
+}
+
+int main(int argc, char **argv)
+{
+ bool
+ lu_decomp=false, cholesky = false, svd_decomp=false, qr_decomp=false,
+ syev=false, stev=false
+ ;
+
+ for (int i = 1; i < argc; ++i) {
+ std::string arg = argv[i];
+ if (arg == "lu_decomp") lu_decomp = true;
+ else if (arg == "cholesky") cholesky = true;
+ else if (arg == "svd_decomp") svd_decomp = true;
+ else if (arg == "qr_decomp") qr_decomp = true;
+ else if (arg == "syev") syev = true;
+ else if (arg == "stev") stev = true;
+ }
+
+ if (lu_decomp) {
+ test(test_LU, "lu_decomp", 3000, 100);
+ }
+
+ if (cholesky) {
+ test(test_cholesky, "cholesky", 3000, 100);
+ }
+
+ if (svd_decomp) {
+ test(test_SVD, "svd_decomp", 1000, 90);
+ }
+
+ if (qr_decomp) {
+ test(test_QR, "qr_decomp", 500, 70);
+ }
+
+ if (syev) {
+ test(test_SYEV, "syev", 1000, 90);
+ }
+
+ if (stev) {
+ test(test_STEV, "stev", 1000, 90);
+ }
+
+ return 0;
+}
diff --git a/btl/accuracy/lapack/timer.hh b/btl/accuracy/lapack/timer.hh
new file mode 100644
index 0000000..82a0767
--- /dev/null
+++ b/btl/accuracy/lapack/timer.hh
@@ -0,0 +1,67 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef TIMER_HH
+#define TIMER_HH
+
+#include <sys/time.h>
+
+class Timer
+{
+public:
+ Timer() : ZERO(0.)
+ { }
+
+ void start()
+ {
+ t = walltime(&ZERO);
+ }
+
+ double elapsed()
+ {
+ return walltime(&t);
+ }
+
+private:
+ double t;
+
+ const double ZERO;
+
+ static double walltime(const double *t0)
+ {
+ double mic;
+ double time;
+ double mega = 0.000001;
+ struct timeval tp;
+ struct timezone tzp;
+ static long base_sec = 0;
+ static long base_usec = 0;
+
+ (void) gettimeofday(&tp, &tzp);
+ if (base_sec == 0) {
+ base_sec = tp.tv_sec;
+ base_usec = tp.tv_usec;
+ }
+
+ time = (double) (tp.tv_sec - base_sec);
+ mic = (double) (tp.tv_usec - base_usec);
+ time = (time + mic * mega) - *t0;
+ return (time);
+ }
+};
+
+#endif /* TIMER_HH */
diff --git a/btl/accuracy/main_blas.cpp b/btl/accuracy/main_blas.cpp
new file mode 100644
index 0000000..aceae58
--- /dev/null
+++ b/btl/accuracy/main_blas.cpp
@@ -0,0 +1,253 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <cmath>
+#include <cstdlib>
+
+#define ADD_
+extern "C" {
+ void daxpy_(const int*, const double*, const double*, const int*, double*, const int*);
+ void dgemv_(const char*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
+ void dtrsv_(const char*, const char*, const char*, const int*, const double*, const int*, double*, const int*);
+ void dgemm_(const char*, const char*, const int*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
+ double dnrm2_(const int*, const double*, const int*);
+}
+
+using namespace std;
+
+template<typename T>
+void print_array(const int& N, const T* array) {
+ for (const T *p = array, *e = array+N; p != e; ++p)
+ cout << *p << " ";
+}
+
+template<typename T>
+void print_matrix(const int& rows, const int& cols, const T* matrix) {
+ for (int row = 0; row < rows; ++row) {
+ for (int col = 0; col < cols; ++col)
+ cout << *(matrix + rows*col + row) << " ";
+ cout << "\n";
+ }
+}
+
+template<typename T>
+vector<T> logspace(const T& min, const T& max, const unsigned& N)
+{
+ vector<T> result;
+ result.reserve(N);
+
+ const double emin = log(static_cast<double>(min)), emax = log(static_cast<double>(max));
+ double e, r = (emax-emin)/(N-1);
+ for (unsigned i = 0; i < N; ++i) {
+ e = emin + i*r;
+ result.push_back(static_cast<T>(exp(e)));
+ }
+
+ return result;
+}
+
+template<typename T>
+vector<T> logsizes(const T& min, const T& max, const unsigned& N)
+{
+ if (N <= 10)
+ return logspace(min, max, N);
+
+ vector<T> result;
+ result.reserve(N);
+
+ for (unsigned i = 0; i < 9; ++i)
+ result.push_back(i+1);
+ vector<T> lres = logspace(10, max, N-9);
+ for (unsigned i = 9; i < N; ++i)
+ result.push_back(lres[i-9]);
+
+ return result;
+}
+
+double axpy_test(const int& size)
+{
+ // Set up
+ const int ONE = 1;
+ const double alpha = 1./3.;
+ double *x = new double[size], *y = new double[size];
+ for (int i = 1; i <= size; ++i) {
+ x[i-1] = 10. / i;
+ y[i-1] = -10./(3. * i);
+ }
+
+ // Execute
+ daxpy_(&size, &alpha, x, &ONE, y, &ONE);
+
+ // Compute the error
+ double error = dnrm2_(&size, y, &ONE);
+
+ delete[] x; delete[] y;
+ return error;
+}
+
+double matrix_vector_test(const int& size)
+{
+ // Set up
+ const int ONE = 1;
+ char TRANS = 'N';
+ const double alpha = 1./size, beta = 1.;
+ double *A = new double[size*size], *x = new double[size], *y = new double[size];
+ for (int i = 1; i <= size; ++i) {
+ x[i-1] = i;
+ y[i-1] = -i;
+ for (int j = 1; j <= size; ++j) {
+ *(A+i-1+(j-1)*size) = static_cast<double>(i)/j;
+ }
+ }
+
+ // Execute
+ dgemv_(&TRANS, &size, &size, &alpha, A, &size, x, &ONE, &beta, y, &ONE);
+
+ // Compute the error
+ double error = dnrm2_(&size, y, &ONE);
+
+ delete[] A; delete[] x; delete[] y;
+ return error;
+}
+
+double trisolve_vector_test(const int& size)
+{
+ // Set up
+ const int ONE = 1;
+ char UPLO = 'U', TRANS = 'N', DIAG = 'U';
+ double *A = new double[size*size], *x = new double[size+1], *y = new double[size];
+ const double alpha = 1.;
+ x[size] = 0.;
+ for (int i = 1; i <= size; ++i) {
+ x[size-i] = x[size-i+1] + 1./i;
+ y[i-1] = -1.;
+ for (int j = i; j <= size; ++j) {
+ *(A+i-1+(j-1)*size) = 1. / (j-i+1);
+ }
+ }
+
+ // Execute
+ dtrsv_(&UPLO, &TRANS, &DIAG, &size, A, &size, x, &ONE);
+ daxpy_(&size, &alpha, x, &ONE, y, &ONE);
+ double error = dnrm2_(&size, y, &ONE);
+
+ delete[] A; delete[] x; delete[] y;
+ return error;
+}
+
+double matrix_matrix_test(const int& size)
+{
+ // rand48 initialization
+ srand48(5);
+
+ // sigma = SUM[k=1..size](k)
+ double sigma = 0;
+ for (int i = 1; i <= size; ++i)
+ sigma += i;
+
+ // Set up
+ const int ONE = 1;
+ char TRANS = 'N';
+ const double alpha = drand48(), beta = -2. * alpha * sigma;
+ const int size2 = size*size;
+ double *A = new double[size2], *B = new double[size2], *C = new double[size2];
+
+ for (int i = 1; i <= size; ++i)
+ for (int j = 1; j <= size; ++j) {
+ *(A+i-1+size*(j-1)) = static_cast<double>(j)/i;
+ *(B+i-1+size*(j-1)) = j;
+ *(C+i-1+size*(j-1)) = static_cast<double>(j)/(2.*i);
+ }
+
+ // Execute
+ dgemm_(&TRANS, &TRANS, &size, &size, &size, &alpha, A, &size, B, &size, &beta, C, &size);
+ double error = dnrm2_(&size2, C, &ONE);
+
+ delete[] A; delete[] B; delete[] C;
+ return error;
+}
+
+template<typename T>
+void test(T t, const int& min, const int& max, const unsigned& N, const string& name)
+{
+ ostringstream fname;
+ ofstream fout;
+ double result;
+ int N_;
+
+ fname << "accuracy_" << name << "_blas.dat";
+ fout.open(fname.str().c_str());
+ cout << name << " test -- " << fname.str() << endl;
+ vector<int> axpy_sizes = logsizes(min, max, N);
+ N_ = 0;
+ for (vector<int>::const_reverse_iterator i = axpy_sizes.rbegin(), e = axpy_sizes.rend(); i!=e; ++i) {
+ result = t(*i);
+ fout << *i << " " << result << endl;
+ cout << " size: " << *i << " " << result << " (" << ++N_ << "/100)" << endl;
+ }
+ fout.close();
+ cout << "\n";
+}
+
+int main(int argv, char **argc)
+{
+ bool
+ axpy=false, axpby=false, rot=false,
+ matrix_vector=false, atv=false, symv=false, syr2=false, ger=false, trisolve_vector=false,
+ matrix_matrix=false, aat=false, trisolve_matrix=false, trmm=false
+ ;
+
+
+ for (int i = 1; i < argv; ++i) {
+ std::string arg = argc[i];
+ if (arg == "axpy") axpy = true;
+ else if (arg == "axpby") axpby = true;
+ else if (arg == "rot") rot = true;
+ else if (arg == "matrix_vector") matrix_vector = true;
+ else if (arg == "atv") atv = true;
+ else if (arg == "symv") symv = true;
+ else if (arg == "syr2") syr2 = true;
+ else if (arg == "ger") ger = true;
+ else if (arg == "trisolve_vector") trisolve_vector = true;
+ else if (arg == "matrix_matrix") matrix_matrix = true;
+ else if (arg == "aat") aat = true;
+ else if (arg == "trisolve_matrix") trisolve_matrix = true;
+ else if (arg == "trmm") trmm = true;
+ }
+
+
+ /* AXPY test */
+ if (axpy)
+ test(axpy_test, 1, 1000000, 100, "axpy");
+
+ if (matrix_vector)
+ test(matrix_vector_test, 1, 3000, 100, "matrix_vector");
+
+ if (trisolve_vector)
+ test(trisolve_vector_test, 1, 3000, 100, "trisolve_vector");
+
+ if (matrix_matrix)
+ test(matrix_matrix_test, 1, 2000, 100, "matrix_matrix");
+
+ return 0;
+
+}
diff --git a/btl/accuracy/sizes.hh b/btl/accuracy/sizes.hh
new file mode 100644
index 0000000..be458bf
--- /dev/null
+++ b/btl/accuracy/sizes.hh
@@ -0,0 +1,59 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef SIZES_HH
+#define SIZES_HH
+
+#include <vector>
+#include <cmath>
+
+template<typename T>
+std::vector<T> logspace(const T& min, const T& max, const unsigned& N)
+{
+ std::vector<T> result;
+ result.reserve(N);
+
+ const double emin = std::log(static_cast<double>(min)),
+ emax = std::log(static_cast<double>(max));
+ double e, r = (emax-emin)/(N-1);
+ for (unsigned i = 0; i < N; ++i) {
+ e = emin + i*r;
+ result.push_back(static_cast<T>(exp(e)));
+ }
+
+ return result;
+}
+
+template<typename T>
+std::vector<T> logsizes(const T& min, const T& max, const unsigned& N)
+{
+ if (N <= 10)
+ return logspace(min, max, N);
+
+ std::vector<T> result;
+ result.reserve(N);
+
+ for (unsigned i = 0; i < 9; ++i)
+ result.push_back(i+1);
+ std::vector<T> lres = logspace(10, max, N-9);
+ for (unsigned i = 9; i < N; ++i)
+ result.push_back(lres[i-9]);
+
+ return result;
+}
+
+#endif /* SIZES_HH */
diff --git a/btl/actions/action_aat_product.hh b/btl/actions/action_aat_product.hh
new file mode 100644
index 0000000..aa5b35c
--- /dev/null
+++ b/btl/actions/action_aat_product.hh
@@ -0,0 +1,145 @@
+//=====================================================
+// File : action_aat_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_AAT_PRODUCT
+#define ACTION_AAT_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_aat_product {
+
+public :
+
+ // Ctor
+
+ Action_aat_product( int size ):_size(size)
+ {
+ MESSAGE("Action_aat_product Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_matrix<null_function>(X_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::matrix_from_stl(X,X_stl);
+
+ }
+
+ // invalidate copy ctor
+
+ Action_aat_product( const Action_aat_product & )
+ {
+ INFOS("illegal call to Action_aat_product Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ ~Action_aat_product( void ){
+
+ MESSAGE("Action_aat_product Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_matrix(X,_size);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_matrix(X_ref,_size);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "aat_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return double(_size)*double(_size)*double(_size);
+ }
+
+ inline void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_matrix(X_ref,X,_size);
+
+ }
+
+ inline void calculate( void ) {
+
+ Interface::aat_product(A,X,_size);
+
+ }
+
+ void check_result( void ){
+ if (_size>128) return;
+ // calculation check
+
+ Interface::matrix_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::aat_product(A_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(1);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_matrix X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_matrix X;
+
+
+ int _size;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_ata_product.hh b/btl/actions/action_ata_product.hh
new file mode 100644
index 0000000..04364fe
--- /dev/null
+++ b/btl/actions/action_ata_product.hh
@@ -0,0 +1,145 @@
+//=====================================================
+// File : action_ata_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_ATA_PRODUCT
+#define ACTION_ATA_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_ata_product {
+
+public :
+
+ // Ctor
+
+ Action_ata_product( int size ):_size(size)
+ {
+ MESSAGE("Action_ata_product Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_matrix<null_function>(X_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::matrix_from_stl(X,X_stl);
+
+ }
+
+ // invalidate copy ctor
+
+ Action_ata_product( const Action_ata_product & )
+ {
+ INFOS("illegal call to Action_ata_product Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ ~Action_ata_product( void ){
+
+ MESSAGE("Action_ata_product Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_matrix(X,_size);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_matrix(X_ref,_size);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "ata_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size*_size;
+ }
+
+ inline void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_matrix(X_ref,X,_size);
+
+ }
+
+ inline void calculate( void ) {
+
+ Interface::ata_product(A,X,_size);
+
+ }
+
+ void check_result( void ){
+ if (_size>128) return;
+ // calculation check
+
+ Interface::matrix_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::ata_product(A_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(1);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_matrix X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_matrix X;
+
+
+ int _size;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_atv_product.hh b/btl/actions/action_atv_product.hh
new file mode 100644
index 0000000..a823451
--- /dev/null
+++ b/btl/actions/action_atv_product.hh
@@ -0,0 +1,134 @@
+//=====================================================
+// File : action_atv_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_ATV_PRODUCT
+#define ACTION_ATV_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_atv_product {
+
+public :
+
+ Action_atv_product( int size ) : _size(size)
+ {
+ MESSAGE("Action_atv_product Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<null_function>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X,X_stl);
+ }
+
+ // invalidate copy ctor
+ Action_atv_product( const Action_atv_product & )
+ {
+ INFOS("illegal call to Action_atv_product Copy Ctor");
+ exit(1);
+ }
+
+ ~Action_atv_product( void )
+ {
+ MESSAGE("Action_atv_product Dtor");
+
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+ }
+
+ static inline std::string name() { return "atv_" + Interface::name(); }
+
+ double nb_op_base( void ) { return 2.0*_size*_size; }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("begin atv");
+ Interface::atv_product(A,B,X,_size);
+ BTL_ASM_COMMENT("end atv");
+ }
+
+ void check_result( void )
+ {
+ if (_size>128) return;
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::atv_product(A_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(1);
+ }
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+
+ int _size;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_axpby.hh b/btl/actions/action_axpby.hh
new file mode 100644
index 0000000..98511ab
--- /dev/null
+++ b/btl/actions/action_axpby.hh
@@ -0,0 +1,127 @@
+//=====================================================
+// File : action_axpby.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_AXPBY
+#define ACTION_AXPBY
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_axpby {
+
+public :
+
+ // Ctor
+ Action_axpby( int size ):_size(size),_alpha(0.5),_beta(0.95)
+ {
+ MESSAGE("Action_axpby Ctor");
+
+ // STL vector initialization
+ init_vector<pseudo_random>(X_stl,_size);
+ init_vector<pseudo_random>(Y_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(Y_ref,Y_stl);
+
+ Interface::vector_from_stl(X,X_stl);
+ Interface::vector_from_stl(Y,Y_stl);
+ }
+
+ // invalidate copy ctor
+ Action_axpby( const Action_axpby & )
+ {
+ INFOS("illegal call to Action_axpby Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+ ~Action_axpby( void ){
+ MESSAGE("Action_axpby Dtor");
+
+ // deallocation
+ Interface::free_vector(X_ref);
+ Interface::free_vector(Y_ref);
+
+ Interface::free_vector(X);
+ Interface::free_vector(Y);
+ }
+
+ // action name
+ static inline std::string name( void )
+ {
+ return "axpby_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 3.0*_size;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_vector(X_ref,X,_size);
+ Interface::copy_vector(Y_ref,Y,_size);
+ }
+
+ inline void calculate( void ) {
+ BTL_ASM_COMMENT("mybegin axpby");
+ Interface::axpby(_alpha,X,_beta,Y,_size);
+ BTL_ASM_COMMENT("myend axpby");
+ }
+
+ void check_result( void ){
+ if (_size>128) return;
+ // calculation check
+ Interface::vector_to_stl(Y,resu_stl);
+
+ STL_interface<typename Interface::real_type>::axpby(_alpha,X_stl,_beta,Y_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(Y_stl,resu_stl);
+
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(2);
+ }
+ }
+
+private :
+
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector Y_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_vector X_ref;
+ typename Interface::gene_vector Y_ref;
+
+ typename Interface::gene_vector X;
+ typename Interface::gene_vector Y;
+
+ typename Interface::real_type _alpha;
+ typename Interface::real_type _beta;
+
+ int _size;
+};
+
+#endif
diff --git a/btl/actions/action_axpy.hh b/btl/actions/action_axpy.hh
new file mode 100644
index 0000000..e4cb3a5
--- /dev/null
+++ b/btl/actions/action_axpy.hh
@@ -0,0 +1,139 @@
+//=====================================================
+// File : action_axpy.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_AXPY
+#define ACTION_AXPY
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_axpy {
+
+public :
+
+ // Ctor
+
+ Action_axpy( int size ):_size(size),_coef(1.0)
+ {
+ MESSAGE("Action_axpy Ctor");
+
+ // STL vector initialization
+
+ init_vector<pseudo_random>(X_stl,_size);
+ init_vector<pseudo_random>(Y_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(Y_ref,Y_stl);
+
+ Interface::vector_from_stl(X,X_stl);
+ Interface::vector_from_stl(Y,Y_stl);
+
+
+ }
+
+ // invalidate copy ctor
+
+ Action_axpy( const Action_axpy & )
+ {
+ INFOS("illegal call to Action_axpy Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_axpy( void ){
+
+ MESSAGE("Action_axpy Dtor");
+
+ // deallocation
+
+ Interface::free_vector(X_ref);
+ Interface::free_vector(Y_ref);
+
+ Interface::free_vector(X);
+ Interface::free_vector(Y);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "axpy_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_vector(X_ref,X,_size);
+ Interface::copy_vector(Y_ref,Y,_size);
+ }
+
+ inline void calculate( void ) {
+ BTL_ASM_COMMENT("mybegin axpy");
+ Interface::axpy(_coef,X,Y,_size);
+ BTL_ASM_COMMENT("myend axpy");
+ }
+
+ void check_result( void ){
+ if (_size>128) return;
+ // calculation check
+
+ Interface::vector_to_stl(Y,resu_stl);
+
+ STL_interface<typename Interface::real_type>::axpy(_coef,X_stl,Y_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(Y_stl,resu_stl);
+
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(0);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector Y_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_vector X_ref;
+ typename Interface::gene_vector Y_ref;
+
+ typename Interface::gene_vector X;
+ typename Interface::gene_vector Y;
+
+ typename Interface::real_type _coef;
+
+ int _size;
+};
+
+#endif
diff --git a/btl/actions/action_cholesky.hh b/btl/actions/action_cholesky.hh
new file mode 100644
index 0000000..a1c751b
--- /dev/null
+++ b/btl/actions/action_cholesky.hh
@@ -0,0 +1,129 @@
+//=====================================================
+// File : action_cholesky.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_CHOLESKY
+#define ACTION_CHOLESKY
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include <cmath>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_cholesky {
+
+public :
+
+ // Ctor
+
+ Action_cholesky( int size ):_size(size)
+ {
+ MESSAGE("Action_cholesky Ctor");
+
+ // STL mat/vec initialization
+ init_matrix_symm<pseudo_random>(X_stl,_size);
+ init_matrix<null_function>(C_stl,_size);
+
+ // make sure X is invertible
+ for (int i=0; i<_size; ++i)
+ X_stl[i][i] = std::abs(X_stl[i][i]) * 1e2 + 100;
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref,X_stl);
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::matrix_from_stl(C,C_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size; ++j)
+ {
+ double r = std::max(_size - j -1,0);
+ _cost += 2*(r*j+r+j);
+ }
+ }
+
+ // invalidate copy ctor
+
+ Action_cholesky( const Action_cholesky & )
+ {
+ INFOS("illegal call to Action_cholesky Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_cholesky( void ){
+
+ MESSAGE("Action_cholesky Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref,_size);
+ Interface::free_matrix(X,_size);
+ Interface::free_matrix(C,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "cholesky_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::cholesky(X,C,_size);
+ }
+
+ void check_result( void ){
+ // calculation check
+// STL_interface<typename Interface::real_type>::cholesky(X_stl,C_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_fftw_1d.hh b/btl/actions/action_fftw_1d.hh
new file mode 100644
index 0000000..25424d6
--- /dev/null
+++ b/btl/actions/action_fftw_1d.hh
@@ -0,0 +1,128 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_FFTW_1D
+#define ACTION_FFTW_1D
+#include <string>
+#include <cmath>
+
+#include "base_action_fftw.hh"
+
+
+/* FORWARD - MEASURE */
+template<class Interface>
+class Action_FFTW_1D_Forward_Measure : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_1D_Forward_Measure(const int& size) :
+ Action_FFTW_base<Interface>(size, 1)
+ {
+ Interface::fftw_init_plan(this->p, size, this->X, this->Y, FFTW_FORWARD, FFTW_MEASURE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_1D_Forward_Measure_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return this->size_ * std::log(this->size_)/log_2;
+ }
+};
+
+
+/* FORWARD - ESTIMATE */
+template<class Interface>
+class Action_FFTW_1D_Forward_Estimate : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_1D_Forward_Estimate(const int& size) :
+ Action_FFTW_base<Interface>(size, 1)
+ {
+ Interface::fftw_init_plan(this->p, size, this->X, this->Y, FFTW_FORWARD, FFTW_ESTIMATE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_1D_Forward_Estimate_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return this->size_ * std::log(this->size_)/log_2;
+ }
+};
+
+/* BACKWARD - MEASURE */
+template<class Interface>
+class Action_FFTW_1D_Backward_Measure : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_1D_Backward_Measure(const int& size) :
+ Action_FFTW_base<Interface>(size, 1)
+ {
+ Interface::fftw_init_plan(this->p, size, this->X, this->Y, FFTW_BACKWARD, FFTW_MEASURE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_1D_Backward_Measure_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return this->size_ * std::log(this->size_)/log_2;
+ }
+};
+
+
+/* BACKWARD - ESTIMATE */
+template<class Interface>
+class Action_FFTW_1D_Backward_Estimate : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_1D_Backward_Estimate(const int& size) :
+ Action_FFTW_base<Interface>(size, 1)
+ {
+ Interface::fftw_init_plan(this->p, size, this->X, this->Y, FFTW_BACKWARD, FFTW_ESTIMATE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_1D_Backward_Estimate_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return this->size_ * std::log(this->size_)/log_2;
+ }
+};
+
+#endif // ACTION_FFTW_1D
diff --git a/btl/actions/action_fftw_2d.hh b/btl/actions/action_fftw_2d.hh
new file mode 100644
index 0000000..34b13e1
--- /dev/null
+++ b/btl/actions/action_fftw_2d.hh
@@ -0,0 +1,128 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_FFTW_2D
+#define ACTION_FFTW_2D
+#include <string>
+#include <cmath>
+
+#include "base_action_fftw.hh"
+
+
+/* FORWARD - MEASURE */
+template<class Interface>
+class Action_FFTW_2D_Forward_Measure : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_2D_Forward_Measure(const int& size) :
+ Action_FFTW_base<Interface>(size, 2)
+ {
+ Interface::fftw_init_plan_2d(this->p, size, this->X, this->Y, FFTW_FORWARD, FFTW_MEASURE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_2D_Forward_Measure_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 2*this->size_;
+ }
+};
+
+
+/* FORWARD - ESTIMATE */
+template<class Interface>
+class Action_FFTW_2D_Forward_Estimate : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_2D_Forward_Estimate(const int& size) :
+ Action_FFTW_base<Interface>(size, 2)
+ {
+ Interface::fftw_init_plan_2d(this->p, size, this->X, this->Y, FFTW_FORWARD, FFTW_ESTIMATE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_2D_Forward_Estimate_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 2*this->size_;
+ }
+};
+
+/* BACKWARD - MEASURE */
+template<class Interface>
+class Action_FFTW_2D_Backward_Measure : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_2D_Backward_Measure(const int& size) :
+ Action_FFTW_base<Interface>(size, 2)
+ {
+ Interface::fftw_init_plan_2d(this->p, size, this->X, this->Y, FFTW_BACKWARD, FFTW_MEASURE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_2D_Backward_Measure_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 2*this->size_;
+ }
+};
+
+
+/* BACKWARD - ESTIMATE */
+template<class Interface>
+class Action_FFTW_2D_Backward_Estimate : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_2D_Backward_Estimate(const int& size) :
+ Action_FFTW_base<Interface>(size, 2)
+ {
+ Interface::fftw_init_plan_2d(this->p, size, this->X, this->Y, FFTW_BACKWARD, FFTW_ESTIMATE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_2D_Backward_Estimate_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 2*this->size_;
+ }
+};
+
+#endif // ACTION_FFTW_2D
diff --git a/btl/actions/action_fftw_3d.hh b/btl/actions/action_fftw_3d.hh
new file mode 100644
index 0000000..a9714db
--- /dev/null
+++ b/btl/actions/action_fftw_3d.hh
@@ -0,0 +1,129 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_FFTW_3D
+#define ACTION_FFTW_3D
+#include <string>
+#include <cmath>
+
+#include "base_action_fftw.hh"
+
+
+/* FORWARD - MEASURE */
+template<class Interface>
+class Action_FFTW_3D_Forward_Measure : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_3D_Forward_Measure(const int& size) :
+ Action_FFTW_base<Interface>(size, 3)
+ {
+ Interface::fftw_init_plan_3d(this->p, size, this->X, this->Y, FFTW_FORWARD, FFTW_MEASURE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_3D_Forward_Measure_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 3*this->size_*this->size_;
+ }
+};
+
+
+/* FORWARD - ESTIMATE */
+template<class Interface>
+class Action_FFTW_3D_Forward_Estimate : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_3D_Forward_Estimate(const int& size) :
+ Action_FFTW_base<Interface>(size, 3)
+ {
+ Interface::fftw_init_plan_3d(this->p, size, this->X, this->Y, FFTW_FORWARD, FFTW_ESTIMATE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_3D_Forward_Estimate_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 3*this->size_*this->size_;
+ }
+};
+
+/* BACKWARD - MEASURE */
+template<class Interface>
+class Action_FFTW_3D_Backward_Measure : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_3D_Backward_Measure(const int& size) :
+ Action_FFTW_base<Interface>(size, 3)
+ {
+ Interface::fftw_init_plan_3d(this->p, size, this->X, this->Y, FFTW_BACKWARD, FFTW_MEASURE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_3D_Backward_Measure_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 3*this->size_*this->size_;
+ }
+};
+
+
+/* BACKWARD - ESTIMATE */
+template<class Interface>
+class Action_FFTW_3D_Backward_Estimate : public Action_FFTW_base<Interface>
+{
+public:
+ // Constructor
+ Action_FFTW_3D_Backward_Estimate(const int& size) :
+ Action_FFTW_base<Interface>(size, 3)
+ {
+ Interface::fftw_init_plan_3d(this->p, size, this->X, this->Y, FFTW_BACKWARD, FFTW_ESTIMATE);
+ }
+
+ // Action name
+ static inline std::string name( void )
+ {
+ return "FFTW_3D_Backward_Estimate_"+Interface::name();
+ }
+
+ // Algorithm complexity
+ double nb_op_base( void ){
+ const static double log_2 = std::log(2.);
+ return (this->size_ * std::log(this->size_)/log_2) * 3*this->size_*this->size_;
+ }
+};
+
+#endif // ACTION_FFTW_3D
+
diff --git a/btl/actions/action_general_solve.hh b/btl/actions/action_general_solve.hh
new file mode 100644
index 0000000..78aebd8
--- /dev/null
+++ b/btl/actions/action_general_solve.hh
@@ -0,0 +1,137 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_GENERAL_SOLVE
+#define ACTION_GENERAL_SOLVE
+
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_general_solve {
+
+public:
+
+ // Ctor
+ Action_general_solve( int size ) : _size(size)
+ {
+ MESSAGE("Action_general_solve Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<null_function>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+
+
+ }
+
+ // invalidate copy ctor
+
+ Action_general_solve( const Action_general_solve & )
+ {
+ INFOS("illegal call to Action_general_solve Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ BTL_DONT_INLINE ~Action_general_solve( void ){
+
+ MESSAGE("Action_general_solve Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "general_solve_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin general_solve");
+ Interface::general_solve(A,B,X,_size);
+ BTL_ASM_COMMENT("end general_solve");
+ }
+
+ BTL_DONT_INLINE void check_result() {
+ // TODO: check result
+ }
+
+
+private:
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+
+ int _size;
+
+
+};
+
+
+#endif// ACTION_GENERAL_SOLVE
diff --git a/btl/actions/action_ger.hh b/btl/actions/action_ger.hh
new file mode 100644
index 0000000..dc766ef
--- /dev/null
+++ b/btl/actions/action_ger.hh
@@ -0,0 +1,128 @@
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_GER
+#define ACTION_GER
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_ger {
+
+public :
+
+ // Ctor
+ BTL_DONT_INLINE Action_ger( int size ):_size(size)
+ {
+ MESSAGE("Action_ger Ctor");
+
+ // STL matrix and vector initialization
+ typename Interface::stl_matrix tmp;
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<pseudo_random>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+ }
+
+ // invalidate copy ctor
+ Action_ger( const Action_ger & )
+ {
+ INFOS("illegal call to Action_ger Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+ BTL_DONT_INLINE ~Action_ger( void ){
+ MESSAGE("Action_ger Dtor");
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+
+ }
+
+ // action name
+ static inline std::string name( void )
+ {
+ return "ger_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin ger");
+ Interface::ger(A,B,X,_size);
+ BTL_ASM_COMMENT("end ger");
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+ // calculation check
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::ger(A_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-3){
+ INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+ int _size;
+};
+
+
+#endif
diff --git a/btl/actions/action_hessenberg.hh b/btl/actions/action_hessenberg.hh
new file mode 100644
index 0000000..2100ebd
--- /dev/null
+++ b/btl/actions/action_hessenberg.hh
@@ -0,0 +1,233 @@
+//=====================================================
+// File : action_hessenberg.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_HESSENBERG
+#define ACTION_HESSENBERG
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_hessenberg {
+
+public :
+
+ // Ctor
+
+ Action_hessenberg( int size ):_size(size)
+ {
+ MESSAGE("Action_hessenberg Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl,_size);
+
+ init_matrix<null_function>(C_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref,X_stl);
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::matrix_from_stl(C,C_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size-2; ++j)
+ {
+ double r = std::max(0,_size-j-1);
+ double b = std::max(0,_size-j-2);
+ _cost += 6 + 3*b + r*r*4 + r*_size*4;
+ }
+ }
+
+ // invalidate copy ctor
+
+ Action_hessenberg( const Action_hessenberg & )
+ {
+ INFOS("illegal call to Action_hessenberg Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_hessenberg( void ){
+
+ MESSAGE("Action_hessenberg Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref,_size);
+ Interface::free_matrix(X,_size);
+ Interface::free_matrix(C,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "hessenberg_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::hessenberg(X,C,_size);
+ }
+
+ void check_result( void ){
+ // calculation check
+ Interface::matrix_to_stl(C,resu_stl);
+
+// STL_interface<typename Interface::real_type>::hessenberg(X_stl,C_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+
+ int _size;
+ double _cost;
+};
+
+template<class Interface>
+class Action_tridiagonalization {
+
+public :
+
+ // Ctor
+
+ Action_tridiagonalization( int size ):_size(size)
+ {
+ MESSAGE("Action_tridiagonalization Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl,_size);
+
+ for(int i=0; i<_size; ++i)
+ {
+ for(int j=0; j<i; ++j)
+ X_stl[i][j] = X_stl[j][i];
+ }
+
+ init_matrix<null_function>(C_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref,X_stl);
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::matrix_from_stl(C,C_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size-2; ++j)
+ {
+ double r = std::max(0,_size-j-1);
+ double b = std::max(0,_size-j-2);
+ _cost += 6. + 3.*b + r*r*8.;
+ }
+ }
+
+ // invalidate copy ctor
+
+ Action_tridiagonalization( const Action_tridiagonalization & )
+ {
+ INFOS("illegal call to Action_tridiagonalization Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_tridiagonalization( void ){
+
+ MESSAGE("Action_tridiagonalization Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref,_size);
+ Interface::free_matrix(X,_size);
+ Interface::free_matrix(C,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void ) { return "tridiagonalization_"+Interface::name(); }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::tridiagonalization(X,C,_size);
+ }
+
+ void check_result( void ){
+ // calculation check
+ Interface::matrix_to_stl(C,resu_stl);
+
+// STL_interface<typename Interface::real_type>::tridiagonalization(X_stl,C_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_least_squares.hh b/btl/actions/action_least_squares.hh
new file mode 100644
index 0000000..f13c7dc
--- /dev/null
+++ b/btl/actions/action_least_squares.hh
@@ -0,0 +1,137 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_LEAST_SQUARES
+#define ACTION_LEAST_SQUARES
+
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_least_squares {
+
+public:
+
+ // Ctor
+ Action_least_squares( int size ) : _size(size)
+ {
+ MESSAGE("Action_least_squares Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<null_function>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+
+
+ }
+
+ // invalidate copy ctor
+
+ Action_least_squares( const Action_least_squares & )
+ {
+ INFOS("illegal call to Action_least_squares Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ BTL_DONT_INLINE ~Action_least_squares( void ){
+
+ MESSAGE("Action_least_squares Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "least_squares_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin least_squares");
+ Interface::least_squares(A,B,X,_size);
+ BTL_ASM_COMMENT("end least_squares");
+ }
+
+ BTL_DONT_INLINE void check_result() {
+ // TODO: check result
+ }
+
+
+private:
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+
+ int _size;
+
+
+};
+
+
+#endif // ACTION_LEAST_SQUARES
diff --git a/btl/actions/action_lu_decomp.hh b/btl/actions/action_lu_decomp.hh
new file mode 100644
index 0000000..770c87d
--- /dev/null
+++ b/btl/actions/action_lu_decomp.hh
@@ -0,0 +1,109 @@
+//=====================================================
+// File : action_lu_decomp.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_LU_DECOMP
+#define ACTION_LU_DECOMP
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_lu_decomp {
+
+public :
+
+ // Ctor
+
+ Action_lu_decomp( int size ):_size(size)
+ {
+ MESSAGE("Action_lu_decomp Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl,_size);
+
+ init_matrix<null_function>(C_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref,X_stl);
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::matrix_from_stl(C,C_stl);
+
+ _cost = 2.0*size*size*size/3.0 + size*size;
+ }
+
+ // invalidate copy ctor
+
+ Action_lu_decomp( const Action_lu_decomp & )
+ {
+ INFOS("illegal call to Action_lu_decomp Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_lu_decomp( void ){
+
+ MESSAGE("Action_lu_decomp Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref,_size);
+ Interface::free_matrix(X,_size);
+ Interface::free_matrix(C,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "lu_decomp_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::lu_decomp(X,C,_size);
+ }
+
+ void check_result( void ){
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_lu_solve.hh b/btl/actions/action_lu_solve.hh
new file mode 100644
index 0000000..5a81e63
--- /dev/null
+++ b/btl/actions/action_lu_solve.hh
@@ -0,0 +1,136 @@
+//=====================================================
+// File : action_lu_solve.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_LU_SOLVE
+#define ACTION_LU_SOLVE
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_lu_solve
+{
+
+public :
+
+ static inline std::string name( void )
+ {
+ return "lu_solve_"+Interface::name();
+ }
+
+ static double nb_op_base(int size){
+ return 2.0*size*size*size/3.0; // questionable but not really important
+ }
+
+
+ static double calculate( int nb_calc, int size ) {
+
+ // STL matrix and vector initialization
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+
+ init_matrix<pseudo_random>(A_stl,size);
+ init_vector<pseudo_random>(B_stl,size);
+ init_vector<null_function>(X_stl,size);
+
+ // generic matrix and vector initialization
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+ typename Interface::gene_matrix LU;
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X,X_stl);
+ Interface::matrix_from_stl(LU,A_stl);
+
+ // local variable :
+
+ typename Interface::Pivot_Vector pivot; // pivot vector
+ Interface::new_Pivot_Vector(pivot,size);
+
+ // timer utilities
+
+ Portable_Timer chronos;
+
+ // time measurement
+
+ chronos.start();
+
+ for (int ii=0;ii<nb_calc;ii++){
+
+ // LU factorization
+ Interface::copy_matrix(A,LU,size);
+ Interface::LU_factor(LU,pivot,size);
+
+ // LU solve
+
+ Interface::LU_solve(LU,pivot,B,X,size);
+
+ }
+
+ // Time stop
+
+ chronos.stop();
+
+ double time=chronos.user_time();
+
+ // check result :
+
+ typename Interface::stl_vector B_new_stl(size);
+ Interface::vector_to_stl(X,X_stl);
+
+ STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl,X_stl,B_new_stl,size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(B_stl,B_new_stl);
+
+ if (error>1.e-5){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ STL_interface<typename Interface::real_type>::display_vector(B_stl);
+ STL_interface<typename Interface::real_type>::display_vector(B_new_stl);
+ exit(0);
+ }
+
+ // deallocation and return time
+
+ Interface::free_matrix(A,size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+ Interface::free_Pivot_Vector(pivot);
+
+ return time;
+ }
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_matrix_matrix_product.hh b/btl/actions/action_matrix_matrix_product.hh
new file mode 100644
index 0000000..f65ee05
--- /dev/null
+++ b/btl/actions/action_matrix_matrix_product.hh
@@ -0,0 +1,150 @@
+//=====================================================
+// File : action_matrix_matrix_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_MATRIX_MATRIX_PRODUCT
+#define ACTION_MATRIX_MATRIX_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_matrix_matrix_product {
+
+public :
+
+ // Ctor
+
+ Action_matrix_matrix_product( int size ):_size(size)
+ {
+ MESSAGE("Action_matrix_matrix_product Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_matrix<pseudo_random>(B_stl,_size);
+ init_matrix<null_function>(X_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(B_ref,B_stl);
+ Interface::matrix_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::matrix_from_stl(B,B_stl);
+ Interface::matrix_from_stl(X,X_stl);
+
+ }
+
+ // invalidate copy ctor
+
+ Action_matrix_matrix_product( const Action_matrix_matrix_product & )
+ {
+ INFOS("illegal call to Action_matrix_matrix_product Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ ~Action_matrix_matrix_product( void ){
+
+ MESSAGE("Action_matrix_matrix_product Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_matrix(B,_size);
+ Interface::free_matrix(X,_size);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_matrix(B_ref,_size);
+ Interface::free_matrix(X_ref,_size);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "matrix_matrix_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size*_size;
+ }
+
+ inline void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_matrix(B_ref,B,_size);
+ Interface::copy_matrix(X_ref,X,_size);
+
+ }
+
+ inline void calculate( void ) {
+ Interface::matrix_matrix_product(A,B,X,_size);
+ }
+
+ void check_result( void ){
+
+ // calculation check
+ if (_size<200)
+ {
+ Interface::matrix_to_stl(X,resu_stl);
+ STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,_size);
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(1);
+ }
+ }
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_matrix B_stl;
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_matrix B_ref;
+ typename Interface::gene_matrix X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_matrix B;
+ typename Interface::gene_matrix X;
+
+
+ int _size;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_matrix_matrix_product_bis.hh b/btl/actions/action_matrix_matrix_product_bis.hh
new file mode 100644
index 0000000..29c10a6
--- /dev/null
+++ b/btl/actions/action_matrix_matrix_product_bis.hh
@@ -0,0 +1,152 @@
+//=====================================================
+// File : action_matrix_matrix_product_bis.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_MATRIX_MATRIX_PRODUCT_BIS
+#define ACTION_MATRIX_MATRIX_PRODUCT_BIS
+#include "utilities.h"
+#include "STL_interface.hh"
+#include "STL_timer.hh"
+#include <string>
+#include "init_function.hh"
+#include "init_vector.hh"
+#include "init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_matrix_matrix_product_bis {
+
+public :
+
+ static inline std::string name( void )
+ {
+ return "matrix_matrix_"+Interface::name();
+ }
+
+ static double nb_op_base(int size){
+ return 2.0*size*size*size;
+ }
+
+ static double calculate( int nb_calc, int size ) {
+
+ // STL matrix and vector initialization
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_matrix B_stl;
+ typename Interface::stl_matrix X_stl;
+
+ init_matrix<pseudo_random>(A_stl,size);
+ init_matrix<pseudo_random>(B_stl,size);
+ init_matrix<null_function>(X_stl,size);
+
+ // generic matrix and vector initialization
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_matrix B_ref;
+ typename Interface::gene_matrix X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_matrix B;
+ typename Interface::gene_matrix X;
+
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(B_ref,B_stl);
+ Interface::matrix_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::matrix_from_stl(B,B_stl);
+ Interface::matrix_from_stl(X,X_stl);
+
+
+ // STL_timer utilities
+
+ STL_timer chronos;
+
+ // Baseline evaluation
+
+ chronos.start_baseline(nb_calc);
+
+ do {
+
+ Interface::copy_matrix(A_ref,A,size);
+ Interface::copy_matrix(B_ref,B,size);
+ Interface::copy_matrix(X_ref,X,size);
+
+
+ // Interface::matrix_matrix_product(A,B,X,size); This line must be commented !!!!
+ }
+ while(chronos.check());
+
+ chronos.report(true);
+
+ // Time measurement
+
+ chronos.start(nb_calc);
+
+ do {
+
+ Interface::copy_matrix(A_ref,A,size);
+ Interface::copy_matrix(B_ref,B,size);
+ Interface::copy_matrix(X_ref,X,size);
+
+ Interface::matrix_matrix_product(A,B,X,size); // here it is not commented !!!!
+ }
+ while(chronos.check());
+
+ chronos.report(true);
+
+ double time=chronos.calculated_time/2000.0;
+
+ // calculation check
+
+ typename Interface::stl_matrix resu_stl(size);
+
+ Interface::matrix_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-6){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(1);
+ }
+
+ // deallocation and return time
+
+ Interface::free_matrix(A,size);
+ Interface::free_matrix(B,size);
+ Interface::free_matrix(X,size);
+
+ Interface::free_matrix(A_ref,size);
+ Interface::free_matrix(B_ref,size);
+ Interface::free_matrix(X_ref,size);
+
+ return time;
+ }
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_matrix_vector_product.hh b/btl/actions/action_matrix_vector_product.hh
new file mode 100644
index 0000000..8bab79d
--- /dev/null
+++ b/btl/actions/action_matrix_vector_product.hh
@@ -0,0 +1,153 @@
+//=====================================================
+// File : action_matrix_vector_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_MATRIX_VECTOR_PRODUCT
+#define ACTION_MATRIX_VECTOR_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_matrix_vector_product {
+
+public :
+
+ // Ctor
+
+ BTL_DONT_INLINE Action_matrix_vector_product( int size ):_size(size)
+ {
+ MESSAGE("Action_matrix_vector_product Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<null_function>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+
+ }
+
+ // invalidate copy ctor
+
+ Action_matrix_vector_product( const Action_matrix_vector_product & )
+ {
+ INFOS("illegal call to Action_matrix_vector_product Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ BTL_DONT_INLINE ~Action_matrix_vector_product( void ){
+
+ MESSAGE("Action_matrix_vector_product Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "matrix_vector_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin matrix_vector_product");
+ Interface::matrix_vector_product(A,B,X,_size);
+ BTL_ASM_COMMENT("end matrix_vector_product");
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+
+ // calculation check
+
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-5){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(0);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+
+ int _size;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_parallel_axpy.hh b/btl/actions/action_parallel_axpy.hh
new file mode 100644
index 0000000..5053446
--- /dev/null
+++ b/btl/actions/action_parallel_axpy.hh
@@ -0,0 +1,158 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_AXPY
+#define ACTION_PARALLEL_AXPY
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include <algorithm>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+#include "blas.h"
+
+using namespace std;
+
+template<class Interface>
+class Action_parallel_axpy {
+public:
+ BTL_DONT_INLINE Action_parallel_axpy( int size ):_size(size), _coef(1.)
+ {
+ MESSAGE("Action_parallel_axpy Ctor");
+ int iZERO = 0, iONE = 1;
+
+ GlobalRows = _size;
+ GlobalCols = 1;
+ BlockRows = 2;
+ BlockCols= 1;
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ init_vector<pseudo_random>(Global_x_stl, _size);
+ init_vector<pseudo_random>(Global_y_stl, _size);
+ }
+
+ Interface::scatter_matrix(Global_x_stl, Local_x_stl, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+ Interface::scatter_matrix(Global_y_stl, Local_y_stl, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+
+ Interface::vector_from_stl(Local_x_ref, Local_x_stl);
+ Interface::vector_from_stl(Local_x , Local_x_stl);
+ Interface::vector_from_stl(Local_y_ref, Local_y_stl);
+ Interface::vector_from_stl(Local_y , Local_y_stl);
+
+ // Descinit
+ int context = Interface::context();
+ int info;
+ int LD = std::max(1, LocalRows);
+ descinit_(descX, &_size, &iONE, &BlockRows, &BlockCols, &iZERO, &iZERO, &context, &LD, &info);
+ descinit_(descY, &_size, &iONE, &BlockRows, &BlockCols, &iZERO, &iZERO, &context, &LD, &info);
+
+ // Copy Y to Test_y
+ Test_y_stl = Global_y_stl;
+ }
+
+ // Invalidate copy constructor
+ Action_parallel_axpy (const Action_parallel_axpy&)
+ {
+ INFOS("illegal call to Action_parallel_axpy Copy Ctor");
+ exit(1);
+ }
+
+ // Destructor
+ BTL_DONT_INLINE ~Action_parallel_axpy(){
+
+ MESSAGE("Action_parallel_axpy Dtor");
+
+ // deallocation
+
+ Interface::free_vector(Local_x_ref);
+ Interface::free_vector(Local_y_ref);
+
+ Interface::free_vector(Local_x);
+ Interface::free_vector(Local_y);
+ }
+
+ // action name
+ static inline std::string name()
+ {
+ return "axpy_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size;
+ }
+
+ BTL_DONT_INLINE void initialize(){
+ Interface::copy_vector(Local_x_ref, Local_x, LocalRows*LocalCols);
+ Interface::copy_vector(Local_y_ref, Local_y, LocalRows*LocalCols);
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin axpy");
+ Interface::parallel_axpy(_coef, Local_x, descX, Local_y, descY, _size);
+ BTL_ASM_COMMENT("end axpy");
+ }
+
+ void check_result( void ){
+ int iONE = 1;
+ Interface::vector_to_stl(Local_y, Local_y_stl);
+ Interface::gather_matrix(Global_y_stl, Local_y_stl, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+
+ // calculation check
+ if (iamroot) {
+
+ // Compute YTest
+ STL_interface<typename Interface::real_type>::axpy(_coef, Global_x_stl, Test_y_stl, _size);
+
+ typename Interface::real_type error =
+ STL_interface<typename Interface::real_type>::norm_diff(Global_y_stl, Test_y_stl);
+
+ if (error > 1e-5)
+ std::cerr << "Error: " << error << std::endl;
+ }
+
+ }
+
+private:
+ int _size;
+ int GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols;
+ typename Interface::real_type _coef;
+ bool iamroot;
+
+ typename Interface::stl_vector Global_x_stl;
+ typename Interface::stl_vector Global_y_stl;
+ typename Interface::stl_vector Test_y_stl;
+
+ typename Interface::stl_vector Local_x_stl;
+ typename Interface::stl_vector Local_y_stl;
+
+ typename Interface::gene_vector Local_x_ref;
+ typename Interface::gene_vector Local_y_ref;
+
+ typename Interface::gene_vector Local_x;
+ typename Interface::gene_vector Local_y;
+
+ int descX[9], descY[9];
+};
+
+#endif
diff --git a/btl/actions/action_parallel_cholesky.hh b/btl/actions/action_parallel_cholesky.hh
new file mode 100644
index 0000000..d6bef14
--- /dev/null
+++ b/btl/actions/action_parallel_cholesky.hh
@@ -0,0 +1,130 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_CHOLESKY_HH_
+#define ACTION_PARALLEL_CHOLESKY_HH_
+
+#include "utilities.h"
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+
+#include "lapack_interface.hh"
+#include "STL_interface.hh"
+
+#include <string>
+#include <sstream>
+#include <fstream>
+
+template<class Interface>
+class Action_parallel_cholesky {
+ typedef lapack_interface<typename Interface::real_type> LapackInterface;
+
+public :
+
+ // Constructor
+ BTL_DONT_INLINE Action_parallel_cholesky( int size ) : _size(size)
+ {
+ MESSAGE("Action_parallel_cholesky Ctor");
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ /* Using a constant seed */
+ const unsigned seed = 3;
+ init_SPD_matrix(Global_A_stl, size, seed);
+ }
+
+ const int blocksize = std::max(std::min(size/4, 64), 2);
+ scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
+ LocalRows = desc[8];
+ LocalCols = Local_A_stl.size()/desc[8];
+
+ // Generic local matrix and vectors initialization
+ Interface::matrix_from_stl(Local_A , Local_A_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size; ++j) {
+ double r = std::max(_size - j -1,0);
+ _cost += 2*(r*j+r+j);
+ }
+ }
+
+
+ // Invalidate copy constructor
+ Action_parallel_cholesky(const Action_parallel_cholesky&)
+ {
+ INFOS("illegal call to Action_parallel_cholesky copy constructor");
+ exit(1);
+ }
+
+ // Destructor
+ ~Action_parallel_cholesky()
+ {
+ MESSAGE("Action_parallel_cholesky destructor");
+
+ // Deallocation
+ Interface::free_matrix(Local_A , Local_A_stl.size());
+ }
+
+ // Action name
+ static inline std::string name()
+ {
+ return "cholesky_" + Interface::name();
+ }
+
+ double nb_op_base()
+ {
+ return _cost;
+ }
+
+ BTL_DONT_INLINE void initialize()
+ {
+ }
+
+ BTL_DONT_INLINE void calculate()
+ {
+ Interface::copy_matrix(&Local_A_stl[0], Local_A, Local_A_stl.size());
+ Interface::parallel_cholesky(Local_A, desc);
+ }
+
+ BTL_DONT_INLINE void check_result()
+ {
+ if (_size > 2) {
+ double error = Interface::test_cholesky(Global_A_stl, Local_A, desc);
+ if (iamroot)
+ cout << " {error: " << error << "} ";
+ }
+ }
+
+
+private:
+ int _size, desc[9], LocalRows, LocalCols;
+ double _cost;
+ bool iamroot;
+
+ typename Interface::stl_matrix Global_A_stl;
+ typename Interface::stl_matrix Local_A_stl;
+ typename Interface::gene_matrix Local_A;
+
+ typename Interface::stl_matrix Glotal_Test_stl;
+ typename Interface::stl_matrix Local_Test_stl;
+};
+
+#endif /* ACTION_PARALLEL_CHOLESKY_HH_ */
diff --git a/btl/actions/action_parallel_lu_decomp.hh b/btl/actions/action_parallel_lu_decomp.hh
new file mode 100644
index 0000000..a6b3600
--- /dev/null
+++ b/btl/actions/action_parallel_lu_decomp.hh
@@ -0,0 +1,142 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_LU_DECOMP_HH_
+#define ACTION_PARALLEL_LU_DECOMP_HH_
+
+#include "utilities.h"
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+
+#include "lapack_interface.hh"
+#include "STL_interface.hh"
+
+#include <string>
+
+template<class Interface>
+class Action_parallel_lu_decomp {
+
+public :
+
+ // Constructor
+ BTL_DONT_INLINE Action_parallel_lu_decomp( int size ) : _size(size)
+ {
+ MESSAGE("Action_parallel_lu_decomp Ctor");
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ /* Using a constant seed */
+ const unsigned seed = 3;
+ init_matrix(Global_A_stl, size, seed);
+ }
+
+ const int blocksize = std::max(std::min(size/4, 64), 2);
+ scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
+ LocalRows = desc[8];
+ LocalCols = Local_A_stl.size()/desc[8];
+
+ // Generic local matrix and vectors initialization
+ Interface::matrix_from_stl(Local_A , Local_A_stl);
+
+ _cost = 2.0*size*size*size/3.0 + static_cast<double>(size*size);
+ }
+
+
+ // Invalidate copy constructor
+ Action_parallel_lu_decomp(const Action_parallel_lu_decomp&)
+ {
+ INFOS("illegal call to Action_parallel_lu_decomp copy constructor");
+ exit(1);
+ }
+
+ // Destructor
+ ~Action_parallel_lu_decomp()
+ {
+ MESSAGE("Action_parallel_lu_decomp destructor");
+
+ // Deallocation
+ Interface::free_matrix(Local_A , Local_A_stl.size());
+ }
+
+ // Action name
+ static inline std::string name()
+ {
+ return "lu_decomp_" + Interface::name();
+ }
+
+ double nb_op_base()
+ {
+ return _cost;
+ }
+
+ BTL_DONT_INLINE void initialize()
+ {
+ }
+
+ BTL_DONT_INLINE void calculate()
+ {
+ Interface::copy_matrix(&Local_A_stl[0], Local_A, Local_A_stl.size());
+ Interface::parallel_lu_decomp(Local_A, ipiv_stl, desc);
+ }
+
+ BTL_DONT_INLINE void check_result()
+ {
+// /* Gather */
+// typename Interface::stl_matrix Global_Y;
+// typename Interface::stl_matrix Local_Y(Local_A_stl.size());
+// Interface::matrix_to_stl(Local_A, Local_Y);
+// Interface::gather_matrix(Global_Y, Local_Y, desc);
+//
+// if (iamroot) {
+//
+// typename Interface::gene_matrix A;
+// Interface::matrix_from_stl(A, Global_A_stl);
+// lapack_interface<typename Interface::real_type>::lu_decomp(&Global_A_stl[0], A, _size);
+// typename Interface::stl_vector correct(A, A+_size*_size);
+// typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(Global_Y, correct);
+// if (error > 10e-5)
+// cerr << " { !! error : " << error << " !! } ";
+//
+// Interface::free_matrix(A, _size*_size);
+// }
+
+
+// if (_size > 2) {
+// double error = Interface::test_LU(Global_A_stl, Local_A, desc);
+// if (iamroot)
+// cout << " {error: " << error << "} ";
+// }
+ }
+
+private:
+ int _size, desc[9], LocalRows, LocalCols;
+ double _cost;
+ bool iamroot;
+
+ typename Interface::stl_matrix Global_A_stl;
+ typename Interface::stl_matrix Local_A_stl;
+ typename Interface::gene_matrix Local_A;
+
+ std::vector<int> ipiv_stl;
+};
+
+
+#endif /* ACTION_PARALLEL_LU_DECOMP_HH_ */
diff --git a/btl/actions/action_parallel_matrix_vector_product.hh b/btl/actions/action_parallel_matrix_vector_product.hh
new file mode 100644
index 0000000..51eafb9
--- /dev/null
+++ b/btl/actions/action_parallel_matrix_vector_product.hh
@@ -0,0 +1,159 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_MATRIX_VECTOR_PRODUCT
+#define ACTION_PARALLEL_MATRIX_VECTOR_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include <algorithm>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+#include "blas.h"
+
+template<class Interface>
+class Action_parallel_matrix_vector_product {
+
+public :
+
+ // Ctor
+
+ BTL_DONT_INLINE Action_parallel_matrix_vector_product( int size ):_size(size)
+ {
+ MESSAGE("Action_parallel_matrix_vector_product Ctor");
+ int iZERO = 0, iONE = 1;
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ init_vector<pseudo_random>(Global_A_stl, size*size);
+ init_vector<pseudo_random>(Global_x_stl, size);
+ init_vector<null_function>(Global_y_stl, size);
+ }
+
+ const int blocksize = std::max(std::min(size/4, 64), 2);
+ Interface::scatter_matrix(Global_A_stl, Local_A_stl, descA, size, size, blocksize, blocksize);
+ Interface::scatter_matrix(Global_x_stl, Local_x_stl, descX, size, 1, blocksize, blocksize);
+ Interface::scatter_matrix(Global_y_stl, Local_y_stl, descY, size, 1, blocksize, blocksize);
+
+ // generic local matrix and vectors initialization
+
+ Interface::matrix_from_stl(Local_A_ref, Local_A_stl);
+ Interface::matrix_from_stl(Local_A , Local_A_stl);
+ Interface::vector_from_stl(Local_x_ref, Local_x_stl);
+ Interface::vector_from_stl(Local_x , Local_x_stl);
+ Interface::vector_from_stl(Local_y_ref, Local_y_stl);
+ Interface::vector_from_stl(Local_y , Local_y_stl);
+ }
+
+ // invalidate copy ctor
+ Action_parallel_matrix_vector_product( const Action_parallel_matrix_vector_product & )
+ {
+ INFOS("illegal call to Action_parallel_matrix_vector_product copy constructor");
+ exit(1);
+ }
+
+ // Dtor
+ BTL_DONT_INLINE ~Action_parallel_matrix_vector_product(){
+
+ MESSAGE("Action_parallel_matrix_vector_product destructor");
+
+ // deallocation
+
+ Interface::free_matrix(Local_A_ref, _size*_size);
+ Interface::free_vector(Local_x_ref);
+ Interface::free_vector(Local_y_ref);
+
+ Interface::free_matrix(Local_A, _size*_size);
+ Interface::free_vector(Local_x);
+ Interface::free_vector(Local_y);
+
+ }
+
+ // action name
+ static inline std::string name( void )
+ {
+ return "matrix_vector_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+ Interface::copy_matrix(Local_A_ref, Local_A, Local_A_stl.size());
+ Interface::copy_vector(Local_x_ref, Local_x, Local_x_stl.size());
+ Interface::copy_vector(Local_y_ref, Local_y, Local_y_stl.size());
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ Interface::parallel_matrix_vector_product(_size, _size, Local_A, descA, Local_x, descX, Local_y, descY);
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+ int GlobalYCols;
+ Interface::vector_to_stl(Local_y, Local_y_stl);
+
+ Interface::gather_matrix(Global_y_stl, Local_y_stl, descY);
+
+ // calculation check
+ if (iamroot) {
+
+ // Compute YTest
+ Test_y_stl.resize(_size);
+ STL_interface<typename Interface::real_type>::matrix_vector_product(Global_A_stl, Global_x_stl, Test_y_stl, _size);
+
+ typename Interface::real_type error = STL_interface<typename Interface::real_type>::norm_diff(Global_y_stl, Test_y_stl);
+
+ if (error > 1e-5)
+ std::cerr << "Error: " << error << " ";
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix Global_A_stl;
+ typename Interface::stl_vector Global_x_stl;
+ typename Interface::stl_vector Global_y_stl;
+ typename Interface::stl_vector Test_y_stl;
+
+ typename Interface::stl_matrix Local_A_stl;
+ typename Interface::stl_vector Local_x_stl;
+ typename Interface::stl_vector Local_y_stl;
+
+ typename Interface::gene_matrix Local_A_ref;
+ typename Interface::gene_vector Local_x_ref;
+ typename Interface::gene_vector Local_y_ref;
+
+ typename Interface::gene_matrix Local_A;
+ typename Interface::gene_vector Local_x;
+ typename Interface::gene_vector Local_y;
+
+ bool iamroot;
+ int _size;
+ int descA[9], descX[9], descY[9];
+
+};
+
+
+#endif
diff --git a/btl/actions/action_parallel_qr_decomp.hh b/btl/actions/action_parallel_qr_decomp.hh
new file mode 100644
index 0000000..3c50fb4
--- /dev/null
+++ b/btl/actions/action_parallel_qr_decomp.hh
@@ -0,0 +1,116 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_QR_DECOMP_HH_
+#define ACTION_PARALLEL_QR_DECOMP_HH_
+
+#include "utilities.h"
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+
+#include "lapack_interface.hh"
+#include "STL_interface.hh"
+
+#include <string>
+#include <algorithm>
+
+template<class Interface>
+class Action_parallel_qr_decomp {
+
+public :
+
+ // Constructor
+ BTL_DONT_INLINE Action_parallel_qr_decomp( int size ) : _size(size)
+ {
+ MESSAGE("Action_parallel_qr_decomp Ctor");
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ /* Using a constant seed */
+ const unsigned seed = 3;
+ init_matrix(Global_A_stl, size, seed);
+ }
+
+ const int blocksize = std::max(std::min(size/4, 64), 2);
+ scatter_matrix(Global_A_stl, Local_A_stl, desc, size, size, blocksize, blocksize);
+ LocalRows = desc[8];
+ LocalCols = Local_A_stl.size()/desc[8];
+
+ // Generic local matrix and vectors initialization
+ Interface::matrix_from_stl(Local_A , Local_A_stl);
+
+ _cost = 2.0*size*size*size;
+ }
+
+
+ // Invalidate copy constructor
+ Action_parallel_qr_decomp(const Action_parallel_qr_decomp&)
+ {
+ INFOS("illegal call to Action_parallel_qr_decomp copy constructor");
+ exit(1);
+ }
+
+ // Destructor
+ ~Action_parallel_qr_decomp()
+ {
+ MESSAGE("Action_parallel_qr_decomp destructor");
+
+ // Deallocation
+ Interface::free_matrix(Local_A , Local_A_stl.size());
+ }
+
+ // Action name
+ static inline std::string name()
+ {
+ return "qr_decomp_" + Interface::name();
+ }
+
+ double nb_op_base()
+ {
+ return _cost;
+ }
+
+ BTL_DONT_INLINE void initialize()
+ {
+ }
+
+ BTL_DONT_INLINE void calculate()
+ {
+ Interface::copy_matrix(&Local_A_stl[0], Local_A, Local_A_stl.size());
+ Interface::parallel_qr_decomp(Local_A, desc);
+ }
+
+ BTL_DONT_INLINE void check_result()
+ {
+ }
+
+private:
+ int _size, desc[9], LocalRows, LocalCols;
+ double _cost;
+ bool iamroot;
+
+ typename Interface::stl_matrix Global_A_stl;
+ typename Interface::stl_matrix Local_A_stl;
+ typename Interface::gene_matrix Local_A;
+};
+
+
+#endif /* ACTION_PARALLEL_QR_DECOMP_HH_ */
diff --git a/btl/actions/action_parallel_svd_decomp.hh b/btl/actions/action_parallel_svd_decomp.hh
new file mode 100644
index 0000000..3281886
--- /dev/null
+++ b/btl/actions/action_parallel_svd_decomp.hh
@@ -0,0 +1,151 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_SVD_DECOMP_HH_
+#define ACTION_PARALLEL_SVD_DECOMP_HH_
+
+#include "utilities.h"
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+
+#include "lapack_interface.hh"
+#include "STL_interface.hh"
+
+#include <string>
+#include <algorithm>
+
+template<class Interface>
+class Action_parallel_svd_decomp {
+
+public :
+
+ // Constructor
+ BTL_DONT_INLINE Action_parallel_svd_decomp( int size ) : _size(size)
+ {
+ MESSAGE("Action_parallel_svd_decomp Ctor");
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ init_vector<pseudo_random>(Global_A_stl, size*size);
+ init_vector<pseudo_random>(Global_U_stl, size*size);
+ init_vector<pseudo_random>(Global_V_stl, size*size);
+ }
+ init_vector<null_function>(Local_s_stl, size);
+
+ const int blocksize = std::max(std::min(size/4, 64), 2);
+ Interface::scatter_matrix(Global_A_stl, Local_A_stl, descA, size, size, blocksize, blocksize);
+ Interface::scatter_matrix(Global_U_stl, Local_U_stl, descU, size, size, blocksize, blocksize);
+ Interface::scatter_matrix(Global_V_stl, Local_V_stl, descV, size, size, blocksize, blocksize);
+ LocalRows = descA[8];
+ LocalCols = Local_A_stl.size()/descA[8];
+
+ // Generic local matrix and vectors initialization
+ Interface::matrix_from_stl(Local_A_ref, Local_A_stl);
+ Interface::matrix_from_stl(Local_A , Local_A_stl);
+ Interface::matrix_from_stl(Local_U_ref, Local_U_stl);
+ Interface::matrix_from_stl(Local_U , Local_U_stl);
+ Interface::matrix_from_stl(Local_V_ref, Local_V_stl);
+ Interface::matrix_from_stl(Local_V , Local_V_stl);
+ Interface::vector_from_stl(Local_s_ref, Local_s_stl);
+ Interface::vector_from_stl(Local_s , Local_s_stl);
+
+ _cost = 2.0*size*size*size;
+ }
+
+
+ // Invalidate copy constructor
+ Action_parallel_svd_decomp(const Action_parallel_svd_decomp&)
+ {
+ INFOS("illegal call to Action_parallel_svd_decomp copy constructor");
+ exit(1);
+ }
+
+ // Destructor
+ ~Action_parallel_svd_decomp()
+ {
+ MESSAGE("Action_parallel_svd_decomp destructor");
+
+ // Deallocation
+ Interface::free_matrix(Local_A_ref, Local_A_stl.size());
+ Interface::free_matrix(Local_A , Local_A_stl.size());
+ Interface::free_matrix(Local_U_ref, Local_U_stl.size());
+ Interface::free_matrix(Local_U , Local_U_stl.size());
+ Interface::free_matrix(Local_V_ref, Local_V_stl.size());
+ Interface::free_matrix(Local_V , Local_V_stl.size());
+ Interface::free_vector(Local_s_ref);
+ Interface::free_vector(Local_s );
+ }
+
+ // Action name
+ static inline std::string name()
+ {
+ return "svd_decomp_" + Interface::name();
+ }
+
+ double nb_op_base()
+ {
+ return _cost;
+ }
+
+ BTL_DONT_INLINE void initialize()
+ {
+ Interface::copy_matrix(Local_A_ref, Local_A, Local_A_stl.size());
+ Interface::copy_matrix(Local_U_ref, Local_U, Local_U_stl.size());
+ Interface::copy_matrix(Local_V_ref, Local_V, Local_V_stl.size());
+ Interface::copy_vector(Local_s_ref, Local_s, Local_s_stl.size());
+ }
+
+ BTL_DONT_INLINE void calculate()
+ {
+ Interface::parallel_svd_decomp(Local_A, descA, Local_U, descU, Local_V, descV, Local_s);
+ }
+
+ BTL_DONT_INLINE void check_result()
+ {
+ }
+
+private:
+ int _size, descA[9], descU[9], descV[9], LocalRows, LocalCols;
+ double _cost;
+ bool iamroot;
+
+ typename Interface::stl_matrix Global_A_stl;
+ typename Interface::stl_matrix Local_A_stl;
+ typename Interface::gene_matrix Local_A_ref;
+ typename Interface::gene_matrix Local_A;
+
+ typename Interface::stl_matrix Global_U_stl;
+ typename Interface::stl_matrix Local_U_stl;
+ typename Interface::gene_matrix Local_U_ref;
+ typename Interface::gene_matrix Local_U;
+
+ typename Interface::stl_matrix Global_V_stl;
+ typename Interface::stl_matrix Local_V_stl;
+ typename Interface::gene_matrix Local_V_ref;
+ typename Interface::gene_matrix Local_V;
+
+ typename Interface::stl_vector Local_s_stl;
+ typename Interface::gene_vector Local_s_ref;
+ typename Interface::gene_vector Local_s;
+};
+
+
+#endif /* ACTION_PARALLEL_SVD_DECOMP_HH */
diff --git a/btl/actions/action_parallel_symm_ev.hh b/btl/actions/action_parallel_symm_ev.hh
new file mode 100644
index 0000000..85a1d13
--- /dev/null
+++ b/btl/actions/action_parallel_symm_ev.hh
@@ -0,0 +1,138 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARALLEL_SYMM_EV_HH_
+#define ACTION_PARALLEL_SYMM_EV_HH_
+
+#include "utilities.h"
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+
+#include "lapack_interface.hh"
+#include "STL_interface.hh"
+
+#include <string>
+
+template<class Interface>
+class Action_parallel_symm_ev {
+
+public :
+
+ // Constructor
+ BTL_DONT_INLINE Action_parallel_symm_ev( int size ) : _size(size)
+ {
+ MESSAGE("Action_parallel_symm_ev constructor");
+
+ int myid, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ iamroot = (myid == 0);
+
+ // STL matrix and vector initialization
+ if (iamroot) {
+ init_vector<pseudo_random>(Global_A_stl, size*size);
+ init_vector<null_function>(Global_Z_stl, size*size);
+ }
+ init_vector<null_function>(Local_w_stl, size);
+
+ const int blocksize = std::max(std::min(size/4, 64), 2);
+ Interface::scatter_matrix(Global_A_stl, Local_A_stl, descA, size, size, blocksize, blocksize);
+ Interface::scatter_matrix(Global_Z_stl, Local_Z_stl, descZ, size, size, blocksize, blocksize);
+ LocalRows = descA[8];
+ LocalCols = Local_A_stl.size()/descA[8];
+
+ // Generic local matrix and vectors initialization
+ Interface::matrix_from_stl(Local_A_ref, Local_A_stl);
+ Interface::matrix_from_stl(Local_A , Local_A_stl);
+ Interface::matrix_from_stl(Local_Z_ref, Local_Z_stl);
+ Interface::matrix_from_stl(Local_Z , Local_Z_stl);
+ Interface::vector_from_stl(Local_w , Local_w_stl);
+ Interface::vector_from_stl(Local_w_ref, Local_w_stl);
+
+ _cost = size*size*size;
+ }
+
+
+ // Invalidate copy constructor
+ Action_parallel_symm_ev(const Action_parallel_symm_ev&)
+ {
+ INFOS("illegal call to Action_parallel_symm_ev copy constructor");
+ exit(1);
+ }
+
+ // Destructor
+ ~Action_parallel_symm_ev()
+ {
+ MESSAGE("Action_parallel_symm_ev destructor");
+
+ // Deallocation
+ Interface::free_matrix(Local_A_ref, Local_A_stl.size());
+ Interface::free_matrix(Local_A , Local_A_stl.size());
+ Interface::free_matrix(Local_Z_ref, Local_Z_stl.size());
+ Interface::free_matrix(Local_Z , Local_Z_stl.size());
+ Interface::free_vector(Local_w_ref);
+ Interface::free_vector(Local_w );
+ }
+
+ // Action name
+ static inline std::string name()
+ {
+ return "symm_ev_" + Interface::name();
+ }
+
+ double nb_op_base()
+ {
+ return _cost;
+ }
+
+ BTL_DONT_INLINE void initialize()
+ {
+ Interface::copy_matrix(Local_A_ref, Local_A, Local_A_stl.size());
+ Interface::copy_matrix(Local_Z_ref, Local_Z, Local_Z_stl.size());
+ Interface::copy_vector(Local_w_ref, Local_w, Local_w_stl.size());
+ }
+
+ BTL_DONT_INLINE void calculate()
+ {
+ Interface::parallel_symm_ev(Local_A, descA, Local_w, Local_Z, descZ);
+ }
+
+ BTL_DONT_INLINE void check_result()
+ {
+ }
+
+private:
+ int _size, descA[9], descZ[9], LocalRows, LocalCols;
+ double _cost;
+ bool iamroot;
+
+ typename Interface::stl_matrix Global_A_stl;
+ typename Interface::stl_matrix Local_A_stl;
+ typename Interface::gene_matrix Local_A_ref;
+ typename Interface::gene_matrix Local_A;
+
+ typename Interface::stl_matrix Global_Z_stl;
+ typename Interface::stl_matrix Local_Z_stl;
+ typename Interface::gene_matrix Local_Z_ref;
+ typename Interface::gene_matrix Local_Z;
+
+ typename Interface::stl_vector Local_w_stl;
+ typename Interface::gene_vector Local_w_ref;
+ typename Interface::gene_vector Local_w;
+};
+
+
+#endif /* ACTION_PARALLEL_SYMM_EV_HH_ */
diff --git a/btl/actions/action_partial_lu.hh b/btl/actions/action_partial_lu.hh
new file mode 100644
index 0000000..770ea1d
--- /dev/null
+++ b/btl/actions/action_partial_lu.hh
@@ -0,0 +1,125 @@
+//=====================================================
+// File : action_lu_decomp.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_PARTIAL_LU
+#define ACTION_PARTIAL_LU
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_partial_lu {
+
+public :
+
+ // Ctor
+
+ Action_partial_lu( int size ):_size(size)
+ {
+ MESSAGE("Action_partial_lu Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl,_size);
+ init_matrix<null_function>(C_stl,_size);
+
+ // make sure X is invertible
+ for (int i=0; i<_size; ++i)
+ X_stl[i][i] = X_stl[i][i] * 1e2 + 1;
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref,X_stl);
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::matrix_from_stl(C,C_stl);
+
+ _cost = 2.0*size*size*size/3.0 + size*size;
+ }
+
+ // invalidate copy ctor
+
+ Action_partial_lu( const Action_partial_lu & )
+ {
+ INFOS("illegal call to Action_partial_lu Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_partial_lu( void ){
+
+ MESSAGE("Action_partial_lu Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref,_size);
+ Interface::free_matrix(X,_size);
+ Interface::free_matrix(C,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "partial_lu_decomp_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::partial_lu_decomp(X,C,_size);
+ }
+
+ void check_result( void ){
+ // calculation check
+// Interface::matrix_to_stl(C,resu_stl);
+
+// STL_interface<typename Interface::real_type>::lu_decomp(X_stl,C_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_qr_decomp.hh b/btl/actions/action_qr_decomp.hh
new file mode 100644
index 0000000..15a4619
--- /dev/null
+++ b/btl/actions/action_qr_decomp.hh
@@ -0,0 +1,112 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_QR_DECOMP
+#define ACTION_QR_DECOMP
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_qr_decomp {
+
+public :
+
+ // Ctor
+
+ Action_qr_decomp( int size ) : _size(size)
+ {
+ MESSAGE("Action_qr_decomp Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl ,_size);
+ init_matrix<null_function>(C_stl, _size);
+ init_vector<null_function>(tau_stl, _size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref, X_stl);
+ Interface::matrix_from_stl(X, X_stl);
+ Interface::matrix_from_stl(C, C_stl);
+ Interface::vector_from_stl(tau, tau_stl);
+
+ _cost = 2.0*size*size*size/3.0 + size*size + 1.0*size/3.0 - 2;
+ }
+
+ // invalidate copy ctor
+
+ Action_qr_decomp( const Action_qr_decomp & )
+ {
+ INFOS("illegal call to Action_qr_decomp Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_qr_decomp( void ){
+
+ MESSAGE("Action_qr_decomp Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref, _size);
+ Interface::free_matrix(X, _size);
+ Interface::free_matrix(C, _size);
+ Interface::free_vector(tau);
+ }
+
+ // action name
+
+ static inline std::string name()
+ {
+ return "qr_decomp_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref, X, _size);
+ }
+
+ inline void calculate( void ) {
+ Interface::qr_decomp(X, C, tau, _size);
+ }
+
+ void check_result( void ){
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix C_stl;
+ typename Interface::stl_vector tau_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix C;
+ typename Interface::gene_vector tau;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_rot.hh b/btl/actions/action_rot.hh
new file mode 100644
index 0000000..df822a6
--- /dev/null
+++ b/btl/actions/action_rot.hh
@@ -0,0 +1,116 @@
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_ROT
+#define ACTION_ROT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_rot {
+
+public :
+
+ // Ctor
+ BTL_DONT_INLINE Action_rot( int size ):_size(size)
+ {
+ MESSAGE("Action_rot Ctor");
+
+ // STL matrix and vector initialization
+ typename Interface::stl_matrix tmp;
+ init_vector<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::vector_from_stl(A_ref,A_stl);
+ Interface::vector_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ }
+
+ // invalidate copy ctor
+ Action_rot( const Action_rot & )
+ {
+ INFOS("illegal call to Action_rot Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+ BTL_DONT_INLINE ~Action_rot( void ){
+ MESSAGE("Action_rot Dtor");
+ Interface::free_vector(A);
+ Interface::free_vector(B);
+ Interface::free_vector(A_ref);
+ Interface::free_vector(B_ref);
+ }
+
+ // action name
+ static inline std::string name( void )
+ {
+ return "rot_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 6.0*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+ Interface::copy_vector(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin rot");
+ Interface::rot(A,B,0.5,0.6,_size);
+ BTL_ASM_COMMENT("end rot");
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+ // calculation check
+// Interface::vector_to_stl(X,resu_stl);
+
+// STL_interface<typename Interface::real_type>::rot(A_stl,B_stl,X_stl,_size);
+
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+// if (error>1.e-3){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_vector A_stl;
+ typename Interface::stl_vector B_stl;
+
+ typename Interface::gene_vector A_ref;
+ typename Interface::gene_vector B_ref;
+
+ typename Interface::gene_vector A;
+ typename Interface::gene_vector B;
+
+ int _size;
+};
+
+
+#endif
diff --git a/btl/actions/action_stev.hh b/btl/actions/action_stev.hh
new file mode 100644
index 0000000..e564571
--- /dev/null
+++ b/btl/actions/action_stev.hh
@@ -0,0 +1,119 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_STEV
+#define ACTION_STEV
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_stev {
+
+public :
+
+ // Ctor
+
+ Action_stev( int size ) : _size(size)
+ {
+ MESSAGE("Action_stev Ctor");
+
+ // STL vector initialization
+ init_vector<pseudo_random>(D_stl, _size);
+ init_vector<pseudo_random>(E_stl, max(0, _size-1));
+ init_matrix<null_function>(V_stl, _size);
+ init_vector<null_function>(W_stl, _size);
+
+ // generic matrix and vector initialization
+ Interface::vector_from_stl(D_ref, D_stl);
+ Interface::vector_from_stl(E_ref, E_stl);
+ Interface::vector_from_stl(D, D_stl);
+ Interface::vector_from_stl(E, E_stl);
+ Interface::matrix_from_stl(V, V_stl);
+ Interface::vector_from_stl(W, W_stl);
+
+ // FIXME: correct?
+ _cost = size*size*size;
+ }
+
+ // invalidate copy ctor
+
+ Action_stev( const Action_stev& )
+ {
+ INFOS("illegal call to Action_stev Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_stev( void ){
+
+ MESSAGE("Action_stev Dtor");
+
+ // deallocation
+ Interface::free_vector(D_ref);
+ Interface::free_vector(E_ref);
+ Interface::free_vector(D);
+ Interface::free_vector(E);
+ Interface::free_matrix(V, _size);
+ Interface::free_vector(W);
+ }
+
+ // action name
+
+ static inline std::string name()
+ {
+ return "stev_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_vector(D_ref, D, _size);
+ Interface::copy_vector(E_ref, E, _size-1);
+ }
+
+ inline void calculate( void ) {
+ Interface::stev(D, E, W, V, _size);
+ }
+
+ void check_result( void ){
+ }
+
+private :
+
+ typename Interface::stl_vector D_stl, E_stl;
+ typename Interface::stl_matrix V_stl;
+ typename Interface::stl_vector W_stl;
+
+ typename Interface::gene_vector D_ref, E_ref;
+ typename Interface::gene_vector D, E;
+ typename Interface::gene_matrix V;
+ typename Interface::gene_vector W;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_svd_decomp.hh b/btl/actions/action_svd_decomp.hh
new file mode 100644
index 0000000..be6740a
--- /dev/null
+++ b/btl/actions/action_svd_decomp.hh
@@ -0,0 +1,115 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_SVD_DECOMP
+#define ACTION_SVD_DECOMP
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_svd_decomp {
+
+public :
+
+ // Ctor
+
+ Action_svd_decomp( int size ) : _size(size)
+ {
+ MESSAGE("Action_svd_decomp Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(X_stl ,_size);
+ init_matrix<null_function>(U_stl, _size);
+ init_matrix<null_function>(VT_stl, _size);
+ init_vector<null_function>(S_stl, _size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref, X_stl);
+ Interface::matrix_from_stl(X, X_stl);
+ Interface::matrix_from_stl(U, U_stl);
+ Interface::matrix_from_stl(VT, VT_stl);
+ Interface::vector_from_stl(S, S_stl);
+
+ _cost = 4*size*size*size;
+ }
+
+ // invalidate copy ctor
+
+ Action_svd_decomp( const Action_svd_decomp & )
+ {
+ INFOS("illegal call to Action_svd_decomp Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_svd_decomp( void ){
+
+ MESSAGE("Action_svd_decomp Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref, _size);
+ Interface::free_matrix(X, _size);
+ Interface::free_matrix(U, _size);
+ Interface::free_matrix(VT, _size);
+ Interface::free_vector(S);
+ }
+
+ // action name
+
+ static inline std::string name()
+ {
+ return "svd_decomp_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref, X, _size);
+ }
+
+ inline void calculate( void ) {
+ Interface::svd_decomp(X, U, S, VT, _size);
+ }
+
+ void check_result( void ){
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix U_stl, VT_stl;
+ typename Interface::stl_vector S_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix U, VT;
+ typename Interface::gene_vector S;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_syev.hh b/btl/actions/action_syev.hh
new file mode 100644
index 0000000..b8f33be
--- /dev/null
+++ b/btl/actions/action_syev.hh
@@ -0,0 +1,113 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_SYEV
+#define ACTION_SYEV
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_syev {
+
+public :
+
+ // Ctor
+
+ Action_syev( int size ) : _size(size)
+ {
+ MESSAGE("Action_syev Ctor");
+
+ // STL vector initialization
+ init_matrix_symm<pseudo_random>(X_stl ,_size);
+ init_matrix<null_function>(V_stl, _size);
+ init_vector<null_function>(W_stl, _size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X_ref, X_stl);
+ Interface::matrix_from_stl(X, X_stl);
+ Interface::matrix_from_stl(V, V_stl);
+ Interface::vector_from_stl(W, W_stl);
+
+ // FIXME: correct?
+ _cost = size*size*size;
+ }
+
+ // invalidate copy ctor
+
+ Action_syev( const Action_syev& )
+ {
+ INFOS("illegal call to Action_syev Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_syev( void ){
+
+ MESSAGE("Action_syev Dtor");
+
+ // deallocation
+ Interface::free_matrix(X_ref, _size);
+ Interface::free_matrix(X, _size);
+ Interface::free_matrix(V, _size);
+ Interface::free_vector(W);
+ }
+
+ // action name
+
+ static inline std::string name()
+ {
+ return "syev_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ Interface::copy_matrix(X_ref, X, _size);
+ }
+
+ inline void calculate( void ) {
+ Interface::syev(X, V, W, _size);
+ }
+
+ void check_result( void ){
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix V_stl;
+ typename Interface::stl_vector W_stl;
+
+ typename Interface::gene_matrix X_ref;
+ typename Interface::gene_matrix X;
+ typename Interface::gene_matrix V;
+ typename Interface::gene_vector W;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_symm_ev.hh b/btl/actions/action_symm_ev.hh
new file mode 100644
index 0000000..c696da2
--- /dev/null
+++ b/btl/actions/action_symm_ev.hh
@@ -0,0 +1,104 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_SYMM_EV
+#define ACTION_SYMM_EV
+
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+template<class Interface>
+class Action_symm_ev {
+
+public:
+
+ // Ctor
+ Action_symm_ev( int size ) : _size(size)
+ {
+ MESSAGE("Action_symm_ev Ctor");
+
+ // STL matrix initialization
+ init_matrix_symm<pseudo_random>(X_stl,_size);
+ init_vector<pseudo_random>(W_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::vector_from_stl(W,W_stl);
+
+
+ }
+
+ // invalidate copy ctor
+
+ Action_symm_ev( const Action_symm_ev & )
+ {
+ INFOS("illegal call to Action_symm_ev Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_symm_ev( void ){
+
+ MESSAGE("Action_symm_ev Dtor");
+
+ // deallocation
+ Interface::free_matrix(X,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "symm_ev_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ // TODO: is this right?
+ return _size*_size;
+ }
+
+ inline void initialize( void ){
+ }
+
+ inline void calculate( void ) {
+ Interface::symm_ev(X,W,_size);
+ }
+
+ void check_result( void ) {
+ // TODO: check result
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_vector W_stl;
+
+ typename Interface::gene_matrix X;
+ typename Interface::gene_vector W;
+
+ int _size;
+ double _cost;
+
+};
+
+
+#endif // ACTION_SYMM_EV
diff --git a/btl/actions/action_symv.hh b/btl/actions/action_symv.hh
new file mode 100644
index 0000000..a32b9df
--- /dev/null
+++ b/btl/actions/action_symv.hh
@@ -0,0 +1,139 @@
+//=====================================================
+// File : action_symv.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_SYMV
+#define ACTION_SYMV
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_symv {
+
+public :
+
+ // Ctor
+
+ BTL_DONT_INLINE Action_symv( int size ):_size(size)
+ {
+ MESSAGE("Action_symv Ctor");
+
+ // STL matrix and vector initialization
+ init_matrix_symm<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<null_function>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+
+ }
+
+ // invalidate copy ctor
+
+ Action_symv( const Action_symv & )
+ {
+ INFOS("illegal call to Action_symv Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+ BTL_DONT_INLINE ~Action_symv( void ){
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "symv_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin symv");
+ Interface::symv(A,B,X,_size);
+ BTL_ASM_COMMENT("end symv");
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+ if (_size>128) return;
+ // calculation check
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::symv(A_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-5){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(0);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+
+ int _size;
+
+};
+
+
+#endif
diff --git a/btl/actions/action_syr2.hh b/btl/actions/action_syr2.hh
new file mode 100644
index 0000000..7c6712b
--- /dev/null
+++ b/btl/actions/action_syr2.hh
@@ -0,0 +1,133 @@
+//=====================================================
+// File : action_syr2.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_SYR2
+#define ACTION_SYR2
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_syr2 {
+
+public :
+
+ // Ctor
+
+ BTL_DONT_INLINE Action_syr2( int size ):_size(size)
+ {
+ // STL matrix and vector initialization
+ typename Interface::stl_matrix tmp;
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<pseudo_random>(X_stl,_size);
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::vector_from_stl(B_ref,B_stl);
+ Interface::vector_from_stl(B,B_stl);
+ Interface::vector_from_stl(X_ref,X_stl);
+ Interface::vector_from_stl(X,X_stl);
+ }
+
+ // invalidate copy ctor
+ Action_syr2( const Action_syr2 & )
+ {
+ INFOS("illegal call to Action_syr2 Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+ BTL_DONT_INLINE ~Action_syr2( void ){
+ Interface::free_matrix(A,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_vector(B_ref);
+ Interface::free_vector(X_ref);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "syr2_" + Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return 2.0*_size*_size;
+ }
+
+ BTL_DONT_INLINE void initialize( void ){
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_vector(B_ref,B,_size);
+ Interface::copy_vector(X_ref,X,_size);
+ }
+
+ BTL_DONT_INLINE void calculate( void ) {
+ BTL_ASM_COMMENT("#begin syr2");
+ Interface::syr2(A,B,X,_size);
+ BTL_ASM_COMMENT("end syr2");
+ }
+
+ BTL_DONT_INLINE void check_result( void ){
+ // calculation check
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::syr2(A_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-3){
+ INFOS("WRONG CALCULATION...residual=" << error);
+// exit(0);
+ }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_vector B_ref;
+ typename Interface::gene_vector X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_vector B;
+ typename Interface::gene_vector X;
+
+
+ int _size;
+
+};
+
+
+#endif
diff --git a/btl/actions/action_trisolve.hh b/btl/actions/action_trisolve.hh
new file mode 100644
index 0000000..d6f0b47
--- /dev/null
+++ b/btl/actions/action_trisolve.hh
@@ -0,0 +1,137 @@
+//=====================================================
+// File : action_trisolve.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_TRISOLVE
+#define ACTION_TRISOLVE
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_trisolve {
+
+public :
+
+ // Ctor
+
+ Action_trisolve( int size ):_size(size)
+ {
+ MESSAGE("Action_trisolve Ctor");
+
+ // STL vector initialization
+ init_matrix<pseudo_random>(L_stl,_size);
+ init_vector<pseudo_random>(B_stl,_size);
+ init_vector<null_function>(X_stl,_size);
+ for (int j=0; j<_size; ++j)
+ {
+ for (int i=0; i<j; ++i)
+ L_stl[j][i] = 0;
+ L_stl[j][j] += 3;
+ }
+
+ init_vector<null_function>(resu_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(L,L_stl);
+ Interface::vector_from_stl(X,X_stl);
+ Interface::vector_from_stl(B,B_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size; ++j)
+ {
+ _cost += 2*j + 1;
+ }
+ }
+
+ // invalidate copy ctor
+
+ Action_trisolve( const Action_trisolve & )
+ {
+ INFOS("illegal call to Action_trisolve Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_trisolve( void ){
+
+ MESSAGE("Action_trisolve Dtor");
+
+ // deallocation
+ Interface::free_matrix(L,_size);
+ Interface::free_vector(B);
+ Interface::free_vector(X);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "trisolve_vector_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+ //Interface::copy_vector(X_ref,X,_size);
+ }
+
+ inline void calculate( void ) {
+ Interface::trisolve_lower(L,B,X,_size);
+ }
+
+ void check_result(){
+ if (_size>128) return;
+ // calculation check
+ Interface::vector_to_stl(X,resu_stl);
+
+ STL_interface<typename Interface::real_type>::trisolve_lower(L_stl,B_stl,X_stl,_size);
+
+ typename Interface::real_type error=
+ STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+
+ if (error>1.e-4){
+ INFOS("WRONG CALCULATION...residual=" << error);
+ exit(2);
+ } //else INFOS("CALCULATION OK...residual=" << error);
+
+ }
+
+private :
+
+ typename Interface::stl_matrix L_stl;
+ typename Interface::stl_vector X_stl;
+ typename Interface::stl_vector B_stl;
+ typename Interface::stl_vector resu_stl;
+
+ typename Interface::gene_matrix L;
+ typename Interface::gene_vector X;
+ typename Interface::gene_vector B;
+
+ int _size;
+ double _cost;
+};
+
+#endif
diff --git a/btl/actions/action_trisolve_matrix.hh b/btl/actions/action_trisolve_matrix.hh
new file mode 100644
index 0000000..0fc2bb9
--- /dev/null
+++ b/btl/actions/action_trisolve_matrix.hh
@@ -0,0 +1,165 @@
+//=====================================================
+// File : action_matrix_matrix_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_TRISOLVE_MATRIX_PRODUCT
+#define ACTION_TRISOLVE_MATRIX_PRODUCT
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_trisolve_matrix {
+
+public :
+
+ // Ctor
+
+ Action_trisolve_matrix( int size ):_size(size)
+ {
+ MESSAGE("Action_trisolve_matrix Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_matrix<pseudo_random>(B_stl,_size);
+ init_matrix<null_function>(X_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ for (int j=0; j<_size; ++j)
+ {
+ for (int i=0; i<j; ++i)
+ A_stl[j][i] = 0;
+ A_stl[j][j] += 3;
+ }
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(B_ref,B_stl);
+ Interface::matrix_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::matrix_from_stl(B,B_stl);
+ Interface::matrix_from_stl(X,X_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size; ++j)
+ {
+ _cost += 2*j + 1;
+ }
+ _cost *= _size;
+ }
+
+ // invalidate copy ctor
+
+ Action_trisolve_matrix( const Action_trisolve_matrix & )
+ {
+ INFOS("illegal call to Action_trisolve_matrix Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ ~Action_trisolve_matrix( void ){
+
+ MESSAGE("Action_trisolve_matrix Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_matrix(B,_size);
+ Interface::free_matrix(X,_size);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_matrix(B_ref,_size);
+ Interface::free_matrix(X_ref,_size);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "trisolve_matrix_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_matrix(B_ref,B,_size);
+ Interface::copy_matrix(X_ref,X,_size);
+
+ }
+
+ inline void calculate( void ) {
+ Interface::trisolve_lower_matrix(A,B,X,_size);
+ }
+
+ void check_result( void ){
+
+ // calculation check
+
+// Interface::matrix_to_stl(X,resu_stl);
+//
+// STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// // exit(1);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_matrix B_stl;
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_matrix B_ref;
+ typename Interface::gene_matrix X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_matrix B;
+ typename Interface::gene_matrix X;
+
+ int _size;
+ double _cost;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/action_trmm.hh b/btl/actions/action_trmm.hh
new file mode 100644
index 0000000..8f78138
--- /dev/null
+++ b/btl/actions/action_trmm.hh
@@ -0,0 +1,165 @@
+//=====================================================
+// File : action_matrix_matrix_product.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_TRMM
+#define ACTION_TRMM
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+using namespace std;
+
+template<class Interface>
+class Action_trmm {
+
+public :
+
+ // Ctor
+
+ Action_trmm( int size ):_size(size)
+ {
+ MESSAGE("Action_trmm Ctor");
+
+ // STL matrix and vector initialization
+
+ init_matrix<pseudo_random>(A_stl,_size);
+ init_matrix<pseudo_random>(B_stl,_size);
+ init_matrix<null_function>(X_stl,_size);
+ init_matrix<null_function>(resu_stl,_size);
+
+ for (int j=0; j<_size; ++j)
+ {
+ for (int i=0; i<j; ++i)
+ A_stl[j][i] = 0;
+ A_stl[j][j] += 3;
+ }
+
+ // generic matrix and vector initialization
+
+ Interface::matrix_from_stl(A_ref,A_stl);
+ Interface::matrix_from_stl(B_ref,B_stl);
+ Interface::matrix_from_stl(X_ref,X_stl);
+
+ Interface::matrix_from_stl(A,A_stl);
+ Interface::matrix_from_stl(B,B_stl);
+ Interface::matrix_from_stl(X,X_stl);
+
+ _cost = 0;
+ for (int j=0; j<_size; ++j)
+ {
+ _cost += 2*j + 1;
+ }
+ _cost *= _size;
+ }
+
+ // invalidate copy ctor
+
+ Action_trmm( const Action_trmm & )
+ {
+ INFOS("illegal call to Action_trmm Copy Ctor");
+ exit(0);
+ }
+
+ // Dtor
+
+ ~Action_trmm( void ){
+
+ MESSAGE("Action_trmm Dtor");
+
+ // deallocation
+
+ Interface::free_matrix(A,_size);
+ Interface::free_matrix(B,_size);
+ Interface::free_matrix(X,_size);
+
+ Interface::free_matrix(A_ref,_size);
+ Interface::free_matrix(B_ref,_size);
+ Interface::free_matrix(X_ref,_size);
+
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "trmm_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ return _cost;
+ }
+
+ inline void initialize( void ){
+
+ Interface::copy_matrix(A_ref,A,_size);
+ Interface::copy_matrix(B_ref,B,_size);
+ Interface::copy_matrix(X_ref,X,_size);
+
+ }
+
+ inline void calculate( void ) {
+ Interface::trmm(A,B,X,_size);
+ }
+
+ void check_result( void ){
+
+ // calculation check
+
+// Interface::matrix_to_stl(X,resu_stl);
+//
+// STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,_size);
+//
+// typename Interface::real_type error=
+// STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
+//
+// if (error>1.e-6){
+// INFOS("WRONG CALCULATION...residual=" << error);
+// // exit(1);
+// }
+
+ }
+
+private :
+
+ typename Interface::stl_matrix A_stl;
+ typename Interface::stl_matrix B_stl;
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_matrix resu_stl;
+
+ typename Interface::gene_matrix A_ref;
+ typename Interface::gene_matrix B_ref;
+ typename Interface::gene_matrix X_ref;
+
+ typename Interface::gene_matrix A;
+ typename Interface::gene_matrix B;
+ typename Interface::gene_matrix X;
+
+ int _size;
+ double _cost;
+
+};
+
+
+#endif
+
+
+
diff --git a/btl/actions/base_action_fftw.hh b/btl/actions/base_action_fftw.hh
new file mode 100644
index 0000000..fb32b51
--- /dev/null
+++ b/btl/actions/base_action_fftw.hh
@@ -0,0 +1,86 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BASE_ACTION_FFTW_HH
+#define BASE_ACTION_FFTW_HH
+
+#include "utilities.h"
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+
+inline int power(const int& base, const int& exp) {
+ int ret = 1;
+ for (int i = 0; i < exp; ++i)
+ ret *= base;
+ return ret;
+}
+
+template<class Interface>
+class Action_FFTW_base
+{
+public:
+ // Constructor
+ Action_FFTW_base(const int& size, const int& dimensions) :
+ size_(size), dimensions_(dimensions), N_(power(size, dimensions))
+ {
+ // STL vector initialization
+ init_vector < pseudo_random > (X_stl, N_);
+ init_vector < null_function > (Y_stl, N_);
+
+ // Generic vector initialization
+ Interface::vector_from_stl(X, X_stl);
+ Interface::vector_from_stl(Y, Y_stl);
+
+ // To be done by the child:
+ /* initialize plan! */
+ }
+
+ // Invalidate copy constructor
+ Action_FFTW_base( const Action_FFTW_base & )
+ {
+ INFOS("illegal call to Action_FFTW_base Copy Ctor");
+ exit(1);
+ }
+
+ // Destructor:
+ // frees the memory
+ ~Action_FFTW_base()
+ {
+ Interface::free_vector(X);
+ Interface::free_vector(Y);
+ }
+
+ inline void initialize() { }
+
+ inline void calculate( void ) {
+ Interface::fftw_run(p);
+ }
+
+ void check_result( void ){
+ }
+
+
+protected:
+ const int size_, dimensions_, N_;
+
+ typename Interface::stl_vector X_stl, Y_stl;
+ typename Interface::gene_vector X, Y;
+
+ typename Interface::plan p;
+};
+
+#endif /* BASE_ACTION_FFTW_HH */
diff --git a/btl/actions/basic_actions.hh b/btl/actions/basic_actions.hh
new file mode 100644
index 0000000..a3333ea
--- /dev/null
+++ b/btl/actions/basic_actions.hh
@@ -0,0 +1,21 @@
+
+#include "action_axpy.hh"
+#include "action_axpby.hh"
+
+#include "action_matrix_vector_product.hh"
+#include "action_atv_product.hh"
+
+#include "action_matrix_matrix_product.hh"
+// #include "action_ata_product.hh"
+#include "action_aat_product.hh"
+
+#include "action_trisolve.hh"
+#include "action_trmm.hh"
+#include "action_symv.hh"
+// #include "action_symm.hh"
+#include "action_syr2.hh"
+#include "action_ger.hh"
+#include "action_rot.hh"
+
+// #include "action_lu_solve.hh"
+
diff --git a/btl/actions/fftw_actions.hh b/btl/actions/fftw_actions.hh
new file mode 100644
index 0000000..b7a6f35
--- /dev/null
+++ b/btl/actions/fftw_actions.hh
@@ -0,0 +1,26 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef ACTION_FFTW
+#define ACTION_FFTW
+
+#include "base_action_fftw.hh"
+#include "action_fftw_1d.hh"
+#include "action_fftw_2d.hh"
+#include "action_fftw_3d.hh"
+
+#endif // ACTION_FFTW
diff --git a/btl/data/action_settings.txt b/btl/data/action_settings.txt
new file mode 100644
index 0000000..da80f56
--- /dev/null
+++ b/btl/data/action_settings.txt
@@ -0,0 +1,18 @@
+aat ; "{/*1.5 A x A^T}" ; "matrix size" ; 4:3000
+ata ; "{/*1.5 A^T x A}" ; "matrix size" ; 4:3000
+atv ; "{/*1.5 matrix^T x vector}" ; "matrix size" ; 4:3000
+axpby ; "{/*1.5 Y = alpha X + beta Y}" ; "vector size" ; 5:1000000
+axpy ; "{/*1.5 Y += alpha X}" ; "vector size" ; 5:1000000
+matrix_matrix ; "{/*1.5 matrix matrix product}" ; "matrix size" ; 4:3000
+matrix_vector ; "{/*1.5 matrix vector product}" ; "matrix size" ; 4:3000
+trisolve_vector ; "{/*1.5 triangular solver - vector (X = inv(L) X)}" ; "size" ; 4:3000
+trisolve_matrix ; "{/*1.5 triangular solver - matrix (M = inv(L) M)}" ; "size" ; 4:3000
+cholesky ; "{/*1.5 Cholesky decomposition}" ; "matrix size" ; 4:3000
+complete_lu_decomp ; "{/*1.5 Complete LU decomposition}" ; "matrix size" ; 4:3000
+partial_lu_decomp ; "{/*1.5 Partial LU decomposition}" ; "matrix size" ; 4:3000
+tridiagonalization ; "{/*1.5 Tridiagonalization}" ; "matrix size" ; 4:3000
+hessenberg ; "{/*1.5 Hessenberg decomposition}" ; "matrix size" ; 4:3000
+symv ; "{/*1.5 symmetric matrix vector product}" ; "matrix size" ; 4:3000
+syr2 ; "{/*1.5 symmretric rank-2 update (A += u^T v + u v^T)}" ; "matrix size" ; 4:3000
+ger ; "{/*1.5 general rank-1 update (A += u v^T)}" ; "matrix size" ; 4:3000
+rot ; "{/*1.5 apply rotation in the plane}" ; "vector size" ; 4:1000000 \ No newline at end of file
diff --git a/btl/data/gnuplot_common_settings.hh b/btl/data/gnuplot_common_settings.hh
new file mode 100644
index 0000000..6f677df
--- /dev/null
+++ b/btl/data/gnuplot_common_settings.hh
@@ -0,0 +1,87 @@
+set noclip points
+set clip one
+set noclip two
+set bar 1.000000
+set border 31 lt -1 lw 1.000
+set xdata
+set ydata
+set zdata
+set x2data
+set y2data
+set boxwidth
+set dummy x,y
+set format x "%g"
+set format y "%g"
+set format x2 "%g"
+set format y2 "%g"
+set format z "%g"
+set angles radians
+set nogrid
+set key title ""
+set key left top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0
+set nolabel
+set noarrow
+# set nolinestyle # deprecated
+set nologscale
+set logscale x 10
+set offsets 0, 0, 0, 0
+set pointsize 1
+set encoding default
+set nopolar
+set noparametric
+set view 60, 30, 1, 1
+set samples 100, 100
+set isosamples 10, 10
+set surface
+set nocontour
+set clabel '%8.3g'
+set mapping cartesian
+set nohidden3d
+set cntrparam order 4
+set cntrparam linear
+set cntrparam levels auto 5
+set cntrparam points 5
+set size ratio 0 1,1
+set origin 0,0
+# set data style lines
+# set function style lines
+set xzeroaxis lt -2 lw 1.000
+set x2zeroaxis lt -2 lw 1.000
+set yzeroaxis lt -2 lw 1.000
+set y2zeroaxis lt -2 lw 1.000
+set tics in
+set ticslevel 0.5
+set tics scale 1, 0.5
+set mxtics default
+set mytics default
+set mx2tics default
+set my2tics default
+set xtics border mirror norotate autofreq
+set ytics border mirror norotate autofreq
+set ztics border nomirror norotate autofreq
+set nox2tics
+set noy2tics
+set timestamp "" bottom norotate offset 0,0
+set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] )
+set trange [ * : * ] noreverse nowriteback # (currently [-5:5] )
+set urange [ * : * ] noreverse nowriteback # (currently [-5:5] )
+set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] )
+set xlabel "matrix size" offset 0,0
+set x2label "" offset 0,0
+set timefmt "%d/%m/%y\n%H:%M"
+set xrange [ 10 : 1000 ] noreverse nowriteback
+set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] )
+set ylabel "MFLOPS" offset 0,0
+set y2label "" offset 0,0
+set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] )
+set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] )
+set zlabel "" offset 0,0
+set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] )
+set zero 1e-08
+set lmargin -1
+set bmargin -1
+set rmargin -1
+set tmargin -1
+set locale "C"
+set xrange [4:1024]
+
diff --git a/btl/data/go_mean b/btl/data/go_mean
new file mode 100755
index 0000000..176c3c9
--- /dev/null
+++ b/btl/data/go_mean
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+if [ $# < 1 ]; then
+ echo "Usage: $0 working_directory [tiny|large [prefix]]"
+else
+
+mkdir -p $1
+##cp ../libs/*/*.dat $1
+
+mode=large
+if [ $# > 2 ]; then
+ mode=$2
+fi
+if [ $# > 3 ]; then
+ prefix=$3
+fi
+
+EIGENDIR=`cat eigen_root_dir.txt`
+
+webpagefilename=$1/index.html
+meanstatsfilename=$1/mean.html
+
+echo '' > $meanstatsfilename
+echo '' > $webpagefilename
+echo '<p><strong>Configuration</strong>' >> $webpagefilename
+echo '<ul>'\
+ '<li>' `cat /proc/cpuinfo | grep "model name" | head -n 1`\
+ ' (' `uname -m` ')</li>'\
+ '<li> compiler: ' `cat compiler_version.txt` '</li>'\
+ '<li> eigen3: ' `hg identify -i $EIGENDIR` '</li>'\
+ '</ul>' \
+ '</p>' >> $webpagefilename
+
+source mk_mean_script.sh axpy $1 11 2500 100000 250000 $mode $prefix
+source mk_mean_script.sh axpby $1 11 2500 100000 250000 $mode $prefix
+source mk_mean_script.sh matrix_vector $1 11 50 300 1000 $mode $prefix
+source mk_mean_script.sh atv $1 11 50 300 1000 $mode $prefix
+source mk_mean_script.sh matrix_matrix $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh aat $1 11 100 300 1000 $mode $prefix
+# source mk_mean_script.sh ata $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh trisolve_vector $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh trisolve_matrix $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh cholesky $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh partial_lu_decomp $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh tridiagonalization $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh hessenberg $1 11 100 300 1000 $mode $prefix
+source mk_mean_script.sh symv $1 11 50 300 1000 $mode $prefix
+source mk_mean_script.sh syr2 $1 11 50 300 1000 $mode $prefix
+source mk_mean_script.sh ger $1 11 50 300 1000 $mode $prefix
+source mk_mean_script.sh rot $1 11 2500 100000 250000 $mode $prefix
+source mk_mean_script.sh complete_lu_decomp $1 11 100 300 1000 $mode $prefix
+
+fi
+
+## compile the web page ##
+
+#echo `cat footer.html` >> $webpagefilename \ No newline at end of file
diff --git a/btl/data/mean.cxx b/btl/data/mean.cxx
new file mode 100644
index 0000000..c567ef3
--- /dev/null
+++ b/btl/data/mean.cxx
@@ -0,0 +1,182 @@
+//=====================================================
+// File : mean.cxx
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "utilities.h"
+#include <vector>
+#include <string>
+#include <iostream>
+#include <fstream>
+#include "bench_parameter.hh"
+#include "utils/xy_file.hh"
+#include <set>
+
+using namespace std;
+
+double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max);
+
+class Lib_Mean{
+
+public:
+ Lib_Mean( void ):_lib_name(),_mean_in_cache(),_mean_out_of_cache(){
+ MESSAGE("Lib_mean Default Ctor");
+ MESSAGE("!!! should not be used");
+ exit(0);
+ }
+ Lib_Mean(const string & name, const double & mic, const double & moc):_lib_name(name),_mean_in_cache(mic),_mean_out_of_cache(moc){
+ MESSAGE("Lib_mean Ctor");
+ }
+ Lib_Mean(const Lib_Mean & lm):_lib_name(lm._lib_name),_mean_in_cache(lm._mean_in_cache),_mean_out_of_cache(lm._mean_out_of_cache){
+ MESSAGE("Lib_mean Copy Ctor");
+ }
+ ~Lib_Mean( void ){
+ MESSAGE("Lib_mean Dtor");
+ }
+
+ double _mean_in_cache;
+ double _mean_out_of_cache;
+ string _lib_name;
+
+ bool operator < ( const Lib_Mean &right) const
+ {
+ //return ( this->_mean_out_of_cache > right._mean_out_of_cache) ;
+ return ( this->_mean_in_cache > right._mean_in_cache) ;
+ }
+
+};
+
+
+int main( int argc , char *argv[] )
+{
+
+ if (argc<6){
+ INFOS("!!! Error ... usage : main what mic Mic moc Moc filename1 finename2...");
+ exit(0);
+ }
+ INFOS(argc);
+
+ int min_in_cache=atoi(argv[2]);
+ int max_in_cache=atoi(argv[3]);
+ int min_out_of_cache=atoi(argv[4]);
+ int max_out_of_cache=atoi(argv[5]);
+
+
+ multiset<Lib_Mean> s_lib_mean ;
+
+ for (int i=6;i<argc;i++){
+
+ string filename=argv[i];
+
+ INFOS(filename);
+
+ double mic=0;
+ double moc=0;
+
+ {
+
+ vector<int> tab_sizes;
+ vector<double> tab_mflops;
+
+ read_xy_file(filename,tab_sizes,tab_mflops);
+
+ mic=mean_calc(tab_sizes,tab_mflops,min_in_cache,max_in_cache);
+ moc=mean_calc(tab_sizes,tab_mflops,min_out_of_cache,max_out_of_cache);
+
+ Lib_Mean cur_lib_mean(filename,mic,moc);
+
+ s_lib_mean.insert(cur_lib_mean);
+
+ }
+
+ }
+
+
+ cout << "<TABLE BORDER CELLPADDING=2>" << endl ;
+ cout << " <TR>" << endl ;
+ cout << " <TH ALIGN=CENTER> " << argv[1] << " </TH>" << endl ;
+ cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> in cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
+ cout << " <TH ALIGN=CENTER> in cache <BR> % best </TH>" << endl ;
+ cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> out of cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
+ cout << " <TH ALIGN=CENTER> out of cache <BR> % best </TH>" << endl ;
+ cout << " <TH ALIGN=CENTER> details </TH>" << endl ;
+ cout << " <TH ALIGN=CENTER> comments </TH>" << endl ;
+ cout << " </TR>" << endl ;
+
+ multiset<Lib_Mean>::iterator is = s_lib_mean.begin();
+ Lib_Mean best(*is);
+
+
+ for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
+
+ cout << " <TR>" << endl ;
+ cout << " <TD> " << is->_lib_name << " </TD>" << endl ;
+ cout << " <TD> " << is->_mean_in_cache << " </TD>" << endl ;
+ cout << " <TD> " << 100*(is->_mean_in_cache/best._mean_in_cache) << " </TD>" << endl ;
+ cout << " <TD> " << is->_mean_out_of_cache << " </TD>" << endl ;
+ cout << " <TD> " << 100*(is->_mean_out_of_cache/best._mean_out_of_cache) << " </TD>" << endl ;
+ cout << " <TD> " <<
+ "<a href=\"#"<<is->_lib_name<<"_"<<argv[1]<<"\">snippet</a>/"
+ "<a href=\"#"<<is->_lib_name<<"_flags\">flags</a> </TD>" << endl ;
+ cout << " <TD> " <<
+ "<a href=\"#"<<is->_lib_name<<"_comments\">click here</a> </TD>" << endl ;
+ cout << " </TR>" << endl ;
+
+ }
+
+ cout << "</TABLE>" << endl ;
+
+ ofstream output_file ("../order_lib",ios::out) ;
+
+ for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
+ output_file << is->_lib_name << endl ;
+ }
+
+ output_file.close();
+
+}
+
+double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max){
+
+ int size=tab_sizes.size();
+ int nb_sample=0;
+ double mean=0.0;
+
+ for (int i=0;i<size;i++){
+
+
+ if ((tab_sizes[i]>=size_min)&&(tab_sizes[i]<=size_max)){
+
+ nb_sample++;
+ mean+=tab_mflops[i];
+
+ }
+
+
+ }
+
+ if (nb_sample==0){
+ INFOS("no data for mean calculation");
+ return 0.0;
+ }
+
+ return mean/nb_sample;
+}
+
+
+
+
diff --git a/btl/data/mk_gnuplot_script.sh b/btl/data/mk_gnuplot_script.sh
new file mode 100644
index 0000000..2ca7b5c
--- /dev/null
+++ b/btl/data/mk_gnuplot_script.sh
@@ -0,0 +1,68 @@
+#! /bin/bash
+WHAT=$1
+DIR=$2
+echo $WHAT script generation
+cat $WHAT.hh > $WHAT.gnuplot
+
+DATA_FILE=`find $DIR -name "*.dat" | grep $WHAT`
+
+echo plot \\ >> $WHAT.gnuplot
+
+for FILE in $DATA_FILE
+do
+ LAST=$FILE
+done
+
+echo LAST=$LAST
+
+for FILE in $DATA_FILE
+do
+ if [ $FILE != $LAST ]
+ then
+ BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+ echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot
+ fi
+done
+BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot
+
+#echo set term postscript color >> $WHAT.gnuplot
+#echo set output "'"$WHAT.ps"'" >> $WHAT.gnuplot
+echo set term pbm small color >> $WHAT.gnuplot
+echo set output "'"$WHAT.ppm"'" >> $WHAT.gnuplot
+echo plot \\ >> $WHAT.gnuplot
+
+for FILE in $DATA_FILE
+do
+ if [ $FILE != $LAST ]
+ then
+ BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+ echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot
+ fi
+done
+BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot
+
+echo set term jpeg large >> $WHAT.gnuplot
+echo set output "'"$WHAT.jpg"'" >> $WHAT.gnuplot
+echo plot \\ >> $WHAT.gnuplot
+
+for FILE in $DATA_FILE
+do
+ if [ $FILE != $LAST ]
+ then
+ BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+ echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot
+ fi
+done
+BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot
+
+
+gnuplot -persist < $WHAT.gnuplot
+
+rm $WHAT.gnuplot
+
+
+
+
diff --git a/btl/data/mk_mean_script.sh b/btl/data/mk_mean_script.sh
new file mode 100644
index 0000000..b10df02
--- /dev/null
+++ b/btl/data/mk_mean_script.sh
@@ -0,0 +1,52 @@
+#! /bin/bash
+WHAT=$1
+DIR=$2
+MINIC=$3
+MAXIC=$4
+MINOC=$5
+MAXOC=$6
+prefix=$8
+
+meanstatsfilename=$2/mean.html
+
+WORK_DIR=tmp
+mkdir $WORK_DIR
+
+DATA_FILE=`find $DIR -name "*.dat" | grep _${WHAT}`
+
+if [ -n "$DATA_FILE" ]; then
+
+ echo ""
+ echo "$1..."
+ for FILE in $DATA_FILE
+ do
+ ##echo hello world
+ ##echo "mk_mean_script1" ${FILE}
+ BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+
+ ##echo "mk_mean_script1" ${TITLE}
+ cp $FILE ${WORK_DIR}/${TITLE}
+
+ done
+
+ cd $WORK_DIR
+ ../main $1 $3 $4 $5 $6 * >> ../$meanstatsfilename
+ ../mk_new_gnuplot.sh $1 $2 $7
+ rm -f *.gnuplot
+ cd ..
+
+ echo '<br/>' >> $meanstatsfilename
+
+ webpagefilename=$2/index.html
+ # echo '<h3>'${WHAT}'</h3>' >> $webpagefilename
+ echo '<hr/><a href="'$prefix$1'.pdf"><img src="'$prefix$1'.png" alt="'${WHAT}'" /></a><br/>' >> $webpagefilename
+
+fi
+
+rm -R $WORK_DIR
+
+
+
+
+
+
diff --git a/btl/data/mk_new_gnuplot.sh b/btl/data/mk_new_gnuplot.sh
new file mode 100755
index 0000000..fad3b23
--- /dev/null
+++ b/btl/data/mk_new_gnuplot.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+WHAT=$1
+DIR=$2
+
+cat ../gnuplot_common_settings.hh > ${WHAT}.gnuplot
+
+echo "set title " `grep ${WHAT} ../action_settings.txt | head -n 1 | cut -d ";" -f 2` >> $WHAT.gnuplot
+echo "set xlabel " `grep ${WHAT} ../action_settings.txt | head -n 1 | cut -d ";" -f 3` " offset 0,0" >> $WHAT.gnuplot
+echo "set xrange [" `grep ${WHAT} ../action_settings.txt | head -n 1 | cut -d ";" -f 4` "]" >> $WHAT.gnuplot
+
+if [ $# > 3 ]; then
+ if [ "$3" == "tiny" ]; then
+ echo "set xrange [2:16]" >> $WHAT.gnuplot
+ echo "set nologscale" >> $WHAT.gnuplot
+ fi
+fi
+
+
+
+DATA_FILE=`cat ../order_lib`
+echo set term postscript color rounded enhanced >> $WHAT.gnuplot
+echo set output "'"../${DIR}/$WHAT.ps"'" >> $WHAT.gnuplot
+
+# echo set term svg color rounded enhanced >> $WHAT.gnuplot
+# echo "set terminal svg enhanced size 1000 1000 fname \"Times\" fsize 36" >> $WHAT.gnuplot
+# echo set output "'"../${DIR}/$WHAT.svg"'" >> $WHAT.gnuplot
+
+echo plot \\ >> $WHAT.gnuplot
+
+for FILE in $DATA_FILE
+do
+ LAST=$FILE
+done
+
+for FILE in $DATA_FILE
+do
+ BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
+
+ echo "'"$FILE"'" `grep $TITLE ../perlib_plot_settings.txt | head -n 1 | cut -d ";" -f 2` "\\" >> $WHAT.gnuplot
+ if [ $FILE != $LAST ]
+ then
+ echo ", \\" >> $WHAT.gnuplot
+ fi
+done
+echo " " >> $WHAT.gnuplot
+
+gnuplot -persist < $WHAT.gnuplot
+
+rm $WHAT.gnuplot
+
+ps2pdf ../${DIR}/$WHAT.ps ../${DIR}/$WHAT.pdf
+convert -background white -density 120 -rotate 90 -resize 800 +dither -colors 256 -quality 0 ../${DIR}/$WHAT.ps -background white -flatten ../${DIR}/$WHAT.png
+
+# pstoedit -rotate -90 -xscale 0.8 -yscale 0.8 -centered -yshift -50 -xshift -100 -f plot-svg aat.ps aat2.svg
diff --git a/btl/data/perlib_plot_settings.txt b/btl/data/perlib_plot_settings.txt
new file mode 100644
index 0000000..6844bab
--- /dev/null
+++ b/btl/data/perlib_plot_settings.txt
@@ -0,0 +1,16 @@
+eigen3 ; with lines lw 4 lt 1 lc rgbcolor "black"
+eigen2 ; with lines lw 3 lt 1 lc rgbcolor "#999999"
+EigenBLAS ; with lines lw 3 lt 3 lc rgbcolor "#999999"
+eigen3_novec ; with lines lw 2 lt 1 lc rgbcolor "#999999"
+eigen3_nogccvec ; with lines lw 2 lt 2 lc rgbcolor "#991010"
+INTEL_MKL ; with lines lw 3 lt 1 lc rgbcolor "#ff0000"
+ATLAS ; with lines lw 3 lt 1 lc rgbcolor "#008000"
+gmm ; with lines lw 3 lt 1 lc rgbcolor "#0000ff"
+ublas ; with lines lw 3 lt 1 lc rgbcolor "#00b7ff"
+mtl4 ; with lines lw 3 lt 1 lc rgbcolor "#d18847"
+blitz ; with lines lw 3 lt 1 lc rgbcolor "#ff00ff"
+F77 ; with lines lw 3 lt 3 lc rgbcolor "#e6e64c"
+GOTO ; with lines lw 3 lt 3 lc rgbcolor "#C05600"
+GOTO2 ; with lines lw 3 lt 1 lc rgbcolor "#C05600"
+C ; with lines lw 3 lt 3 lc rgbcolor "#e6bd96"
+ACML ; with lines lw 2 lt 3 lc rgbcolor "#e6e64c"
diff --git a/btl/data/regularize.cxx b/btl/data/regularize.cxx
new file mode 100644
index 0000000..eea2b8b
--- /dev/null
+++ b/btl/data/regularize.cxx
@@ -0,0 +1,131 @@
+//=====================================================
+// File : regularize.cxx
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "utilities.h"
+#include <vector>
+#include <string>
+#include <iostream>
+#include <fstream>
+#include "bench_parameter.hh"
+#include <set>
+
+using namespace std;
+
+void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
+void regularize_curve(const string & filename,
+ const vector<double> & tab_mflops,
+ const vector<int> & tab_sizes,
+ int start_cut_size, int stop_cut_size);
+/////////////////////////////////////////////////////////////////////////////////////////////////
+
+int main( int argc , char *argv[] )
+{
+
+ // input data
+
+ if (argc<4){
+ INFOS("!!! Error ... usage : main filename start_cut_size stop_cut_size regularize_filename");
+ exit(0);
+ }
+ INFOS(argc);
+
+ int start_cut_size=atoi(argv[2]);
+ int stop_cut_size=atoi(argv[3]);
+
+ string filename=argv[1];
+ string regularize_filename=argv[4];
+
+ INFOS(filename);
+ INFOS("start_cut_size="<<start_cut_size);
+
+ vector<int> tab_sizes;
+ vector<double> tab_mflops;
+
+ read_xy_file(filename,tab_sizes,tab_mflops);
+
+ // regularizeing
+
+ regularize_curve(regularize_filename,tab_mflops,tab_sizes,start_cut_size,stop_cut_size);
+
+
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void regularize_curve(const string & filename,
+ const vector<double> & tab_mflops,
+ const vector<int> & tab_sizes,
+ int start_cut_size, int stop_cut_size)
+{
+ int size=tab_mflops.size();
+ ofstream output_file (filename.c_str(),ios::out) ;
+
+ int i=0;
+
+ while(tab_sizes[i]<start_cut_size){
+
+ output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
+ i++;
+
+ }
+
+ output_file << endl ;
+
+ while(tab_sizes[i]<stop_cut_size){
+
+ i++;
+
+ }
+
+ while(i<size){
+
+ output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
+ i++;
+
+ }
+
+ output_file.close();
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
+
+ ifstream input_file (filename.c_str(),ios::in) ;
+
+ if (!input_file){
+ INFOS("!!! Error opening "<<filename);
+ exit(0);
+ }
+
+ int nb_point=0;
+ int size=0;
+ double mflops=0;
+
+ while (input_file >> size >> mflops ){
+ nb_point++;
+ tab_sizes.push_back(size);
+ tab_mflops.push_back(mflops);
+ }
+ SCRUTE(nb_point);
+
+ input_file.close();
+}
+
diff --git a/btl/data/smooth.cxx b/btl/data/smooth.cxx
new file mode 100644
index 0000000..e5270cc
--- /dev/null
+++ b/btl/data/smooth.cxx
@@ -0,0 +1,198 @@
+//=====================================================
+// File : smooth.cxx
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "utilities.h"
+#include <vector>
+#include <deque>
+#include <string>
+#include <iostream>
+#include <fstream>
+#include "bench_parameter.hh"
+#include <set>
+
+using namespace std;
+
+void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
+void write_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
+void smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width);
+void centered_smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width);
+
+/////////////////////////////////////////////////////////////////////////////////////////////////
+
+int main( int argc , char *argv[] )
+{
+
+ // input data
+
+ if (argc<3){
+ INFOS("!!! Error ... usage : main filename window_half_width smooth_filename");
+ exit(0);
+ }
+ INFOS(argc);
+
+ int window_half_width=atoi(argv[2]);
+
+ string filename=argv[1];
+ string smooth_filename=argv[3];
+
+ INFOS(filename);
+ INFOS("window_half_width="<<window_half_width);
+
+ vector<int> tab_sizes;
+ vector<double> tab_mflops;
+
+ read_xy_file(filename,tab_sizes,tab_mflops);
+
+ // smoothing
+
+ vector<double> smooth_tab_mflops;
+
+ //smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
+ centered_smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
+
+ // output result
+
+ write_xy_file(smooth_filename,tab_sizes,smooth_tab_mflops);
+
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+template<class VECTOR>
+double weighted_mean(const VECTOR & data)
+{
+
+ double mean=0.0;
+
+ for (int i=0 ; i<data.size() ; i++){
+
+ mean+=data[i];
+
+ }
+
+ return mean/double(data.size()) ;
+
+}
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+void smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width){
+
+ int window_width=2*window_half_width+1;
+
+ int size=tab_mflops.size();
+
+ vector<double> sample(window_width);
+
+ for (int i=0 ; i < size ; i++){
+
+ for ( int j=0 ; j < window_width ; j++ ){
+
+ int shifted_index=i+j-window_half_width;
+ if (shifted_index<0) shifted_index=0;
+ if (shifted_index>size-1) shifted_index=size-1;
+ sample[j]=tab_mflops[shifted_index];
+
+ }
+
+ smooth_tab_mflops.push_back(weighted_mean(sample));
+
+ }
+
+}
+
+void centered_smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width){
+
+ int max_window_width=2*window_half_width+1;
+
+ int size=tab_mflops.size();
+
+
+ for (int i=0 ; i < size ; i++){
+
+ deque<double> sample;
+
+
+ sample.push_back(tab_mflops[i]);
+
+ for ( int j=1 ; j <= window_half_width ; j++ ){
+
+ int before=i-j;
+ int after=i+j;
+
+ if ((before>=0)&&(after<size)) // inside of the vector
+ {
+ sample.push_front(tab_mflops[before]);
+ sample.push_back(tab_mflops[after]);
+ }
+ }
+
+ smooth_tab_mflops.push_back(weighted_mean(sample));
+
+ }
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void write_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
+
+ ofstream output_file (filename.c_str(),ios::out) ;
+
+ for (int i=0 ; i < tab_sizes.size() ; i++)
+ {
+ output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
+ }
+
+ output_file.close();
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
+
+ ifstream input_file (filename.c_str(),ios::in) ;
+
+ if (!input_file){
+ INFOS("!!! Error opening "<<filename);
+ exit(0);
+ }
+
+ int nb_point=0;
+ int size=0;
+ double mflops=0;
+
+ while (input_file >> size >> mflops ){
+ nb_point++;
+ tab_sizes.push_back(size);
+ tab_mflops.push_back(mflops);
+ }
+ SCRUTE(nb_point);
+
+ input_file.close();
+}
+
diff --git a/btl/data/smooth_all.sh b/btl/data/smooth_all.sh
new file mode 100755
index 0000000..3e5bfdf
--- /dev/null
+++ b/btl/data/smooth_all.sh
@@ -0,0 +1,68 @@
+#! /bin/bash
+ORIG_DIR=$1
+SMOOTH_DIR=${ORIG_DIR}_smooth
+mkdir ${SMOOTH_DIR}
+
+AXPY_FILE=`find ${ORIG_DIR} -name "*.dat" | grep axpy`
+for FILE in ${AXPY_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}_tmp
+ ./regularize ${SMOOTH_DIR}/${BASE}_tmp 2500 15000 ${SMOOTH_DIR}/${BASE}
+ rm -f ${SMOOTH_DIR}/${BASE}_tmp
+done
+
+
+MATRIX_VECTOR_FILE=`find ${ORIG_DIR} -name "*.dat" | grep matrix_vector`
+for FILE in ${MATRIX_VECTOR_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}_tmp
+ ./regularize ${SMOOTH_DIR}/${BASE}_tmp 50 180 ${SMOOTH_DIR}/${BASE}
+ rm -f ${SMOOTH_DIR}/${BASE}_tmp
+done
+
+MATRIX_MATRIX_FILE=`find ${ORIG_DIR} -name "*.dat" | grep matrix_matrix`
+for FILE in ${MATRIX_MATRIX_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}
+done
+
+AAT_FILE=`find ${ORIG_DIR} -name "*.dat" | grep _aat`
+for FILE in ${AAT_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}
+done
+
+
+ATA_FILE=`find ${ORIG_DIR} -name "*.dat" | grep _ata`
+for FILE in ${ATA_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ ./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}
+done
+
+### no smoothing for tinyvector and matrices libs
+
+TINY_BLITZ_FILE=`find ${ORIG_DIR} -name "*.dat" | grep tiny_blitz`
+for FILE in ${TINY_BLITZ_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ cp ${ORIG_DIR}/${BASE} ${SMOOTH_DIR}/${BASE}
+done
+
+TVMET_FILE=`find ${ORIG_DIR} -name "*.dat" | grep tvmet`
+for FILE in ${TVMET_FILE}
+do
+ echo $FILE
+ BASE=${FILE##*/}
+ cp ${ORIG_DIR}/${BASE} ${SMOOTH_DIR}/${BASE}
+done
diff --git a/btl/generic_bench/bench.hh b/btl/generic_bench/bench.hh
new file mode 100644
index 0000000..4004797
--- /dev/null
+++ b/btl/generic_bench/bench.hh
@@ -0,0 +1,103 @@
+//=====================================================
+// File : bench.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:16 CEST 2002
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BENCH_HH
+#define BENCH_HH
+
+#include "btl.hh"
+#include "bench_parameter.hh"
+#include <iostream>
+#include "utilities.h"
+#include "size_lin_log.hh"
+#include "xy_file.hh"
+#include <vector>
+#include <string>
+#include "timers/portable_perf_analyzer.hh"
+
+#ifdef DISTRIBUTED
+#include "timers/distributed_perf_analyzer_root.hh"
+#include "timers/distributed_perf_analyzer_node.hh"
+#endif
+
+// #include "timers/mixed_perf_analyzer.hh"
+// #include "timers/x86_perf_analyzer.hh"
+// #include "timers/STL_perf_analyzer.hh"
+#ifdef HAVE_MKL
+extern "C" void cblas_saxpy(const int, const float, const float*, const int, float *, const int);
+#endif
+
+template <template<class> class Perf_Analyzer, class Action>
+BTL_DONT_INLINE void bench( int size_min, int size_max, int nb_point, bool silent = false )
+{
+ std::string filename = "bench_"+Action::name()+".dat";
+
+ if (!silent) { INFOS("starting " <<filename); }
+
+ // utilities
+
+ std::vector<double> tab_mflops(nb_point);
+ std::vector<int> tab_sizes(nb_point);
+
+ // matrices and vector size calculations
+ size_lin_log(nb_point,size_min,size_max,tab_sizes);
+
+ // loop on matrix size
+ Perf_Analyzer<Action> perf_action;
+ for (int i=nb_point-1; i>=0; i--)
+ {
+ if (!silent)
+ std::cout << " " << "size = " << tab_sizes[i] << " " << std::flush;
+
+ BTL_DISABLE_SSE_EXCEPTIONS();
+
+ tab_mflops[i] = perf_action.eval_mflops(tab_sizes[i], silent);
+ if (!silent)
+ std::cout << tab_mflops[i] << " MFlops (" << nb_point-i << "/" << nb_point << ")" << std::endl;
+ }
+
+ // dump the result in a file :
+ if (!silent) dump_xy_file(tab_sizes, tab_mflops, filename);
+
+}
+
+// default Perf Analyzer
+
+template <class Action>
+BTL_DONT_INLINE void bench( int size_min, int size_max, int nb_point, bool silent = false)
+{
+ bench<Portable_Perf_Analyzer,Action>(size_min,size_max,nb_point,silent);
+}
+
+#ifdef DISTRIBUTED
+// distributed Perf Analyzer
+
+template <class Action>
+BTL_DONT_INLINE void distr_bench( int size_min, int size_max, int nb_point, bool silent = false)
+{
+ int myid, nproc;
+ blacs_pinfo_(&myid, &nproc);
+ if (myid)
+ bench<Distributed_Perf_Analyzer_Node, Action>(size_min, size_max, nb_point, silent);
+ else
+ bench<Distributed_Perf_Analyzer_Root, Action>(size_min, size_max, nb_point, silent);
+}
+#endif
+
+#endif
diff --git a/btl/generic_bench/bench_parameter.hh b/btl/generic_bench/bench_parameter.hh
new file mode 100644
index 0000000..4c355cd
--- /dev/null
+++ b/btl/generic_bench/bench_parameter.hh
@@ -0,0 +1,53 @@
+//=====================================================
+// File : bench_parameter.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:16 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BENCH_PARAMETER_HH
+#define BENCH_PARAMETER_HH
+
+// minimal time for each measurement
+#define REAL_TYPE float
+// minimal time for each measurement
+#define MIN_TIME 0.2
+// nb of point on bench curves
+#define NB_POINT 100
+// min vector size for axpy bench
+#define MIN_AXPY 5
+// max vector size for axpy bench
+#define MAX_AXPY 1000000
+// min matrix size for matrix vector product bench
+#define MIN_MV 5
+// max matrix size for matrix vector product bench
+#define MAX_MV 3000
+// min matrix size for matrix matrix product bench
+#define MIN_MM 5
+// max matrix size for matrix matrix product bench
+#define MAX_MM MAX_MV
+// min matrix size for LU bench
+#define MIN_LU 5
+// max matrix size for LU bench
+#define MAX_LU 3000
+// max size for tiny vector and matrix
+#define TINY_MV_MAX_SIZE 16
+// default nb_sample for x86 timer
+#define DEFAULT_NB_SAMPLE 1000
+
+// how many times we run a single bench (keep the best perf)
+#define DEFAULT_NB_TRIES 3
+
+#endif
diff --git a/btl/generic_bench/btl.hh b/btl/generic_bench/btl.hh
new file mode 100644
index 0000000..17cd397
--- /dev/null
+++ b/btl/generic_bench/btl.hh
@@ -0,0 +1,247 @@
+//=====================================================
+// File : btl.hh
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BTL_HH
+#define BTL_HH
+
+#include "bench_parameter.hh"
+#include <iostream>
+#include <algorithm>
+#include <vector>
+#include <string>
+#include "utilities.h"
+
+#if (defined __GNUC__)
+#define BTL_ALWAYS_INLINE __attribute__((always_inline)) inline
+#else
+#define BTL_ALWAYS_INLINE inline
+#endif
+
+#if (defined __GNUC__)
+#define BTL_DONT_INLINE __attribute__((noinline))
+#else
+#define BTL_DONT_INLINE
+#endif
+
+#if (defined __GNUC__)
+#define BTL_ASM_COMMENT(X) asm("#"X)
+#else
+#define BTL_ASM_COMMENT(X)
+#endif
+
+#if (defined __GNUC__) && (!defined __INTEL_COMPILER) && !defined(__arm__) && !defined(__powerpc__)
+#define BTL_DISABLE_SSE_EXCEPTIONS() { \
+ int aux; \
+ asm( \
+ "stmxcsr %[aux] \n\t" \
+ "orl $32832, %[aux] \n\t" \
+ "ldmxcsr %[aux] \n\t" \
+ : : [aux] "m" (aux)); \
+}
+#else
+#define BTL_DISABLE_SSE_EXCEPTIONS()
+#endif
+
+/** Enhanced std::string
+*/
+class BtlString : public std::string
+{
+public:
+ BtlString() : std::string() {}
+ BtlString(const BtlString& str) : std::string(static_cast<const std::string&>(str)) {}
+ BtlString(const std::string& str) : std::string(str) {}
+ BtlString(const char* str) : std::string(str) {}
+
+ operator const char* () const { return c_str(); }
+
+ void trim( bool left = true, bool right = true )
+ {
+ int lspaces, rspaces, len = length(), i;
+ lspaces = rspaces = 0;
+
+ if ( left )
+ for (i=0; i<len && (at(i)==' '||at(i)=='\t'||at(i)=='\r'||at(i)=='\n'); ++lspaces,++i);
+
+ if ( right && lspaces < len )
+ for(i=len-1; i>=0 && (at(i)==' '||at(i)=='\t'||at(i)=='\r'||at(i)=='\n'); rspaces++,i--);
+
+ *this = substr(lspaces, len-lspaces-rspaces);
+ }
+
+ std::vector<BtlString> split( const BtlString& delims = "\t\n ") const
+ {
+ std::vector<BtlString> ret;
+ unsigned int numSplits = 0;
+ size_t start, pos;
+ start = 0;
+ do
+ {
+ pos = find_first_of(delims, start);
+ if (pos == start)
+ {
+ ret.push_back("");
+ start = pos + 1;
+ }
+ else if (pos == npos)
+ ret.push_back( substr(start) );
+ else
+ {
+ ret.push_back( substr(start, pos - start) );
+ start = pos + 1;
+ }
+ //start = find_first_not_of(delims, start);
+ ++numSplits;
+ } while (pos != npos);
+ return ret;
+ }
+
+ bool endsWith(const BtlString& str) const
+ {
+ if(str.size()>this->size())
+ return false;
+ return this->substr(this->size()-str.size(),str.size()) == str;
+ }
+ bool contains(const BtlString& str) const
+ {
+ return this->find(str)<this->size();
+ }
+ bool beginsWith(const BtlString& str) const
+ {
+ if(str.size()>this->size())
+ return false;
+ return this->substr(0,str.size()) == str;
+ }
+
+ BtlString toLowerCase( void )
+ {
+ std::transform(begin(), end(), begin(), static_cast<int(*)(int)>(::tolower) );
+ return *this;
+ }
+ BtlString toUpperCase( void )
+ {
+ std::transform(begin(), end(), begin(), static_cast<int(*)(int)>(::toupper) );
+ return *this;
+ }
+
+ /** Case insensitive comparison.
+ */
+ bool isEquiv(const BtlString& str) const
+ {
+ BtlString str0 = *this;
+ str0.toLowerCase();
+ BtlString str1 = str;
+ str1.toLowerCase();
+ return str0 == str1;
+ }
+
+ /** Decompose the current string as a path and a file.
+ For instance: "dir1/dir2/file.ext" leads to path="dir1/dir2/" and filename="file.ext"
+ */
+ void decomposePathAndFile(BtlString& path, BtlString& filename) const
+ {
+ std::vector<BtlString> elements = this->split("/\\");
+ path = "";
+ filename = elements.back();
+ elements.pop_back();
+ if (this->at(0)=='/')
+ path = "/";
+ for (unsigned int i=0 ; i<elements.size() ; ++i)
+ path += elements[i] + "/";
+ }
+};
+
+class BtlConfig
+{
+public:
+ BtlConfig()
+ : overwriteResults(false), checkResults(true), realclock(false), tries(DEFAULT_NB_TRIES)
+ {
+ char * _config;
+ _config = getenv ("BTL_CONFIG");
+ if (_config!=NULL)
+ {
+ std::vector<BtlString> config = BtlString(_config).split(" \t\n");
+ for (int i = 0; i<config.size(); i++)
+ {
+ if (config[i].beginsWith("-a"))
+ {
+ if (i+1==config.size())
+ {
+ std::cerr << "error processing option: " << config[i] << "\n";
+ exit(2);
+ }
+ Instance.m_selectedActionNames = config[i+1].split(":");
+
+ i += 1;
+ }
+ else if (config[i].beginsWith("-t"))
+ {
+ if (i+1==config.size())
+ {
+ std::cerr << "error processing option: " << config[i] << "\n";
+ exit(2);
+ }
+ Instance.tries = atoi(config[i+1].c_str());
+
+ i += 1;
+ }
+ else if (config[i].beginsWith("--overwrite"))
+ {
+ Instance.overwriteResults = true;
+ }
+ else if (config[i].beginsWith("--nocheck"))
+ {
+ Instance.checkResults = false;
+ }
+ else if (config[i].beginsWith("--real"))
+ {
+ Instance.realclock = true;
+ }
+ }
+ }
+
+ BTL_DISABLE_SSE_EXCEPTIONS();
+ }
+
+ BTL_DONT_INLINE static bool skipAction(const std::string& _name)
+ {
+ if (Instance.m_selectedActionNames.empty())
+ return false;
+
+ BtlString name(_name);
+ for (int i=0; i<Instance.m_selectedActionNames.size(); ++i)
+ if (name.contains(Instance.m_selectedActionNames[i]))
+ return false;
+
+ return true;
+ }
+
+ static BtlConfig Instance;
+ bool overwriteResults;
+ bool checkResults;
+ bool realclock;
+ int tries;
+
+protected:
+ std::vector<BtlString> m_selectedActionNames;
+};
+
+#define BTL_MAIN \
+ BtlConfig BtlConfig::Instance
+
+#endif // BTL_HH
diff --git a/btl/generic_bench/init/init_function.hh b/btl/generic_bench/init/init_function.hh
new file mode 100644
index 0000000..7b3bdba
--- /dev/null
+++ b/btl/generic_bench/init/init_function.hh
@@ -0,0 +1,54 @@
+//=====================================================
+// File : init_function.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:18 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef INIT_FUNCTION_HH
+#define INIT_FUNCTION_HH
+
+double simple_function(int index)
+{
+ return index;
+}
+
+double simple_function(int index_i, int index_j)
+{
+ return index_i+index_j;
+}
+
+double pseudo_random(int index)
+{
+ return std::rand()/double(RAND_MAX);
+}
+
+double pseudo_random(int index_i, int index_j)
+{
+ return std::rand()/double(RAND_MAX);
+}
+
+
+double null_function(int index)
+{
+ return 0.0;
+}
+
+double null_function(int index_i, int index_j)
+{
+ return 0.0;
+}
+
+#endif
diff --git a/btl/generic_bench/init/init_matrix.hh b/btl/generic_bench/init/init_matrix.hh
new file mode 100644
index 0000000..c598ffc
--- /dev/null
+++ b/btl/generic_bench/init/init_matrix.hh
@@ -0,0 +1,93 @@
+//=====================================================
+// File : init_matrix.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef INIT_MATRIX_HH
+#define INIT_MATRIX_HH
+
+#include "LinearCongruential.hh"
+
+// The Vector class must satisfy the following part of STL vector concept :
+// resize() method
+// [] operator for setting element
+// value_type defined
+template<double init_function(int,int), class Vector>
+BTL_DONT_INLINE void init_row(Vector & X, int size, int row){
+
+ X.resize(size);
+
+ for (int j=0;j<X.size();j++){
+ X[j]=typename Vector::value_type(init_function(row,j));
+ }
+}
+
+
+// Matrix is a Vector of Vector
+// The Matrix class must satisfy the following part of STL vector concept :
+// resize() method
+// [] operator for setting rows
+template<double init_function(int,int),class Vector>
+BTL_DONT_INLINE void init_matrix(Vector & A, int size){
+ A.resize(size);
+ for (int row=0; row<A.size() ; row++){
+ init_row<init_function>(A[row],size,row);
+ }
+}
+
+template<double init_function(int,int),class Matrix>
+BTL_DONT_INLINE void init_matrix_symm(Matrix& A, int size){
+ A.resize(size);
+ for (int row=0; row<A.size() ; row++)
+ A[row].resize(size);
+ for (int row=0; row<A.size() ; row++){
+ A[row][row] = init_function(row,row);
+ for (int col=0; col<row ; col++){
+ double x = init_function(row,col);
+ A[row][col] = A[col][row] = x;
+ }
+ }
+}
+
+template<class Matrix> BTL_DONT_INLINE
+void init_matrix(Matrix& A, const int& size, const unsigned& seed)
+{
+ typedef typename Matrix::value_type value_t;
+ A.resize(size*size);
+ LinearCongruential rng(seed);
+ for (typename Matrix::iterator i = A.begin(), end = A.end(); i != end; ++i)
+ *i = rng.get_01();
+}
+
+template<class Matrix> BTL_DONT_INLINE
+void init_SPD_matrix(Matrix& A, const int& size, const unsigned& seed)
+{
+ typedef typename Matrix::value_type value_t;
+ A.resize(size*size);
+ LinearCongruential rng(seed);
+ for (int r = 0; r < size; ++r) {
+ A[r+size*r] = rng.get_01() + size;
+ for (int c = r+1; c < size; ++c) {
+ const value_t v = rng.get_01();
+ A[r+size*c] = v;
+ A[c+size*r] = v;
+ }
+ }
+}
+
+#endif
diff --git a/btl/generic_bench/init/init_vector.hh b/btl/generic_bench/init/init_vector.hh
new file mode 100644
index 0000000..efaf0c9
--- /dev/null
+++ b/btl/generic_bench/init/init_vector.hh
@@ -0,0 +1,37 @@
+//=====================================================
+// File : init_vector.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:18 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef INIT_VECTOR_HH
+#define INIT_VECTOR_HH
+
+// The Vector class must satisfy the following part of STL vector concept :
+// resize() method
+// [] operator for setting element
+// value_type defined
+template<double init_function(int), class Vector>
+void init_vector(Vector & X, int size){
+
+ X.resize(size);
+
+ for (int i=0;i<X.size();i++){
+ X[i]=typename Vector::value_type(init_function(i));
+ }
+}
+
+#endif
diff --git a/btl/generic_bench/static/bench_static.hh b/btl/generic_bench/static/bench_static.hh
new file mode 100644
index 0000000..23b55ec
--- /dev/null
+++ b/btl/generic_bench/static/bench_static.hh
@@ -0,0 +1,80 @@
+//=====================================================
+// File : bench_static.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:16 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BENCH_STATIC_HH
+#define BENCH_STATIC_HH
+
+#include "btl.hh"
+#include "bench_parameter.hh"
+#include <iostream>
+#include "utilities.h"
+#include "xy_file.hh"
+#include "static/static_size_generator.hh"
+#include "timers/portable_perf_analyzer.hh"
+// #include "timers/mixed_perf_analyzer.hh"
+// #include "timers/x86_perf_analyzer.hh"
+
+using namespace std;
+
+
+template <template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
+BTL_DONT_INLINE void bench_static(void)
+{
+ if (BtlConfig::skipAction(Action<Interface<REAL_TYPE,10> >::name()))
+ return;
+
+ string filename = "bench_" + Action<Interface<REAL_TYPE,10> >::name() + ".dat";
+
+ INFOS("starting " << filename);
+
+ const int max_size = TINY_MV_MAX_SIZE;
+
+ std::vector<double> tab_mflops;
+ std::vector<double> tab_sizes;
+
+ static_size_generator<max_size,Perf_Analyzer,Action,Interface>::go(tab_sizes,tab_mflops);
+
+ dump_xy_file(tab_sizes,tab_mflops,filename);
+}
+
+// default Perf Analyzer
+template <template<class> class Action, template<class,int> class Interface>
+BTL_DONT_INLINE void bench_static(void)
+{
+ bench_static<Portable_Perf_Analyzer,Action,Interface>();
+ //bench_static<Mixed_Perf_Analyzer,Action,Interface>();
+ //bench_static<X86_Perf_Analyzer,Action,Interface>();
+}
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/btl/generic_bench/static/intel_bench_fixed_size.hh b/btl/generic_bench/static/intel_bench_fixed_size.hh
new file mode 100644
index 0000000..b4edcbc
--- /dev/null
+++ b/btl/generic_bench/static/intel_bench_fixed_size.hh
@@ -0,0 +1,66 @@
+//=====================================================
+// File : intel_bench_fixed_size.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar déc 3 18:59:37 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _BENCH_FIXED_SIZE_HH_
+#define _BENCH_FIXED_SIZE_HH_
+
+#include "utilities.h"
+#include "function_time.hh"
+
+template <class Action>
+double bench_fixed_size(int size, unsigned long long & nb_calc,unsigned long long & nb_init)
+{
+
+ Action action(size);
+
+ double time_baseline=time_init(nb_init,action);
+
+ while (time_baseline < MIN_TIME) {
+
+ //INFOS("nb_init="<<nb_init);
+ //INFOS("time_baseline="<<time_baseline);
+ nb_init*=2;
+ time_baseline=time_init(nb_init,action);
+ }
+
+ time_baseline=time_baseline/(double(nb_init));
+
+ double time_action=time_calculate(nb_calc,action);
+
+ while (time_action < MIN_TIME) {
+
+ nb_calc*=2;
+ time_action=time_calculate(nb_calc,action);
+ }
+
+ INFOS("nb_init="<<nb_init);
+ INFOS("nb_calc="<<nb_calc);
+
+
+ time_action=time_action/(double(nb_calc));
+
+ action.check_result();
+
+ time_action=time_action-time_baseline;
+
+ return action.nb_op_base()/(time_action*1000000.0);
+
+}
+
+#endif
diff --git a/btl/generic_bench/static/static_size_generator.hh b/btl/generic_bench/static/static_size_generator.hh
new file mode 100644
index 0000000..dd02df3
--- /dev/null
+++ b/btl/generic_bench/static/static_size_generator.hh
@@ -0,0 +1,57 @@
+//=====================================================
+// File : static_size_generator.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar déc 3 18:59:36 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _STATIC_SIZE_GENERATOR_HH
+#define _STATIC_SIZE_GENERATOR_HH
+#include <vector>
+
+using namespace std;
+
+//recursive generation of statically defined matrix and vector sizes
+
+template <int SIZE,template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
+struct static_size_generator{
+ static void go(vector<double> & tab_sizes, vector<double> & tab_mflops)
+ {
+ tab_sizes.push_back(SIZE);
+ std::cout << tab_sizes.back() << " \t" << std::flush;
+ Perf_Analyzer<Action<Interface<REAL_TYPE,SIZE> > > perf_action;
+ tab_mflops.push_back(perf_action.eval_mflops(SIZE));
+ std::cout << tab_mflops.back() << " MFlops" << std::endl;
+ static_size_generator<SIZE-1,Perf_Analyzer,Action,Interface>::go(tab_sizes,tab_mflops);
+ };
+};
+
+//recursion end
+
+template <template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
+struct static_size_generator<1,Perf_Analyzer,Action,Interface>{
+ static void go(vector<double> & tab_sizes, vector<double> & tab_mflops)
+ {
+ tab_sizes.push_back(1);
+ Perf_Analyzer<Action<Interface<REAL_TYPE,1> > > perf_action;
+ tab_mflops.push_back(perf_action.eval_mflops(1));
+ };
+};
+
+#endif
+
+
+
+
diff --git a/btl/generic_bench/timers/STL_perf_analyzer.hh b/btl/generic_bench/timers/STL_perf_analyzer.hh
new file mode 100644
index 0000000..c9f894b
--- /dev/null
+++ b/btl/generic_bench/timers/STL_perf_analyzer.hh
@@ -0,0 +1,82 @@
+//=====================================================
+// File : STL_perf_analyzer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar déc 3 18:59:35 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _STL_PERF_ANALYSER_HH
+#define _STL_PERF_ANALYSER_HH
+
+#include "STL_timer.hh"
+#include "bench_parameter.hh"
+
+template<class ACTION>
+class STL_Perf_Analyzer{
+public:
+ STL_Perf_Analyzer(unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos()
+ {
+ MESSAGE("STL_Perf_Analyzer Ctor");
+ };
+ STL_Perf_Analyzer( const STL_Perf_Analyzer & ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~STL_Perf_Analyzer( void ){
+ MESSAGE("STL_Perf_Analyzer Dtor");
+ };
+
+
+ inline double eval_mflops(int size)
+ {
+
+ ACTION action(size);
+
+ _chronos.start_baseline(_nb_sample);
+
+ do {
+
+ action.initialize();
+ } while (_chronos.check());
+
+ double baseline_time=_chronos.get_time();
+
+ _chronos.start(_nb_sample);
+ do {
+ action.initialize();
+ action.calculate();
+ } while (_chronos.check());
+
+ double calculate_time=_chronos.get_time();
+
+ double corrected_time=calculate_time-baseline_time;
+
+ // cout << size <<" "<<baseline_time<<" "<<calculate_time<<" "<<corrected_time<<" "<<action.nb_op_base() << endl;
+
+ return action.nb_op_base()/(corrected_time*1000000.0);
+ //return action.nb_op_base()/(calculate_time*1000000.0);
+
+ }
+private:
+
+ STL_Timer _chronos;
+ unsigned long long _nb_sample;
+
+
+};
+
+
+
+#endif
diff --git a/btl/generic_bench/timers/STL_timer.hh b/btl/generic_bench/timers/STL_timer.hh
new file mode 100644
index 0000000..19c54e9
--- /dev/null
+++ b/btl/generic_bench/timers/STL_timer.hh
@@ -0,0 +1,78 @@
+//=====================================================
+// File : STL_Timer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar déc 3 18:59:35 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// STL Timer Class. Adapted (L.P.) from the timer class by Musser et Al
+// described int the Book : STL Tutorial and reference guide.
+// Define a timer class for analyzing algorithm performance.
+#include <iostream>
+#include <iomanip>
+#include <vector>
+#include <map>
+#include <algorithm>
+using namespace std;
+
+class STL_Timer {
+public:
+ STL_Timer(){ baseline = false; }; // Default constructor
+ // Start a series of r trials:
+ void start(unsigned int r){
+ reps = r;
+ count = 0;
+ iterations.clear();
+ iterations.reserve(reps);
+ initial = time(0);
+ };
+ // Start a series of r trials to determine baseline time:
+ void start_baseline(unsigned int r)
+ {
+ baseline = true;
+ start(r);
+ }
+ // Returns true if the trials have been completed, else false
+ bool check()
+ {
+ ++count;
+ final = time(0);
+ if (initial < final) {
+ iterations.push_back(count);
+ initial = final;
+ count = 0;
+ }
+ return (iterations.size() < reps);
+ };
+ // Returns the results for external use
+ double get_time( void )
+ {
+ sort(iterations.begin(), iterations.end());
+ return 1.0/iterations[reps/2];
+ };
+private:
+ unsigned int reps; // Number of trials
+ // For storing loop iterations of a trial
+ vector<long> iterations;
+ // For saving initial and final times of a trial
+ time_t initial, final;
+ // For counting loop iterations of a trial
+ unsigned long count;
+ // true if this is a baseline computation, false otherwise
+ bool baseline;
+ // For recording the baseline time
+ double baseline_time;
+};
+
diff --git a/btl/generic_bench/timers/distributed_perf_analyzer_node.hh b/btl/generic_bench/timers/distributed_perf_analyzer_node.hh
new file mode 100644
index 0000000..924eb87
--- /dev/null
+++ b/btl/generic_bench/timers/distributed_perf_analyzer_node.hh
@@ -0,0 +1,95 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _PORTABLE_PERF_ANALYZER_NODE_HH
+#define _PORTABLE_PERF_ANALYZER_NODE_HH
+
+#include "utilities.h"
+#include "timers/portable_timer.hh"
+#include "blacs.h"
+
+template <class Action>
+class Distributed_Perf_Analyzer_Node{
+public:
+ Distributed_Perf_Analyzer_Node( ):_nb_calc(0){
+ MESSAGE("Distributed_Perf_Analyzer_Node Ctor");
+ int temp, what = 0;
+ blacs_get_(&temp, &what, &context);
+ };
+ Distributed_Perf_Analyzer_Node( const Distributed_Perf_Analyzer_Node& ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~Distributed_Perf_Analyzer_Node(){
+ MESSAGE("Distributed_Perf_Analyzer_Node Dtor");
+ };
+
+ BTL_DONT_INLINE double eval_mflops(int size, bool silent = false)
+ {
+ Action action(size);
+
+ /* Find best _nb_calc_ */
+ int bcast_receive, iZERO = 0, iONE = 1;
+ igebr2d_(&context, "A", " ", &iONE, &iONE, &bcast_receive, &iONE, &iZERO, &iZERO);
+ while (bcast_receive > 0) {
+ _nb_calc = bcast_receive;
+ action.initialize();
+ time_calculate(action);
+ igebr2d_(&context, "A", " ", &iONE, &iONE, &bcast_receive, &iONE, &iZERO, &iZERO);
+ }
+ int tries = -bcast_receive;
+
+ /* Optimize */
+ for (int i = 1; i < tries; ++i) {
+ Action _action(size);
+ _action.initialize();
+ time_calculate(_action);
+ }
+
+ /* Check */
+ int do_check;
+ igebr2d_(&context, "A", " ", &iONE, &iONE, &do_check, &iONE, &iZERO, &iZERO);
+ if (do_check > 0) {
+ action.initialize();
+ action.calculate();
+ action.check_result();
+ }
+
+ /* Return a void value */
+ return 0.;
+ }
+
+ BTL_DONT_INLINE void time_calculate(Action & action)
+ {
+ // no need for time measurement
+ action.calculate();
+ for (int i = 0; i < _nb_calc; ++i)
+ action.calculate();
+ }
+
+ unsigned long long get_nb_calc()
+ {
+ return _nb_calc;
+ }
+
+
+private:
+ int context;
+ unsigned long long _nb_calc;
+};
+
+#endif //_PORTABLE_PERF_ANALYZER_NODE_HH
diff --git a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh
new file mode 100644
index 0000000..bbab901
--- /dev/null
+++ b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh
@@ -0,0 +1,116 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _PORTABLE_PERF_ANALYZER_ROOT_HH
+#define _PORTABLE_PERF_ANALYZER_ROOT_HH
+
+#include "utilities.h"
+#include "timers/portable_timer.hh"
+#include "blacs.h"
+
+template <class Action>
+class Distributed_Perf_Analyzer_Root{
+public:
+ Distributed_Perf_Analyzer_Root( ):_nb_calc(0), m_time_action(0), _chronos(){
+ MESSAGE("Distributed_Perf_Analyzer_Root Ctor");
+ int temp, what = 0;
+ blacs_get_(&temp, &what, &context);
+ };
+ Distributed_Perf_Analyzer_Root( const Distributed_Perf_Analyzer_Root & ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~Distributed_Perf_Analyzer_Root(){
+ MESSAGE("Distributed_Perf_Analyzer_Root Dtor");
+ };
+
+ BTL_DONT_INLINE double eval_mflops(int size, bool silent = false)
+ {
+ Action action(size);
+ m_time_action = 0;
+ _nb_calc = 0;
+
+ /* Find best _nb_calc_ */
+ int bcast_send = _nb_calc;
+ int iONE = 1;
+ while (m_time_action < MIN_TIME) {
+ _nb_calc = _nb_calc ? 2*_nb_calc : 1;
+ bcast_send = _nb_calc;
+ igebs2d_(&context, "A", " ", &iONE, &iONE, &bcast_send, &iONE);
+ action.initialize();
+ m_time_action = time_calculate(action);
+ }
+ int tries = BtlConfig::Instance.tries;
+ bcast_send = -tries;
+ igebs2d_(&context, "A", " ", &iONE, &iONE, &bcast_send, &iONE);
+
+ /* Optimize */
+ for (int i = 1; i < tries; ++i) {
+ Action _action(size);
+ if (!silent)
+ std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " " << std::flush;
+ _action.initialize();
+ m_time_action = std::min(m_time_action, time_calculate(_action));
+ }
+ double time_action = m_time_action / (double(_nb_calc));
+
+ /* Check */
+ int do_check = (BtlConfig::Instance.checkResults && size<128) ? 1 : 1;
+ igebs2d_(&context, "A", " ", &iONE, &iONE, &do_check, &iONE);
+ if (do_check > 0) {
+ action.initialize();
+ action.calculate();
+ action.check_result();
+ }
+
+ return action.nb_op_base()/(time_action*1e6);
+ }
+
+ BTL_DONT_INLINE double time_calculate(Action & action)
+ {
+ // time measurement
+ action.calculate();
+ _chronos.start();
+ for (int ii=0; ii<_nb_calc; ii++)
+ {
+ action.calculate();
+ }
+ _chronos.stop();
+
+ double user_time = _chronos.user_time();
+ if (user_time < 0) {
+ std::cout << " { error: nb=" << _nb_calc << ", time=" << user_time << " } " << std::flush;
+ }
+ return user_time;
+ }
+
+ unsigned long long get_nb_calc()
+ {
+ return _nb_calc;
+ }
+
+
+private:
+ int context;
+ unsigned long long _nb_calc;
+ double m_time_action;
+ Portable_Timer _chronos;
+
+};
+
+#endif //_PORTABLE_PERF_ANALYZER_ROOT_HH
+
diff --git a/btl/generic_bench/timers/mixed_perf_analyzer.hh b/btl/generic_bench/timers/mixed_perf_analyzer.hh
new file mode 100644
index 0000000..e190236
--- /dev/null
+++ b/btl/generic_bench/timers/mixed_perf_analyzer.hh
@@ -0,0 +1,73 @@
+//=====================================================
+// File : mixed_perf_analyzer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar déc 3 18:59:36 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _MIXED_PERF_ANALYSER_HH
+#define _MIXED_PERF_ANALYSER_HH
+
+#include "x86_perf_analyzer.hh"
+#include "portable_perf_analyzer.hh"
+
+// choose portable perf analyzer for long calculations and x86 analyser for short ones
+
+
+template<class Action>
+class Mixed_Perf_Analyzer{
+
+public:
+ Mixed_Perf_Analyzer( void ):_x86pa(),_ppa(),_use_ppa(true)
+ {
+ MESSAGE("Mixed_Perf_Analyzer Ctor");
+ };
+ Mixed_Perf_Analyzer( const Mixed_Perf_Analyzer & ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~Mixed_Perf_Analyzer( void ){
+ MESSAGE("Mixed_Perf_Analyzer Dtor");
+ };
+
+
+ inline double eval_mflops(int size)
+ {
+
+ double result=0.0;
+ if (_use_ppa){
+ result=_ppa.eval_mflops(size);
+ if (_ppa.get_nb_calc()>DEFAULT_NB_SAMPLE){_use_ppa=false;}
+ }
+ else{
+ result=_x86pa.eval_mflops(size);
+ }
+
+ return result;
+ }
+
+private:
+
+ Portable_Perf_Analyzer<Action> _ppa;
+ X86_Perf_Analyzer<Action> _x86pa;
+ bool _use_ppa;
+
+};
+
+#endif
+
+
+
+
diff --git a/btl/generic_bench/timers/portable_perf_analyzer.hh b/btl/generic_bench/timers/portable_perf_analyzer.hh
new file mode 100644
index 0000000..b207bde
--- /dev/null
+++ b/btl/generic_bench/timers/portable_perf_analyzer.hh
@@ -0,0 +1,110 @@
+//=====================================================
+// File : portable_perf_analyzer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002
+// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _PORTABLE_PERF_ANALYZER_HH
+#define _PORTABLE_PERF_ANALYZER_HH
+
+#include "utilities.h"
+#include "timers/portable_timer.hh"
+#include <iomanip>
+
+template <class Action>
+class Portable_Perf_Analyzer{
+public:
+ Portable_Perf_Analyzer( ):_nb_calc(0), m_time_action(0), _chronos(){
+ MESSAGE("Portable_Perf_Analyzer Ctor");
+ };
+ Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~Portable_Perf_Analyzer(){
+ MESSAGE("Portable_Perf_Analyzer Dtor");
+ };
+
+ BTL_DONT_INLINE double eval_mflops(int size, bool silent = false)
+ {
+ Action action(size);
+
+ while (m_time_action < MIN_TIME) {
+ _nb_calc = _nb_calc ? 2*_nb_calc : 1;
+ action.initialize();
+ m_time_action = time_calculate(action);
+ }
+
+ // optimize
+ for (int i=1; i<BtlConfig::Instance.tries; ++i)
+ {
+ Action _action(size);
+ if (!silent) {
+ if (_action.nb_op_base()*_nb_calc < 0)
+ std::cout << " { op*calc = " << _action.nb_op_base()*_nb_calc << " } " << std::flush;
+ std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " ";
+ }
+ _action.initialize();
+ m_time_action = std::min(m_time_action, time_calculate(_action));
+ }
+
+ double time_action = m_time_action / (double(_nb_calc));
+
+ // check
+ if (BtlConfig::Instance.checkResults && size<128)
+ {
+ action.initialize();
+ action.calculate();
+ action.check_result();
+ }
+ return action.nb_op_base()/(time_action*1e6);
+ }
+
+ BTL_DONT_INLINE double time_calculate(Action & action)
+ {
+ // time measurement
+ action.calculate();
+ _chronos.start();
+ for (int ii=0; ii<_nb_calc; ii++)
+ {
+ action.calculate();
+ }
+ _chronos.stop();
+
+ double user_time = _chronos.user_time();
+ if (user_time < 0) {
+ std::cout << " { error: nb=" << _nb_calc << ", time=" << user_time << " } " << std::flush;
+ }
+ return user_time;
+ }
+
+ unsigned long long get_nb_calc()
+ {
+ return _nb_calc;
+ }
+
+
+private:
+ unsigned long long _nb_calc;
+ double m_time_action;
+ Portable_Timer _chronos;
+
+};
+
+#endif //_PORTABLE_PERF_ANALYZER_HH
+
diff --git a/btl/generic_bench/timers/portable_perf_analyzer_old.hh b/btl/generic_bench/timers/portable_perf_analyzer_old.hh
new file mode 100644
index 0000000..fce3781
--- /dev/null
+++ b/btl/generic_bench/timers/portable_perf_analyzer_old.hh
@@ -0,0 +1,134 @@
+//=====================================================
+// File : portable_perf_analyzer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _PORTABLE_PERF_ANALYZER_HH
+#define _PORTABLE_PERF_ANALYZER_HH
+
+#include "utilities.h"
+#include "timers/portable_timer.hh"
+
+template <class Action>
+class Portable_Perf_Analyzer{
+public:
+ Portable_Perf_Analyzer( void ):_nb_calc(1),_nb_init(1),_chronos(){
+ MESSAGE("Portable_Perf_Analyzer Ctor");
+ };
+ Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~Portable_Perf_Analyzer( void ){
+ MESSAGE("Portable_Perf_Analyzer Dtor");
+ };
+
+
+
+ inline double eval_mflops(int size)
+ {
+
+ Action action(size);
+
+// double time_baseline = time_init(action);
+// while (time_baseline < MIN_TIME_INIT)
+// {
+// _nb_init *= 2;
+// time_baseline = time_init(action);
+// }
+//
+// // optimize
+// for (int i=1; i<NB_TRIES; ++i)
+// time_baseline = std::min(time_baseline, time_init(action));
+//
+// time_baseline = time_baseline/(double(_nb_init));
+
+ double time_action = time_calculate(action);
+ while (time_action < MIN_TIME)
+ {
+ _nb_calc *= 2;
+ time_action = time_calculate(action);
+ }
+
+ // optimize
+ for (int i=1; i<NB_TRIES; ++i)
+ time_action = std::min(time_action, time_calculate(action));
+
+// INFOS("size="<<size);
+// INFOS("_nb_init="<<_nb_init);
+// INFOS("_nb_calc="<<_nb_calc);
+
+ time_action = time_action / (double(_nb_calc));
+
+ action.check_result();
+
+
+ double time_baseline = time_init(action);
+ for (int i=1; i<NB_TRIES; ++i)
+ time_baseline = std::min(time_baseline, time_init(action));
+ time_baseline = time_baseline/(double(_nb_init));
+
+
+
+// INFOS("time_baseline="<<time_baseline);
+// INFOS("time_action="<<time_action);
+
+ time_action = time_action - time_baseline;
+
+// INFOS("time_corrected="<<time_action);
+
+ return action.nb_op_base()/(time_action*1000000.0);
+ }
+
+ inline double time_init(Action & action)
+ {
+ // time measurement
+ _chronos.start();
+ for (int ii=0; ii<_nb_init; ii++)
+ action.initialize();
+ _chronos.stop();
+ return _chronos.user_time();
+ }
+
+
+ inline double time_calculate(Action & action)
+ {
+ // time measurement
+ _chronos.start();
+ for (int ii=0;ii<_nb_calc;ii++)
+ {
+ action.initialize();
+ action.calculate();
+ }
+ _chronos.stop();
+ return _chronos.user_time();
+ }
+
+ unsigned long long get_nb_calc( void )
+ {
+ return _nb_calc;
+ }
+
+
+private:
+ unsigned long long _nb_calc;
+ unsigned long long _nb_init;
+ Portable_Timer _chronos;
+
+};
+
+#endif //_PORTABLE_PERF_ANALYZER_HH
diff --git a/btl/generic_bench/timers/portable_timer.hh b/btl/generic_bench/timers/portable_timer.hh
new file mode 100755
index 0000000..e6ad309
--- /dev/null
+++ b/btl/generic_bench/timers/portable_timer.hh
@@ -0,0 +1,145 @@
+//=====================================================
+// File : portable_timer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)> from boost lib
+// Copyright (C) EDF R&D, lun sep 30 14:23:17 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// simple_time extracted from the boost library
+//
+#ifndef _PORTABLE_TIMER_HH
+#define _PORTABLE_TIMER_HH
+
+#include <ctime>
+#include <cstdlib>
+
+#include <time.h>
+
+
+#define USEC_IN_SEC 1000000
+
+
+// timer -------------------------------------------------------------------//
+
+// A timer object measures CPU time.
+#ifdef _MSC_VER
+
+#define NOMINMAX
+#include <windows.h>
+
+/*#ifndef hr_timer
+#include "hr_time.h"
+#define hr_timer
+#endif*/
+
+ class Portable_Timer
+ {
+ public:
+
+ typedef struct {
+ LARGE_INTEGER start;
+ LARGE_INTEGER stop;
+ } stopWatch;
+
+
+ Portable_Timer()
+ {
+ startVal.QuadPart = 0;
+ stopVal.QuadPart = 0;
+ QueryPerformanceFrequency(&frequency);
+ }
+
+ void start() { QueryPerformanceCounter(&startVal); }
+
+ void stop() { QueryPerformanceCounter(&stopVal); }
+
+ double elapsed() {
+ LARGE_INTEGER time;
+ time.QuadPart = stopVal.QuadPart - startVal.QuadPart;
+ return LIToSecs(time);
+ }
+
+ double user_time() { return elapsed(); }
+
+
+ private:
+
+ double LIToSecs(LARGE_INTEGER& L) {
+ return ((double)L.QuadPart /(double)frequency.QuadPart) ;
+ }
+
+ LARGE_INTEGER startVal;
+ LARGE_INTEGER stopVal;
+ LARGE_INTEGER frequency;
+
+
+ }; // Portable_Timer
+
+#else
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <sys/times.h>
+
+class Portable_Timer
+{
+ public:
+
+ Portable_Timer()
+ {
+ m_clkid = BtlConfig::Instance.realclock ? CLOCK_REALTIME : CLOCK_PROCESS_CPUTIME_ID;
+ }
+
+ Portable_Timer(int clkid) : m_clkid(clkid)
+ {}
+
+ void start()
+ {
+ timespec ts;
+ clock_gettime(m_clkid, &ts);
+ m_start_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
+
+ }
+
+ void stop()
+ {
+ timespec ts;
+ clock_gettime(m_clkid, &ts);
+ m_stop_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
+
+ }
+
+ double elapsed()
+ {
+ return user_time();
+ }
+
+ double user_time()
+ {
+ return m_stop_time - m_start_time;
+ }
+
+
+private:
+
+ int m_clkid;
+ double m_stop_time, m_start_time;
+
+}; // Portable_Timer
+
+#endif
+
+#endif // PORTABLE_TIMER_HPP
diff --git a/btl/generic_bench/timers/x86_perf_analyzer.hh b/btl/generic_bench/timers/x86_perf_analyzer.hh
new file mode 100644
index 0000000..37ea21d
--- /dev/null
+++ b/btl/generic_bench/timers/x86_perf_analyzer.hh
@@ -0,0 +1,108 @@
+//=====================================================
+// File : x86_perf_analyzer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _X86_PERF_ANALYSER_HH
+#define _X86_PERF_ANALYSER_HH
+
+#include "x86_timer.hh"
+#include "bench_parameter.hh"
+
+template<class ACTION>
+class X86_Perf_Analyzer{
+public:
+ X86_Perf_Analyzer( unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos()
+ {
+ MESSAGE("X86_Perf_Analyzer Ctor");
+ _chronos.find_frequency();
+ };
+ X86_Perf_Analyzer( const X86_Perf_Analyzer & ){
+ INFOS("Copy Ctor not implemented");
+ exit(0);
+ };
+ ~X86_Perf_Analyzer( void ){
+ MESSAGE("X86_Perf_Analyzer Dtor");
+ };
+
+
+ inline double eval_mflops(int size)
+ {
+
+ ACTION action(size);
+
+ int nb_loop=5;
+ double calculate_time=0.0;
+ double baseline_time=0.0;
+
+ for (int j=0 ; j < nb_loop ; j++){
+
+ _chronos.clear();
+
+ for(int i=0 ; i < _nb_sample ; i++)
+ {
+ _chronos.start();
+ action.initialize();
+ action.calculate();
+ _chronos.stop();
+ _chronos.add_get_click();
+ }
+
+ calculate_time += double(_chronos.get_shortest_clicks())/_chronos.frequency();
+
+ if (j==0) action.check_result();
+
+ _chronos.clear();
+
+ for(int i=0 ; i < _nb_sample ; i++)
+ {
+ _chronos.start();
+ action.initialize();
+ _chronos.stop();
+ _chronos.add_get_click();
+
+ }
+
+ baseline_time+=double(_chronos.get_shortest_clicks())/_chronos.frequency();
+
+ }
+
+ double corrected_time = (calculate_time-baseline_time)/double(nb_loop);
+
+
+// INFOS("_nb_sample="<<_nb_sample);
+// INFOS("baseline_time="<<baseline_time);
+// INFOS("calculate_time="<<calculate_time);
+// INFOS("corrected_time="<<corrected_time);
+
+// cout << size <<" "<<baseline_time<<" "<<calculate_time<<" "<<corrected_time<<" "<<action.nb_op_base() << endl;
+
+ return action.nb_op_base()/(corrected_time*1000000.0);
+ //return action.nb_op_base()/(calculate_time*1000000.0);
+ }
+
+private:
+
+ X86_Timer _chronos;
+ unsigned long long _nb_sample;
+
+
+};
+
+
+
+#endif
diff --git a/btl/generic_bench/timers/x86_timer.hh b/btl/generic_bench/timers/x86_timer.hh
new file mode 100644
index 0000000..cfb5ee8
--- /dev/null
+++ b/btl/generic_bench/timers/x86_timer.hh
@@ -0,0 +1,246 @@
+//=====================================================
+// File : x86_timer.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef _X86_TIMER_HH
+#define _X86_TIMER_HH
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <sys/times.h>
+//#include "system_time.h"
+#define u32 unsigned int
+#include <asm/msr.h>
+#include "utilities.h"
+#include <map>
+#include <fstream>
+#include <string>
+#include <iostream>
+
+// frequence de la becanne en Hz
+//#define FREQUENCY 648000000
+//#define FREQUENCY 1400000000
+#define FREQUENCY 1695000000
+
+using namespace std;
+
+
+class X86_Timer {
+
+public :
+
+ X86_Timer( void ):_frequency(FREQUENCY),_nb_sample(0)
+ {
+ MESSAGE("X86_Timer Default Ctor");
+ }
+
+ inline void start( void ){
+
+ rdtsc(_click_start.n32[0],_click_start.n32[1]);
+
+ }
+
+
+ inline void stop( void ){
+
+ rdtsc(_click_stop.n32[0],_click_stop.n32[1]);
+
+ }
+
+
+ inline double frequency( void ){
+ return _frequency;
+ }
+
+ double get_elapsed_time_in_second( void ){
+
+ return (_click_stop.n64-_click_start.n64)/double(FREQUENCY);
+
+
+ }
+
+ unsigned long long get_click( void ){
+
+ return (_click_stop.n64-_click_start.n64);
+
+ }
+
+ inline void find_frequency( void ){
+
+ time_t initial, final;
+ int dummy=2;
+
+ initial = time(0);
+ start();
+ do {
+ dummy+=2;
+ }
+ while(time(0)==initial);
+ // On est au debut d'un cycle d'une seconde !!!
+ initial = time(0);
+ start();
+ do {
+ dummy+=2;
+ }
+ while(time(0)==initial);
+ final=time(0);
+ stop();
+ // INFOS("fine grained time : "<< get_elapsed_time_in_second());
+ // INFOS("coarse grained time : "<< final-initial);
+ _frequency=_frequency*get_elapsed_time_in_second()/double(final-initial);
+ /// INFOS("CPU frequency : "<< _frequency);
+
+ }
+
+ void add_get_click( void ){
+
+ _nb_sample++;
+ _counted_clicks[get_click()]++;
+ fill_history_clicks();
+
+ }
+
+ void dump_statistics(string filemane){
+
+ ofstream outfile (filemane.c_str(),ios::out) ;
+
+ std::map<unsigned long long , unsigned long long>::iterator itr;
+ for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++)
+ {
+ outfile << (*itr).first << " " << (*itr).second << endl ;
+ }
+
+ outfile.close();
+
+ }
+
+ void dump_history(string filemane){
+
+ ofstream outfile (filemane.c_str(),ios::out) ;
+
+
+
+ for(int i=0 ; i<_history_mean_clicks.size() ; i++)
+ {
+ outfile << i << " "
+ << _history_mean_clicks[i] << " "
+ << _history_shortest_clicks[i] << " "
+ << _history_most_occured_clicks[i] << endl ;
+ }
+
+ outfile.close();
+
+ }
+
+
+
+ double get_mean_clicks( void ){
+
+ std::map<unsigned long long,unsigned long long>::iterator itr;
+
+ unsigned long long mean_clicks=0;
+
+ for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++)
+ {
+
+ mean_clicks+=(*itr).second*(*itr).first;
+ }
+
+ return mean_clicks/double(_nb_sample);
+
+ }
+
+ double get_shortest_clicks( void ){
+
+ return double((*_counted_clicks.begin()).first);
+
+ }
+
+ void fill_history_clicks( void ){
+
+ _history_mean_clicks.push_back(get_mean_clicks());
+ _history_shortest_clicks.push_back(get_shortest_clicks());
+ _history_most_occured_clicks.push_back(get_most_occured_clicks());
+
+ }
+
+
+ double get_most_occured_clicks( void ){
+
+ unsigned long long moc=0;
+ unsigned long long max_occurence=0;
+
+ std::map<unsigned long long,unsigned long long>::iterator itr;
+
+ for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++)
+ {
+
+ if (max_occurence<=(*itr).second){
+ max_occurence=(*itr).second;
+ moc=(*itr).first;
+ }
+ }
+
+ return double(moc);
+
+ }
+
+ void clear( void )
+ {
+ _counted_clicks.clear();
+
+ _history_mean_clicks.clear();
+ _history_shortest_clicks.clear();
+ _history_most_occured_clicks.clear();
+
+ _nb_sample=0;
+ }
+
+
+
+private :
+
+ union
+ {
+ unsigned long int n32[2] ;
+ unsigned long long n64 ;
+ } _click_start;
+
+ union
+ {
+ unsigned long int n32[2] ;
+ unsigned long long n64 ;
+ } _click_stop;
+
+ double _frequency ;
+
+ map<unsigned long long,unsigned long long> _counted_clicks;
+
+ vector<double> _history_mean_clicks;
+ vector<double> _history_shortest_clicks;
+ vector<double> _history_most_occured_clicks;
+
+ unsigned long long _nb_sample;
+
+
+
+};
+
+
+#endif
diff --git a/btl/generic_bench/utils/LinearCongruential.hh b/btl/generic_bench/utils/LinearCongruential.hh
new file mode 100644
index 0000000..3aa3716
--- /dev/null
+++ b/btl/generic_bench/utils/LinearCongruential.hh
@@ -0,0 +1,83 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LINEARCONGRUENTIAL_HH_
+#define LINEARCONGRUENTIAL_HH_
+
+#include <vector>
+
+class LinearCongruential
+{
+ typedef std::vector<unsigned> buffer_t;
+ typedef unsigned int_t;
+
+public:
+ LinearCongruential(const int_t& seed) :
+ a_(1664525u), c_(1013904223u), m_(getM()), i_(0)
+ {
+ buffer_.resize(4096/sizeof(unsigned));
+ fillBuffer(seed);
+ }
+
+ int_t a() const { return a_; }
+ int_t c() const { return c_; }
+ int_t m() const { return m_; }
+
+ int_t get_int() {
+ if (i_ >= buffer_.size()) {
+ fillBuffer();
+ i_ = 0;
+ }
+ return buffer_.at(i_++);
+ }
+
+ double get_01() {
+ return static_cast<double>(get_int())/static_cast<double>(m_);
+ }
+
+private:
+ buffer_t buffer_;
+ const int_t a_, c_, m_;
+ std::size_t i_;
+
+ void fillBuffer(const int_t& seed)
+ {
+ buffer_.front() = (seed*a_+c_) & m_;
+ for (
+ typename buffer_t::iterator i = buffer_.begin()+1, end = buffer_.end();
+ i != end; ++i)
+ *i = (*(i-1)*a_ + c_) & m_;
+ }
+
+ void fillBuffer()
+ {
+ const int_t seed = buffer_.back();
+ fillBuffer(seed);
+ }
+
+ static int_t getM()
+ {
+ int_t _m = 1;
+ for (int i = 1; i < 32; ++i) {
+ _m <<= 1;
+ _m += 1;
+ }
+ return _m;
+ }
+};
+
+#endif /* LINEARCONGRUENTIAL_HH_ */
diff --git a/btl/generic_bench/utils/size_lin_log.hh b/btl/generic_bench/utils/size_lin_log.hh
new file mode 100644
index 0000000..7c272c0
--- /dev/null
+++ b/btl/generic_bench/utils/size_lin_log.hh
@@ -0,0 +1,70 @@
+//=====================================================
+// File : size_lin_log.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, mar déc 3 18:59:37 CET 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef SIZE_LIN_LOG
+#define SIZE_LIN_LOG
+
+#include "size_log.hh"
+
+template<class Vector>
+void size_lin_log(const int nb_point, const int size_min, const int size_max, Vector & X)
+{
+ int ten=10;
+ int nine=9;
+
+ X.resize(nb_point);
+
+ if (nb_point>ten){
+
+ for (int i=0;i<nine;i++){
+
+ X[i]=i+size_min;
+
+ }
+
+ Vector log_size;
+ size_log(nb_point-nine,nine+size_min,size_max,log_size);
+
+ for (int i=0;i<nb_point-nine;i++){
+
+ X[i+nine]=log_size[i];
+
+ }
+ }
+ else{
+
+ for (int i=0;i<nb_point;i++){
+
+ X[i]=i+1;
+
+ }
+ }
+
+ // for (int i=0;i<nb_point;i++){
+
+// INFOS("computed sizes : X["<<i<<"]="<<X[i]);
+
+// }
+
+}
+
+#endif
+
+
+
diff --git a/btl/generic_bench/utils/size_log.hh b/btl/generic_bench/utils/size_log.hh
new file mode 100644
index 0000000..13a3da7
--- /dev/null
+++ b/btl/generic_bench/utils/size_log.hh
@@ -0,0 +1,54 @@
+//=====================================================
+// File : size_log.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:17 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef SIZE_LOG
+#define SIZE_LOG
+
+#include "math.h"
+// The Vector class must satisfy the following part of STL vector concept :
+// resize() method
+// [] operator for seting element
+// the vector element are int compatible.
+template<class Vector>
+void size_log(const int nb_point, const int size_min, const int size_max, Vector & X)
+{
+ X.resize(nb_point);
+
+ float ls_min=log(float(size_min));
+ float ls_max=log(float(size_max));
+
+ float ls=0.0;
+
+ float delta_ls=(ls_max-ls_min)/(float(nb_point-1));
+
+ int size=0;
+
+ for (int i=0;i<nb_point;i++){
+
+ ls = ls_min + float(i)*delta_ls ;
+
+ size=int(exp(ls));
+
+ X[i]=size;
+ }
+
+}
+
+
+#endif
diff --git a/btl/generic_bench/utils/utilities.h b/btl/generic_bench/utils/utilities.h
new file mode 100644
index 0000000..d2330d0
--- /dev/null
+++ b/btl/generic_bench/utils/utilities.h
@@ -0,0 +1,90 @@
+//=============================================================================
+// File : utilities.h
+// Created : mar jun 19 13:18:14 CEST 2001
+// Author : Antoine YESSAYAN, Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2001
+// $Header$
+//=============================================================================
+
+/* --- Definition macros file to print information if _DEBUG_ is defined --- */
+
+# ifndef UTILITIES_H
+# define UTILITIES_H
+
+# include <stdlib.h>
+//# include <iostream> ok for gcc3.01
+# include <iostream>
+
+/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
+
+# define HEREWEARE cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;
+# define INFOS(chain) {HEREWEARE ; cerr << chain << endl ;}
+# define PYSCRIPT(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
+
+/* --- To print date and time of compilation of current source on stdout --- */
+
+# if defined ( __GNUC__ )
+# define COMPILER "g++" ;
+# elif defined ( __sun )
+# define COMPILER "CC" ;
+# elif defined ( __KCC )
+# define COMPILER "KCC" ;
+# elif defined ( __PGI )
+# define COMPILER "pgCC" ;
+# else
+# define COMPILER "undefined" ;
+# endif
+
+# ifdef INFOS_COMPILATION
+# error INFOS_COMPILATION already defined
+# endif
+# define INFOS_COMPILATION {\
+ cerr << flush;\
+ cout << __FILE__ ;\
+ cout << " [" << __LINE__ << "] : " ;\
+ cout << "COMPILED with " << COMPILER ;\
+ cout << ", " << __DATE__ ; \
+ cout << " at " << __TIME__ << endl ;\
+ cout << "\n\n" ;\
+ cout << flush ;\
+ }
+
+# ifdef _DEBUG_
+
+/* --- the following MACROS are useful at debug time --- */
+
+# define HERE cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;
+# define SCRUTE(var) HERE ; cerr << #var << "=" << var << endl ;
+# define MESSAGE(chain) {HERE ; cerr << chain << endl ;}
+# define INTERRUPTION(code) HERE ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;
+
+# ifndef ASSERT
+# define ASSERT(condition) if (!(condition)){ HERE ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION(1) ;}
+# endif /* ASSERT */
+
+#define REPERE cout<<flush ; cerr << " --------------" << endl << flush ;
+#define BEGIN_OF(chain) {REPERE ; HERE ; cerr << "Begin of: " << chain << endl ; REPERE ; }
+#define END_OF(chain) {REPERE ; HERE ; cerr << "Normal end of: " << chain << endl ; REPERE ; }
+
+
+
+# else /* ifdef _DEBUG_*/
+
+# define HERE
+# define SCRUTE(var)
+# define MESSAGE(chain)
+# define INTERRUPTION(code)
+
+# ifndef ASSERT
+# define ASSERT(condition)
+# endif /* ASSERT */
+
+#define REPERE
+#define BEGIN_OF(chain)
+#define END_OF(chain)
+
+
+# endif /* ifdef _DEBUG_*/
+
+# endif /* ifndef UTILITIES_H */
diff --git a/btl/generic_bench/utils/xy_file.hh b/btl/generic_bench/utils/xy_file.hh
new file mode 100644
index 0000000..4571bed
--- /dev/null
+++ b/btl/generic_bench/utils/xy_file.hh
@@ -0,0 +1,75 @@
+//=====================================================
+// File : dump_file_x_y.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:20 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef XY_FILE_HH
+#define XY_FILE_HH
+#include <fstream>
+#include <iostream>
+#include <string>
+#include <vector>
+using namespace std;
+
+bool read_xy_file(const std::string & filename, std::vector<int> & tab_sizes,
+ std::vector<double> & tab_mflops, bool quiet = false)
+{
+
+ std::ifstream input_file (filename.c_str(),std::ios::in);
+
+ if (!input_file){
+ if (!quiet) {
+ INFOS("!!! Error opening "<<filename);
+ }
+ return false;
+ }
+
+ int nb_point=0;
+ int size=0;
+ double mflops=0;
+
+ while (input_file >> size >> mflops ){
+ nb_point++;
+ tab_sizes.push_back(size);
+ tab_mflops.push_back(mflops);
+ }
+ SCRUTE(nb_point);
+
+ input_file.close();
+ return true;
+}
+
+// The Vector class must satisfy the following part of STL vector concept :
+// resize() method
+// [] operator for seting element
+// the vector element must have the << operator define
+
+using namespace std;
+
+template<class Vector_A, class Vector_B>
+void dump_xy_file(const Vector_A & X, const Vector_B & Y, const std::string & filename){
+
+ ofstream outfile (filename.c_str(),ios::out) ;
+ int size=X.size();
+
+ for (int i=0;i<size;i++)
+ outfile << X[i] << " " << Y[i] << endl;
+
+ outfile.close();
+}
+
+#endif
diff --git a/btl/libs/BLACS/blacs.h b/btl/libs/BLACS/blacs.h
new file mode 100644
index 0000000..97c863b
--- /dev/null
+++ b/btl/libs/BLACS/blacs.h
@@ -0,0 +1,50 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BLACS_H_
+#define BLACS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* BLACS declarations */
+ void blacs_pinfo_(int*, int*);
+ void blacs_get_(int*, int*, int*);
+ void blacs_gridinit_(int*, const char*, int*, int*);
+ void blacs_gridinfo_(const int*, int*, int*, int*, int*);
+ void blacs_pcoord_(const int*, const int*, int*, int*);
+ void blacs_gridexit_(int*);
+ void blacs_exit_(int*);
+ void blacs_barrier_(const int*, const char*);
+ void dgerv2d_(const int*, const int*, const int*, double*, const int*, const int*, const int*);
+ void dgesd2d_(const int*, const int*, const int*, const double*, const int*, const int*, const int*);
+ void sgerv2d_(const int*, const int*, const int*, float*, const int*, const int*, const int*);
+ void sgesd2d_(const int*, const int*, const int*, const float*, const int*, const int*, const int*);
+ void igebs2d_(const int*, const char*, const char*, const int*, const int*, const int*, const int*);
+ void igebr2d_(const int*, const char*, const char*, const int*, const int*, int*, const int*, const int*, const int*);
+ void dgebs2d_(const int*, const char*, const char*, const int*, const int*, const double*, const int*);
+ void dgebr2d_(const int*, const char*, const char*, const int*, const int*, double*, const int*, const int*, const int*);
+ void dgsum2d_(const int*, const char*, const char*, const int*, const int*, double*, const int*, const int*, const int*);
+ void igsum2d_(const int*, const char*, const char*, const int*, const int*, int*, const int*, const int*, const int*);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* BLACS_H_ */
diff --git a/btl/libs/BLACS/blacs_interface.hh b/btl/libs/BLACS/blacs_interface.hh
new file mode 100644
index 0000000..09f57b3
--- /dev/null
+++ b/btl/libs/BLACS/blacs_interface.hh
@@ -0,0 +1,153 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BTL_BLACS_INTERFACE_H
+#define BTL_BLACS_INTERFACE_H
+
+#include <vector>
+#include <algorithm>
+#include "blacs.h"
+extern "C" {
+ void descinit_(int*, const int*, const int*, const int*, const int*, const int*, const int*, const int*, const int*, int*);
+ int numroc_(const int*, const int*, const int*, const int*, const int*);
+}
+
+#include "scatter.h"
+#include "gather.h"
+
+template<typename real>
+class blacs_interface
+{
+
+public:
+ typedef real real_type;
+ typedef std::vector<real_type> stl_vector;
+ typedef stl_vector stl_matrix;
+
+ typedef real* gene_matrix;
+ typedef real* gene_vector;
+
+
+ static void free_matrix(gene_matrix & A, int N){
+ delete A;
+ }
+
+ static void free_vector(gene_vector & B){
+ delete B;
+ }
+
+ static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
+ int N = A_stl.size();
+ A = new real[N];
+ for (int j=0;j<N;j++)
+ A[j] = A_stl[j];
+ }
+
+ static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
+ int N = B_stl.size();
+ B = new real[N];
+ for (int i=0;i<N;i++)
+ B[i] = B_stl[i];
+ }
+
+ static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
+ int N = B_stl.size();
+ for (int i=0;i<N;i++)
+ B_stl[i] = B[i];
+ }
+
+ static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
+ int N = A_stl.size();
+ for (int i=0;i<N;i++)
+ A_stl[i] = A[i];
+ }
+
+ static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
+ for (int i=0;i<N;i++)
+ cible[i]=source[i];
+ }
+
+ static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
+ for (int i=0;i<N;i++)
+ cible[i]=source[i];
+ }
+
+
+public:
+ static int context() {
+ int ctxt, ignored, what = 0;
+ blacs_get_(&ignored, &what, &ctxt);
+ return ctxt;
+ }
+ static int myid() {
+ int procnum, myid;
+ blacs_pinfo_(&myid, &procnum);
+ return myid;
+ }
+
+
+ static void scatter_matrix(const stl_vector& GlobalMatrix, stl_vector& LocalMatrix,
+ int& GlobalRows, int& GlobalCols,
+ int& BlockRows, int& BlockCols,
+ int& LocalRows, int& LocalCols
+ ) {
+ scatter(context(), GlobalMatrix, LocalMatrix, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+ }
+
+ static void scatter_matrix(const stl_vector& GlobalMatrix, stl_vector& LocalMatrix,
+ int *desc,
+ const int& GlobalRows=0, const int& GlobalCols=0,
+ const int& BlockRows=0, const int& BlockCols=0
+ ) {
+ int GlobalRows_ = GlobalRows, GlobalCols_ = GlobalCols,
+ BlockRows_ = BlockRows, BlockCols_ = BlockCols,
+ LocalRows_, LocalCols_;
+ const int ctxt = context();
+ scatter(ctxt, GlobalMatrix, LocalMatrix,
+ GlobalRows_, GlobalCols_, BlockRows_, BlockCols_, LocalRows_, LocalCols_
+ );
+
+ const int iZERO = 0;
+ int info;
+ const int LLD = std::max(1, LocalRows_);
+ descinit_(desc, &GlobalRows_, &GlobalCols_, &BlockRows_, &BlockCols_,
+ &iZERO, &iZERO, &ctxt, &LLD, &info
+ );
+ }
+
+ static void gather_matrix(stl_vector& GlobalMatrix, const stl_vector& LocalMatrix,
+ int& GlobalRows, int& GlobalCols,
+ int& BlockRows, int& BlockCols,
+ int& LocalRows, int& LocalCols
+ ) {
+ gather(context(), GlobalMatrix, LocalMatrix, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+ }
+
+ static void gather_matrix(stl_vector& GlobalMatrix, const stl_vector& LocalMatrix,
+ int* desc
+ ) {
+ int GlobalRows = desc[2], GlobalCols = desc[3],
+ BlockRows = desc[4], BlockCols = desc[5],
+ LocalRows = desc[8], LocalCols = LocalMatrix.size()/desc[8];
+ const int ctxt = context();
+ gather(ctxt, GlobalMatrix, LocalMatrix, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+ }
+
+
+};
+
+#endif /* BTL_BLACS_INTERFACE_H */
diff --git a/btl/libs/BLACS/blacsinit.hh b/btl/libs/BLACS/blacsinit.hh
new file mode 100644
index 0000000..41f5ebf
--- /dev/null
+++ b/btl/libs/BLACS/blacsinit.hh
@@ -0,0 +1,38 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BLACSINIT_HH
+#define BLACSINIT_HH
+
+#include <cmath>
+
+bool blacsinit(int *argc, char ***argv)
+{
+ int context, myid, numproc, prows, pcols, iZERO = 0;
+ MPI_Init(argc, argv);
+ blacs_pinfo_(&myid, &numproc);
+ blacs_get_(&iZERO, &iZERO, &context);
+
+ int p = static_cast<double>(std::sqrt(static_cast<double>(numproc)) + 1.);
+ while (numproc % p) --p;
+ prows = p; pcols = numproc/p;
+
+ blacs_gridinit_(&context, "Row-major", &prows, &pcols);
+ return (myid == 0);
+}
+
+#endif /* BLACSINIT_HH */
diff --git a/btl/libs/BLACS/gather.h b/btl/libs/BLACS/gather.h
new file mode 100644
index 0000000..957f7c7
--- /dev/null
+++ b/btl/libs/BLACS/gather.h
@@ -0,0 +1,49 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef GATHER_H_
+#define GATHER_H_
+
+#define TYPENAME float
+#define TYPEPREFIX s
+#include "gather_impl.h"
+#undef TYPENAME
+#undef TYPEPREFIX
+
+#define TYPENAME double
+#define TYPEPREFIX d
+#include "gather_impl.h"
+#undef TYPENAME
+#undef TYPEPREFIX
+
+template<typename T>
+static void gather_matrix(std::vector<T>& GlobalMatrix, const std::vector<T>& LocalMatrix,
+ const int* desc
+) {
+ int GlobalRows = desc[2], GlobalCols = desc[3],
+ BlockRows = desc[4], BlockCols = desc[5],
+ LocalRows = desc[8], LocalCols = LocalMatrix.size()/desc[8];
+ int ctxt;
+ {
+ int ignored, what = 0;
+ blacs_get_(&ignored, &what, &ctxt);
+ }
+ gather(ctxt, GlobalMatrix, LocalMatrix, GlobalRows, GlobalCols, BlockRows, BlockCols, LocalRows, LocalCols);
+}
+
+
+#endif /* GATHER_H_ */
diff --git a/btl/libs/BLACS/gather_impl.h b/btl/libs/BLACS/gather_impl.h
new file mode 100644
index 0000000..3b57d57
--- /dev/null
+++ b/btl/libs/BLACS/gather_impl.h
@@ -0,0 +1,126 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#define PRFX d
+#define CAT_(x,y) x##y
+#define CAT(x,y) CAT_(x,y)
+
+#define FUNCNAME(name) CAT(CAT(TYPEPREFIX, name),_)
+#define vector_t std::vector<TYPENAME>
+
+#include <vector>
+
+
+inline void gather(
+ const int& context, // [IN]
+ vector_t& GlobalMatrixVector, // [OUT] Only relevant for root
+ const vector_t& LocalMatrixVector, // [IN]
+ int& GlobalRows, // [OUT]
+ int& GlobalCols, // [OUT]
+ int& BlockRows, // [IN (root) / OUT (other)]
+ int& BlockCols, // [IN (root) / OUT (other)]
+ int& LocalRows, // [IN]
+ int& LocalCols, // [IN]
+ const int& rootrow = 0, // [IN]
+ const int& rootcol = 0 // [IN]
+) {
+ /* Helper variables */
+ int iONE = 1, iTWO = 2, imONE = -1;
+
+ int myid, myrow, mycol, procrows, proccols, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ blacs_gridinfo_(&context, &procrows, &proccols, &myrow, &mycol);
+ bool iamroot = (myrow == rootrow && mycol == rootcol);
+ TYPENAME *GlobalMatrix;
+ const TYPENAME *LocalMatrix = &LocalMatrixVector[0];
+
+ /* Broadcast matrix info */
+ int binfo[2];
+ if (iamroot) {
+ binfo[0] = BlockRows;
+ binfo[1] = BlockCols;
+
+ igebs2d_(&context, "All", " ", &iTWO, &iONE, binfo, &iTWO);
+ } else {
+ igebr2d_(&context, "All", " ", &iTWO, &iONE, binfo, &iTWO,
+ &rootrow, &rootcol);
+ }
+ BlockRows = binfo[0];
+ BlockCols = binfo[1];
+
+ /* Retrieve matrix global dimensions */
+ int minfo[2];
+ minfo[0] = LocalRows; minfo[1] = LocalCols;
+ igsum2d_(&context, "Col", " ", &iONE, &iONE, minfo, &iONE, &imONE, &imONE);
+ igsum2d_(&context, "Row", " ", &iONE, &iONE, minfo+1, &iONE, &imONE, &imONE);
+ GlobalRows = minfo[0]; GlobalCols = minfo[1];
+
+
+ /* Reserve space on root */
+ if (iamroot) {
+ GlobalMatrixVector.resize(GlobalRows*GlobalCols);
+ GlobalMatrix = &GlobalMatrixVector[0];
+ }
+
+ /* Gather matrix */
+ int srcr = 0, srcc = 0;
+ int SendRows, SendCols;
+ int StartRow = 0, StartCol = 0;
+ for (int r = 0; r < GlobalRows; r += BlockRows, srcr=(srcr+1)%procrows) {
+ srcc = 0;
+
+ // Is this the last row bloc?
+ SendRows = BlockRows;
+ if (GlobalRows-r < BlockRows)
+ SendRows = GlobalRows-r;
+ if (SendRows <= 0)
+ SendRows = 0;
+
+ for (int c=0; c<GlobalCols; c+=BlockCols, srcc=(srcc+1)%proccols) {
+
+ // Is this the last column block?
+ SendCols = BlockCols;
+ if (GlobalCols-c < BlockCols)
+ SendCols = GlobalCols-c;
+
+ // Send data
+ if (myrow == srcr && mycol == srcc) {
+ FUNCNAME(gesd2d) (&context, &SendRows, &SendCols,
+ LocalMatrix+LocalRows*StartCol+StartRow,
+ &LocalRows, &rootrow, &rootcol
+ );
+
+ // Adjust the next starting column
+ StartCol = (StartCol + SendCols) % LocalCols;
+ }
+
+ // Receive data
+ if (iamroot) {
+ FUNCNAME(gerv2d) (&context, &SendRows, &SendCols,
+ GlobalMatrix + GlobalRows*c + r,
+ &GlobalRows, &srcr, &srcc
+ );
+ }
+ }
+
+ // Adjust the next starting row
+ if (myrow == srcr)
+ StartRow = (StartRow + SendRows) % LocalRows;
+
+ }
+
+}
diff --git a/btl/libs/BLACS/scatter.h b/btl/libs/BLACS/scatter.h
new file mode 100644
index 0000000..170e82a
--- /dev/null
+++ b/btl/libs/BLACS/scatter.h
@@ -0,0 +1,61 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef SCATTER_H_
+#define SCATTER_H_
+
+#define TYPENAME float
+#define TYPEPREFIX s
+#include "scatter_impl.h"
+#undef TYPENAME
+#undef TYPEPREFIX
+
+#define TYPENAME double
+#define TYPEPREFIX d
+#include "scatter_impl.h"
+#undef TYPENAME
+#undef TYPEPREFIX
+
+template<typename T>
+void scatter_matrix(const std::vector<T>& GlobalMatrix, std::vector<T>& LocalMatrix,
+ int *desc,
+ const int& GlobalRows=0, const int& GlobalCols=0,
+ const int& BlockRows=0, const int& BlockCols=0
+ )
+{
+ int GlobalRows_ = GlobalRows, GlobalCols_ = GlobalCols,
+ BlockRows_ = BlockRows, BlockCols_ = BlockCols,
+ LocalRows_, LocalCols_;
+ int ctxt;
+ {
+ int ignored, what = 0;
+ blacs_get_(&ignored, &what, &ctxt);
+ }
+ scatter(ctxt, GlobalMatrix, LocalMatrix,
+ GlobalRows_, GlobalCols_, BlockRows_, BlockCols_, LocalRows_, LocalCols_
+ );
+
+ const int iZERO = 0;
+ int info;
+ const int LLD = std::max(1, LocalRows_);
+ descinit_(desc, &GlobalRows_, &GlobalCols_, &BlockRows_, &BlockCols_,
+ &iZERO, &iZERO, &ctxt, &LLD, &info
+ );
+}
+
+
+#endif /* SCATTER_H_ */
diff --git a/btl/libs/BLACS/scatter_impl.h b/btl/libs/BLACS/scatter_impl.h
new file mode 100644
index 0000000..7c38c22
--- /dev/null
+++ b/btl/libs/BLACS/scatter_impl.h
@@ -0,0 +1,121 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#define CAT_(x,y) x##y
+#define CAT(x,y) CAT_(x,y)
+
+#define FUNCNAME(name) CAT(CAT(TYPEPREFIX, name),_)
+#define vector_t std::vector<TYPENAME>
+
+#include <vector>
+
+inline void scatter(
+ const int& context, // [IN]
+ const vector_t& GlobalMatrixVector, // [IN] Only relevant for root
+ vector_t& LocalMatrixVector, // [OUT] The space is reserved here
+ int& GlobalRows, // [IN (root) / OUT (other)]
+ int& GlobalCols, // [IN (root) / OUT (other)]
+ int& BlockRows, // [IN (root) / OUT (other)]
+ int& BlockCols, // [IN (root) / OUT (other)]
+ int& LocalRows, // [OUT]
+ int& LocalCols, // [OUT]
+ const int& rootrow = 0, // [IN]
+ const int& rootcol = 0 // [IN]
+) {
+ /* Helper variables */
+ int iZERO = 0, iONE = 1, iFOUR = 4;
+
+ int myid, myrow, mycol, procrows, proccols, procnum;
+ blacs_pinfo_(&myid, &procnum);
+ blacs_gridinfo_(&context, &procrows, &proccols, &myrow, &mycol);
+ bool iamroot = (myrow == rootrow && mycol == rootcol);
+ const TYPENAME *GlobalMatrix = &GlobalMatrixVector[0];
+ TYPENAME *LocalMatrix;
+
+ /* Broadcast matrix info */
+ int minfo[4];
+ if (iamroot) {
+ minfo[0] = GlobalRows;
+ minfo[1] = GlobalCols;
+ minfo[2] = BlockRows;
+ minfo[3] = BlockCols;
+ igebs2d_(&context, "All", " ", &iFOUR, &iONE, minfo, &iFOUR);
+ } else {
+ igebr2d_(&context, "All", " ", &iFOUR, &iONE, minfo, &iFOUR,
+ &iZERO, &iZERO);
+ }
+
+ GlobalRows = minfo[0];
+ GlobalCols = minfo[1];
+ BlockRows = minfo[2];
+ BlockCols = minfo[3];
+
+
+ /* Reserve space */
+ LocalRows = numroc_(&GlobalRows, &BlockRows, &myrow, &iZERO, &procrows);
+ LocalCols = numroc_(&GlobalCols, &BlockCols, &mycol, &iZERO, &proccols);
+ LocalMatrixVector.resize(LocalRows*LocalCols);
+ LocalMatrix = &LocalMatrixVector[0];
+
+ /* Scatter matrix */
+ int destr = 0, destc = 0;
+ int SendRows, SendCols;
+ int RecvRow = 0, RecvCol = 0;
+ for (int r = 0; r < GlobalRows; r += BlockRows, destr=(destr+1)%procrows) {
+ destc = 0;
+
+ // Is this the last row bloc?
+ SendRows = BlockRows;
+ if (GlobalRows-r < BlockRows)
+ SendRows = GlobalRows-r;
+ if (SendRows <= 0)
+ SendRows = 0;
+
+ for (int c=0; c<GlobalCols; c+=BlockCols, destc=(destc+1)%proccols) {
+
+ // Is this the last column block?
+ SendCols = BlockCols;
+ if (GlobalCols-c < BlockCols)
+ SendCols = GlobalCols-c;
+
+ // Send data
+ if (iamroot) {
+ FUNCNAME(gesd2d) (&context, &SendRows, &SendCols,
+ GlobalMatrix + GlobalRows*c + r,
+ &GlobalRows, &destr, &destc
+ );
+ }
+
+ // Rerceive data
+ if (myrow == destr && mycol == destc) {
+ FUNCNAME(gerv2d) (&context, &SendRows, &SendCols,
+ LocalMatrix+LocalRows*RecvCol+RecvRow,
+ &LocalRows, &rootrow, &rootcol
+ );
+
+ // Adjust the next starting column
+ RecvCol = (RecvCol + SendCols) % LocalCols;
+ }
+ }
+
+ // Adjust the next starting row
+ if (myrow == destr)
+ RecvRow = (RecvRow + SendRows) % LocalRows;
+
+ }
+
+}
diff --git a/btl/libs/BLAS/CMakeLists.txt b/btl/libs/BLAS/CMakeLists.txt
new file mode 100644
index 0000000..de42fe0
--- /dev/null
+++ b/btl/libs/BLAS/CMakeLists.txt
@@ -0,0 +1,60 @@
+
+find_package(ATLAS)
+if (ATLAS_FOUND)
+ btl_add_bench(btl_atlas main.cpp)
+ if(BUILD_btl_atlas)
+ target_link_libraries(btl_atlas ${ATLAS_LIBRARIES})
+ set_target_properties(btl_atlas PROPERTIES COMPILE_FLAGS "-DCBLASNAME=ATLAS -DHAS_LAPACK=1")
+ endif(BUILD_btl_atlas)
+endif (ATLAS_FOUND)
+
+find_package(MKL)
+if (MKL_FOUND)
+ btl_add_bench(btl_mkl main.cpp)
+ if(BUILD_btl_mkl)
+ target_link_libraries(btl_mkl ${MKL_LIBRARIES})
+ set_target_properties(btl_mkl PROPERTIES COMPILE_FLAGS "-DCBLASNAME=INTEL_MKL -DHAS_LAPACK=1")
+ endif(BUILD_btl_mkl)
+endif (MKL_FOUND)
+
+
+find_package(GOTO2)
+if (GOTO2_FOUND)
+ btl_add_bench(btl_goto2 main.cpp)
+ if(BUILD_btl_goto2)
+ target_link_libraries(btl_goto2 ${GOTO_LIBRARIES} )
+ set_target_properties(btl_goto2 PROPERTIES COMPILE_FLAGS "-DCBLASNAME=GOTO2")
+ endif(BUILD_btl_goto2)
+endif (GOTO2_FOUND)
+
+find_package(GOTO)
+if (GOTO_FOUND)
+ if(GOTO2_FOUND)
+ btl_add_bench(btl_goto main.cpp OFF)
+ else()
+ btl_add_bench(btl_goto main.cpp)
+ endif()
+ if(BUILD_btl_goto)
+ target_link_libraries(btl_goto ${GOTO_LIBRARIES} )
+ set_target_properties(btl_goto PROPERTIES COMPILE_FLAGS "-DCBLASNAME=GOTO")
+ endif(BUILD_btl_goto)
+endif (GOTO_FOUND)
+
+find_package(ACML)
+if (ACML_FOUND)
+ btl_add_bench(btl_acml main.cpp)
+ if(BUILD_btl_acml)
+ target_link_libraries(btl_acml ${ACML_LIBRARIES} )
+ set_target_properties(btl_acml PROPERTIES COMPILE_FLAGS "-DCBLASNAME=ACML -DHAS_LAPACK=1")
+ endif(BUILD_btl_acml)
+endif (ACML_FOUND)
+
+if(Eigen_SOURCE_DIR AND CMAKE_Fortran_COMPILER_WORKS)
+ # we are inside Eigen and blas/lapack interface is compilable
+ include_directories(${Eigen_SOURCE_DIR})
+ btl_add_bench(btl_eigenblas main.cpp)
+ if(BUILD_btl_eigenblas)
+ target_link_libraries(btl_eigenblas eigen_blas eigen_lapack )
+ set_target_properties(btl_eigenblas PROPERTIES COMPILE_FLAGS "-DCBLASNAME=EigenBLAS")
+ endif()
+endif()
diff --git a/btl/libs/BLAS/blas.h b/btl/libs/BLAS/blas.h
new file mode 100644
index 0000000..25607a5
--- /dev/null
+++ b/btl/libs/BLAS/blas.h
@@ -0,0 +1,681 @@
+#ifndef BLAS_H
+#define BLAS_H
+
+#define BLASFUNC(FUNC) FUNC##_
+
+#ifdef __WIN64__
+typedef long long BLASLONG;
+typedef unsigned long long BLASULONG;
+#else
+typedef long BLASLONG;
+typedef unsigned long BLASULONG;
+#endif
+
+#include <complex>
+
+extern "C" {
+
+int BLASFUNC(xerbla)(const char *, int *info, int);
+
+float BLASFUNC(sdot) (int *, float *, int *, float *, int *);
+float BLASFUNC(sdsdot)(int *, float *, float *, int *, float *, int *);
+
+double BLASFUNC(dsdot) (int *, float *, int *, float *, int *);
+double BLASFUNC(ddot) (int *, double *, int *, double *, int *);
+double BLASFUNC(qdot) (int *, double *, int *, double *, int *);
+
+#if defined(F_INTERFACE_GFORT) && !defined(__64BIT__)
+int BLASFUNC(cdotu) (int *, float * , int *, float *, int *);
+int BLASFUNC(cdotc) (int *, float *, int *, float *, int *);
+void BLASFUNC(zdotu) (double *, int *, double *, int *, double *, int *);
+void BLASFUNC(zdotc) (double *, int *, double *, int *, double *, int *);
+void BLASFUNC(xdotu) (double *, int *, double *, int *, double *, int *);
+void BLASFUNC(xdotc) (double *, int *, double *, int *, double *, int *);
+#elif defined(F_INTERFACE_F2C) || \
+ defined(F_INTERFACE_PGI) || \
+ defined(F_INTERFACE_GFORT) || \
+ (defined(F_INTERFACE_PATHSCALE) && defined(__64BIT__))
+void BLASFUNC(cdotu) (float *, int *, float * , int *, float *, int *);
+void BLASFUNC(cdotc) (float *, int *, float *, int *, float *, int *);
+void BLASFUNC(zdotu) (double *, int *, double *, int *, double *, int *);
+void BLASFUNC(zdotc) (double *, int *, double *, int *, double *, int *);
+void BLASFUNC(xdotu) (double *, int *, double *, int *, double *, int *);
+void BLASFUNC(xdotc) (double *, int *, double *, int *, double *, int *);
+#else
+std::complex<float> BLASFUNC(cdotu) (int *, float *, int *, float *, int *);
+std::complex<float> BLASFUNC(cdotc) (int *, float *, int *, float *, int *);
+std::complex<double> BLASFUNC(zdotu) (int *, double *, int *, double *, int *);
+std::complex<double> BLASFUNC(zdotc) (int *, double *, int *, double *, int *);
+double BLASFUNC(xdotu) (int *, double *, int *, double *, int *);
+double BLASFUNC(xdotc) (int *, double *, int *, double *, int *);
+#endif
+
+int BLASFUNC(cdotuw) (int *, float *, int *, float *, int *, float*);
+int BLASFUNC(cdotcw) (int *, float *, int *, float *, int *, float*);
+int BLASFUNC(zdotuw) (int *, double *, int *, double *, int *, double*);
+int BLASFUNC(zdotcw) (int *, double *, int *, double *, int *, double*);
+
+int BLASFUNC(saxpy) (int *, float *, float *, int *, float *, int *);
+int BLASFUNC(daxpy) (int *, double *, double *, int *, double *, int *);
+int BLASFUNC(qaxpy) (int *, double *, double *, int *, double *, int *);
+int BLASFUNC(caxpy) (int *, float *, float *, int *, float *, int *);
+int BLASFUNC(zaxpy) (int *, double *, double *, int *, double *, int *);
+int BLASFUNC(xaxpy) (int *, double *, double *, int *, double *, int *);
+int BLASFUNC(caxpyc)(int *, float *, float *, int *, float *, int *);
+int BLASFUNC(zaxpyc)(int *, double *, double *, int *, double *, int *);
+int BLASFUNC(xaxpyc)(int *, double *, double *, int *, double *, int *);
+
+int BLASFUNC(scopy) (int *, float *, int *, float *, int *);
+int BLASFUNC(dcopy) (int *, double *, int *, double *, int *);
+int BLASFUNC(qcopy) (int *, double *, int *, double *, int *);
+int BLASFUNC(ccopy) (int *, float *, int *, float *, int *);
+int BLASFUNC(zcopy) (int *, double *, int *, double *, int *);
+int BLASFUNC(xcopy) (int *, double *, int *, double *, int *);
+
+int BLASFUNC(sswap) (int *, float *, int *, float *, int *);
+int BLASFUNC(dswap) (int *, double *, int *, double *, int *);
+int BLASFUNC(qswap) (int *, double *, int *, double *, int *);
+int BLASFUNC(cswap) (int *, float *, int *, float *, int *);
+int BLASFUNC(zswap) (int *, double *, int *, double *, int *);
+int BLASFUNC(xswap) (int *, double *, int *, double *, int *);
+
+float BLASFUNC(sasum) (int *, float *, int *);
+float BLASFUNC(scasum)(int *, float *, int *);
+double BLASFUNC(dasum) (int *, double *, int *);
+double BLASFUNC(qasum) (int *, double *, int *);
+double BLASFUNC(dzasum)(int *, double *, int *);
+double BLASFUNC(qxasum)(int *, double *, int *);
+
+int BLASFUNC(isamax)(int *, float *, int *);
+int BLASFUNC(idamax)(int *, double *, int *);
+int BLASFUNC(iqamax)(int *, double *, int *);
+int BLASFUNC(icamax)(int *, float *, int *);
+int BLASFUNC(izamax)(int *, double *, int *);
+int BLASFUNC(ixamax)(int *, double *, int *);
+
+int BLASFUNC(ismax) (int *, float *, int *);
+int BLASFUNC(idmax) (int *, double *, int *);
+int BLASFUNC(iqmax) (int *, double *, int *);
+int BLASFUNC(icmax) (int *, float *, int *);
+int BLASFUNC(izmax) (int *, double *, int *);
+int BLASFUNC(ixmax) (int *, double *, int *);
+
+int BLASFUNC(isamin)(int *, float *, int *);
+int BLASFUNC(idamin)(int *, double *, int *);
+int BLASFUNC(iqamin)(int *, double *, int *);
+int BLASFUNC(icamin)(int *, float *, int *);
+int BLASFUNC(izamin)(int *, double *, int *);
+int BLASFUNC(ixamin)(int *, double *, int *);
+
+int BLASFUNC(ismin)(int *, float *, int *);
+int BLASFUNC(idmin)(int *, double *, int *);
+int BLASFUNC(iqmin)(int *, double *, int *);
+int BLASFUNC(icmin)(int *, float *, int *);
+int BLASFUNC(izmin)(int *, double *, int *);
+int BLASFUNC(ixmin)(int *, double *, int *);
+
+float BLASFUNC(samax) (int *, float *, int *);
+double BLASFUNC(damax) (int *, double *, int *);
+double BLASFUNC(qamax) (int *, double *, int *);
+float BLASFUNC(scamax)(int *, float *, int *);
+double BLASFUNC(dzamax)(int *, double *, int *);
+double BLASFUNC(qxamax)(int *, double *, int *);
+
+float BLASFUNC(samin) (int *, float *, int *);
+double BLASFUNC(damin) (int *, double *, int *);
+double BLASFUNC(qamin) (int *, double *, int *);
+float BLASFUNC(scamin)(int *, float *, int *);
+double BLASFUNC(dzamin)(int *, double *, int *);
+double BLASFUNC(qxamin)(int *, double *, int *);
+
+float BLASFUNC(smax) (int *, float *, int *);
+double BLASFUNC(dmax) (int *, double *, int *);
+double BLASFUNC(qmax) (int *, double *, int *);
+float BLASFUNC(scmax) (int *, float *, int *);
+double BLASFUNC(dzmax) (int *, double *, int *);
+double BLASFUNC(qxmax) (int *, double *, int *);
+
+float BLASFUNC(smin) (int *, float *, int *);
+double BLASFUNC(dmin) (int *, double *, int *);
+double BLASFUNC(qmin) (int *, double *, int *);
+float BLASFUNC(scmin) (int *, float *, int *);
+double BLASFUNC(dzmin) (int *, double *, int *);
+double BLASFUNC(qxmin) (int *, double *, int *);
+
+int BLASFUNC(sscal) (int *, float *, float *, int *);
+int BLASFUNC(dscal) (int *, double *, double *, int *);
+int BLASFUNC(qscal) (int *, double *, double *, int *);
+int BLASFUNC(cscal) (int *, float *, float *, int *);
+int BLASFUNC(zscal) (int *, double *, double *, int *);
+int BLASFUNC(xscal) (int *, double *, double *, int *);
+int BLASFUNC(csscal)(int *, float *, float *, int *);
+int BLASFUNC(zdscal)(int *, double *, double *, int *);
+int BLASFUNC(xqscal)(int *, double *, double *, int *);
+
+float BLASFUNC(snrm2) (int *, float *, int *);
+float BLASFUNC(scnrm2)(int *, float *, int *);
+
+double BLASFUNC(dnrm2) (int *, double *, int *);
+double BLASFUNC(qnrm2) (int *, double *, int *);
+double BLASFUNC(dznrm2)(int *, double *, int *);
+double BLASFUNC(qxnrm2)(int *, double *, int *);
+
+int BLASFUNC(srot) (int *, float *, int *, float *, int *, float *, float *);
+int BLASFUNC(drot) (int *, double *, int *, double *, int *, double *, double *);
+int BLASFUNC(qrot) (int *, double *, int *, double *, int *, double *, double *);
+int BLASFUNC(csrot) (int *, float *, int *, float *, int *, float *, float *);
+int BLASFUNC(zdrot) (int *, double *, int *, double *, int *, double *, double *);
+int BLASFUNC(xqrot) (int *, double *, int *, double *, int *, double *, double *);
+
+int BLASFUNC(srotg) (float *, float *, float *, float *);
+int BLASFUNC(drotg) (double *, double *, double *, double *);
+int BLASFUNC(qrotg) (double *, double *, double *, double *);
+int BLASFUNC(crotg) (float *, float *, float *, float *);
+int BLASFUNC(zrotg) (double *, double *, double *, double *);
+int BLASFUNC(xrotg) (double *, double *, double *, double *);
+
+int BLASFUNC(srotmg)(float *, float *, float *, float *, float *);
+int BLASFUNC(drotmg)(double *, double *, double *, double *, double *);
+
+int BLASFUNC(srotm) (int *, float *, int *, float *, int *, float *);
+int BLASFUNC(drotm) (int *, double *, int *, double *, int *, double *);
+int BLASFUNC(qrotm) (int *, double *, int *, double *, int *, double *);
+
+/* Level 2 routines */
+
+int BLASFUNC(sger)(int *, int *, float *, float *, int *,
+ float *, int *, float *, int *);
+int BLASFUNC(dger)(int *, int *, double *, double *, int *,
+ double *, int *, double *, int *);
+int BLASFUNC(qger)(int *, int *, double *, double *, int *,
+ double *, int *, double *, int *);
+int BLASFUNC(cgeru)(int *, int *, float *, float *, int *,
+ float *, int *, float *, int *);
+int BLASFUNC(cgerc)(int *, int *, float *, float *, int *,
+ float *, int *, float *, int *);
+int BLASFUNC(zgeru)(int *, int *, double *, double *, int *,
+ double *, int *, double *, int *);
+int BLASFUNC(zgerc)(int *, int *, double *, double *, int *,
+ double *, int *, double *, int *);
+int BLASFUNC(xgeru)(int *, int *, double *, double *, int *,
+ double *, int *, double *, int *);
+int BLASFUNC(xgerc)(int *, int *, double *, double *, int *,
+ double *, int *, double *, int *);
+
+int BLASFUNC(sgemv)(char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dgemv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(qgemv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(cgemv)(char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zgemv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xgemv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(strsv) (char *, char *, char *, int *, float *, int *,
+ float *, int *);
+int BLASFUNC(dtrsv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+int BLASFUNC(qtrsv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+int BLASFUNC(ctrsv) (char *, char *, char *, int *, float *, int *,
+ float *, int *);
+int BLASFUNC(ztrsv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+int BLASFUNC(xtrsv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+
+int BLASFUNC(stpsv) (char *, char *, char *, int *, float *, float *, int *);
+int BLASFUNC(dtpsv) (char *, char *, char *, int *, double *, double *, int *);
+int BLASFUNC(qtpsv) (char *, char *, char *, int *, double *, double *, int *);
+int BLASFUNC(ctpsv) (char *, char *, char *, int *, float *, float *, int *);
+int BLASFUNC(ztpsv) (char *, char *, char *, int *, double *, double *, int *);
+int BLASFUNC(xtpsv) (char *, char *, char *, int *, double *, double *, int *);
+
+int BLASFUNC(strmv) (char *, char *, char *, int *, float *, int *,
+ float *, int *);
+int BLASFUNC(dtrmv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+int BLASFUNC(qtrmv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+int BLASFUNC(ctrmv) (char *, char *, char *, int *, float *, int *,
+ float *, int *);
+int BLASFUNC(ztrmv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+int BLASFUNC(xtrmv) (char *, char *, char *, int *, double *, int *,
+ double *, int *);
+
+int BLASFUNC(stpmv) (char *, char *, char *, int *, float *, float *, int *);
+int BLASFUNC(dtpmv) (char *, char *, char *, int *, double *, double *, int *);
+int BLASFUNC(qtpmv) (char *, char *, char *, int *, double *, double *, int *);
+int BLASFUNC(ctpmv) (char *, char *, char *, int *, float *, float *, int *);
+int BLASFUNC(ztpmv) (char *, char *, char *, int *, double *, double *, int *);
+int BLASFUNC(xtpmv) (char *, char *, char *, int *, double *, double *, int *);
+
+int BLASFUNC(stbmv) (char *, char *, char *, int *, int *, float *, int *, float *, int *);
+int BLASFUNC(dtbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+int BLASFUNC(qtbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+int BLASFUNC(ctbmv) (char *, char *, char *, int *, int *, float *, int *, float *, int *);
+int BLASFUNC(ztbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+int BLASFUNC(xtbmv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+
+int BLASFUNC(stbsv) (char *, char *, char *, int *, int *, float *, int *, float *, int *);
+int BLASFUNC(dtbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+int BLASFUNC(qtbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+int BLASFUNC(ctbsv) (char *, char *, char *, int *, int *, float *, int *, float *, int *);
+int BLASFUNC(ztbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+int BLASFUNC(xtbsv) (char *, char *, char *, int *, int *, double *, int *, double *, int *);
+
+int BLASFUNC(ssymv) (char *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dsymv) (char *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(qsymv) (char *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(csymv) (char *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zsymv) (char *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xsymv) (char *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(sspmv) (char *, int *, float *, float *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dspmv) (char *, int *, double *, double *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(qspmv) (char *, int *, double *, double *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(cspmv) (char *, int *, float *, float *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zspmv) (char *, int *, double *, double *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xspmv) (char *, int *, double *, double *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(ssyr) (char *, int *, float *, float *, int *,
+ float *, int *);
+int BLASFUNC(dsyr) (char *, int *, double *, double *, int *,
+ double *, int *);
+int BLASFUNC(qsyr) (char *, int *, double *, double *, int *,
+ double *, int *);
+int BLASFUNC(csyr) (char *, int *, float *, float *, int *,
+ float *, int *);
+int BLASFUNC(zsyr) (char *, int *, double *, double *, int *,
+ double *, int *);
+int BLASFUNC(xsyr) (char *, int *, double *, double *, int *,
+ double *, int *);
+
+int BLASFUNC(ssyr2) (char *, int *, float *,
+ float *, int *, float *, int *, float *, int *);
+int BLASFUNC(dsyr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *, int *);
+int BLASFUNC(qsyr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *, int *);
+int BLASFUNC(csyr2) (char *, int *, float *,
+ float *, int *, float *, int *, float *, int *);
+int BLASFUNC(zsyr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *, int *);
+int BLASFUNC(xsyr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *, int *);
+
+int BLASFUNC(sspr) (char *, int *, float *, float *, int *,
+ float *);
+int BLASFUNC(dspr) (char *, int *, double *, double *, int *,
+ double *);
+int BLASFUNC(qspr) (char *, int *, double *, double *, int *,
+ double *);
+int BLASFUNC(cspr) (char *, int *, float *, float *, int *,
+ float *);
+int BLASFUNC(zspr) (char *, int *, double *, double *, int *,
+ double *);
+int BLASFUNC(xspr) (char *, int *, double *, double *, int *,
+ double *);
+
+int BLASFUNC(sspr2) (char *, int *, float *,
+ float *, int *, float *, int *, float *);
+int BLASFUNC(dspr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *);
+int BLASFUNC(qspr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *);
+int BLASFUNC(cspr2) (char *, int *, float *,
+ float *, int *, float *, int *, float *);
+int BLASFUNC(zspr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *);
+int BLASFUNC(xspr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *);
+
+int BLASFUNC(cher) (char *, int *, float *, float *, int *,
+ float *, int *);
+int BLASFUNC(zher) (char *, int *, double *, double *, int *,
+ double *, int *);
+int BLASFUNC(xher) (char *, int *, double *, double *, int *,
+ double *, int *);
+
+int BLASFUNC(chpr) (char *, int *, float *, float *, int *, float *);
+int BLASFUNC(zhpr) (char *, int *, double *, double *, int *, double *);
+int BLASFUNC(xhpr) (char *, int *, double *, double *, int *, double *);
+
+int BLASFUNC(cher2) (char *, int *, float *,
+ float *, int *, float *, int *, float *, int *);
+int BLASFUNC(zher2) (char *, int *, double *,
+ double *, int *, double *, int *, double *, int *);
+int BLASFUNC(xher2) (char *, int *, double *,
+ double *, int *, double *, int *, double *, int *);
+
+int BLASFUNC(chpr2) (char *, int *, float *,
+ float *, int *, float *, int *, float *);
+int BLASFUNC(zhpr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *);
+int BLASFUNC(xhpr2) (char *, int *, double *,
+ double *, int *, double *, int *, double *);
+
+int BLASFUNC(chemv) (char *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zhemv) (char *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xhemv) (char *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(chpmv) (char *, int *, float *, float *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zhpmv) (char *, int *, double *, double *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xhpmv) (char *, int *, double *, double *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(snorm)(char *, int *, int *, float *, int *);
+int BLASFUNC(dnorm)(char *, int *, int *, double *, int *);
+int BLASFUNC(cnorm)(char *, int *, int *, float *, int *);
+int BLASFUNC(znorm)(char *, int *, int *, double *, int *);
+
+int BLASFUNC(sgbmv)(char *, int *, int *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(qgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(cgbmv)(char *, int *, int *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xgbmv)(char *, int *, int *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(ssbmv)(char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dsbmv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(qsbmv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(csbmv)(char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zsbmv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xsbmv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(chbmv)(char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zhbmv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xhbmv)(char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+/* Level 3 routines */
+
+int BLASFUNC(sgemm)(char *, char *, int *, int *, int *, float *,
+ float *, int *, float *, int *, float *, float *, int *);
+int BLASFUNC(dgemm)(char *, char *, int *, int *, int *, double *,
+ double *, int *, double *, int *, double *, double *, int *);
+int BLASFUNC(qgemm)(char *, char *, int *, int *, int *, double *,
+ double *, int *, double *, int *, double *, double *, int *);
+int BLASFUNC(cgemm)(char *, char *, int *, int *, int *, float *,
+ float *, int *, float *, int *, float *, float *, int *);
+int BLASFUNC(zgemm)(char *, char *, int *, int *, int *, double *,
+ double *, int *, double *, int *, double *, double *, int *);
+int BLASFUNC(xgemm)(char *, char *, int *, int *, int *, double *,
+ double *, int *, double *, int *, double *, double *, int *);
+
+int BLASFUNC(cgemm3m)(char *, char *, int *, int *, int *, float *,
+ float *, int *, float *, int *, float *, float *, int *);
+int BLASFUNC(zgemm3m)(char *, char *, int *, int *, int *, double *,
+ double *, int *, double *, int *, double *, double *, int *);
+int BLASFUNC(xgemm3m)(char *, char *, int *, int *, int *, double *,
+ double *, int *, double *, int *, double *, double *, int *);
+
+int BLASFUNC(sge2mm)(char *, char *, char *, int *, int *,
+ float *, float *, int *, float *, int *,
+ float *, float *, int *);
+int BLASFUNC(dge2mm)(char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *,
+ double *, double *, int *);
+int BLASFUNC(cge2mm)(char *, char *, char *, int *, int *,
+ float *, float *, int *, float *, int *,
+ float *, float *, int *);
+int BLASFUNC(zge2mm)(char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *,
+ double *, double *, int *);
+
+int BLASFUNC(strsm)(char *, char *, char *, char *, int *, int *,
+ float *, float *, int *, float *, int *);
+int BLASFUNC(dtrsm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+int BLASFUNC(qtrsm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+int BLASFUNC(ctrsm)(char *, char *, char *, char *, int *, int *,
+ float *, float *, int *, float *, int *);
+int BLASFUNC(ztrsm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+int BLASFUNC(xtrsm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+
+int BLASFUNC(strmm)(char *, char *, char *, char *, int *, int *,
+ float *, float *, int *, float *, int *);
+int BLASFUNC(dtrmm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+int BLASFUNC(qtrmm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+int BLASFUNC(ctrmm)(char *, char *, char *, char *, int *, int *,
+ float *, float *, int *, float *, int *);
+int BLASFUNC(ztrmm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+int BLASFUNC(xtrmm)(char *, char *, char *, char *, int *, int *,
+ double *, double *, int *, double *, int *);
+
+int BLASFUNC(ssymm)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dsymm)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(qsymm)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(csymm)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zsymm)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xsymm)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(csymm3m)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zsymm3m)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xsymm3m)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(ssyrk)(char *, char *, int *, int *, float *, float *, int *,
+ float *, float *, int *);
+int BLASFUNC(dsyrk)(char *, char *, int *, int *, double *, double *, int *,
+ double *, double *, int *);
+int BLASFUNC(qsyrk)(char *, char *, int *, int *, double *, double *, int *,
+ double *, double *, int *);
+int BLASFUNC(csyrk)(char *, char *, int *, int *, float *, float *, int *,
+ float *, float *, int *);
+int BLASFUNC(zsyrk)(char *, char *, int *, int *, double *, double *, int *,
+ double *, double *, int *);
+int BLASFUNC(xsyrk)(char *, char *, int *, int *, double *, double *, int *,
+ double *, double *, int *);
+
+int BLASFUNC(ssyr2k)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(dsyr2k)(char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+int BLASFUNC(qsyr2k)(char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+int BLASFUNC(csyr2k)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zsyr2k)(char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+int BLASFUNC(xsyr2k)(char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+
+int BLASFUNC(chemm)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zhemm)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xhemm)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(chemm3m)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zhemm3m)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+int BLASFUNC(xhemm3m)(char *, char *, int *, int *, double *, double *, int *,
+ double *, int *, double *, double *, int *);
+
+int BLASFUNC(cherk)(char *, char *, int *, int *, float *, float *, int *,
+ float *, float *, int *);
+int BLASFUNC(zherk)(char *, char *, int *, int *, double *, double *, int *,
+ double *, double *, int *);
+int BLASFUNC(xherk)(char *, char *, int *, int *, double *, double *, int *,
+ double *, double *, int *);
+
+int BLASFUNC(cher2k)(char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zher2k)(char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+int BLASFUNC(xher2k)(char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+int BLASFUNC(cher2m)(char *, char *, char *, int *, int *, float *, float *, int *,
+ float *, int *, float *, float *, int *);
+int BLASFUNC(zher2m)(char *, char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+int BLASFUNC(xher2m)(char *, char *, char *, int *, int *, double *, double *, int *,
+ double*, int *, double *, double *, int *);
+
+int BLASFUNC(sgemt)(char *, int *, int *, float *, float *, int *,
+ float *, int *);
+int BLASFUNC(dgemt)(char *, int *, int *, double *, double *, int *,
+ double *, int *);
+int BLASFUNC(cgemt)(char *, int *, int *, float *, float *, int *,
+ float *, int *);
+int BLASFUNC(zgemt)(char *, int *, int *, double *, double *, int *,
+ double *, int *);
+
+int BLASFUNC(sgema)(char *, char *, int *, int *, float *,
+ float *, int *, float *, float *, int *, float *, int *);
+int BLASFUNC(dgema)(char *, char *, int *, int *, double *,
+ double *, int *, double*, double *, int *, double*, int *);
+int BLASFUNC(cgema)(char *, char *, int *, int *, float *,
+ float *, int *, float *, float *, int *, float *, int *);
+int BLASFUNC(zgema)(char *, char *, int *, int *, double *,
+ double *, int *, double*, double *, int *, double*, int *);
+
+int BLASFUNC(sgems)(char *, char *, int *, int *, float *,
+ float *, int *, float *, float *, int *, float *, int *);
+int BLASFUNC(dgems)(char *, char *, int *, int *, double *,
+ double *, int *, double*, double *, int *, double*, int *);
+int BLASFUNC(cgems)(char *, char *, int *, int *, float *,
+ float *, int *, float *, float *, int *, float *, int *);
+int BLASFUNC(zgems)(char *, char *, int *, int *, double *,
+ double *, int *, double*, double *, int *, double*, int *);
+
+int BLASFUNC(sgetf2)(int *, int *, float *, int *, int *, int *);
+int BLASFUNC(dgetf2)(int *, int *, double *, int *, int *, int *);
+int BLASFUNC(qgetf2)(int *, int *, double *, int *, int *, int *);
+int BLASFUNC(cgetf2)(int *, int *, float *, int *, int *, int *);
+int BLASFUNC(zgetf2)(int *, int *, double *, int *, int *, int *);
+int BLASFUNC(xgetf2)(int *, int *, double *, int *, int *, int *);
+
+//int BLASFUNC(sgetrf)(int *, int *, float *, int *, int *, int *);
+//int BLASFUNC(dgetrf)(int *, int *, double *, int *, int *, int *);
+int BLASFUNC(qgetrf)(int *, int *, double *, int *, int *, int *);
+int BLASFUNC(cgetrf)(int *, int *, float *, int *, int *, int *);
+int BLASFUNC(zgetrf)(int *, int *, double *, int *, int *, int *);
+int BLASFUNC(xgetrf)(int *, int *, double *, int *, int *, int *);
+
+int BLASFUNC(slaswp)(int *, float *, int *, int *, int *, int *, int *);
+int BLASFUNC(dlaswp)(int *, double *, int *, int *, int *, int *, int *);
+int BLASFUNC(qlaswp)(int *, double *, int *, int *, int *, int *, int *);
+int BLASFUNC(claswp)(int *, float *, int *, int *, int *, int *, int *);
+int BLASFUNC(zlaswp)(int *, double *, int *, int *, int *, int *, int *);
+int BLASFUNC(xlaswp)(int *, double *, int *, int *, int *, int *, int *);
+
+int BLASFUNC(sgetrs)(char *, int *, int *, float *, int *, int *, float *, int *, int *);
+int BLASFUNC(dgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);
+int BLASFUNC(qgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);
+int BLASFUNC(cgetrs)(char *, int *, int *, float *, int *, int *, float *, int *, int *);
+int BLASFUNC(zgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);
+int BLASFUNC(xgetrs)(char *, int *, int *, double *, int *, int *, double *, int *, int *);
+
+int BLASFUNC(sgesv)(int *, int *, float *, int *, int *, float *, int *, int *);
+int BLASFUNC(dgesv)(int *, int *, double *, int *, int *, double*, int *, int *);
+int BLASFUNC(qgesv)(int *, int *, double *, int *, int *, double*, int *, int *);
+int BLASFUNC(cgesv)(int *, int *, float *, int *, int *, float *, int *, int *);
+int BLASFUNC(zgesv)(int *, int *, double *, int *, int *, double*, int *, int *);
+int BLASFUNC(xgesv)(int *, int *, double *, int *, int *, double*, int *, int *);
+
+int BLASFUNC(spotf2)(char *, int *, float *, int *, int *);
+int BLASFUNC(dpotf2)(char *, int *, double *, int *, int *);
+int BLASFUNC(qpotf2)(char *, int *, double *, int *, int *);
+int BLASFUNC(cpotf2)(char *, int *, float *, int *, int *);
+int BLASFUNC(zpotf2)(char *, int *, double *, int *, int *);
+int BLASFUNC(xpotf2)(char *, int *, double *, int *, int *);
+
+//int BLASFUNC(spotrf)(char *, int *, float *, int *, int *);
+//int BLASFUNC(dpotrf)(char *, int *, double *, int *, int *);
+int BLASFUNC(qpotrf)(char *, int *, double *, int *, int *);
+int BLASFUNC(cpotrf)(char *, int *, float *, int *, int *);
+int BLASFUNC(zpotrf)(char *, int *, double *, int *, int *);
+int BLASFUNC(xpotrf)(char *, int *, double *, int *, int *);
+
+int BLASFUNC(slauu2)(char *, int *, float *, int *, int *);
+int BLASFUNC(dlauu2)(char *, int *, double *, int *, int *);
+int BLASFUNC(qlauu2)(char *, int *, double *, int *, int *);
+int BLASFUNC(clauu2)(char *, int *, float *, int *, int *);
+int BLASFUNC(zlauu2)(char *, int *, double *, int *, int *);
+int BLASFUNC(xlauu2)(char *, int *, double *, int *, int *);
+
+int BLASFUNC(slauum)(char *, int *, float *, int *, int *);
+int BLASFUNC(dlauum)(char *, int *, double *, int *, int *);
+int BLASFUNC(qlauum)(char *, int *, double *, int *, int *);
+int BLASFUNC(clauum)(char *, int *, float *, int *, int *);
+int BLASFUNC(zlauum)(char *, int *, double *, int *, int *);
+int BLASFUNC(xlauum)(char *, int *, double *, int *, int *);
+
+int BLASFUNC(strti2)(char *, char *, int *, float *, int *, int *);
+int BLASFUNC(dtrti2)(char *, char *, int *, double *, int *, int *);
+int BLASFUNC(qtrti2)(char *, char *, int *, double *, int *, int *);
+int BLASFUNC(ctrti2)(char *, char *, int *, float *, int *, int *);
+int BLASFUNC(ztrti2)(char *, char *, int *, double *, int *, int *);
+int BLASFUNC(xtrti2)(char *, char *, int *, double *, int *, int *);
+
+int BLASFUNC(strtri)(char *, char *, int *, float *, int *, int *);
+int BLASFUNC(dtrtri)(char *, char *, int *, double *, int *, int *);
+int BLASFUNC(qtrtri)(char *, char *, int *, double *, int *, int *);
+int BLASFUNC(ctrtri)(char *, char *, int *, float *, int *, int *);
+int BLASFUNC(ztrtri)(char *, char *, int *, double *, int *, int *);
+int BLASFUNC(xtrtri)(char *, char *, int *, double *, int *, int *);
+
+int BLASFUNC(spotri)(char *, int *, float *, int *, int *);
+int BLASFUNC(dpotri)(char *, int *, double *, int *, int *);
+int BLASFUNC(qpotri)(char *, int *, double *, int *, int *);
+int BLASFUNC(cpotri)(char *, int *, float *, int *, int *);
+int BLASFUNC(zpotri)(char *, int *, double *, int *, int *);
+int BLASFUNC(xpotri)(char *, int *, double *, int *, int *);
+
+}
+
+#endif
diff --git a/btl/libs/BLAS/blas_interface.hh b/btl/libs/BLAS/blas_interface.hh
new file mode 100644
index 0000000..19fc3c1
--- /dev/null
+++ b/btl/libs/BLAS/blas_interface.hh
@@ -0,0 +1,77 @@
+//=====================================================
+// File : blas_interface.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:28 CEST 2002
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef blas_PRODUIT_MATRICE_VECTEUR_HH
+#define blas_PRODUIT_MATRICE_VECTEUR_HH
+
+#include <c_interface_base.h>
+#include <complex>
+extern "C"
+{
+#include "blas.h"
+#ifdef CBLAS_INTERFACE
+# include "cblas.h"
+#endif
+}
+
+#define MAKE_STRING2(S) #S
+#define MAKE_STRING(S) MAKE_STRING2(S)
+
+#define CAT2(A,B) A##B
+#define CAT(A,B) CAT2(A,B)
+
+
+template<class real> class blas_interface;
+
+
+static char notrans = 'N';
+static char trans = 'T';
+static char nonunit = 'N';
+static char lower = 'L';
+static char right = 'R';
+static char left = 'L';
+static int intone = 1;
+
+
+#define SCALAR float
+#define SCALAR_PREFIX s
+#ifdef CBLAS_INTERFACE
+# include "cblas_interface_impl.hh"
+#else
+# include "blas_interface_impl.hh"
+#endif
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+
+#define SCALAR double
+#define SCALAR_PREFIX d
+#ifdef CBLAS_INTERFACE
+# include "cblas_interface_impl.hh"
+#else
+# include "blas_interface_impl.hh"
+#endif
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+#endif
+
+
+
diff --git a/btl/libs/BLAS/blas_interface_impl.hh b/btl/libs/BLAS/blas_interface_impl.hh
new file mode 100644
index 0000000..63883a9
--- /dev/null
+++ b/btl/libs/BLAS/blas_interface_impl.hh
@@ -0,0 +1,96 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+
+#define BLAS_FUNC(NAME) CAT(CAT(SCALAR_PREFIX,NAME),_)
+
+template<> class blas_interface<SCALAR> : public c_interface_base<SCALAR>
+{
+
+public :
+
+ static SCALAR fone;
+ static SCALAR fzero;
+
+ static inline std::string name()
+ {
+ return MAKE_STRING(CBLASNAME);
+ }
+
+ static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(gemv)(&notrans,&N,&N,&fone,A,&N,B,&intone,&fzero,X,&intone);
+ }
+
+ static inline void symv(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(symv)(&lower, &N,&fone,A,&N,B,&intone,&fzero,X,&intone);
+ }
+
+ static inline void syr2(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(syr2)(&lower,&N,&fone,B,&intone,X,&intone,A,&N);
+ }
+
+ static inline void ger(gene_matrix & A, gene_vector & X, gene_vector & Y, int N){
+ BLAS_FUNC(ger)(&N,&N,&fone,X,&intone,Y,&intone,A,&N);
+ }
+
+ static inline void rot(gene_vector & A, gene_vector & B, SCALAR c, SCALAR s, int N){
+ BLAS_FUNC(rot)(&N,A,&intone,B,&intone,&c,&s);
+ }
+
+ static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(gemv)(&trans,&N,&N,&fone,A,&N,B,&intone,&fzero,X,&intone);
+ }
+
+ static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+ BLAS_FUNC(gemm)(&notrans,&notrans,&N,&N,&N,&fone,A,&N,B,&N,&fzero,X,&N);
+ }
+
+ static inline void transposed_matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+ BLAS_FUNC(gemm)(&notrans,&notrans,&N,&N,&N,&fone,A,&N,B,&N,&fzero,X,&N);
+ }
+
+ static inline void aat_product(gene_matrix & A, gene_matrix & X, int N){
+ BLAS_FUNC(syrk)(&lower,&notrans,&N,&N,&fone,A,&N,&fzero,X,&N);
+ }
+
+ static inline void axpy(SCALAR coef, const gene_vector & X, gene_vector & Y, int N){
+ BLAS_FUNC(axpy)(&N,&coef,X,&intone,Y,&intone);
+ }
+
+ static inline void axpby(SCALAR a, const gene_vector & X, SCALAR b, gene_vector & Y, int N){
+ BLAS_FUNC(scal)(&N,&b,Y,&intone);
+ BLAS_FUNC(axpy)(&N,&a,X,&intone,Y,&intone);
+ }
+
+ static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
+ BLAS_FUNC(copy)(&N, B, &intone, X, &intone);
+ BLAS_FUNC(trsv)(&lower, &notrans, &nonunit, &N, L, &N, X, &intone);
+ }
+
+ static inline void trisolve_lower_matrix(const gene_matrix & L, const gene_matrix& B, gene_matrix & X, int N){
+ BLAS_FUNC(copy)(&N, B, &intone, X, &intone);
+ BLAS_FUNC(trsm)(&right, &lower, &notrans, &nonunit, &N, &N, &fone, L, &N, X, &N);
+ }
+
+ static inline void trmm(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+ BLAS_FUNC(trmm)(&left, &lower, &notrans,&nonunit, &N,&N,&fone,A,&N,B,&N);
+ }
+
+};
+
+SCALAR blas_interface<SCALAR>::fone = SCALAR(1);
+SCALAR blas_interface<SCALAR>::fzero = SCALAR(0);
diff --git a/btl/libs/BLAS/c_interface_base.h b/btl/libs/BLAS/c_interface_base.h
new file mode 100644
index 0000000..3b6afbb
--- /dev/null
+++ b/btl/libs/BLAS/c_interface_base.h
@@ -0,0 +1,89 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BTL_C_INTERFACE_BASE_H
+#define BTL_C_INTERFACE_BASE_H
+
+#include "utilities.h"
+#include <vector>
+
+template<class real> class c_interface_base
+{
+
+public:
+
+ typedef real real_type;
+ typedef std::vector<real> stl_vector;
+ typedef std::vector<stl_vector > stl_matrix;
+
+ typedef real* gene_matrix;
+ typedef real* gene_vector;
+
+ static void free_matrix(gene_matrix & A, int N){
+ delete A;
+ }
+
+ static void free_vector(gene_vector & B){
+ delete B;
+ }
+
+ static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
+ int N = A_stl.size();
+ A = new real[N*N];
+ for (int j=0;j<N;j++)
+ for (int i=0;i<N;i++)
+ A[i+N*j] = A_stl[j][i];
+ }
+
+ static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
+ int N = B_stl.size();
+ B = new real[N];
+ for (int i=0;i<N;i++)
+ B[i] = B_stl[i];
+ }
+
+ static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
+ int N = B_stl.size();
+ for (int i=0;i<N;i++)
+ B_stl[i] = B[i];
+ }
+
+ static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
+ int N = A_stl.size();
+ for (int j=0;j<N;j++){
+ A_stl[j].resize(N);
+ for (int i=0;i<N;i++)
+ A_stl[j][i] = A[i+N*j];
+ }
+ }
+
+ static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
+ for (int i=0;i<N;i++)
+ cible[i]=source[i];
+ }
+
+ static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
+ for (int j=0;j<N;j++){
+ for (int i=0;i<N;i++){
+ cible[i+N*j] = source[i+N*j];
+ }
+ }
+ }
+
+};
+
+#endif
diff --git a/btl/libs/BLAS/cblas_interface_impl.hh b/btl/libs/BLAS/cblas_interface_impl.hh
new file mode 100644
index 0000000..2da195e
--- /dev/null
+++ b/btl/libs/BLAS/cblas_interface_impl.hh
@@ -0,0 +1,96 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+
+#define BLAS_FUNC(NAME) CAT(cblas_,CAT(SCALAR_PREFIX,NAME))
+
+template<> class blas_interface<SCALAR> : public c_interface_base<SCALAR>
+{
+
+public :
+
+ static SCALAR fone;
+ static SCALAR fzero;
+
+ static inline std::string name()
+ {
+ return MAKE_STRING(CBLASNAME);
+ }
+
+ static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(gemv)(CblasColMajor,CblasNoTrans,N,N,fone,A,N,B,intone,fzero,X,intone);
+ }
+
+ static inline void symv(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(symv)(CblasColMajor,CblasLower,N,fone,A,N,B,intone,fzero,X,intone);
+ }
+
+ static inline void syr2(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(syr2)(CblasColMajor,CblasLower,N,fone,B,intone,X,intone,A,N);
+ }
+
+ static inline void ger(gene_matrix & A, gene_vector & X, gene_vector & Y, int N){
+ BLAS_FUNC(ger)(CblasColMajor,N,N,fone,X,intone,Y,intone,A,N);
+ }
+
+ static inline void rot(gene_vector & A, gene_vector & B, SCALAR c, SCALAR s, int N){
+ BLAS_FUNC(rot)(N,A,intone,B,intone,c,s);
+ }
+
+ static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+ BLAS_FUNC(gemv)(CblasColMajor,CblasTrans,N,N,fone,A,N,B,intone,fzero,X,intone);
+ }
+
+ static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+ BLAS_FUNC(gemm)(CblasColMajor,CblasNoTrans,CblasNoTrans,N,N,N,fone,A,N,B,N,fzero,X,N);
+ }
+
+ static inline void transposed_matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+ BLAS_FUNC(gemm)(CblasColMajor,CblasTrans,CblasNoTrans,N,N,N,fone,A,N,B,N,fzero,X,N);
+ }
+
+ static inline void aat_product(gene_matrix & A, gene_matrix & X, int N){
+ BLAS_FUNC(syrk)(CblasColMajor,CblasLower,CblasNoTrans,N,N,fone,A,N,fzero,X,N);
+ }
+
+ static inline void axpy(SCALAR coef, const gene_vector & X, gene_vector & Y, int N){
+ BLAS_FUNC(axpy)(N,coef,X,intone,Y,intone);
+ }
+
+ static inline void axpby(SCALAR a, const gene_vector & X, SCALAR b, gene_vector & Y, int N){
+ BLAS_FUNC(scal)(N,b,Y,intone);
+ BLAS_FUNC(axpy)(N,a,X,intone,Y,intone);
+ }
+
+ static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
+ BLAS_FUNC(copy)(N, B, intone, X, intone);
+ BLAS_FUNC(trsv)(CblasColMajor,CblasLower, CblasNoTrans, CblasNonUnit, N, L, N, X, intone);
+ }
+
+ static inline void trisolve_lower_matrix(const gene_matrix & L, const gene_matrix& B, gene_matrix & X, int N){
+ BLAS_FUNC(copy)(N, B, intone, X, intone);
+ BLAS_FUNC(trsm)(CblasColMajor,CblasRight, CblasLower, CblasNoTrans, CblasNonUnit, N, N, fone, L, N, X, N);
+ }
+
+ static inline void trmm(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+ BLAS_FUNC(trmm)(CblasColMajor,CblasLeft, CblasLower, CblasNoTrans,CblasNonUnit, N,N,fone,A,N,B,N);
+ }
+
+};
+
+SCALAR blas_interface<SCALAR>::fone = SCALAR(1);
+SCALAR blas_interface<SCALAR>::fzero = SCALAR(0);
diff --git a/btl/libs/BLAS/main.cpp b/btl/libs/BLAS/main.cpp
new file mode 100644
index 0000000..401cb5b
--- /dev/null
+++ b/btl/libs/BLAS/main.cpp
@@ -0,0 +1,116 @@
+//=====================================================
+// File : main.cpp
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:28 CEST 2002
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+
+#ifndef BLAS_INTERFACE
+# ifndef CBLAS_INTERFACE
+# define BLAS_INTERFACE
+# endif
+#endif
+
+#include "utilities.h"
+#include "blas_interface.hh"
+#include "bench.hh"
+#include "basic_actions.hh"
+#include "action_trisolve_matrix.hh"
+
+#include <string>
+
+BTL_MAIN;
+
+int main(int argv, char **argc)
+{
+ bool
+ axpy=false, axpby=false, rot=false,
+ matrix_vector=false, atv=false, symv=false, syr2=false, ger=false, trisolve_vector=false,
+ matrix_matrix=false, aat=false, trisolve_matrix=false, trmm=false
+ ;
+ int N = 100;
+
+
+ for (int i = 1; i < argv; ++i) {
+ std::string arg = argc[i];
+ if (arg == "axpy") axpy = true;
+ else if (arg == "axpby") axpby = true;
+ else if (arg == "rot") rot = true;
+ else if (arg == "matrix_vector") matrix_vector = true;
+ else if (arg == "atv") atv = true;
+ else if (arg == "symv") symv = true;
+ else if (arg == "syr2") syr2 = true;
+ else if (arg == "ger") ger = true;
+ else if (arg == "trisolve_vector") trisolve_vector = true;
+ else if (arg == "matrix_matrix") matrix_matrix = true;
+ else if (arg == "aat") aat = true;
+ else if (arg == "trisolve_matrix") trisolve_matrix = true;
+ else if (arg == "trmm") trmm = true;
+
+ else if (arg[0] == '1' && arg[1] == '\0') {
+ axpy = true; axpby = true; rot = true;
+ }
+ else if (arg[0] == '2' && arg[1] == '\0') {
+ matrix_vector=true; atv=true; symv=true; syr2=true; ger=true; trisolve_vector=true;
+ }
+ else if (arg[0] == '3' && arg[1] == '\0') {
+ matrix_matrix=true; aat=true; trisolve_matrix=true; trmm=true;
+ }
+
+ // Check switch -N
+ else if (arg[0] == '-' && arg[1] == 'N') {
+ if (arg[2] != '\0')
+ N = atoi(arg.c_str()+2);
+ else
+ N = atoi(argc[++i]);
+ }
+ }
+
+ if (axpy)
+ bench<Action_axpy<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY, N);
+ if (axpby)
+ bench<Action_axpby<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY, N);
+ if (rot)
+ bench<Action_rot<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY, N);
+
+ if (matrix_vector)
+ bench<Action_matrix_vector_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV, N);
+ if (atv)
+ bench<Action_atv_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV, N);
+ if (symv)
+ bench<Action_symv<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV, N);
+ if (syr2)
+ bench<Action_syr2<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV, N);
+ if (ger)
+ bench<Action_ger<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV, N);
+ if (trisolve_vector)
+ bench<Action_trisolve<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N);
+
+ if (matrix_matrix)
+ bench<Action_matrix_matrix_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N);
+ if (aat)
+ bench<Action_aat_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N);
+ if (trisolve_matrix)
+ bench<Action_trisolve_matrix<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N);
+ if (trmm)
+ bench<Action_trmm<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N);
+
+
+ return 0;
+}
+
+
diff --git a/btl/libs/FFTW/fftw_interface.hh b/btl/libs/FFTW/fftw_interface.hh
new file mode 100644
index 0000000..81701e7
--- /dev/null
+++ b/btl/libs/FFTW/fftw_interface.hh
@@ -0,0 +1,87 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef BTL_FFTW_INTERFACE_H
+#define BTL_FFTW_INTERFACE_H
+
+#include <complex>
+#include <fftw3.h>
+#include <vector>
+
+class fftw_interface
+{
+public:
+
+ static inline std::string name()
+ {
+ return std::string("fftw");
+ }
+
+ typedef std::complex<double> real_type;
+ typedef std::vector<std::complex<double> > stl_vector;
+
+ typedef fftw_complex* gene_vector;
+
+ typedef fftw_plan plan;
+
+ static inline void free_vector(gene_vector & B){
+ fftw_free(B);
+ }
+
+ static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
+ int N = B_stl.size();
+ B = (gene_vector) fftw_malloc(sizeof(fftw_complex) * N);
+ std::complex<double>* B_cplx = reinterpret_cast<std::complex<double>* >(B);
+
+ for (int i=0;i<N;i++)
+ B_cplx[i] = B_stl[i];
+ }
+
+ static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
+ int N = B_stl.size();
+ std::complex<double>* B_cplx = reinterpret_cast<std::complex<double>* >(B);
+ for (int i=0;i<N;i++)
+ B_stl[i] = B_cplx[i];
+ }
+
+ static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
+ for (int i=0;i<N;i++) {
+ cible[i][0]=source[i][0];
+ cible[i][1]=source[i][1];
+ }
+ }
+
+ /* Begin FFTW operations */
+
+ static inline void fftw_init_plan(plan & p, const int & N, gene_vector & x, gene_vector & y, const int & sign, const int & flags){
+ p = fftw_plan_dft_1d(N, x, y, sign, flags);
+ }
+
+ static inline void fftw_init_plan_2d(plan & p, const int & N, gene_vector & x, gene_vector& y, const int & sign, const int & flags){
+ p = fftw_plan_dft_2d(N, N, x, y, sign, flags);
+ }
+
+ static inline void fftw_init_plan_3d(plan & p, const int & N, gene_vector & x, gene_vector& y, const int & sign, const int & flags){
+ p = fftw_plan_dft_3d(N, N, N, x, y, sign, flags);
+ }
+
+ static inline void fftw_run(plan & p){
+ fftw_execute(p);
+ }
+};
+
+#endif // BTL_FFTW_INTERFACE_H
diff --git a/btl/libs/FFTW/main.cpp b/btl/libs/FFTW/main.cpp
new file mode 100644
index 0000000..8fa452b
--- /dev/null
+++ b/btl/libs/FFTW/main.cpp
@@ -0,0 +1,107 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "utilities.h"
+#include "bench.hh"
+#include "fftw_interface.hh"
+#include "fftw_actions.hh"
+
+#include <string>
+
+BTL_MAIN;
+
+int main(int argc, char **argv)
+{
+ bool
+ fftw_1d_forward_measure = false,
+ fftw_1d_forward_estimate = false,
+ fftw_1d_backward_measure = false,
+ fftw_1d_backward_estimate = false,
+
+ fftw_2d_forward_measure = false,
+ fftw_2d_forward_estimate = false,
+ fftw_2d_backward_measure = false,
+ fftw_2d_backward_estimate = false,
+
+ fftw_3d_forward_measure = false,
+ fftw_3d_forward_estimate = false,
+ fftw_3d_backward_measure = false,
+ fftw_3d_backward_estimate = false
+ ;
+ int N = 100;
+
+
+ for (int i = 1; i < argc; ++i) {
+ std::string arg = argv[i];
+
+ if (arg == "FFTW_1D_Forward_Measure" || arg == "all") fftw_1d_forward_measure = true;
+ else if (arg == "FFTW_1D_Forward_Estimate" || arg == "all") fftw_1d_forward_estimate = true;
+ else if (arg == "FFTW_1D_Backward_Measure" || arg == "all") fftw_1d_backward_measure = true;
+ else if (arg == "FFTW_1D_Backward_Estimate" || arg == "all") fftw_1d_backward_estimate = true;
+
+ else if (arg == "FFTW_2D_Forward_Measure" || arg == "all") fftw_2d_forward_measure = true;
+ else if (arg == "FFTW_2D_Forward_Estimate" || arg == "all") fftw_2d_forward_estimate = true;
+ else if (arg == "FFTW_2D_Backward_Measure" || arg == "all") fftw_2d_backward_measure = true;
+ else if (arg == "FFTW_2D_Backward_Estimate" || arg == "all") fftw_2d_backward_estimate = true;
+
+ else if (arg == "FFTW_3D_Forward_Measure" || arg == "all") fftw_3d_forward_measure = true;
+ else if (arg == "FFTW_3D_Forward_Estimate" || arg == "all") fftw_3d_forward_estimate = true;
+ else if (arg == "FFTW_3D_Backward_Measure" || arg == "all") fftw_3d_backward_measure = true;
+ else if (arg == "FFTW_3D_Backward_Estimate" || arg == "all") fftw_3d_backward_estimate = true;
+
+ // Check switch -N
+ else if (arg[0] == '-' && arg[1] == 'N') {
+ if (arg[2] != '\0')
+ N = atoi(arg.c_str()+2);
+ else
+ N = atoi(argv[++i]);
+ }
+ }
+
+
+ if (fftw_1d_forward_measure)
+ bench<Action_FFTW_1D_Forward_Measure<fftw_interface> >(MIN_MV,MAX_MV, N);
+ if (fftw_1d_forward_estimate)
+ bench<Action_FFTW_1D_Forward_Estimate<fftw_interface> >(MIN_MV,MAX_MV, N);
+ if (fftw_1d_backward_measure)
+ bench<Action_FFTW_1D_Backward_Measure<fftw_interface> >(MIN_MV,MAX_MV, N);
+ if (fftw_1d_backward_estimate)
+ bench<Action_FFTW_1D_Backward_Estimate<fftw_interface> >(MIN_MV,MAX_MV, N);
+
+ if (fftw_2d_forward_measure)
+ bench<Action_FFTW_2D_Forward_Measure<fftw_interface> >(MIN_MV,MAX_MV, N);
+ if (fftw_2d_forward_estimate)
+ bench<Action_FFTW_2D_Forward_Estimate<fftw_interface> >(MIN_MV,MAX_MV, N);
+ if (fftw_2d_backward_measure)
+ bench<Action_FFTW_2D_Backward_Measure<fftw_interface> >(MIN_MV,MAX_MV, N);
+ if (fftw_2d_backward_estimate)
+ bench<Action_FFTW_2D_Backward_Estimate<fftw_interface> >(MIN_MV,MAX_MV, N);
+
+ if (fftw_3d_forward_measure)
+ bench<Action_FFTW_3D_Forward_Measure<fftw_interface> >(MIN_MV,250, N);
+ if (fftw_3d_forward_estimate)
+ bench<Action_FFTW_3D_Forward_Estimate<fftw_interface> >(MIN_MV,250, N);
+ if (fftw_3d_backward_measure)
+ bench<Action_FFTW_3D_Backward_Measure<fftw_interface> >(MIN_MV,250, N);
+ if (fftw_3d_backward_estimate)
+ bench<Action_FFTW_3D_Backward_Estimate<fftw_interface> >(MIN_MV,250, N);
+
+
+ return 0;
+}
+
+
diff --git a/btl/libs/LAPACK/lapack.hh b/btl/libs/LAPACK/lapack.hh
new file mode 100644
index 0000000..a6d46f1
--- /dev/null
+++ b/btl/libs/LAPACK/lapack.hh
@@ -0,0 +1,33 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_HH
+#define LAPACK_HH
+
+#define SCALAR float
+#define SCALAR_PREFIX s
+#include "lapack_.hh"
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+#define SCALAR double
+#define SCALAR_PREFIX d
+#include "lapack_.hh"
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+#endif /* LAPACK_HH */
diff --git a/btl/libs/LAPACK/lapack_.hh b/btl/libs/LAPACK/lapack_.hh
new file mode 100644
index 0000000..e7c8c3f
--- /dev/null
+++ b/btl/libs/LAPACK/lapack_.hh
@@ -0,0 +1,38 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef CAT
+# define CAT2(A,B) A##B
+# define CAT(A,B) CAT2(A,B)
+#endif
+#define LAPACKFUNC(NAME) CAT(CAT(SCALAR_PREFIX,NAME),_)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void LAPACKFUNC(getrf)(const int*, const int*, SCALAR*, const int*, int*, int*);
+void LAPACKFUNC(potrf)(const char*, const int*, SCALAR*, const int*, int*);
+void LAPACKFUNC(geqrf)(const int*, const int*, SCALAR*, const int*, SCALAR*, SCALAR*, const int*, int*);
+void LAPACKFUNC(gesvd)(const char*, const char*, const int*, const int*, SCALAR*, const int*, SCALAR*, SCALAR*, const int*, SCALAR*, const int*, SCALAR*, const int*, int*);
+void LAPACKFUNC(syev)(const char*, const char*, const int*, SCALAR*, const int*, SCALAR*, SCALAR*, const int*, int*);
+void LAPACKFUNC(stev)(const char*, const int*, SCALAR*, SCALAR*, SCALAR*, const int*, SCALAR*, int*);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/btl/libs/LAPACK/lapack_interface.hh b/btl/libs/LAPACK/lapack_interface.hh
new file mode 100644
index 0000000..a0ec52b
--- /dev/null
+++ b/btl/libs/LAPACK/lapack_interface.hh
@@ -0,0 +1,78 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef LAPACK_INTERFACE_HH
+#define LAPACK_INTERFACE_HH
+
+#include <../BLAS/c_interface_base.h>
+#include <complex>
+#include "lapack.hh"
+
+extern "C" {
+#include "../BLAS/blas.h"
+
+//void sgesv_(int*, int*, float *, int*, int*, float *, int*, int*);
+//void dgesv_(int*, int*, double*, int*, int*, double*, int*, int*);
+
+void sgels_(char*, int*, int*, int*, float *, int*, float *, int*, float *, int*, int*);
+void dgels_(char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, int*);
+
+//void sgetrf_(int*, int*, float *, int*, int*, int*);
+//void dgetrf_(int*, int*, double*, int*, int*, int*);
+
+//void spotrf_(char*, int*, float *, int*, int*);
+//void dpotrf_(char*, int*, double*, int*, int*);
+
+//void ssyev_(char*, char*, int*, float *, int*, float *, float *, int*, int*);
+//void dsyev_(char*, char*, int*, double*, int*, double*, double*, int*, int*);
+}
+
+
+#define MAKE_STRING2(S) #S
+#define MAKE_STRING(S) MAKE_STRING2(S)
+
+#ifndef CAT
+# define CAT2(A,B) A##B
+# define CAT(A,B) CAT2(A,B)
+#endif
+
+template <typename real> class lapack_interface;
+
+
+static char notrans = 'N';
+static char trans = 'T';
+static char nonunit = 'N';
+static char lower = 'L';
+static char right = 'R';
+static char left = 'L';
+static int intone = 1;
+static int zeroint = 0;
+
+
+#define SCALAR float
+#define SCALAR_PREFIX s
+#include "lapack_interface_impl.hh"
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+#define SCALAR double
+#define SCALAR_PREFIX d
+#include "lapack_interface_impl.hh"
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+#endif /* LAPACK_INTERFACE_HH */
diff --git a/btl/libs/LAPACK/lapack_interface_impl.hh b/btl/libs/LAPACK/lapack_interface_impl.hh
new file mode 100644
index 0000000..a95bc5b
--- /dev/null
+++ b/btl/libs/LAPACK/lapack_interface_impl.hh
@@ -0,0 +1,139 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#define LAPACKFUNC(NAME) CAT(CAT(SCALAR_PREFIX,NAME),_)
+
+template<> class lapack_interface<SCALAR> : public c_interface_base<SCALAR>
+{
+public:
+
+ static inline std::string name()
+ {
+ return MAKE_STRING(LAPACKNAME);
+ }
+
+ static inline void general_solve(gene_matrix& A, gene_vector& b, gene_vector& x, int N)
+ {
+ int *ipiv = new int[N];
+ int info;
+ LAPACKFUNC(copy)(&N, b, &intone, x, &intone);
+ LAPACKFUNC(gesv)(&N, &intone, A, &N, ipiv, x, &N, &info);
+ delete[] ipiv;
+ }
+
+ static inline void least_squares(gene_matrix& A, gene_vector& b, gene_vector& x, int N)
+ {
+ int *ipiv = new int[N];
+ int info;
+ LAPACKFUNC(copy)(&N, b, &intone, x, &intone);
+ SCALAR work1;
+ int MONE = -1;
+ LAPACKFUNC(gels)(&notrans, &N, &N, &intone, A, &N, x, &N, &work1, &MONE, &info);
+ int lwork = (int)work1;
+ SCALAR *work2 = new SCALAR[lwork];
+ LAPACKFUNC(gels)(&notrans, &N, &N, &intone, A, &N, x, &N, work2, &lwork, &info);
+ delete[] work2;
+ delete[] ipiv;
+ }
+
+ static inline void lu_decomp(const gene_matrix& X, gene_matrix& C, int N)
+ {
+ int N2 = N*N;
+ int *ipiv = new int[N];
+ int info;
+ LAPACKFUNC(copy)(&N2, X, &intone, C, &intone);
+ LAPACKFUNC(getrf)(&N, &N, C, &N, ipiv, &info);
+ delete[] ipiv;
+ }
+
+ static inline void cholesky(const gene_matrix& X, gene_matrix& C, int N)
+ {
+ int N2 = N*N;
+ int info;
+ LAPACKFUNC(copy)(&N2, X, &intone, C, &intone);
+ LAPACKFUNC(potrf)(&lower, &N, C, &N, &info);
+ }
+
+ static inline void qr_decomp(const gene_matrix& X, gene_matrix& QR, gene_vector& tau, const int& N)
+ {
+ int N2 = N*N;
+ LAPACKFUNC(copy)(&N2, X, &intone, QR, &intone);
+
+ SCALAR *work = new SCALAR;
+ int lwork = -1, info;
+ LAPACKFUNC(geqrf)(&N, &N, QR, &N, tau, work, &lwork, &info);
+ lwork = *work;
+ delete work;
+ work = new SCALAR[lwork];
+ LAPACKFUNC(geqrf)(&N, &N, QR, &N, tau, work, &lwork, &info);
+ delete[] work;
+ }
+
+ static inline void svd_decomp(const gene_matrix& X, gene_matrix& U, gene_vector& S, gene_matrix& VT, const int& N)
+ {
+ int N2 = N*N;
+ stl_vector Xcopy(N2);
+ LAPACKFUNC(copy)(&N2, X, &intone, &Xcopy[0], &intone);
+
+ stl_vector work(1);
+ int lwork = -1, info;
+ LAPACKFUNC(gesvd)("A", "A", &N, &N, &Xcopy[0], &N, S, U, &N, VT, &N, &work[0], &lwork, &info);
+ lwork = work[0];
+ work.resize(lwork);
+ LAPACKFUNC(gesvd)("A", "A", &N, &N, &Xcopy[0], &N, S, U, &N, VT, &N, &work[0], &lwork, &info);
+ }
+
+ static inline void syev(const gene_matrix& X, gene_matrix& V, gene_vector& W, const int& N)
+ {
+ int N2 = N*N;
+ LAPACKFUNC(copy)(&N2, X, &intone, V, &intone);
+
+ stl_vector work(1);
+ int lwork = -1, info;
+ LAPACKFUNC(syev)("V", "U", &N, V, &N, W, &work[0], &lwork, &info);
+ lwork = work[0];
+ work.resize(lwork);
+ LAPACKFUNC(syev)("V", "U", &N, V, &N, W, &work[0], &lwork, &info);
+ }
+
+ /* Size of D, W: N; size of E: N-1, size of V: NxN */
+ static inline void stev(const gene_vector& D, const gene_vector& E, gene_vector& W, gene_matrix& V, const int& N)
+ {
+ int N0 = N;
+ int N1 = N-1;
+ LAPACKFUNC(copy)(&N0, D, &intone, W, &intone);
+ stl_vector E_(E, E+N-1), work(max(1, 2*N-2));
+
+ int info;
+ LAPACKFUNC(stev)("V", &N, W, &E_[0], V, &N, &work[0], &info);
+ }
+
+ static inline void symm_ev(const gene_matrix& X, gene_vector& W, int N)
+ {
+ char jobz = 'N';
+ SCALAR *work = new SCALAR;
+ int lwork = -1, info;
+ LAPACKFUNC(syev)(&jobz, &lower, &N, X, &N, W, work, &lwork, &info);
+ lwork = *work;
+ delete work;
+ work = new SCALAR[lwork];
+ LAPACKFUNC(syev)(&jobz, &lower, &N, X, &N, W, work, &lwork, &info);
+ delete[] work;
+ }
+
+
+};
diff --git a/btl/libs/LAPACK/main.cpp b/btl/libs/LAPACK/main.cpp
new file mode 100644
index 0000000..e70c161
--- /dev/null
+++ b/btl/libs/LAPACK/main.cpp
@@ -0,0 +1,95 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include <btl.hh>
+#include <bench.hh>
+#include <action_general_solve.hh>
+#include <action_least_squares.hh>
+#include <action_lu_decomp.hh>
+#include <action_cholesky.hh>
+#include <action_qr_decomp.hh>
+#include <action_svd_decomp.hh>
+#include <action_syev.hh>
+#include <action_stev.hh>
+#include <action_symm_ev.hh>
+#include <lapack_interface.hh>
+
+#include <string>
+#include <cstdlib>
+
+BTL_MAIN;
+
+int main(int argc, char **argv)
+{
+ bool
+ general_solve=false, least_squares=false, lu_decomp=false, cholesky=false, qr_decomp=false, svd_decomp=false,
+ syev=false, stev=false, symm_ev=false
+ ;
+ int N = 100;
+
+
+ for (int i = 1; i < argc; ++i) {
+ std::string arg = argv[i];
+ if (arg == "general_solve") general_solve = true;
+ else if (arg == "least_squares") least_squares = true;
+ else if (arg == "lu_decomp") lu_decomp = true;
+ else if (arg == "cholesky") cholesky = true;
+ else if (arg == "qr_decomp") qr_decomp = true;
+ else if (arg == "svd_decomp") svd_decomp = true;
+ else if (arg == "syev") syev = true;
+ else if (arg == "stev") stev = true;
+ else if (arg == "symm_ev") symm_ev = true;
+
+ // Check switch -N
+ else if (arg[0] == '-' && arg[1] == 'N') {
+ if (arg[2] != '\0')
+ N = atoi(arg.c_str()+2);
+ else
+ N = atoi(argv[++i]);
+ }
+ }
+
+
+ if (general_solve)
+ bench<Action_general_solve<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,N);
+
+ if (least_squares)
+ bench<Action_least_squares<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,N);
+
+ if (lu_decomp)
+ bench<Action_lu_decomp<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,N);
+
+ if (cholesky)
+ bench<Action_cholesky<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,N);
+
+ if (qr_decomp)
+ bench<Action_qr_decomp<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,N);
+
+ if (svd_decomp)
+ bench<Action_svd_decomp<lapack_interface<REAL_TYPE> > >(MIN_MM,750,N);
+
+ if (syev)
+ bench<Action_syev<lapack_interface<REAL_TYPE> > >(MIN_MM,750,N);
+
+ if (stev)
+ bench<Action_stev<lapack_interface<REAL_TYPE> > >(MIN_MM,1000,N);
+
+ if (symm_ev)
+ bench<Action_symm_ev<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,N);
+
+ return 0;
+}
diff --git a/btl/libs/PBLAS/main.cpp b/btl/libs/PBLAS/main.cpp
new file mode 100644
index 0000000..427cf7e
--- /dev/null
+++ b/btl/libs/PBLAS/main.cpp
@@ -0,0 +1,103 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#define DISTRIBUTED
+
+#include "mpi.h"
+#include "utilities.h"
+#include "bench.hh"
+
+#include <iostream>
+//using namespace std;
+
+#include "pblas_interface.hh"
+#include "blacsinit.hh"
+
+#include "action_parallel_axpy.hh"
+#include "action_parallel_matrix_vector_product.hh"
+#include "action_parallel_lu_decomp.hh"
+#include "action_parallel_cholesky.hh"
+#include "action_parallel_qr_decomp.hh"
+#include "action_parallel_svd_decomp.hh"
+#include "action_parallel_symm_ev.hh"
+
+#include <string>
+
+BTL_MAIN;
+
+int main(int argc, char **argv)
+{
+ bool iamroot = blacsinit(&argc, &argv);
+
+ bool
+ axpy=false, matrix_vector=false,
+ lu_decomp=false, cholesky=false, qr_decomp=false, svd_decomp=false,
+ symm_ev=false
+ ;
+
+ int N = 100;
+
+
+ for (int i = 1; i < argc; ++i) {
+ std::string arg = argv[i];
+ if (arg == "axpy") axpy = true;
+ else if (arg == "matrix_vector") matrix_vector=true;
+ else if (arg == "lu_decomp") lu_decomp = true;
+ else if (arg == "cholesky") cholesky = true;
+ else if (arg == "qr_decomp") qr_decomp = true;
+ else if (arg == "svd_decomp") svd_decomp = true;
+ else if (arg == "symm_ev") symm_ev = true;
+
+ // Check switch -N
+ else if (arg[0] == '-' && arg[1] == 'N') {
+ if (arg[2] != '\0')
+ N = atoi(arg.c_str()+2);
+ else
+ N = atoi(argv[++i]);
+ }
+ }
+
+
+
+ if (axpy)
+ distr_bench<Action_parallel_axpy<pblas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY, N, !iamroot);
+
+ if (matrix_vector)
+ distr_bench<Action_parallel_matrix_vector_product<pblas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV, N, !iamroot);
+
+ if (lu_decomp)
+ distr_bench<Action_parallel_lu_decomp<pblas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N, !iamroot);
+
+ if (cholesky)
+ distr_bench<Action_parallel_cholesky<pblas_interface<REAL_TYPE> > >(MIN_MM, MAX_MM, N, !iamroot);
+
+ if (qr_decomp)
+ distr_bench<Action_parallel_qr_decomp<pblas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM, N, !iamroot);
+
+ if (svd_decomp)
+ distr_bench<Action_parallel_svd_decomp<pblas_interface<REAL_TYPE> > >(MIN_MM,750, N, !iamroot);
+
+ if (symm_ev)
+ distr_bench<Action_parallel_symm_ev<pblas_interface<REAL_TYPE> > >(MIN_MM,750, N, !iamroot);
+
+
+ int iZERO = 0;
+ blacs_exit_(&iZERO);
+ return 0;
+}
+
+
diff --git a/btl/libs/PBLAS/pblas.h b/btl/libs/PBLAS/pblas.h
new file mode 100644
index 0000000..be76e8f
--- /dev/null
+++ b/btl/libs/PBLAS/pblas.h
@@ -0,0 +1,106 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef SCALAPACK_H_
+#define SCALAPACK_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ int numroc_(const int*, const int*, const int*, const int*, const int*);
+ void descinit_(int*, const int*, const int*, const int*, const int*, const int*, const int*, const int*, const int*, int*);
+
+
+ /* Level 1 */
+
+ // Single
+ void psaxpy_(const int*, const float*,
+ const float*, const int*, const int*, const int*, const int*,
+ const float*, const int*, const int*, const int*, const int*
+ );
+
+ // Double
+ void pdaxpy_(const int*, const double*,
+ const double*, const int*, const int*, const int*, const int*,
+ const double*, const int*, const int*, const int*, const int*
+ );
+
+
+
+ /* Level 2 */
+
+ // Single
+ void psgemv_(const char*, const int*, const int*,
+ const float*, const float*, const int*, const int*, const int*,
+ const float*, const int*, const int*, const int*, const int*,
+ const float*, float*, const int*, const int*, const int*, const int*
+ );
+
+ // Double
+ void pdgemv_(const char*, const int*, const int*,
+ const double*, const double*, const int*, const int*, const int*,
+ const double*, const int*, const int*, const int*, const int*,
+ const double*, double*, const int*, const int*, const int*, const int*
+ );
+
+
+ /* Level 3 */
+
+ // Single
+ void pstrmm_(const char*, const char*, const char*, const char*, const int*, const int*, const float*,
+ const float*, const int*, const int*, const int*,
+ float*, const int*, const int*, const int*);
+
+ // Double
+ void pdtrmm_(const char*, const char*, const char*, const char*, const int*, const int*, const double*,
+ const double*, const int*, const int*, const int*,
+ double*, const int*, const int*, const int*);
+
+
+
+ /*************
+ * Scalapack *
+ *************/
+ // lu_decomp
+ void psgetrf_(const int*, const int*, float*, const int*, const int*, const int*, int*, int*);
+ void pdgetrf_(const int*, const int*, double*, const int*, const int*, const int*, int*, int*);
+
+ // cholesky
+ void pspotrf_(const char*, const int*, float*, const int*, const int*, const int*, int*);
+ void pdpotrf_(const char*, const int*, double*, const int*, const int*, const int*, int*);
+
+ // qr_decomp
+ void psgeqpf_(const int*, const int*, float*, const int*, const int*, const int*, int*, float*, float*, const int*, int*);
+ void pdgeqpf_(const int*, const int*, double*, const int*, const int*, const int*, int*, double*, double*, const int*, int*);
+
+ // svd_decomp
+ void psgesvd_(const char*, const char*, const int*, const int*, float*, const int*, const int*, const int*, float*, float*, const int*, const int*, const int*, float*, const int*, const int*, const int*, float*, const int*, int*);
+ void pdgesvd_(const char*, const char*, const int*, const int*, double*, const int*, const int*, const int*, double*, double*, const int*, const int*, const int*, double*, const int*, const int*, const int*, double*, const int*, int*);
+
+ // symm_ev
+ void pssyevd_(const char*, const char*, const int*, float*, const int*, const int*, const int*, float*, float*, const int*, const int*, const int*, float*, const int*, int*, const int*, int*);
+ void pdsyevd_(const char*, const char*, const int*, double*, const int*, const int*, const int*, double*, double*, const int*, const int*, const int*, double*, const int*, int*, const int*, int*);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* SCALAPACK_H_ */
diff --git a/btl/libs/PBLAS/pblas_interface.hh b/btl/libs/PBLAS/pblas_interface.hh
new file mode 100644
index 0000000..6dfd201
--- /dev/null
+++ b/btl/libs/PBLAS/pblas_interface.hh
@@ -0,0 +1,57 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "blas.h"
+#include "pblas.h"
+#include "blacs_interface.hh"
+
+#define MAKE_STRING2(S) #S
+#define MAKE_STRING(S) MAKE_STRING2(S)
+
+#ifndef CAT
+#define CAT2(A,B) A##B
+#define CAT(A,B) CAT2(A,B)
+#endif
+
+
+template<class real> class pblas_interface;
+
+/*
+static char notrans = 'N';
+static char trans = 'T';
+static char nonunit = 'N';
+static char lower = 'L';
+static char right = 'R';
+static char left = 'L';
+static int intone = 1;
+*/
+
+#define SCALAR float
+#define SCALAR_PREFIX s
+#include "pblas_interface_impl.hh"
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+
+#define SCALAR double
+#define SCALAR_PREFIX d
+#include "pblas_interface_impl.hh"
+#undef SCALAR
+#undef SCALAR_PREFIX
+
+
+
diff --git a/btl/libs/PBLAS/pblas_interface_impl.hh b/btl/libs/PBLAS/pblas_interface_impl.hh
new file mode 100644
index 0000000..a96b0fd
--- /dev/null
+++ b/btl/libs/PBLAS/pblas_interface_impl.hh
@@ -0,0 +1,246 @@
+//=====================================================
+// Copyright (C) 2011 Andrea Arteaga <andyspiros@gmail.com>
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+
+#define PBLAS_PREFIX p
+#define PBLAS_FUNC(NAME) CAT(CAT(CAT(PBLAS_PREFIX, SCALAR_PREFIX),NAME),_)
+#define BLAS_FUNC(NAME) CAT(CAT(SCALAR_PREFIX,NAME),_)
+
+template<> class pblas_interface<SCALAR> : public blacs_interface<SCALAR>
+{
+public:
+ static inline std::string name()
+ {
+ return MAKE_STRING(PBLASNAME);
+ }
+
+ static inline void parallel_axpy(const SCALAR& coef,
+ gene_vector& x, int *descX,
+ gene_vector& y, int *descY,
+ const int& size
+ )
+ {
+ int iZERO = 0, iONE = 1;
+ PBLAS_FUNC(axpy)(&size, &coef,
+ x, &iONE, &iONE, descX, &iONE,
+ y, &iONE, &iONE, descY, &iONE
+ );
+ }
+
+ static inline void parallel_matrix_vector_product(
+ int GlobalRows, int GlobalCols,
+ gene_matrix& A, int *descA,
+ gene_vector& x, int *descX,
+ gene_vector& y, int *descY
+ )
+ {
+ real_type alpha = 1., beta = 0.;
+ int iONE = 1;
+ int myid, procnum;
+ const char notrans = 'N';
+ blacs_pinfo_(&myid, &procnum);
+
+ PBLAS_FUNC(gemv)(&notrans, &GlobalRows, &GlobalCols,
+ &alpha, A, &iONE, &iONE, descA,
+ x, &iONE, &iONE, descX, &iONE,
+ &beta, y, &iONE, &iONE, descY, &iONE
+ );
+
+ }
+
+
+ static inline void parallel_lu_decomp(gene_matrix& X, std::vector<int>& ipiv, const int* desc)
+ {
+ const int GlobalRows = desc[2], GlobalCols = desc[3];
+ const int iONE = 1;
+ int info;
+ ipiv.resize(desc[8] + desc[4]);
+ PBLAS_FUNC(getrf)(&GlobalRows, &GlobalCols, X, &iONE, &iONE, desc,
+ &ipiv[0], &info);
+ if (info != 0 && myid() == 0)
+ cout << " { LU error : " << info << " } ";
+ }
+
+ static inline void parallel_cholesky(gene_matrix& X, const int* desc)
+ {
+ const int N = desc[2], iONE = 1;
+ const char UP = 'U';
+ int info;
+ PBLAS_FUNC(potrf)(&UP, &N, X, &iONE, &iONE, desc, &info);
+ if (info != 0 && myid() == 0)
+ cout << " { cholesky error : " << info << " } ";
+ }
+
+ static inline void parallel_qr_decomp(gene_matrix& X, const int* desc)
+ {
+ const int GlobalRows = desc[2], GlobalCols = desc[3],
+ BlockRows = desc[4], BlockCols = desc[5],
+ ctxt = desc[1];
+
+ int myrow, mycol, nprow, npcol, lwork;
+ SCALAR lworkd;
+ blacs_gridinfo_(&ctxt, &nprow, &npcol, &myrow, &mycol);
+
+ const int iONE = 1, iZERO = 0, imONE = -1,
+ ipivdim = numroc_(&GlobalCols, &BlockCols, &mycol, &iZERO, &npcol);
+ int info;
+ std::vector<int> ipiv(ipivdim);
+ std::vector<SCALAR> tau(ipivdim);
+
+ // Retrieve LWORK
+ PBLAS_FUNC(geqpf)(&GlobalRows, &GlobalCols, X, &iONE, &iONE, desc, &ipiv[0], &tau[0], &lworkd, &imONE, &info);
+ lwork = static_cast<int>(lworkd);
+ if (info != 0 && myid() == 0)
+ cout << " { qr_decomp lwork error } ";
+
+ std::vector<SCALAR> work(lwork);
+ PBLAS_FUNC(geqpf)(&GlobalRows, &GlobalCols, X, &iONE, &iONE, desc, &ipiv[0], &tau[0], &work[0], &lwork, &info);
+ if (info != 0 && myid() == 0)
+ cout << " { qr_decomp computation error } ";
+ }
+
+ static inline void parallel_symm_ev(gene_matrix& A, const int* descA, gene_vector& w, gene_matrix& Z, const int* descZ)
+ {
+ const char jobz = 'V', uplo = 'u';
+ const int N = descA[2], iONE = 1, iZERO = 0, imONE = -1;
+ std::vector<SCALAR> work;
+ std::vector<int> iwork;
+ int lwork, liwork, info;
+ SCALAR lworkd;
+
+ // Retrieve l(i)work
+ PBLAS_FUNC(syevd)(&jobz, &uplo, &N, A, &iONE, &iONE, descA, w,
+ Z, &iONE, &iONE, descZ, &lworkd, &imONE, &liwork, &imONE, &info);
+ lwork = static_cast<int>(lworkd);
+ work.resize(lwork); iwork.resize(liwork);
+ if (info != 0 && myid() == 0)
+ cout << " { symm_ev l(i)work error } ";
+
+ PBLAS_FUNC(syevd)(&jobz, &uplo, &N, A, &iONE, &iONE, descA, w,
+ Z, &iONE, &iONE, descZ, &work[0], &lwork, &iwork[0], &liwork, &info);
+ if (info != 0 && myid() == 0)
+ cout << " { symm_ev computation error } ";
+ }
+
+ static inline void parallel_svd_decomp(gene_matrix& A, int* descA, gene_matrix& U, int *descU, gene_matrix& V, int *descV, gene_vector& s)
+ {
+ const char job = 'V';
+ const int size = descA[2], iONE = 1, iZERO = 0, imONE = -1;
+ std::vector<SCALAR> work;
+ int info, lwork;
+ SCALAR lworkd;
+
+ // Retrieve lwork
+ PBLAS_FUNC(gesvd)(&job, &job, &size, &size, A, &iONE, &iONE, descA, s,
+ U, &iONE, &iONE, descU, V, &iONE, &iONE, descV, &lworkd, &imONE, &info);
+ if (info != 0 && myid() == 0)
+ cout << " { svd_decomp lwork error } ";
+ lwork = static_cast<int>(lworkd);
+ work.resize(lwork);
+
+ PBLAS_FUNC(gesvd)(&job, &job, &size, &size, A, &iONE, &iONE, descA, s,
+ U, &iONE, &iONE, descU, V, &iONE, &iONE, descV, &work[0], &lwork, &info);
+ if (info != 0 && myid() == 0)
+ cout << " { svd_decomp computation error } ";
+ }
+
+ static inline real_type
+ test_LU(stl_matrix& Global_A, gene_matrix& Local_LU, int *desc)
+ {
+ bool iamroot = myid() == 0;
+ int _size = desc[2];
+
+ // Create and scatter Identity
+ int Testdesc[9];
+ stl_matrix Global_Test_stl, Local_Test_stl;
+ if (iamroot)
+ {
+ stl_matrix Identity(_size * _size);
+ for (int r = 0; r < _size; ++r)
+ Identity[r + _size * r] = 1;
+ scatter_matrix(Identity, Local_Test_stl, Testdesc, _size, _size,
+ desc[4], desc[5]);
+ }
+ else
+ scatter_matrix(stl_matrix(), Local_Test_stl, Testdesc);
+
+ // Compute L * U
+ real_type alpha = 1., malpha = -1;
+ int iONE = 1;
+ PBLAS_FUNC(trmm)("L", "L", "N", "N", desc + 2, desc + 2, &alpha, Local_LU,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+ PBLAS_FUNC(trmm)("R", "U", "N", "N", desc + 2, desc + 2, &alpha, Local_LU,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+
+ // Gather result
+ gather_matrix(Global_Test_stl, Local_Test_stl, desc);
+ if (iamroot)
+ {
+ int size2 = _size*_size;
+ BLAS_FUNC(axpy)(&size2, &malpha, &Global_A[0], &iONE,
+ &Global_Test_stl[0], &iONE);
+ double error = BLAS_FUNC(nrm2)(&size2, &Global_Test_stl[0], &iONE);
+ error /= BLAS_FUNC(nrm2)(&size2, &Global_A[0], &iONE);
+ return error;
+ }
+ else
+ return 0.;
+ }
+
+ static inline real_type
+ test_cholesky(stl_matrix& Global_A, gene_matrix& Local_U, int *desc)
+ {
+ bool iamroot = myid() == 0;
+ int _size = desc[2];
+
+ // Create and scatter Identity
+ int Testdesc[9];
+ stl_matrix Global_Test_stl, Local_Test_stl;
+ if (iamroot)
+ {
+ stl_matrix Identity(_size * _size);
+ for (int r = 0; r < _size; ++r)
+ Identity[r + _size * r] = 1;
+ scatter_matrix(Identity, Local_Test_stl, Testdesc, _size, _size,
+ desc[4], desc[5]);
+ }
+ else
+ scatter_matrix(stl_matrix(), Local_Test_stl, Testdesc);
+
+ // Compute U' * U
+ real_type alpha = 1., malpha = -1;
+ int iONE = 1;
+ PBLAS_FUNC(trmm)("L", "U", "T", "N", desc + 2, desc + 2, &alpha, Local_U,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+ PBLAS_FUNC(trmm)("R", "U", "N", "N", desc + 2, desc + 2, &alpha, Local_U,
+ &iONE, &iONE, desc, &Local_Test_stl[0], &iONE, &iONE, Testdesc);
+
+ // Gather result
+ gather_matrix(Global_Test_stl, Local_Test_stl, desc);
+ if (iamroot)
+ {
+ int size2 = _size*_size;
+ BLAS_FUNC(axpy)(&size2, &malpha, &Global_A[0], &iONE,
+ &Global_Test_stl[0], &iONE);
+ double error = BLAS_FUNC(nrm2)(&size2, &Global_Test_stl[0], &iONE);
+ error /= BLAS_FUNC(nrm2)(&size2, &Global_A[0], &iONE);
+ return error;
+ }
+ else
+ return 0.;
+ }
+};
diff --git a/btl/libs/STL/CMakeLists.txt b/btl/libs/STL/CMakeLists.txt
new file mode 100644
index 0000000..4cfc2dc
--- /dev/null
+++ b/btl/libs/STL/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+btl_add_bench(btl_STL main.cpp OFF)
diff --git a/btl/libs/STL/STL_interface.hh b/btl/libs/STL/STL_interface.hh
new file mode 100644
index 0000000..060cb69
--- /dev/null
+++ b/btl/libs/STL/STL_interface.hh
@@ -0,0 +1,255 @@
+//=====================================================
+// File : STL_interface.hh
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:24 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#ifndef STL_INTERFACE_HH
+#define STL_INTERFACE_HH
+#include <string>
+#include <vector>
+#include "utilities.h"
+
+using namespace std;
+
+template<class real>
+class STL_interface{
+
+public :
+
+ typedef real real_type ;
+
+ typedef std::vector<real> stl_vector;
+ typedef std::vector<stl_vector > stl_matrix;
+
+ typedef stl_matrix gene_matrix;
+
+ typedef stl_vector gene_vector;
+
+ static inline std::string name( void )
+ {
+ return "STL";
+ }
+
+ static void free_matrix(gene_matrix & A, int N){}
+
+ static void free_vector(gene_vector & B){}
+
+ static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
+ A = A_stl;
+ }
+
+ static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
+ B = B_stl;
+ }
+
+ static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
+ B_stl = B ;
+ }
+
+
+ static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
+ A_stl = A ;
+ }
+
+ static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
+ for (int i=0;i<N;i++){
+ cible[i]=source[i];
+ }
+ }
+
+
+ static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
+ for (int i=0;i<N;i++)
+ for (int j=0;j<N;j++)
+ cible[i][j]=source[i][j];
+ }
+
+// static inline void ata_product(const gene_matrix & A, gene_matrix & X, int N)
+// {
+// real somme;
+// for (int j=0;j<N;j++){
+// for (int i=0;i<N;i++){
+// somme=0.0;
+// for (int k=0;k<N;k++)
+// somme += A[i][k]*A[j][k];
+// X[j][i]=somme;
+// }
+// }
+// }
+
+ static inline void aat_product(const gene_matrix & A, gene_matrix & X, int N)
+ {
+ real somme;
+ for (int j=0;j<N;j++){
+ for (int i=0;i<N;i++){
+ somme=0.0;
+ if(i>=j)
+ {
+ for (int k=0;k<N;k++){
+ somme+=A[k][i]*A[k][j];
+ }
+ X[j][i]=somme;
+ }
+ }
+ }
+ }
+
+
+ static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N)
+ {
+ real somme;
+ for (int j=0;j<N;j++){
+ for (int i=0;i<N;i++){
+ somme=0.0;
+ for (int k=0;k<N;k++)
+ somme+=A[k][i]*B[j][k];
+ X[j][i]=somme;
+ }
+ }
+ }
+
+ static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N)
+ {
+ real somme;
+ for (int i=0;i<N;i++){
+ somme=0.0;
+ for (int j=0;j<N;j++)
+ somme+=A[j][i]*B[j];
+ X[i]=somme;
+ }
+ }
+
+ static inline void matrix_vector_product(gene_vector& A, gene_vector & B, gene_vector & X, int N)
+ {
+ real somme;
+ for (int i=0;i<N;i++){
+ somme=0.0;
+ for (int j=0;j<N;j++)
+ somme+=A[j*N+i]*B[j];
+ X[i]=somme;
+ }
+ }
+
+ static inline void symv(gene_matrix & A, gene_vector & B, gene_vector & X, int N)
+ {
+ for (int j=0; j<N; ++j)
+ X[j] = 0;
+ for (int j=0; j<N; ++j)
+ {
+ real t1 = B[j];
+ real t2 = 0;
+ X[j] += t1 * A[j][j];
+ for (int i=j+1; i<N; ++i) {
+ X[i] += t1 * A[j][i];
+ t2 += A[j][i] * B[i];
+ }
+ X[j] += t2;
+ }
+ }
+
+ static inline void syr2(gene_matrix & A, gene_vector & B, gene_vector & X, int N)
+ {
+ for (int j=0; j<N; ++j)
+ {
+ for (int i=j; i<N; ++i)
+ A[j][i] += B[i]*X[j] + B[j]*X[i];
+ }
+ }
+
+ static inline void ger(gene_matrix & A, gene_vector & X, gene_vector & Y, int N)
+ {
+ for (int j=0; j<N; ++j)
+ {
+ for (int i=j; i<N; ++i)
+ A[j][i] += X[i]*Y[j];
+ }
+ }
+
+ static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N)
+ {
+ real somme;
+ for (int i=0;i<N;i++){
+ somme = 0.0;
+ for (int j=0;j<N;j++)
+ somme += A[i][j]*B[j];
+ X[i] = somme;
+ }
+ }
+
+ static inline void axpy(real coef, const gene_vector & X, gene_vector & Y, int N){
+ for (int i=0;i<N;i++)
+ Y[i]+=coef*X[i];
+ }
+
+ static inline void axpby(real a, const gene_vector & X, real b, gene_vector & Y, int N){
+ for (int i=0;i<N;i++)
+ Y[i] = a*X[i] + b*Y[i];
+ }
+
+ static inline void trisolve_lower(const gene_matrix & L, const gene_vector & B, gene_vector & X, int N){
+ copy_vector(B,X,N);
+ for(int i=0; i<N; ++i)
+ {
+ X[i] /= L[i][i];
+ real tmp = X[i];
+ for (int j=i+1; j<N; ++j)
+ X[j] -= tmp * L[i][j];
+ }
+ }
+
+ static inline real norm_diff(const stl_vector & A, const stl_vector & B)
+ {
+ int N=A.size();
+ real somme=0.0;
+ real somme2=0.0;
+
+ for (int i=0;i<N;i++){
+ real diff=A[i]-B[i];
+ somme+=diff*diff;
+ somme2+=A[i]*A[i];
+ }
+ return somme/somme2;
+ }
+
+ static inline real norm_diff(const stl_matrix & A, const stl_matrix & B)
+ {
+ int N=A[0].size();
+ real somme=0.0;
+ real somme2=0.0;
+
+ for (int i=0;i<N;i++){
+ for (int j=0;j<N;j++){
+ real diff=A[i][j] - B[i][j];
+ somme += diff*diff;
+ somme2 += A[i][j]*A[i][j];
+ }
+ }
+
+ return somme/somme2;
+ }
+
+ static inline void display_vector(const stl_vector & A)
+ {
+ int N=A.size();
+ for (int i=0;i<N;i++){
+ INFOS("A["<<i<<"]="<<A[i]<<endl);
+ }
+ }
+
+};
+
+#endif
diff --git a/btl/libs/STL/main.cpp b/btl/libs/STL/main.cpp
new file mode 100644
index 0000000..4e73328
--- /dev/null
+++ b/btl/libs/STL/main.cpp
@@ -0,0 +1,42 @@
+//=====================================================
+// File : main.cpp
+// Author : L. Plagne <laurent.plagne@edf.fr)>
+// Copyright (C) EDF R&D, lun sep 30 14:23:23 CEST 2002
+//=====================================================
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+#include "utilities.h"
+#include "STL_interface.hh"
+#include "bench.hh"
+#include "basic_actions.hh"
+
+BTL_MAIN;
+
+int main()
+{
+ bench<Action_axpy<STL_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+ bench<Action_axpby<STL_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+ bench<Action_matrix_vector_product<STL_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+ bench<Action_atv_product<STL_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+ bench<Action_symv<STL_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+ bench<Action_syr2<STL_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+ bench<Action_matrix_matrix_product<STL_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+ bench<Action_ata_product<STL_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+ bench<Action_aat_product<STL_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+
+ return 0;
+}
+
+
diff --git a/numbench/benchconfig.py b/numbench/benchconfig.py
index 244ac63..c0d8e8e 100644
--- a/numbench/benchconfig.py
+++ b/numbench/benchconfig.py
@@ -32,7 +32,7 @@ if not locals().has_key('initialized'):
if os.environ.has_key('BTLDIR'):
btldir = os.environ['BTLDIR']
else:
- btldir = '/usr/include/btl'
+ btldir = '/usr/include/numbench/btl'
# Library directory (lib vs. lib32 vs. lib64)
libdir = sp.Popen \
diff --git a/setup.py b/setup.py
index 4f366cf..776e4f3 100644
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,7 @@
#
import os
+from os.path import isdir, join as pjoin
from distutils.core import setup
def recursiveGetPackage(pkg, directory):
@@ -34,12 +35,29 @@ setupdir = os.path.dirname(os.path.abspath(__file__))
numdir = os.path.join(setupdir, 'numbench')
+def recursiveGetBTL(frompath, topath):
+
+ ls = [i for i in os.listdir(frompath)]
+ dirs = [i for i in ls if isdir(pjoin(frompath, i))]
+ files = [pjoin(frompath, i) for i in ls if not i in dirs]
+
+ ret = [(topath, files)]
+
+ for d in dirs:
+ ret += recursiveGetBTL(pjoin(frompath, d), pjoin(topath, d))
+
+ return ret
+
+
+
setup(name='Numbench',
- version='1.0',
+ version='0.2',
description='Numerical benchmarks for Gentoo',
author='Andrea Arteaga',
author_email='andyspiros@gmail.com',
- url='http://soc.dev.gentoo.org/~spiros',
+ url='http://github.com/andyspiros/numbench',
+ license='GPL-2',
packages=recursiveGetPackage('', numdir),
+ data_files=recursiveGetBTL('btl', 'include/numbench/btl')
)