In this example, we replace the definition of FFT used by a program, by another one that makes a more efficient computation exploiting multiple CPUs. Given the new FFT service, the extension should simply bridge differences in the interface:
void fft_bridge(float *data, long size)
n = get_num_processors();
new_data = reshape_data(n, data);
spawn(n, parallel_fft, new_data, size);
This routine computes the available number of processors, prepares the data to be used by the threads, and spawns threads to execute a parallel FFT using the reshaped data. Once built, we should simply override the old FFT service using the redefinition facility, either through the config file or at run-time (di_rebind).