{"title":"An improved version of PyWolf with multithread-based parallelism support","authors":"Tiago E.C. Magalhães","doi":"10.1016/j.cpc.2024.109431","DOIUrl":null,"url":null,"abstract":"<div><div>PyWolf is an open-source software with a graphical user interface that performs numerical simulations of the cross-spectral density function propagation of planar sources using parallel computation through PyOpenCL. In the previous versions of PyWolf, the user could select the OpenCL devices and platforms to perform the parallel computations on several tasks, except for that related to the two-dimensional (2D) fast Fourier transform (FFT) algorithm. The latter task can have a large computation time since one has to perform a large amount of 2D FFTs over 2D slices of a four-dimensional array. The option of using multithread-based computation on these loops and other tasks can be an advantage for multi-core CPUs and can significantly decrease the computation time. Here, I present version 3.0.0 of PyWolf, which adds a multithreading option to be used for the 2D FFT computations. This multithreading option can also be easily implemented in other time-consuming tasks.</div></div><div><h3>New version program summary</h3><div><em>Program Title:</em> PyWolf</div><div><em>CPC Library link to program files:</em> <span><span>https://doi.org/10.17632/frjscxypkd.3</span><svg><path></path></svg></span></div><div><em>Developer's repository link:</em> <span><span>https://github.com/tiagoecmagalhaes/PyWolf</span><svg><path></path></svg></span></div><div><em>Licensing provisions:</em> GPLv3</div><div><em>Programming language:</em> Python</div><div><em>Supplementary material:</em> Overview of the main changes with performance results.</div><div><em>Journal reference of previous version:</em> Comput. Phys. Commun. 294 (2024) 108899.</div><div><em>Reasons for the new version:</em> In the original paper of PyWolf <span><span>[1]</span></span> and in the previous version <span><span>[2]</span></span>, parallel computation was performed only using PyOpenCL. However, in some cases where multiple cores are available in the CPU, multithreading <span><span>[3]</span></span> can significantly decrease the computation time of some tasks, for instance, the loops of 2D fast Fourier transforms (FFTs). This new version includes a built-in option for multithreading, enabling users to select the number of threads to be used in the numerical simulation.</div><div><em>Summary of revisions:</em> Multithreading support was added to PyWolf and users can now select this feature in PyWolf's graphical user interface and choose the number of available threads to be used in the simulation. In the current version, multithreading is only used for the loops of 2D FFTs but can be easily extended to other tasks. Other small features have been added and some issues have been corrected, namely: (i) a requirements file has been added listing all the libraries used; (ii) some errors associated with file paths have been corrected.</div><div><em>Nature of problem:</em> Propagation of partially coherent light from planar sources in the Fresnel or far field approximations using four-dimensional arrays <span><span>[4]</span></span>, <span><span>[5]</span></span> demands large memory and computation time. PyWolf uses PyOpenCL to perform parallel computation to reduce time-consuming calculations in the propagation of the cross-spectral density function <span><span>[4]</span></span>, restricting the memory capacity as the main limitation.</div><div><em>Solution method:</em> The open-source toolkit PyOpenCL along with multithreading is used to decrease the computation time. Users can modify and add more features to PyWolf, such as source, propagation, and geometrical models. Custom-made optical components can also be added (e.g., lenses and apertures). The PyQt5-based graphical user interface enables users to easily set the input parameters to simulate their optical setup, plot and export the simulated results, and save or load the simulation session.</div></div>","PeriodicalId":285,"journal":{"name":"Computer Physics Communications","volume":"307 ","pages":"Article 109431"},"PeriodicalIF":7.2000,"publicationDate":"2024-11-15","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Computer Physics Communications","FirstCategoryId":"101","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S0010465524003540","RegionNum":2,"RegionCategory":"物理与天体物理","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q1","JCRName":"COMPUTER SCIENCE, INTERDISCIPLINARY APPLICATIONS","Score":null,"Total":0}
引用次数: 0
Abstract
PyWolf is an open-source software with a graphical user interface that performs numerical simulations of the cross-spectral density function propagation of planar sources using parallel computation through PyOpenCL. In the previous versions of PyWolf, the user could select the OpenCL devices and platforms to perform the parallel computations on several tasks, except for that related to the two-dimensional (2D) fast Fourier transform (FFT) algorithm. The latter task can have a large computation time since one has to perform a large amount of 2D FFTs over 2D slices of a four-dimensional array. The option of using multithread-based computation on these loops and other tasks can be an advantage for multi-core CPUs and can significantly decrease the computation time. Here, I present version 3.0.0 of PyWolf, which adds a multithreading option to be used for the 2D FFT computations. This multithreading option can also be easily implemented in other time-consuming tasks.
New version program summary
Program Title: PyWolf
CPC Library link to program files:https://doi.org/10.17632/frjscxypkd.3
Reasons for the new version: In the original paper of PyWolf [1] and in the previous version [2], parallel computation was performed only using PyOpenCL. However, in some cases where multiple cores are available in the CPU, multithreading [3] can significantly decrease the computation time of some tasks, for instance, the loops of 2D fast Fourier transforms (FFTs). This new version includes a built-in option for multithreading, enabling users to select the number of threads to be used in the numerical simulation.
Summary of revisions: Multithreading support was added to PyWolf and users can now select this feature in PyWolf's graphical user interface and choose the number of available threads to be used in the simulation. In the current version, multithreading is only used for the loops of 2D FFTs but can be easily extended to other tasks. Other small features have been added and some issues have been corrected, namely: (i) a requirements file has been added listing all the libraries used; (ii) some errors associated with file paths have been corrected.
Nature of problem: Propagation of partially coherent light from planar sources in the Fresnel or far field approximations using four-dimensional arrays [4], [5] demands large memory and computation time. PyWolf uses PyOpenCL to perform parallel computation to reduce time-consuming calculations in the propagation of the cross-spectral density function [4], restricting the memory capacity as the main limitation.
Solution method: The open-source toolkit PyOpenCL along with multithreading is used to decrease the computation time. Users can modify and add more features to PyWolf, such as source, propagation, and geometrical models. Custom-made optical components can also be added (e.g., lenses and apertures). The PyQt5-based graphical user interface enables users to easily set the input parameters to simulate their optical setup, plot and export the simulated results, and save or load the simulation session.
期刊介绍:
The focus of CPC is on contemporary computational methods and techniques and their implementation, the effectiveness of which will normally be evidenced by the author(s) within the context of a substantive problem in physics. Within this setting CPC publishes two types of paper.
Computer Programs in Physics (CPiP)
These papers describe significant computer programs to be archived in the CPC Program Library which is held in the Mendeley Data repository. The submitted software must be covered by an approved open source licence. Papers and associated computer programs that address a problem of contemporary interest in physics that cannot be solved by current software are particularly encouraged.
Computational Physics Papers (CP)
These are research papers in, but are not limited to, the following themes across computational physics and related disciplines.
mathematical and numerical methods and algorithms;
computational models including those associated with the design, control and analysis of experiments; and
algebraic computation.
Each will normally include software implementation and performance details. The software implementation should, ideally, be available via GitHub, Zenodo or an institutional repository.In addition, research papers on the impact of advanced computer architecture and special purpose computers on computing in the physical sciences and software topics related to, and of importance in, the physical sciences may be considered.