Here are the slides from my talk about GPULib and FastDL today to the Scientific Programming in IDL class at the Exelis VIS office.
Category "IDL"
Turning around WHERE
posted Tue 17 Jun 2014 by Michael Galloy under IDLMotivated by this idiom from Python, I have been experimenting with using a small helper routine from my library, MG_ANY. MY_ANY flips around the return value and count parameter of WHERE and is used something like the following:
if (mg_any(condition, indices=ind)) then begin
; use ind for purpose
endif
This replaces the following standard code where count is checked after the fact (and often neglected by novice programmers):
ind = where(condition, count)
if (count gt 0L) then begin
; use ind for purpose
end
To me, this small change of flipping the return value with a value passed back through a parameter/keyword makes this more readable and harder to write a bug into.
I cleaned up a few visual bugs in the beta and IDLdoc 3.6 is ready for release. Get the new version at the (releases)[1] page of the GitHub IDLdoc wiki. Features are the same as listed for the beta:
- Checks for updates when using the VERSION keyword.
- Added Exelis VIS Doc Center output.
- Provides links to IDL library routines referenced in rst markup code syntax.
- HTML rst markup directive to include HTML directly into output (contributed by Phillip Bitzer).
- Reporting only non-empty, non-comment lines in routines/files now.
- Improved algorithm for computing cyclomatic complexity and also reporting modified cyclomatic complexity.
- Updated to MathJax 2.0 and using the complete MathJax distribution for better LaTeX rendering.
- Listing methods inherited from parent classes.
- Miscellaneous bug fixes.
UPDATE 6/11/14: I released 3.6.1 adding some missing library routines in the .sav file. Download is on the same page.
You can always get the latest version from the GitHub repo. ??
IDL in an IPython notebook!
posted Tue 3 Jun 2014 by Michael Galloy under IDLThanks to Eric Bellmās idlmagic, it is now possible to use IDL inside an IPython notebook! For example, hereās the HTML output of the first section of Modern IDL as an IPython notebook (download notebook). Note there are some mistakes still, notably the printing of a string as a long array.
If this is not exciting to you, you need to learn more about IPythonĀ notebooks.
Sankey diagrams of careers after degree
posted Fri 30 May 2014 by Michael Galloy under IDLBen Schmidt has made an interactive visualization to explore the careers of college graduates using Sankey diagrams from D3 in Javascript. I hope I need to make a visualization for the web soon, so that I can play with D3.

