Julia has become a popular programming language. In this article, I will use multi-threading both on multi-core PCs and HPC clusters.
First, I give an example of parallel computing with for loop:
In this example, we implement 50 Monte Calo simulations with function simulation() in parallel. @btime a benmark to print out the runtime of the for loop.
On a multi-core PC, we can run the Julia file code.jl with 8 threads as follows
On a HPC cluster, we can run Julia file with 8 threads as follows
In this slurm file, please modify xxxx@gmail.com to your email address where you can receive a notification when the computation is done.
Parallel computing with Python
Python is also a very popular programming language. In the example, I will use multi-processing on HPC clusters. On multi-core PCs, we can simply set cpus = 4 in the Python file.
First, I give an example of parallel computing with map function:
In this example, we implement 50 Monte Calo simulations with function simulation() in parallel.
On a HPC cluster, we can run Python file as follows