Non-traditional High-Level Languages for HPC Applications: GNU OctaveJuan Carlos Chaves, Ph.D. SIP On-site at ARL MSRCOhio Supercomputer CenterUsers Group Conference (UGC2006)26 Jun 2006Distribution Statement A: Cleared for Public Release. Distribution is unlimited.1Purpose of This Tutorial• Provide an introduction to the Octave system• Teach how to obtain and configure Octave for your own PC• Teach how to configure, build and install Octave at the HPCMP HPC platforms• Teach how to exploit Octave HPC technology at the HPCMP Centers • Be a concise guide to relevant Octave info on the WebDistribution Statement A: Cleared for Public Release. Distribution is unlimited.2What is Octave?• High-level language, primarily intended for numerical computations initiated and maintained by John W. Eaton (University of Wisconsin)• A stated goal of Octave is to be compatible with MATLAB• Provides a convenient command line interactive interface for solving scientific and technical problems numerically• Has built-in a large collection of mathematical algorithms and convenience functionsDistribution Statement A: Cleared for Public Release. Distribution is unlimited.3Typical uses of Octave• Prototyping: an interactive Octave session becomes a system-prototyping environment rivaling systems such as the well-known MATLAB• Programming language: a powerful but easy to use programming language, mostly compatible with MATLAB, for use in developing ...
Non-traditional High-Level Languages for HPC Applications:
GNU Octave
Juan Carlos Chaves, Ph.D. SIP On-site at ARL MSRC Ohio Supercomputer Center
Users Group Conference (UGC2006) 26 Jun 2006
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
1
Purpose of This Tutorial
• Provide an introduction to the Octave system
• Teach how to obtain and configure Octave for your own PC
• Teachhow to configure, build and install Octave at the HPCMP HPC platforms
• Teachhow to exploit Octave HPC technology at the HPCMP Centers
• Be a concise guide to relevant Octave info on the Web
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
2
•
•
•
•
What is Octave?
High-level language, primarily intended for numerical computations initiated and maintained byJohn W. Eaton(University of Wisconsin)
A stated goal of Octave isto be compatible with MATLAB
Provides aconvenient command line interactive interfacefor solving scientific and technical problems numerically
Has built-ina large collection of mathematical algorithms and convenience functions
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
3
•
•
•
Typical uses of Octave
Prototyping:an interactive Octave session becomes a system-prototyping environment rivaling systems such as the well-known MATLAB
Programming language:a powerful but easy to use programming language, mostly compatible with MATLAB, for use in developing sophisticated programs and algorithms
Batch-oriented HPC applications:Octave and its parallel extensions may also be run under a batch system such as LSF, the mandate queuing system at the DoD HPCMP Centers
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
4
•
•
•
•
Octave Advantages
Free programavailable under the GNU General Public License (GNU GPL) and runs on Windows, Linux and Mac OS Xincluding architectures unsupported by MATLAB
MATLAB clone:syntax is very similar to MATLAB. Careful programming will allow a script to run on both Octave and MATLAB
Open source community: large and very active support communityall over the world
High productivity system:interactive - code development proceeds incrementally. Excellent development and rapid prototyping environment
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
5
•
•
•
•
•
Octave Disadvantages
Relativelyomc’nsiexplioatlltadecorpneru(But fortunately, you re taking this tutorial!)
Unlike MATLAB, it does not support object-oriented programming
Unlike MATLAB supportsonly basic graphic capabilities, limiting the application of Octave in scientific and engineering graphics, including the creation of GUIs.
Unlike MATLAB, lacks support from a multi-million dollar companysuch as the MathWorks, Inc.
Unlike MATLAB,fewer toolboxes are available
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
6
Octave basic features
•No declarations needed: octave:1> 14 + 28 ans = 42
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
7
Octave Matrix notation
•Working with matrices: octave:7> a = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ] a = 1 1 2 3 5 8 13 21 34
•Row vectors and the colon operator : _ octave:8> row vector = 1:5 row vector = _
1 2 3 4 5
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
8
Octave Matrix Subscripting
•Working with subscripts: octave:13> b = rand (3, 3); octave:14> b(3,1), b(3,2), b(3,3) ans = 0.27638 ans = 0.94927 ans = 0.36208
octave:15> b(3,2) = 1; octave:16> b b = 0.46079 0.31457 0.53600 0.55636 0.22555 0.11940 0.276381.000000.36208
Distribution Statement A: Cleared for Public Release. Distribution is unlimited.
9
Octave Multidimensional Arrays • Example of a 3D random array filled with normal data: octave:20> r = randn(2,3,4) r = ans(:,:,1) = -1.05765 -0.16023 0.72208 0.48319 0.84360 0.20065