parallel_sort problem fixed

My problem with crashing programs using TBB has been solved. Alexey Kukanov replied to my question explaining that because I use TBB 2.1, thus I have to explicitly initialise the task scheduler. Without this initialization, no context (root) for tasks is created, so no tasks possible.

Simply, I was reading latest manual which was generated for TBB 2.2 (available in Ubuntu 10.04), so I missed this legacy requirement. In TBB 2.2 and later, the initialization is optional:

Using task_scheduler_init is optional in Intel? TBB 2.2. By default, Intel? TBB 2.2 automatically creates a task scheduler the first time that a thread uses task scheduling services and destroys it when the last such thread exits.

Correct version of the example program should look as follows:

#include <tbb/task_scheduler_init.h>
#include <tbb/parallel_sort.h>
#include <cmath>
#include <vector>
using namespace tbb;
int main()
{
    task_scheduler_init tbb_init; // automatic

    const int n = 100000;
    std::vector<double> a(n);
    for (int i = 0; i< n; i++)
    {
        a[i] = std::sin(double(i));
    }
    parallel_sort(a.begin(), a.end());
}

GDAL meets EDINA

Martin Daly has started posting on A Higher Education with details about use case of GDAL to serve large datasets through Web:

We use GDAL to read the files, and were opening them via GDALOpenShared, so that GDAL only opened the file once and used reference counting to manage the lifetime of the GDALDataset object. Unfortunately (for us) GDAL is not thread safe. This isn’t a criticism, the fault is entirely ours for using it in this way.

Criticism or not, the reality is that we (software developers) have already jumped to an era of parallelism (count number of physical or logical CPUs in your computer) where thread-safety becomes a minimum requirement as basic as avoiding buffer overruns.

Co za CUDA!

The singular processing is dead. Long live the multiprocessing.

I can not even imagine effectiveness of exploitation of such a power by issuing little gdalwarp command. GDAL, libLAS, are we ready to squeeze out this CUDA’ny juice?

Co za CUDA! Yes, indeed!

C++ Concurrency in Action

By the beginning of the year 2009, new must-read book for C++ hackers is rolling around. Anthony Williams is writing book titled: C++ Concurrency in Action (ISBN: 1933988770):

I will be covering all aspects of multithreaded programming with the new C++0x standard, from the details of the new C++0x memory model and atomic operations to managing threads and designing parallel algorithms and thread-safe containers. The book will also feature a complete reference to the C++0x Standard Thread Library.

from Anthony’s blog

Since June, Anthony’s book is available through Manning Early Access Program. The final release is planned on February 2009.

In the meantime, Anthony has published an article Simpler Multithreading in C++0x introducing multithreading support and thread library as a new feature in the C++0x standard.