-
Notifications
You must be signed in to change notification settings - Fork 0
SmallapackSqueak
Installing Smallapack on Squeak and Pharo is now automated with Metacello tool, at least in Squeak 4.5 up to 5.2 and in Pharo 1.4, 2.0, 3.0, 4.0 and 5.0 versions. However the BLAS/LAPACK dynamic link library are a pre-requisite.
"In Squeak"
Installer ss
project: 'MetacelloRepository';
install: 'ConfigurationOfSmallapack'.
((Smalltalk at: #ConfigurationOfSmallapack) project version: #development) load.
"In Pharo"
Gofer new
squeaksource: 'MetacelloRepository';
package: 'ConfigurationOfSmallapack';
load.
((Smalltalk at: #ConfigurationOfSmallapack) project version: #development) load.
The Metacello tools solves the following problems:
The problem of FFI calls with 15 arguments
Some LAPACK functions have more than 15 arguments, while Squeak/Pharo currently do not support invoking a Smalltalk method with more than 15 arguments. However, FFI can invoke a function with more than 15 arguments by simply passing an Array. It would have been possible to reify the external procedure, forming an Array of arguments and explicitely invoking the procedure object with the array of arguments, but that would have lead to even more unreadable and bad code. Instead, a trick has been implemented on Squeak/Pharo to let the compiler perform this single Array argument trick transparently when it encounters a method with 16 args or more. Two options are available for implementing the trick:
- use a compiler override (the configuration version 1.0 did that)
- use a specific compiler for Smallapack (implemented in version 1.1)
The later solution is a bit easier to maintain, and is thus preferred. But any class wishing to send a message with 16 or more arguments have to implement a class side #compilerClass message returning SmallapackCompiler.
The presence of Complex and required extensions
- Squeak contains a Complex class. But this class lacks a few methods. These will be loaded automatically (I recommend using Squeak trunk >= 4.3).
- Pharo does not provide a Complex class, and the configuration will load it from http//www.squeaksource.com/Complex package.
The Smallapack packages
The Smallapack packages may have load order problems too. I generally load with the following order:
- Smallapack-Collection
- Smallapack-External
- Smallapack-Algorithm
- Smallapack-Matrix
- Smallapack-SUnitTests
With the Smallapack-Compiler solution, two additional prerequisites are mandatory due to Monticello limitations concerning alternate compilerClass support.
- Smallapack-ExternalPrereq
- Smallapack-AlgorithmPrereq
You may have to replay manually some LapackMatrix initializations, handling how Monticello works with this respect is not a pleasure.
The package Smallapack-Builder is not mandatory. it is just a helper that helps generating Smallapack-External from comments in LAPACK source
The BLAS/LAPACK libraries
Some dynamic libraries must be provided SmallapackPrerequisites. They must be found on the path used by Squeak FFI (I generally put the DLL in the same directory as the squeak .image). And their name must be matching the Smalltalk declaration in #moduleName (you'll have to adapt one or the other).