Why is funeral service so popular with math majors (though Iām not sure what āMiscellaneous manager, including Funeral Serviceā really means)?
via FlowingData
I havenāt released IDLdoc for awhile and quite a few new features have accumulated[1] (download):
- Checks for updates when using the VERSION keyword.
- Added Exelis VIS Doc Center output.
- Reporting only non-empty, non-comment lines in routines/files now.
- Improved algorithm for computing cyclomatic complexity and also reporting modified cyclomatic complexity.
- Updated to MathJax 2.0 and using the complete MathJax distribution for better LaTeX rendering.
- Listing methods inherited from parent classes.
- Miscellaneous bug fixes.
- Provides links to IDL library routines referenced in rst markup code syntax.
- HTML rst markup directive to include HTML directly into output (contributed by Phillip Bitzer).
If you check it out, please let me know if you have any issues. Formal release should happen in the next week or two.
You can always get the latest version from the GitHub repo. ??
When using the rst markup, IDLdoc has been able to lookup the names of routines, files, directories, keywords, etc. when referencing them using syntax like:
; :Returns:
; Returns a string array for the names if `NAMES` keyword is set.
Here a link to the āNAMESā keyword is created automatically by IDLdoc. IDLdoc searches the namespace āaroundā the mention to determine what is given priority, i.e., look first for keywords and parameters of the given routine/method, then check for routines/methods in the current file, classes in the current file, the name of the current file, etc. expanding to include all the symbols defined in the hierarchy of files being documented.
New in the development version of IDLdoc is another check against the names of the IDL library routines, producing a link to the online help on exelisvis.com/docs. For example, the following comments would automatically link to CONGRID:
; Resize an image similarly to `CONGRID`. Advantage over `CONGRID` is
; that nearest neighbor interpolation is used even for multiple band
; images.
To get the development version of IDLdoc at any time, check the IDLdoc repo on GitHub.
★ IDL online help bookmarklet
posted Tue 13 May 2014 by Michael Galloy under IDLOne thing that I have to do regularly is send people a link to a particular page of IDLās documentation. The problem is that I normally browse the local documentation from the ? command a the IDL prompt which opens a local webpage in my browser, but is not accessible to someone else on their machine (the path is different depending on platform, version, etc.). What I needed was a way to translate local help URLs to URLs pointing at the online help at exelisvis.com.
Here is a bookmarklet that does the translation:
javascript:(function(){name=location.href.substring(location.href.lastIndexOf('/')+1);name=name.substring(0,name.indexOf('.'));location.href='http://exelisvis.com/docs/'+name+'.html';})();
Just drag it to your bookmarks bar and click it when on a local IDL help page and it should navigate to the corresponding exelisvis.com documentation page. It doesnāt do any error checking right now and it doesnāt work for some of the pages that are not the syntax for a particular routine, but it has been very useful for me in the past few days.
One of the features I was most excited about in CUDA 6 is the drop-in library (nvBLAS) support for BLAS. The idea is to use LD_PRELOAD when launching IDL to indicate that BLAS should be coming from the nvBLAS instead of the BLAS implementation that would normally be found, e.g., in IDLās case, the idl_lapack.so distributed with IDL. Iāve had problems getting it to work so far, though.
Right now, the way Iām starting IDL is something like the following:
$ export NVBLAS_CONFIG_FILE=/path/to/nvblas.conf
$ export LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib64
$ LD_PRELOAD=/usr/local/cuda-6.0/lib64/libnvblas.so idl
This seems to be recognizing nvBLAS because it will crash if I donāt set LD_LIBRARY_PATH and NVBLAS_CONFIG_FILE (Iām using a default configuration file). But I have not been able to get any different results testing performance of MATRIX_MULTIPLY between using nvBLAS or not. I will continue to test this, because itās too interesting to pass up and there are a couple of items that I havenāt explored yet:
- Iām not using big enough matrices at 5000 x 5000 elements.
- Iām not setting something in the configuration file specified by
NVBLAS_CONFIG_FILE.
I donāt imagine the speedup from nvBLAS is going to be amazing because memory transfer will eat into the performance, but you canāt beat not having to change any code at all. I am worried that the way that IDL loads dynamic libraries might get in the way of this working.
The LAPACK library is distributed along with IDL, but wrappers to most of the routines are not provided. On Linux, CALL_EXTERNAL can be used to easily access any of the routines. On OS X, the Accelerate Framework can be used. I have not found a solution for Windows[1] since the needed symbols in the DLL provided by IDL arenāt exported.
In the following code example for Linux, we will call SGEQRF to determine the QR factorization of a given matrix. First, we need to specify the location of the LAPACK library:
ext = !version.os_family eq 'unix' ? '.so' : '.dll'
lapack = filepath('idl_lapack' + ext, $
root=expand_path('', /dlm))
m = 20L
n = 10L
x = randomu(seed, m, n)
info = 0L
tau = fltarr(m < n)
lwork = -1L
work = fltarr(1)
status = call_external(lapack, 'sgeqrf_', m, n, x, m, tau, work, lwork, info, $
value=[0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L], $
/auto_glue)
lwork = long(work[0])
work2 = fltarr(lwork)
status = call_external(lapack, 'sgeqrf_', m, n, x, m, tau, work2, lwork, info, $
value=[0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L], $
/auto_glue)
Here is a more generic routine as an example of calling into LAPACK that works on Linux and OS X.
Please let me know if you have a way to do this on Windows! ??
