Posts tagged daily
Posts tagged daily
0 notes &
As I mentioned in my introductory post, I am working on the overall design of a native Cocoa port of the Systemic Console (currently a Java/Swing application). This involves carefully thinking about what some of the core needs will be and which of the core libraries (frameworks) will address them. Therefore, every few days I will talk briefly about what class/library I am learning for a particular section of the port, with some useful links I have perused and possibly some small snippets of code. This will also be useful to me to store my resources in a centralized place.
The lion’s share of the code resides in a “kernel” class (which delegates to a decent number of focused classes), and is dedicated to complex and not-so-complex numerical tasks, often executed in parallel. A good number of these are implemented using custom numerical routines, ThreadPoolExecutor and Apache Commons-Math.
Objective-C’s ability to interface trivially with C libraries opens up a wealth of options to choose from. GSL, for instance, has been conveniently packaged as a framework here. Mac OS X comes with the Accelerate framework preinstalled, which includes LAPACK, BLAS and a number of vectorizing operations calls. The documentation is a bit sparse for some of it; the Apple-provided PDF doc and this nice article were very helpful. SuperMegaUltraGroovy has a simple ObjC wrapper for it (SMUGMath), which I’m testing out now - seems nice so far.
I’m dipping my toes into the threading facilities provided by Cocoa, trying to do a bunch of numerical stuff in a test Foundation project. So far, it looks pretty easy. Specifically, I am using NSOperationQueue (implemented with Grand Central Dispatch in 10.6) to submit a bunch of numerical jobs.
NSOperationQueue is supposed to figure out the best number of threads to be spawned for the available hardware, and reusing threads as possible. Each task in my test code is implemented with NSInvocationOperation, which invokes the specified @selector, and stuffed in a NSArray. Finally, the jobs are queued and executed using -addOperations:waitUntilFinished: by setting the last parameter to YES, the current thread is blocked until all operations have finished running. Setting up NSInvocationOperations was a cinch. So far so good!