Imatest IT now includes parallel processing capabilities that allows the user to more completely utilize their computer’s resources by running multiple concurrent processes.
Imatest IT includes an additional C++ project that demonstrates a multi-process configuration wherein a parent process distributes images for analysis to a pool of child processes. In order to orchestrate this pool of concurrent processes, the C++ project utilizes a particular type of interprocess communication (from Boost.Interprocess). Using interprocess control objects and shared memory, the parent process can safely manage child processes and distribute tasks as child processes become free.
Parallel testing can enable up to 2 to 3 times more testing throughput per machine. Here are benchmarking details:
Benefits of running multiple processes
On many multi-core machines, running a single Imatest IT module does not utilize all of the computer’s resources. Allowing for multiple analysis processes to run in parallel (up to the saturation point for the system’s resources) can increase the testing throughput, i.e. the number of tests a machine can accomplish in a given time.
One such example is shown in the plot on the right, wherein the computer (Intel I7-3930K processor – 6 physical cores @ 3.2 GHz, 16 GB RAM) was analysing multiple 8MP SFRplus images with an increasing number of concurrent SFRplus processes. In this example, the testing throughput at its peak has increased by a factor of roughly 3.7 over the testing throughput of a single process. The testing throughput reached saturation roughly where the number of processes equals the number of physical cores. The throughput improvement will vary depending on the computers processor and amount of RAM.
While Imatest IT/DLL is used for image quality analysis, the interprocess communication and synchronization in the parallel C++ project is managed by another library, the Boost Interprocess library. The Boost Interprocess library is by no means the only interprocess library, but it was chosen because of its portability and relative simplicity. In order to understand the various objects involved in interprocess communication and concurrency, please read the Boost Interprocess documentation. Gaining an understanding of the challenges of concurrency is necessary to programming a parallel processing system.
After the installation of Imatest IT is complete, the sample project will be located in the samplescppCPP_parallel_test_project subdirectory within the IT installation directory (C:Program FilesImatestv5.0IT ).
Visual Studio project
Included with the installation of IT is a Visual Studio 2008 C++ project wherein a pool of parallel processes of Imatest IT analyze a sequence of images stored as files. This process pool is managed by a parent process that communicates with the pool using shared memory and synchronization objects from the Boost Interprocess C++ library v1.54. Through shared memory, the parent communicates the test details (i.e. the image source and whether to run sfrplus_shell() or blemish_shell() on the image) to individual child processes. The child processes perform tests and wait for further instructions. Once the parent process has no more tests for the child process, it sends the commands to cause the child process to terminate themselves.
- Analyzes SFRplus and Blemish RAW image files of multiple resolutions.
- Each child process can analyze an image with the sfrplus_shell() or blemish_shell() function without having to restart to switch between the two functions.
- Child processes, upon completing analysis of an image, wait for instruction from the parent process.
- Collision of console output from each child process is suppressed by redirecting each child process’ output through shared memory to the parent process.
- The parent process can terminate a child process if it does not return results quickly enough and start a new child process to analyze the prior process’ image.
- Access to the data shared between the parent and a particular child process is controlled by interprocess mutexes and interprocess condition variables.
- Have parent process monitor a directory, or directories, for incoming images and assign them to a child that is waiting.
C++ Project architecture
In the C++ project, a parent process launches a pool of three child processes that each contain an instance of the Imatest IT/DLL. Testing data (i.e. the image file name and what test to perform) are distributed to the child processes through shared memory. The child processes then analyze the image, with the settings input from the .ini control file, and output the results to uniquely named JSON files. The output of each child process that would have otherwise go to the console window (via std::cout) is redirected through shared memory back to the parent process to suppress collision of output to the console. Once a child process has finished an image analysis, it waits for further instruction from the parent process.
Important classes and objects
This struct is loaded into shared memory as an interface between each child process and the parent process. It contains all information on the test to be run as well as housing several control constructs, including interprocess mutexes and interprocess conditional variables. Note the Boost Interprocess shared memory objects cannot contain standard C++ containers as they do not allocate into shared memory (link). Instead use either the Boost Interprocess containers or plain data objects.
This class allows the parent process to better control the child processes and the shared memory ChildProcessSettings structs. This class is necessary because when a child process is terminated by the parent process, e.g. in the case of the child process stalling, then the shared memory containing the ChildProcessSettings struct needs to be deleted and a new shared memory object created.
This struct contains all the information for a particular SFRplus test, e.g the file name.
This struct contains all the information for a particular Blemish test, e.g. the file name..
This struct contains all identifying information for a given camera, e.g. the camera resolution, serial number and part number.
- Boost Interprocess documentation.
- Important note on the limitations of mapped regions in shared memory: (link).