OCTAVE |
---|
Description: Mostly compatible language with Matlab primarily intended for numerical computations |
SHARCNET Package information: see OCTAVE software page in web portal |
Full list of SHARCNET supported software |
NOTICE : On December 1st 2011 octave/3.4.0 will be removed from all sharcnet clusters since version octave/3.4.3 is now installed and contains significant performance enhancements. Also on Dec 1 the octave/3.2.4 module will no longer load by default on goblin and hound clusters.
For best performance load the latest version of octave by doing:
module unload octave module load octave
On SHARCNET clusters Octave should only be run via the queuing system. Octave serial jobs bas best submitted to the serial queue on kraken assuming they use less than 1gb by doing:
sqsub -t -r 60m -f wha -o ofile.%J octave mycode.m
As of version 3.4.3 the sharcnet octave installation supports multithreading which based on initial testing can result in an order of magnitude speedup for octave codes that are specifically lapack and blas intensive (compared to simply using a single core in the serial queue) without making any changes to your code. Once the optimal number of processors is determined by scaling tests submit the job to the threaded queue for example:
sqsub -t -r 60m -n 16 -q threaded --mpp=1G -o ofile.%J time octave mycode.m
WORKING WITH ADDITIONAL PACKAGES
The "Octave Forge"[1] project provides extra packages for use with octave that can be downloaded and manually installed into your own sharcnet account. A list of packages which can be downloaded can be found "here"[2]. Consider setting up a directory called my_octave_sources in your sharcnet home account for all your downloaded packages as is assumed in the following example:
[jole@bul125:~] octave octave:1> help pkg
To install a package such as linear-algebra do
octave:2> cd ~/my_octave_sources octave:3> pkg install linear-algebra-2.1.0.tar.gz
To then remove the linear-algebra do
octave:4> pkg uninstall linear-algebra
To list all installed packages do
octave:5> pkg list
To add a named packages to your path do
octave:6> pkg load name
To remove a named package from your path do
octave:8> pkg unload
To list all functions provided by a package do
octave:9> pkg describe -verbose all
To list functions provide by extra odepkg package do
octave:10> pkg describe odepkg
To list functions details for extra financial package
octave:11> pkg describe financial -verbose
To get documentation for a topic such as sin do
octave:12> doc sin
To get help using the doc command do
octave:13> help doc
To get documentation for a topic such as matrix do
octave:14> doc matrix
To get documentation for any topic run the doc command alone
octave:15> doc
READING OR WRITING FILES
There are two strategies for handling file "input and output"[3] described in the "Octave manual"[4]. The following are some demonstrating the "simple file I/O"[5] approach
save myiofile.dat A B C save ("-text", "myiofile.dat", "A", "B", "C") save ("-binary", "myiofile.dat", "A", "B", "C") load myiofile.dat load ("-text", "myiofile.dat", "A", "B", "C") load ("-binary", "myiofile.dat", "A", "B", "C")
where A, B and C are a potential mix of entities such as scalars, vectors or matrices. Note that for large files the binary format is strongly recommended to both minimize disk space and file read/write wallclock times.
A COMPLETE PACKAGE EXAMPLE
This example assumes you first create two directories in your home account one being named ~/my_octave_packages and the other ~/my_octave_sources then download the required three tar.gz files into the latter from here [6]
[roberpj@orc-login1:~] module unload octave [roberpj@orc-login1:~] module load octave [roberpj@orc-login1:~] octave GNU Octave, version 3.4.3 octave:1> pkg prefix ~/my_octave_packages ans = /home/roberpj/my_octave_packages octave:2> cd my_octave_sources octave:3> ls miscellaneous-1.0.11.tar.gz optim-1.0.17.tar.gz struct-1.0.9.tar.gz octave:4> pkg install miscellaneous-1.0.11.tar.gz optim-1.0.17.tar.gz struct-1.0.9.tar.gz octave:5> pkg list Package Name | Version | Installation directory ---------------|---------|----------------------- miscellaneous *| 1.0.11 | /home/roberpj/my_octave_packages/miscellaneous-1.0.11 optim *| 1.0.17 | /home/roberpj/my_octave_packages/optim-1.0.17 struct *| 1.0.9 | /home/roberpj/my_octave_packages/struct-1.0.9
MATLAB COMPATIBILITY
The online wiki resources "Octave Wiki"[7] or "Wikibook"[8] provide good introductory explanations of code compatibility between Octave and Matlab.
LARGE MEMORY ARRAY ALLOCATION TESTING
The following command sequence should successfully run on hound or tope. Since tope is recommended for interactive use and has 32gb of memory the test will be demonstrated there:
[mypc ~] ssh tope.sharcnet.ca [tope ~] module load octave/3.4.0 [tope ~] octave GNU Octave, version 3.4.0 octave:3> N=4e8; A=[1:N]; B=[2*(1:N)]; C=A+B; C(1); C(N); 3*N ans = 1.2000e+09 [tope ~] top 24985 roberpj 24 0 9406m 9.0g 12m S 0.0 32.6 0:34.34 octave