<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>IMPLEMENTING THE GRAPH MODEL OF THE SPREAD OF A PANDEMIC ON GPUS</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Vladimir Sudakov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nikita Yashin</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Vladimir Sudakov</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nikita Yashin</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Keldysh Institute of Applied Mathematics, Russian Academy of Sciences</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Plekhanov Russian University of Economics</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <fpage>5</fpage>
      <lpage>9</lpage>
      <abstract>
        <p>Modeling the spread of viruses is an urgent task in modern conditions. In the created model, contacts between people are represented in the form of the Watz and Strogatz graph. We studied graphs with tens of thousands of vertices with a simulation period of six months. The paper proposes methods for accelerating computations on graph models using graphics processors. In the considered problem, there were two resource-intensive computational tasks: generating an adjacency matrix of a graph that simulates the presence of contacts between people and traversing this graph in order to simulate infection. The calculations were carried out in sequential mode and with acceleration on GPUs. The modeling system software is implemented using the Cuda, CuPy, PyTorch libraries. The calculations were carried out using the Tesla T4 graphics accelerator. Compared to computations without using graphics accelerators, their application gave a 7-fold increase in speed.</p>
      </abstract>
      <kwd-group>
        <kwd>graph</kwd>
        <kwd>pandemic</kwd>
        <kwd>graphics accelerator</kwd>
        <kwd>simulation</kwd>
        <kwd>small world</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Computing on graphs is a large cluster of problems with a wide range of applications.
