Python Parallel Processing and Multiproc
Python Parallel Processing and Multiproc
3, 2021
This is an open access article distributed under the Creative Commons Attribution License
Copyright ©2017. e-ISSN: 2520-789X
https://doi.org/10.25007/ajnu.v10n3a1145
ABSTRACT
Parallel and multiprocessing algorithms break down significant numerical problems into smaller subtasks, reducing the total
computing time on multiprocessor and multicore computers. Parallel programming is well supported in proven programming
languages such as C and Python, which are well suited to “heavy-duty” computational tasks. Historically, Python has been
regarded as a strong supporter of parallel programming due to the global interpreter lock (GIL). However, times have changed.
Parallel programming in Python is supported by the creation of a diverse set of libraries and packages. This review focused on
Python libraries that support parallel processing and multiprocessing, intending to accelerate computation in various fields,
including multimedia, attack detection, supercomputers, and genetic algorithms. Furthermore, we discussed some Python
libraries that can be used for this purpose.
1. Introduction
In recent years, the Python programming language has clusters, and clouds.
gained momentum for scientific computing. Often Parallel computing, on the other hand, is a
conventional tools like MatLab are replaced. [1]. It is computational paradigm where several instructions
open to all at no cost because Python is open source, are performed concurrently. It is based on the premise
and its portability makes its usability possible on many that significant problems can often be broken into
platforms. The language itself is lightweight, abridged, separate ones and solved simultaneously (parallel).
and highly suitable for quick prototyping, although it Bit-level parallelism, instruction-level parallelism,
is strong enough to write significant applications. data parallelism, and task parallelism are the four
Some people don't give it enough credit for its usability types of parallel computation [6].
and flexibility. Hiotas been used for many years, especially in high-
Python can very well be integrated with the C/C++ so performance computing; however, interest in this field
that external performance or code-based modules can has recently increased due to physical hardware
be easily invoked. Besides, it offers a wide range of constraints on CPU frequency, such as shared-memory
scientific libraries, e.g. Processing and analyzing data, and distributed services, as well as infrastructure
plotting and graphical user interfaces [2][3][4]. All networks, clusters, and clouds [7][8]. Furthermore, the
these feature makes Python attractive to the scientific use of such resources and the generation of heat by
public but it has to be parallel to the languages used in computers has become a focus of recent technological
large projects. CPython is the default implementation advancement. As a result, parallel computing has
and most commonly used. [5], due to the global look established itself as a key concept in computer
in the interpreter, several threads cannot be run at architecture, specifically in multi-core processors.
once. A variety of options have been developed to The Python multiprocessing module [9] allows
create many Python processes, Shared and elastic processes to be spawned in SMP machines with an API
infrastructure environments, including networks, like the module for threading, explicit calls for process
345
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
346
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
▪ MRI images and models of bone implantation in the system rather than using several copies of
systems are examined using medical parallel the same data.
processing equipment. • In this method increase reliability, since the ability
▪ Other uses include broken coding, geological is spread over many processors, the reliability is
research, animated graphics, computer fluid increased. If one of the processors fails, the
dynamics, chemistry, the science of physics, system's speed will be slightly slowed, but the
electronic styling, and climatology. system will continue to function normally.
3. Multiprocessing
4. Python
The capacity of a device to support more than one
For learning as well as actual world programming,
processor at the same time is referred to as
Python is an appropriate language. Python is Guido
multiprocessing. In a multiprocessing method,
van Rossum's strong object-oriented language of
applications are divided into smaller chunks of code
programming. The language designs allow the user to
that run independently. The operating system assigns
write simple programs on large and small scales. [5].
these threads to the processors, which improves
Python supports many programming paradigms,
system performance. It does two things at once: it runs
including object-oriented, mandatory, functional, or
code on multiple CPUs at the same time, or it runs code
procedural types. Python supports the essential
on the same CPU and achieves speedups by using
feature. Python supports an automatic memory
"wasted" CPU cycles while the software is waiting for
management system of a dynamic kind and has broad
external resources such as file loading, API calls, and
and extensive standard libraries. Many operating
so on.
systems have Python interpreters available.
347
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
Python script or a C/C++ execution from a Python the client-side, serializes Python code and related
script. [17]. data and stores it in object storage. The client
b. JMetalPy: Create an environment for solving instructs the stored actions to run concurrently
multi-objective optimization problems using and then awaits the output. PyWren takes the code
traditional meta-heuristics and techniques for and processes the related data from object storage
preference articulation and emotional problems, on the server-side, saving the output. [21].
as well as a rich set of features and real-time and f. PyNetLogo: Is a connector. The Python general-
interactive visualization. JMetalPy also supports purpose programming language will be used to
parallel computing in multicore and cluster handle NetLogo. Due to Python’s increasing
systems. [18]. demand in the field of IT in general, the analysts
c. Parsl: It is a Python-based parallel scripting library and modelers have the ability to choose within
that facilitates data-oriented workflows that are many different selections. PyNetLogo features
both asynchronous and implicitly parallel. Using include monitoring using one of NetLogo's
Swift's model as a foundation [12], Parsl extends example frameworks in an interactive Python
Python scripts (or applications) with advanced environment to conduct a global data analysis
parallel workflow capabilities. Parsl scripting links with parallel processing. [22].
selected python functions, and external 5. Literature Review
applications (called apps), with shared This paper reviewed many papers related to
input/output data objects in versatile parallel multiprocessing and parallel processing issues that
workflows. Parsl summarizes the execution Python solved. And demonstrates how
environment for multi-core processors, clusters, multiprocessing and parallel processing can
and supercomputers [19]. significantly reduce calculation time by using python
d. Ray: Is an open-source Python parallel and libraries.
distributed library. Ray provides a cohesive D. Meunier et al., [23] NetLogo can be controlled
interface for expressing in cooperation calculations through the programming language of Python. Given
that are parallel to the role and actor based on a Python's growing popularity in computer science,
single dynamic implementation motor. Ray modelers and analysts now have more choices.
monitors the system's control state using a PyNetLogo features include controlling one of
distributed scheduler and a parallel fault-tolerant NetLogo's example models from an integrated Python
store to meet performance requirements. [20]. environment and performing a global sensitivity
e. PyWren: an open-source project that runs user- analysis with parallel processing.
supplied Python code and dependencies as server- J. Kready et al., [24] This paper proposes an
less activities on a server-less platform. PyWren implementation using multiprocessing from Python to
performs server-less actions at a large scale and process a parallel application for the YouTube Data
tracks the effects without needing awareness of API. First, parallel data collection from YouTube. The
how they are invoked and run. PyWren provides tests show that multiprocessing increases the output
a client that operates locally and a runtime by 400 percent with parallel processing for YouTube
deployed as a server-less action in the cloud. data collection. These enhancements minimize
PyWren uses object storage to communicate calculation time by using multi-threaded CPUs.
between the client and server sides. PyWren, on J. Niruthika et al., [25] The output of the parallel Aho-
348
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
Corasick algorithm was compared to that of the serial computer programming expertise. BayesFactorFMRI
version. Aho-Corasick is a well-known algorithm that can be downloaded for free from Zenodo and GitHub.
solves the problem of exact string matching, which is a Neuroimaging researchers who wish to analyze their
significant problem in the field of computer science. fMRI data with Bayesian analysis will usually use it, as
The results show that parallel Aho-Corasick it is more sensitive than conventional analysis and
implemented in Python has a lower time performance increases efficiency by spreading analytical tasks
than its serial counterpart, while parallel Aho-Corasick across multiple processors.
implemented in C has a higher time performance than G. Heine, T et al., [29] Introduced a method for
its serial counterpart. As a result, Python is unsuitable asynchronous streaming. Stream subscriptions are
for parallelizing the Aho-Corasick algorithm since the proposed as a tool for monitoring public opinion. A
algorithm's CPU consumption may be significant prototype is presented that integrates Twitter sources,
compared to its I/O usage. Python text processing, and Cassandra storage
A. Benítez-Hidalgo et al ., [26] jMetalPy is methods, with three main points elaborated on: 1) A
implemented in a Python-based multi-objective comparison of results in writing techniques. 2) Data
optimization system with meta-heuristics. It is parallelization and asynchronous concurrent database
distributed under the MIT license and is freely writes are used in multiprocessing procedures. 3)
available to the public on GitHub. They presented and Monitoring of public opinion by noun extraction.
discussed the central architecture of the NSGA-II D. Datta et al., [30] The performance of parallelized
program and some of its variants as ample examples CPUs was compared. Python's Ray library is used to
of how to use this framework. Dynamic optimization, parallelize multicore CPUs. In this project, the
parallelism, and data processing decision-making are benchmark image classification algorithm used is
all assisted by Metal. based Convolutional Neural Network. The author
Y. Babuji et al., [27] Parsl is a parallel script library that attempted to demonstrate the Parallelization of a
extends Python through fast, scalable, and adaptable CPU's multicores which allows for faster training of a
encoding parallels. Experimental results on computing model. In this paper, a comparison analysis was
in Blue Waters show that Python scripts can run conducted between three different Convolutional
components of just 5 MS overhead, scale to over Neural Network models.
250,000 employees across more than 8,000 nodes, and T. Shaffer et al., [31] Native Python functions were
process up to 1200 tasks a second. It has shown proposed at scale, and techniques for dynamically
multitasking, collaborative, web-based, and machine evaluating a minimal collection of dependencies and
learning skills in biology, cosmology, and materials assembling a lightweight function monitor (LFM) that
science. captures the software environment and manages
D. S. Wahyuni [28] The BayesFactorFMRI tool, written resources at the granularity of single functions were
in R and Python, was presented to enable Bayesian introduced. The author tests these approaches in
second-level analysis and Bayesian meta-analysis for various settings, from a campus cluster to a
multiprocessing fMRI image data by neuroimaging supercomputer, and demonstrates that their advanced
researchers. This tool accelerates computer-intensive dependency management planning and complex
Bayesian fMRI analysis by using multiprocessing. Its resource management strategies outperform the
graphical user interface (GUI) enables researchers to competition.
conduct Bayesian fMRI analysis without the need for E. Jonas et al., [32] Introduced the MPI Python connect
349
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
with the standard MPI communication API, known as subsequent implementation. For example purposes,
mpiPython. The author discussed the design issues the Python programming language is used. Various
associated with the implementation of the mpiPython models of genetic algorithm parallel processing are
API in this paper. The second part of the paper also provided and described. The Python
addressed the node/parallel output to compare implementations of the models are then defined and
mpiPython with other MPI bindings on a Linux compared using iteration count as a criterion. While
cluster. individual model output can only be compared to a
Galvez et al., [33] CharmPy was introduced as a certain degree, all parallel models outperform the
parallel programming model and application based on simple serial model.
the Python programming language. It had many H. Jan et al., [37] In this article, the NetLogo connector
distinguishing features, including a simpler model and was initially introduced, which connects the NetLogo
API, improved flexibility, and writing anything in modeling agent to a Python environment. This was
Python. Another example is a general-purpose illustrated with one of NetLogo's sample versions. The
distributed map function that can run independent library SALib Python was used as an example of the
jobs on multiple nodes simultaneously and supports more complex tests given in a Python GUI in Sobol's
load balancing. The authors also demonstrated how to variance-based structural reliability analysis of the
use CharmPy to write parallel Python applications that model. For better results in the study, the ipyparallel
scale to massive core counts on supercomputers and library was used to parallel sequential simulations.
perform similarly to MPI or C++ versions. Zhang et al., [38] This paper proposed Quant Cloud, a
R. Eggen et al,. [34] The effect of the global python program that integrates a parallel Python framework
interpreter lock (GIL) has been examined. To show the with a C++-coded Big Data system. This extensive data
effect of GIL, the authors analyze a comparison of framework is built in C++, and the user methods are
python threads to python processes. The GIL leads to written in Python. A coprocessor-based parallel
sequential execution of threads, while concurrent strategy underpins the automatic parallel execution of
processing is executed. Processes need more start-up Python code. They have put the program into two
time; it answers the amount of data needed to execute popular algorithms: moving window and self-
processes faster than threads. adjusting average movements (ARMA). The Intel Xeon
M. R. Rizqullah et al., [35] The middleware in this E5 and Xeon Phi processors are thoroughly compared.
paper was developed using the Python parallel Their approach to parallelization is almost linear and
programming language and installed on a Raspberry is suitable for today's multicore processors. The
Pi 3. The console frame was designed to help people findings show that their method is almost linear.
learn the basics of IoT through the transmission and Sindhu et al.,[39] A Python multi-processing library
receipt of control data to access sensors or actuators. has implemented a simultaneous implementation of
This middleware transforms a command line for the Max-p problem. The author achieves speeds up to
running or accessing the various IoT module features. 12 and 19 times with the best sequential algorithm for
In order to increase program operating time developing and improving phases utilizing an
performance, Python employs multiprocessing or intuitive multi-lock data structure. In order to validate
multithreading. the algorithms, the author provides detailed
V. Skorpil et al., [36] The paper discussed various experiential results.
methods for parallelizing genetic algorithms with Real et al., [40] This paper has presented Auto Parallel
350
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
which is a Python module that facilitates parallelism A. V. M. Barone et al., [44] Introduce a broad and
and runs on distributed infrastructures. It is built on diverse Parallel Corpus with its documentation strings
top of PyCOMP and is sequential, This helps in ("docstrings") created by scrapping open source
making it easy to scale up to hundreds of cores for repositories on GitHub, with a hundred thousand
creative purposes. Users can specify the affine loop on Python functionalities. The paper defined the
sequential methods using the @parallel annotation fundamental results in neural machine-created
instead of testifying sequential python code. As it translations for the code documentation and code
turns out, the generated codes for Choles, LU, and QR generation tasks. To further increase the number of
algorithms can achieve similar performance without training information
any effort from the programmer. Thus, taking the Auto Table 1: Summary of Review Papers Based on Parallel
Processing and Multiprocessing in Python
Pip parallelizes distributed systems one step further.
Ref. Year Objectives Methods / Research Applied Field
Tools Problem
Z. Rinkevicius et al ., [41] Prsened an Open source [23] 2020 Create parallel NeuroPyc Multi-modal Health Care
processing on and decided (Brain
software named VeloxChem that was created to pipelines that can reproducible Pipelines)
be shared and keep brain
measure electronic complicated, real linear response track of all connectivity
analyses. pipelines
functions for functional theories of Hartree–Fock and [24] 2020 Reduce Python The requests Multimedia
computation time from the (YouTube)
Kohn–Sham density. Points to an objective software of YouTube Data YouTube Data
API request in API take time
framework written in Python/C++ layered fashion, parallel.
[25] 2019 Checking the Pyrhon. Problem of Electronic
VeloxChem enables the time-efficiently prototyping of performance of the Exact String Dictionary
parallel version of Matching (Aho–
new techniques without cooperating computational the Aho-Corasick Corasick)
algorithm against
achievement. its serial version
[26] 2019 Create multi-object jMetalPy Multi- Engineering,
V. Canh Vu et al,. [42] In parallel, a genetic optimizations like Objective Economics and
quick prototyping Optimization Logistics
programming technique for classifying data patterns facilities and a vast with Met-
number of data Heuristics
for wireless attack detection was presented. The author libraries available,
and support multi-
performed tests on the same computer system core and cluster
systems for parallel
computing
configuration, parameters and datasets in order to processing,
analyzing, and
associate the performance of Karoo GP and standard viewing.
[27] 2019 Build a dynamic Parsl Encoding Biology,
GP. Karoo GP was, however, implemented alongside component parallelism cosmology,
dependency graph and materials
the high-speed GPU processing mechanism when the that can then run science.
effectively on one
mainstream GP for multi-core CPUs has been used. or more processors
[28] 2021 Comparing BayesFact Perform Image
Karoo GP is much faster than its average GP, according Bayesian meta- orFMRI Bayesian Processing
analysis of fMRI second-level
to performance. image data with analysis and
multiprocessing Bayesian meta-
S. Khan and A. Latif [43] Proposed solution eliminates with serial analysis. analysis
351
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
352
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
353
Academic Journal of Nawroz University (AJNU), Vol.10, No.3, 2021
354