Forum Navigation
You need to log in to create posts and topics.

How do ovito computations RUN in PARALLEL on a LINUX system ?

12
Dear professor Stukowski :

I am a graduate student in Hunan university, Changsha, China.
Thank you very much for your ovito software !
It really is my favorite, the most excellent molecular dynamics simulation post-processing software !
I have a question and a suggestion.
1.  My question
The purpose of using ovito is to apply ovito's algorithm for dynamic post-processing in the lammps script. The specific idea is to write a python program, import ovito's modules, and then launch the python program through the "shell" command of the lammps script to conduct post-processing of dump files. After testing, I found that under Linux system (Ubuntu 18.04 LTS server), python program (which has imported the ovito 's modules) cannot be calculated in parallel, nor can it be calculated in parallel in the way of "ovitos". However, the same program, under windows7 will automatically parallel computing. I have been confirmed by the test time and see the "task manager".
2.  My suggestion
I just want to connect the excellent algorithms in ovito to lammps' computation under Linux. In the post-processing process, the ovito computation part is expected to be parallel computation, and no graphical function is required.So, can you make a Linux tar package, has nothing to do with the graphics function, that is, does not need to install the graphics card.
Thank you very much for your software ! 
Wish you all the best !
Yours Sincerely,
Rui Zhao
May 10, 2020

Dear Rui Zhao,

In response to your question I added a new section to the Python scripting documentation of OVITO. Hopefully you can now find an answer to your question here:

http://www.ovito.org/docs/current/python/introduction/advanced_topics.php#multithreading-settings

Note that the OVITO_THREAD_COUNT environment variable described in the documentation was newly added in OVITO build 3.0.0-dev974 (released today). Please upgrade your installation of OVITO and the ovito Python module to the latest version if you want to make use of this option. Let me know if you have any further questions.

Hi Alexander:

Thank you very much for your positive update and reply !

I used the same python code to test the average speed of processing a single dump file in different cases .  In the code, "CNA indices" and "rdf" and numpy array are mainly used for calculation.

1.    1CPU4Core, windows7 + anaconda (python3.7, already imported ovito794 modules)

anaconda powershell :  python CNABI.py

time=1.38 s (The "task manager" shows that all 4 cores are at 100%CPU utilization)

2.    2CPU24Core, windows7 + anaconda (python3.7, already imported ovito785 modules)

anaconda powershell :  python CNABI.py

time=1.18 s (The "task manager" shows that about only 3~8 cores are at 10~80%CPU utilization)

3.    2CPU24Core, ubuntu18.04 server + python3.8 (already imported ovito794 modules)

command line : python  CNABI.py

time=4.16 s (print(QThread.idealThreadCount())  show 48)

4.    2CPU24Core, ubuntu18.04 server + ovitos794

command line : ovitos  CNABI.py

time=4.06 s (print(QThread.idealThreadCount())  show 48)

5.    2CPU24Core, ubuntu18.04 server + ovitos794

command line : ovitos --nthreads 4 CNABI.py

time=3.73 s (print(QThread.idealThreadCount())  show 48)

6.    2CPU24Core, ubuntu18.04 server + ovitos794

command line : ovitos --nthreads 8 CNABI.py

time=3.64 s (print(QThread.idealThreadCount())  show 48)

Does that mean ovito doesn't run in parallel on Linux ?
Or, what did I do wrong ?
Request your guidance, thank you !

 

- Rui Zhao

 

Uploaded files:
  • You need to login to have access to uploads.

In terms of parallelisation, OVITO should behave the same on all operating systems. There is no restriction on Linux.

What kind of computation do you perform in your Python script? Perhaps you want to attach the script code.

Note that not all algorithms of OVITO are parallelized and will make use of multiple cores. I am asking to make sure that OVITO is really using all cores on Windows for a computation, and that the fully utilised cores shown by the task manager are not just an artefact.

Now assuming you are actually performing a computation in OVITO that is parallelised, I am not sure why it doesn't run any faster on Linux. There are various possible explanations. Theoretically, there could be adverse circumstances leading to a negative parallel scaling. Or the operating system may force all threads of the process to be executed by a single core due to some server configuration. We can try to find out more.

Hi Alexander :

I have uploaded the code, please check it, sorry to bother you, thank you very much !

- Rui Zhao

In your script, the CoordinationAnalysisModifier and the CommonNeighborAnalysisModifier are parallelized and should utilise all cores. Anything else runs serially and will not benefit from several CPU cores.

It's difficult to tell, just by looking at the source code, how much time the program is going to spend in the different steps. You can use the ovito.enable_logging() function to get an idea of the relative run times of the different algorithm steps. The fact that CoordinationAnalysisModifier and the CommonNeighborAnalysisModifier are parallelized may or may not have a significant effect on the overall running time of the script. File I/O or other tasks may sometimes dominate the execution time when reading the data from a slow filesystem, and the speed up from parallelisation will barely be noticeable.

I have written a small test script for you, which is attached to this post, running the CoordinationAnalysisModifier on a synthetic 20,000 particle system created in memory without any file I/O. So this benchmark measures just the parallel scaling behaviour of OVITO.

On my MacBook Pro, the benchmark reports an execution time of ~4.7 secs when running on all 4 CPU cores, and 14.8 secs if I restrict ovitos to a single core using the --nthreads command line option. Please check the behaviour on your Linux box.

Uploaded files:
  • You need to login to have access to uploads.

Hi Alexander :

 

I used your file to test:

1.    1CPU4Core, windows7+anaconda (python3.7 has imported ovito794)

IdealThreadCount: 4

Time: 4.91 s

2.    2CPU24Core, Ubuntu18.04Server+python3.8 (imported ovito794) (or "ovitos")

Please look at picture

Maybe it's my fault. I'll think it over.

Thank you very much !

Uploaded files:
  • You need to login to have access to uploads.

Your Linux timings are somewhat surprising indeed. It seems that ovitos --nthreads behaves as expected. However, without the --nthreads option, the timing is as if ovitos uses just 4 cores. Perhaps because you have set the OVITO_THREAD_COUNT environment variable to a value of 4? Furthermore, when running in the external Python interpreter, the benchmark seems to use all processor cores and finishes after ~2 secs. I would expect, however, ovitos and python to produce exactly the same timings. Maybe you are not running dev794 in the external interpreter? Please check the value of ovito.version_string.

On the Windows machine the timings may be completely different, of course, if CPU/memory hardware is different. Windows and Linux versions of OVITO were also built with different compilers.

Explain :
1.     "python alex.py"
I installed python3.8 and then I installed the ovito791 module ( NOT 794,sorry ! I am currently using the "pypi" domestic mirror source, so it cannot be updated to 794 for the time being) with "python -m pip install -U ovito".
(I did use "export OVITO_THREAD_COUNT=4" before, but I changed it to "export OVITO_THREAD_COUNT=48" now, which requires setting "export..." every time before running "python alex.py" ?)
(what's the difference between "export OVITO_THREAD_COUNT=48" and "export OVITO_THREAD_COUNT=24" ?)
2.     "ovitos alex.py"
I downloaded ovito-pro-3.0.0-dev794-x86_64.tar.xz and then "tar -xvf ...", and set "~/bin/" (the path of "ovitos") as the environment variable.

Thank you very much !

Uploaded files:
  • You need to login to have access to uploads.

Right, the fact that you were using version dev791 of the Python modules explains why it did not obey the current value of the OVITO_THREAD_COUNT variable. Only the newer version of ovitos did.

If you run the command export OVITO_THREAD_COUNT=4 in the terminal, the variable will keep its value until the terminal session ends or until you assign a new value. You can also delete the variable by assigning no value: export OVITO_THREAD_COUNT=

Most Linux shells also allow setting the value of the variable temporarily just for one process invocation. This is done by prepending the assignment to the command line as follows:

 OVITO_THREAD_COUNT=4 ovitos script.py
OVITO_THREAD_COUNT=1 ovitos script.py

12