Application of the tensor approach to the software implementation of the cellular automaton flow model

Бесплатный доступ

Cellular-automaton models are actively used to model physical processes. The cellular automata in these models are large and require a large number of iterations to observe effects of interest. Researchers use parallel technologies to organize calculations in order to get the result quickly. The choice of technology usually depends on the level of the researcher’s skills in the field of parallel programming. Parallel programming is a complex skill, and to get it you need to learn a lot of theory and even more practice. We have proposed a special tensor approach to the software implementation of cellular automata to free the researcher from these difficulties and help to create a parallel software product. A special framework that automatically parallelizes computations at NVIDIA GPU cores is central to the approach. The chosen framework is TensorFlow. The main data structure of TensorFlow is a tensor (multidimensional matrix). Thus, in order to implement a cellular automaton using the tensor approach, it is necessary to represent the cellular automaton as a tensor, and the logic of the automaton transition from one state to another as operations on tensors. There are two options for applying tensor operations. The first option is to use ready-made operations. The framework implements simple operations that work with ordinary matrices, and more complex operations, such as convolution. In this case, the researcher needs to analyze how the cellular automaton works and select the necessary tensor operations that implement the automaton. The second option is to create your own tensor operation. A custom operation is created using CUDA technology. In this case, the structural elements are ordinary two-dimensional arrays that represent tensors. The user needs to independently allocate the number of threads and blocks required for calculations. The TensorFlow developer libraries allow you to implement operations on data both as programs for the central processor and as programs for graphics adapters in the CUDA C programming language. In this paper, to demonstrate the performance and capabilities of the tensor approach, the well- known cellular automaton FHP flow model is implemented. There are two phases in this model: collision and propagation. It was decided to implement our own operation, which describes the logic of the automaton, after analyzing the existing TensorFlow operations. Both phases of the FHP model are implemented by us with one custom operation, which is implemented in TensorFlow. The operation takes as input a tensor corresponding to a cellular automaton and a tensor of random numbers to determine the propagation direction. At the output, the operation generates a tensor, to the elements of which the propagation phase and the collision phase are applied. Experiments with the model implemented using the tensor approach were carried out. The gas flow in an open longitudinal pipe is simulated. The particle source is located on one side of the pipe. In the first part of the experiment, an obstacle in the form of a small oblong object is located in the pipe, in the second part - a small round object. The experimental results are visualized and the picture of the process agrees with the results obtained in other literature sources. Additionally, a comparative experiment was carried out to evaluate the effectiveness of the tensor approach. In this case, we compared the number of automaton cells processed per second in our implementation on TensorFlow and in an implementation written using only CUDA technology. The results of the comparison showed that when implementing the FHP flow model using the tensor approach, fewer (by 10 or 100 times, depending on the size of the cellular automaton) cells are processed in the same time than in an implementation built on only one CUDA technology. Despite the fact that the implementation of the flow model in TensorFlow is inferior to the implementation written in CUDA in terms of time, the process of building a parallel software implementation is simpler and does not require the researcher to have a deep understanding of the features of parallel programming.

Еще

Cellular automaton, tensor approach, gas flow

Короткий адрес: https://sciup.org/143181002

IDR: 143181002   |   DOI: 10.24412/2073-0667-2023-2-74-85

Статья научная