Task parallelization means that, e.g., on the same image, different tasks are performed in different threads (see figure 2.3).
Figure 2.3: Minimize response time using task parallelization. On the same image, three tasks are processed in parallel: QR code reading, ECC 200 reading, and bar code reading.
The HDevelop example program hdevelop/Control/par_start.hdev reads bar codes and different types of data codes in parallel.
After the creation and training of the bar code and data code models, for each reading task a corresponding procedure is called in a separate thread using the par_start qualifier: a procedure to read bar codes, a procedure to read ECC 200 codes, and a procedure to read QR codes. The operator par_join waits for all sub-threads to finish before the results of the individual threads are used for further processing (e.g., the display of results).
par_start<ThreadQRCode> : find_qr_codes (Image, QrCodeXlds, QrCodeModel, \
QrCodeHandlesSeq, \
QrCodeStringsSeq)
par_start<ThreadECC200> : find_ecc200_codes (Image, Ecc200Xlds, Ecc200Model, \
Ecc200Handles, Ecc200Strings)
par_start<ThreadBarcode> : find_bar_codes (Image, BarCodeRegions, \
BarCodeModel, BarCodeStrings)
par_join ([ThreadQRCode,ThreadECC200,ThreadBarcode])
dev_display (QrCodeXlds)
dev_display (Ecc200Xlds)
dev_display (BarCodeRegions)
Note that the example program not only shows how to parallelize the three identification tasks, but also provides hints for which kinds of tasks parallelization is reasonable. Additionally, the speedup of the parallelization is demonstrated by a comparison of the runtimes needed for the parallelized procedure calls and the corresponding sequentially applied procedure calls.