Parasolid offers two distinct mechanisms that enable application developers to take advantage of multiple processors: Thread safety and symmetric multi-processing (SMP). Parasolid is licensed by over 130 independent software vendors (ISVs), many of whom implement these techniques to take advantage of the latest processor technology on desktop, server and mobile devices.
Software achieves performance improvements with SMP by dividing tasks which would run in series on a single processor (or core) into a number of different threads, each of which may be executed on separate processors (or cores) at the same time - this is known as multi-threading.
Special care must be taken when developing code that runs in parallel threads. For example, processors in SMP environments may share resources, such as local cache and main memory management, and it may be necessary for functions to have exclusive access to certain resources, depending upon the architecture of the processor chip. Errors can arise when functions run in parallel and are allowed to clash (see panel below).
Problematic scenarios in Symmetric Multi-Processing
- Thread 1 accesses resource A
- Thread 2 accesses resource B
- Thread 1 requests resource B, pending its release by thread 2
- Thread 2 requests resource A, pending its release by thread 1
Outcome: threads 1 and 2 stall
Data Race (example)
- Thread 1 function increments value x
- Thread 2 function increments value x
Desired outcome: x increases by 2
Possible outcome of parallel processing: x increases by 1
Parasolid uses thread synchronization and locking techniques to prevent these scenarios on behalf of application developers, so they can call functions in their applications with confidence that they are getting optimal parallel processing performance without the responsibility of managing it directly. Synchronization and locking incur their own processor time overheads, which is one reason why performance gains through SMP rarely scale in linear proportion to the number of processors available.
In general, functions that enquire data can be run in parallel because they are read-only. These tend to have low processor demands but can be very large in number, so strategies are used to execute them in groups to minimize overheads.
Functions that change data, need exclusive access to avoid edits over-writing each other. To make the most of SMP, algorithms that change data need to be re-written to reduce the need for exclusive access to an absolute minimum by performing pre-edit and post edit work in parallel before locking to do the actual editing that requires exclusive access.
It may also be possible to determine that an editing operation impacts only a portion of the data and so other functions can continue to operate in parallel on unaffected portions of the data. But, there is a balance between the processor time needed to determine which portions of the data are unaffected and the potential overall saving of processor time.
Parasolid-based applications may create their own threads to run across multiple processors. Each of these application threads may call functions in the same Parasolid session safely, without causing resource clash errors of the kind described above. Parasolid is said to be thread safe.
To take advantage of SMP, many Parasolid functions may be executed at the same time by different applications threads - these are known as concurrent functions. Some Parasolid functions, however, need to operate in isolation of other Parasolid functions - these are known as exclusive functions.
Parasolid manages application threads in a queue. This permits concurrent functions in different threads to run in parallel while ensuring that exclusive functions run independently of all other functions. Parasolid also manages the queue such that no functions are stalled indefinitely or given unexpected priority.
Parasolid performs a thread protection operation before and after a given number of functions in a thread to determine whether that thread should continue to run, or be temporarily locked, for example to permit a different thread to call an exclusive function. Applications can chain functions together in a thread to reduce the overhead of locking/unlocking and speed up sections of their code, as illustrated in the figure below.
Calling an exclusive function temporarily restricts Parasolid access to a single thread. In this case, Parasolid can still take advantage of multiple processors via SMP. Many geometric modeling operations do not lend themselves well to running concurrently with others. Finding ways to adapt Parasolid functions that must run exclusively into functions that could run concurrently without error is an active area of research, and the proportion of Parasolid functions that can run concurrently has been continuously increasing.
Many Parasolid algorithms create their own worker threads to split the computing effort across multiple processors. These worker threads are used to process independent calculations simultaneously and reduce the execution time for certain Parasolid operations. Application threads can therefore invoke Parasolid functions that in turn spawn their own threads. Functional areas in Parasolid that already make use of multiple processors include:
The range of functional areas that benefit from SMP is continually evolving, and increasing the extent to which some of the functional areas listed above make use of SMP is another active area of research. That said, SMP is not a substitute for general performance optimisation, which has always been an integral part of Parasolid development.
Parasolid’s leading position among geometric modeling kernels relies on taking a responsible approach to expanding established SMP capabilities, while maintaining unrivalled quality and breadth of functionality for a diverse and sophisticated customer base. With over 4,000,000 end-users of Parasolid-based applications doing complex modeling and editing every day, it is inevitable that priorities vary. For this reason, Parasolid also offers a number of controls that allow application developers to choose appropriate strategies for different types of operation for their user base.