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

how to run a user-defined modifier in parallel

Hi, all,


I wrote a user-defined modifier. However, it run with only a CPU core. I wonder if it is possible to run with multi cores? if so, how to realize it with programming. Is there any tutorial?




As you may already know, parallelizing algorithms written in the Python language is inherently difficult. See for example this article. That is because the CPython interpreter, which serves also the basis for OVITO Pro's embedded Python interpreter, does not support true multi-core execution of code. And, as a word of caution: Because this general limitation of Python exists, the programming interface and the data structures exposed by OVITO to Python have not been made thread-safe so far. That means, if you intend to apply any of the existing concurrency techniques available in Python, you must properly isolate your parallel code and not call any OVITO API's from it.

OVITO's internal architecture allows parallelization for modifiers written in C++. Thus, if you really have a performance-critical algorithm, it would be best to port it from Python to C++. The source code of OVITO Basic is openly available, giving you the possibility to extend the code and add your own modifier.  And I could provide you some help with this. However, it is only worth the effort, I would say, if your algorithm is of broad enough interested, and if you would like to share it with the user community of OVITO Basic and OVITO Pro.

I am wondering what kind of algorithm is implemented in your user-defined modifier. Does it contain loops? Does it make heavy use of Numpy array computations? Depending on the nature of the algorithm, it may be more or less difficult to parallelize it in the first place.


Hi, Alex,


Thanks for your reply.

I'm implementing a algorithm which can identify the solid-liquid interface of metal with FCC structure, as presented in this paper [J. Chem. Phys. 116, 9352 (2002)].  To my knowledge, it is the best solid-liquid interface identification algorithm for FCC. I'm not sure if it works for other structure such as BCC. To implement it, loops over each atoms and their neighbour atoms have to be done, so the computation is high cost. I'm not sure does this algorithm has implemented in OVITO yet or similar modifier in OVITO can identify solid-liquid interface. If so, could you provide me some suggestion? If not, effort may be worth to implement it.