Modeling interactions between objects in a group is one such challenge. However, this type of
problem is resource-intensive in the case of a graph with a huge number of vertices. For computations
on graphs, an adjacency matrix is used, which in full form takes O(n2) time to complete a round trip,
where n is the number of vertices. There are several ways to improve the execution speed of the
algorithm - using the multi-threading approach on the CPU or porting the calculations to CUDA. This
study explored the second approach. Behavioral comparison and speed of execution of the algorithm
at the CPU and the GPU. Effectiveness of the technology was demonstrated on model of the
interaction among people and the spread of the virus among them.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Literary review</title>
      <p>
        In 2016, the GraphOps library was written [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. This library performs its calculations on FPGA,
which made it possible to accelerate computations, but the basis of this work was the creation of a
library that accelerates work with graphs for the end user. There have also been several studies on
speeding up certain algorithms that run on graphs. Improvement of the GlimmerHHM algorithm [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
consisted in parallelization and transfer of computations to GPU and FPGA, which led to acceleration
up to 34 and 200 times, respectively. Semantic search [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] has been successfully accelerated on both
GPU and FPGA. It was study of the possible benefits FGPA front of CPU and GPU, but the results
show accelerating work on the GPU in 5.6 times in comparison with a CPU. Most of these papers
investigate the use of FGPA. However, the use of these devices requires a lot of labor costs for the
development and availability of computing equipment with FGPA, while graphics accelerators are
more common, it is easier to start working with them, and there are many different libraries in
different languages that support using of GPU. Regarding the issues of modeling pandemics using
graphic processors, it is worth highlighting the work [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. There are offered effective approaches to the
treatment of co-occurrence matrices for large graphs on the GPU, but there are no algorithms that are
designed to prepare these graphs. In the context of the threatening spread of COVID-19, approaches
based on SEIR models are actively developing [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Basically, such models presuppose a description of
pandemics through a system of differential equations that describe the situation well under typical
conditions, but do not allow assessing the consequences of certain decisions on isolating the
population at the micro level.
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. Method</title>
      <p>The constructed model of virus propagation works on graphs. The vertices of the graph
describe people, and the edges describe the presence of contacts between them through which the virus
can be transmitted. Simulation is carried out with a fixed time step. Every unit of time, all the vertices
of the graph are traversed and checked for a change in health status - whether the person has become
infected, if he was not infected earlier, or whether the disease has passed to a new stage if the person is
already infected.</p>
      <p>
        In total, a person can have four conditions, which are taken from the SEIR model [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The first
condition (Susceptible) - the person is healthy, he is not a distributor, but can be infected. Most people
have this condition initially. The second state (Exposed) - a person has become infected, and the
disease is in the incubation stage. Such a person cannot infect anyone yet and cannot be more infected.
This condition is obtained after a successful test for transmission of infection from carriers with whom
there were contacts. The third state (Infectious) - a person's disease has passed into the active stage.
Such a person can infect others and is the only way to directly transmit the infection, but he himself
cannot get the disease more. The state is obtained after a certain time has elapsed in the second state.
The fourth and final state of a person (Recovered) is recovered or passed away. A sick person is no
Proceedings of the 9th International Conference "Distributed Computing and Grid Technologies in Science and
      </p>
      <p>Education" (GRID'2021), Dubna, Russia, July 5-9, 2021
longer contagious and cannot transmit the infection, and it is also believed that he has immunity and
he himself can no longer become infected at a given simulation period. This state is obtained after a
certain time in the third state.</p>
      <p>In the proposed model, it is proposed to separate the types of contacts. A separate graph is
built for each type of contacts. Next, the union of the resulting graphs is constructed. Testing model
was carried out on two types of contacts. The first is constant contact that does not appear or disappear
over time, for example, communication with relatives. Such contacts are described in a permanent
graph that is created once before the state updates start. The second is an accidental contact, it can
appear and disappear absolutely by accident, for example, an occasional meeting in a transport. Such
contacts are described in a graph that is rebuilt every unit of time. Each time unit, these two graphs are
combined, and the spread of the virus is calculated from the resulting graph.</p>
      <p>
        For the software implementation of the model, the programming language Python3 was
chosen. This language is very easy to learn, and has a huge variety of libraries, which allows you to
write programs with a minimum of knowledge in the shortest possible time. Of the libraries used in the
work – CuPy [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and NetworkX [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], which were used to build graphs, and PyTorch [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], which can
traverse graphs using their adjacency matrices.
      </p>
      <p>
        First, you need to build a graph of the first type contacts. The so-called “small world” concept
proposed in work [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] is well suited for solving this problem. It is built using the Watts-Strogatz
algorithm, in two steps.
satisfy the condition:
      </p>
      <p>The first step is to build N vertices and build edges between each i-th and j-th vertices, if they
0 &lt; | −  | mod ( − 1 −

2
) ≤ ,

2
where K is the number of edges at each vertex.</p>
      <p>The second step - each edge (i, j) with a chance β changes to (i, k), where k ≠ j, edge (i, k) does
not exist yet, k is a random vertex.</p>
      <p>
        Thereafter must renew states. The first step in updating states is building a random graph. In
this graph, each vertex has the same degree. There are two ways to construct such a graph. The first,
using the CPU, is the fast_gnp_random_graph [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] function of the NetworkX library. The second,
using the GPU, is the sparse.rand [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] function of the CuPy library. NetworkX, unlike CuPy, does not
support using the power of graphics accelerators, so two different libraries are used. CuPy also creates
directly an adjacency matrix, not a graph.
      </p>
      <p>The second stage of updating states is directly traversing all vertices. It is done with the help
of library Pytorch, which can perform calculations as the CPU, as well as on the GPU. If a specific
person is not yet infected, the number N of his infectious contacts is considered and according to the
formula</p>
      <p>= 1 − (1 −  ) ,
where α is the probability of infection from one contact.</p>
      <p>
        If a person has just passed to the second or third stage of infection, then for him, using the
Monte Carlo method, the time spent in this state is modeled using the
Weibull distribution. The
applicability of the Weibull distribution to this problem was substantiated in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
    </sec>
    <sec id="sec-4">
      <title>4. Results</title>
      <p>To check the results of the program, four programs were written with different levels of use of
the graphics accelerator. Each of the programs was wrapped in a separate function, and the execution
time of each function was measured. For measurement accuracy, each function was run 50 times and
the average running time was taken. To compare the efficiency on different sizes of matrices, only one
variable changed in the functions - the number of people in the model. Efficiency was compared for
different population sizes, and, accordingly, for different graph sizes. This value was measured in the
range [1000, 17000] with a step of 1000.</p>
      <p>Первая функция, no_cuda, не использовала графического ускорителя, все вычисления
проводились исключительно на процессоре. Вторая функция, torch_cuda, использовала
графический ускоритель только для моделирования непосредственно распространения вируса.
Матрица смежности строилась на обычном процессоре. Третья функция, graph_cuda,
использовала графический ускоритель для построения матрицы смежности, а распространение
между людьми вычисляется на обычном процессоре. Четвертая функция, all_cuda,
использовала графический ускоритель для обоих задач – и для построения матрицы смежности,
и для расчетов распространения вируса.</p>
      <p>The first function, no_cuda, did not use a graphics accelerator, all calculations were performed
exclusively on the processor. The second function, torch_cuda, used a graphics accelerator only to
simulate the actual spread of the virus. The adjacency matrix was built on a conventional processor.
The third function, graph_cuda, used a graphics accelerator to build an adjacency matrix, and the
spread between people was computed on a regular processor. The fourth function, all_cuda, used a
graphics accelerator for both tasks - both for building an adjacency matrix and for calculating the
spread of the virus.</p>
      <p>Computing devices used: CPU: Intel Xeon CPU @ 2.00GHz; GPU: NVIDIA Tesla T4 16GB.
The calculation results are shown in Tab. 1. A comparative graph is also built based on these data
(Fig.1).</p>
      <p>As a result, it can be seen that the use of a graphics accelerator gives a significant gain in
computing speed. This gain becomes more significant as the graph size increases. How many times a
full cuda program is faster than a full CPU program is shown in Tab. 2.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusions</title>
      <p>The advantage of using graphics accelerators to increase the speed of computations on graphs
was investigated. A new approach to modeling contacts in pandemics based on combining graphs of
different types is proposed. The use of the “small world” graph for modeling permanent contacts is
investigated. The premium rate of different libraries of working on graphics processors for solving
problems of this type has been investigated. Result showed approbation evident an advantage of using
GPU, on graphs of high dimensionality. The proposed model of the spread of the virus makes it
possible to assess the consequences of decisions to limit the number of contacts of different types.</p>
    </sec>
    <sec id="sec-6">
      <title>6. Acknowledgement References</title>
      <p>The reported study was funded by RFBR and CNPq, FASIE, DBT, DST, MOST, NSFC,
SAMRC according to the research project No. 20-51-80002.
available</p>
      <p>at:
(accessed</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Tayo</given-names>
            <surname>Oguntebi</surname>
          </string-name>
          , Kunle Olukotun.
          <source>GraphOps: A Dataflow Library for Graph Analytics Acceleration // FPGA '16: Proceedings of the 2016 ACM/SIGDA International Symposium on FieldProgrammable Gate Arrays. Feb</source>
          <year>2016</year>
          . pp.
          <fpage>111</fpage>
          -
          <lpage>117</lpage>
          - DOI: 10.1145/2847263.2847337
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Nafsika</given-names>
            <surname>Chrysanthou</surname>
          </string-name>
          , Grigorios Chrysos, Euripides Sotiriades,
          <string-name>
            <given-names>Ioannis</given-names>
            <surname>Papaefstathiou</surname>
          </string-name>
          . Parallel accelerators for GlimmerHMM Bioinformatics Algorithm // Design, Automation and Test in Europe, Grenoble, France, March 14-18,
          <fpage>2011</fpage>
          - DOI: 10.1109/DATE.
          <year>2011</year>
          .5763024
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Abhinandan</given-names>
            <surname>Majumdar</surname>
          </string-name>
          , Hari Cadambi, Srimat T. Chakradhar,
          <string-name>
            <given-names>H.P.</given-names>
            <surname>Graf</surname>
          </string-name>
          .
          <article-title>A parallel accelerator for semantic search /</article-title>
          / SASP '11
          <source>: Proceedings of the 2011 IEEE 9th Symposium on Application Specific Processors</source>
          ,
          <year>June 2011</year>
          , pp.
          <fpage>122</fpage>
          -
          <lpage>128</lpage>
          - DOI: 10.1109/SASP.
          <year>2011</year>
          .5941090
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Peng</given-names>
            <surname>Zou</surname>
          </string-name>
          ,
          <article-title>Ya-shuai Lu, Ling-da Wu, Li-li Chen, Yi-ping Yao. Epidemic simulation of a largescale social contact network on GPU clusters /</article-title>
          / SIMULATION, vol.
          <volume>89</volume>
          , no.
          <issue>10</issue>
          ,
          <string-name>
            <surname>Oct</surname>
          </string-name>
          .
          <year>2013</year>
          , pp.
          <fpage>1154</fpage>
          -
          <lpage>1172</lpage>
          - DOI:10.1177/0037549713482026.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Wilfredo</given-names>
            <surname>Angulo</surname>
          </string-name>
          , José M. Ramírez, Dany De Cecchis, Juan Primera, Henry Pacheco , Eduardo
          <string-name>
            <surname>Rodríguez-Román</surname>
          </string-name>
          .
          <article-title>A modified SEIR model to predict the behavior of the early stage in coronavirus and coronavirus-like outbreaks</article-title>
          // Scientific reports vol.
          <volume>11</volume>
          ,1
          <volume>16331</volume>
          . 11 Aug.
          <year>2021</year>
          , - DOI:10.1038/s41598-021-95785-y
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6] CuPy software available at: https://cupy.dev/ (accessed 20.08.
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7] NetworkX software available at: https://networkx.org
          <source>/ (accessed 20.08</source>
          .
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8] PyTorch software available at: http://pytorch.org
          <source>/ (accessed 20.08</source>
          .
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Watts</surname>
            ,
            <given-names>D. J.</given-names>
          </string-name>
          ; Strogatz,
          <string-name>
            <surname>S. H</surname>
          </string-name>
          . Collective dynamics of 'small-world' networks // Nature 393.
          <year>1998</year>
          .
          <volume>440</volume>
          -
          <fpage>442</fpage>
          - DOI:10.1038/30918.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <article-title>Networkx function fast_gnp_random_graph</article-title>
          , documentation available at: https://networkx.org/documentation/stable/reference/generated/networkx.generators.
          <article-title>random_graphs.fa st_gnp_random_graph</article-title>
          .
          <source>html (accessed 20.08</source>
          .
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <article-title>Cupy function sparse</article-title>
          .rand, documentation https://docs.cupy.dev/en/stable/reference/generated/cupyx.scipy.
          <source>sparse.rand.html 20.08</source>
          .
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <surname>Jing</surname>
            <given-names>Qin</given-names>
          </string-name>
          , Chong You, Qiushi Lin, Taojun
          <string-name>
            <surname>Hu</surname>
          </string-name>
          , Shicheng Yu,
          <string-name>
            <surname>Xiao-Hua Zhou</surname>
          </string-name>
          .
          <article-title>Estimation of incubation period distribution of COVID-19 using disease onset forward time: a novel cross-sectional and forward follow-up study //</article-title>
          <source>SCIENCE ADVANCES, 14 Aug</source>
          <year>2020</year>
          , Vol
          <volume>6</volume>
          ,
          <string-name>
            <surname>Issue</surname>
          </string-name>
          33 - DOI: 10.1126/sciadv.abc1202
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>