<!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>Dimensionality Reduction using GPU-accelerated Gradient Descent</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Evgeny Myasnikov</string-name>
          <email>mevg@geosamara.ru</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Alexey Borisov</string-name>
          <email>borisovalexey1996@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Geoinformatics and Information Security, Samara National Research University</institution>
          ,
          <addr-line>Samara</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2020</year>
      </pub-date>
      <fpage>248</fpage>
      <lpage>250</lpage>
      <abstract>
        <p>-In this paper, we discuss several possible implementations of GPU-targeted gradient descent algorithm for dimensionality reduction. Four realizations of the gradient descent algorithm are created using HIP, a new framework for GPGPU programming. We get six times performance improvement over a multithreaded CPU version using AMD Radeon RX Vega 56.</p>
      </abstract>
      <kwd-group>
        <kwd>dimensionality reduction</kwd>
        <kwd>gradient descent</kwd>
        <kwd>GPU</kwd>
        <kwd>GPGPU</kwd>
        <kwd>HIP</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>At first, we should define a cost function. In the case of
Sammon’s mapping the cast function is as follows:</p>
    </sec>
    <sec id="sec-2">
      <title>I. INTRODUCTION</title>
      <p>In the present days, data mining becomes more and more
popular research area. Data mining techniques process
enormous amounts of data in order to detect significant
dependencies in data. In many cases, such data can be
interpreted as points in some multidimensional space.</p>
      <p>Processing multidimensional data causes problems. The
first problem is that multidimensional data requires more
storage capacity. The second problem is that the time needed
to process these data grows fast with the number of
dimensions. But in many cases, multidimensional data
contains substantial redundancy in terms of information.
Therefore, one can map the data into the space of lower
dimensionality without a major information loss. This
process can be referred to as dimensionality reduction.</p>
      <p>
        Dimensionality reduction techniques are often used in
different problems of image analysis (see [
        <xref ref-type="bibr" rid="ref1 ref3 ref4">1-4</xref>
        ], for
example).
      </p>
      <p>
        There is a variety of dimensionality reduction methods.
The most famous methods are Principal component analysis
(PCA) and Independent Component Analysis (ICA), which
are linear methods. The major disadvantage of linear
methods is that they can find only linear dependencies within
data. The nonlinear dimensionality reduction methods are
Curvilinear Component Analysis (CCA) [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], Curvilinear
Distance Analysis (CDA) [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], nonlinear mapping (Sammon’s
mapping [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]), etc. It was shown [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] that the latter technique
can deliver better results compared to some other
dimensionality reduction methods, for example, in
hyperspectral image analysis.
      </p>
      <p>
        While there are GPU implementations for linear
dimensionality reduction techniques [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ], the problem of
the long running time is more related to nonlinear
techniques. In this paper, we study the performance of the
Sammon’s mapping dimensionality reduction method based
on the gradient descent implemented for GPUs.
      </p>
      <p>II. DIMENSIONALITY REDUCTION USING GRADIENT DESCENT</p>
      <p>Let N denote the number of points, n denote the
dimensionality of a high-dimensional base space and m
denote the dimensionality of a low-dimensional target space.
Our goal is to map points from the n-dimensional space into
where dnij is the distance between points i and j in the base
space, dmij is the distance between points i and j in the target
space. In this case, the Euclidean distance was used.
Gradient descent is a common iterative optimization
algorithm. Its common definition is:</p>
      <p>x(t+1) = x(t) - f,
where the x = {x0, …, xk} denotes the parameters vector, t
denotes the iteration number, denotes the speed constant
and f denotes the gradient of the cost function f(x) in the
current point.</p>
      <p>If we take the gradient of the Sammon’s error with the
coordinates of all the points in the lower-dimensional space
as a vector of parameters, we will get the following equation,
describing the Sammon’s mapping procedure:
(1)
(2)
(3)
(4)
where yi = {y0i, …, ymi-1} denotes the coordinates vector of
the i-th point , t denotes the iteration number, dnij denotes the
distance between points i and j in the base space, dmij denotes
the distance between points i and j in the target space, and
denotes the descent speed constant.</p>
      <p>The computational complexity of this algorithm is
O(N2(n+m)). But it is worth noting that all points are updated
independently during an iteration and therefore can be
processed in parallel. This idea opens the possibility to use
the graphics processing units (GPU).</p>
      <p>III. HIP</p>
      <p>
        HIP is a new framework for GPU programming. It is
developed by the GPUOpen initiative [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. The HIP is
actually an abstraction layer based on C++ macros, which
exposes a programming interface and programming language
similar to NVIDIA CUDA. Programs written in CUDA can
be converted to HIP using a special tool. Depending on a
platform used, the HIP code can be compiled using HCC for
AMD devices or NVCC for NVIDIA devices.
      </p>
      <p>The terminology and programming model of HIP are
inherited from CUDA. The interaction with a GPU is
performed using API calls that perform data copy,
synchronization, and execution launching. Each command is
issued to some command stream. Commands in different
command streams are executed in parallel if possible.</p>
      <p>A function that was dedicated to perform on a GPU is
called a kernel. Each kernel is executed using many GPU
threads. GPU threads are grouped into thread blocks, whose
size and count are specified on a kernel call. Available
memory regions are global memory and shared memory. The
global memory is an equivalent of the RAM. The shared
memory has very high throughput but also a very small
volume, so it was not used in the current work.</p>
    </sec>
    <sec id="sec-3">
      <title>IV. IMPLEMENTATION OF GRADIENT DESCENT</title>
      <p>Equation 3 shows that points are updated independently
from each other at one iteration. Therefore, several threads
can be used to process points in parallel. The more threads
used, the better performance may be obtained in theory.
Since GPUs can process thousands of threads
simultaneously, they may be used to accelerate the
processing.</p>
      <p>To implement the iterative gradient descent, 3 buffers
were used:</p>
      <p>1. the buffer to store the coordinates of points in the
original space;</p>
      <p>2. the buffer to store the coordinates of points in the
target space obtained at the previous iteration;</p>
      <p>3. the buffer to store the coordinates of points in the
target space calculated at the current iteration.</p>
      <p>We discuss two approaches for the gradient descent
implementation. The first approach (denoted below as a
standard approach) is to process data according to (3), i.e.
for each point all distances to other point was computed, and
then the point was updated. The second approach (denoted
below as a modified approach) uses a fact that dnij= dnji.
Therefore we may compute each distance only once and then
perform an atomic update of points i and j. This approach
reduces the number of inner cycle iterations from N(N-1) to
N(N-1)/2, but also adds an overhead caused by the atomic
operations. In this case, the linear indexing of the virtual
distances matrix was used to exclude the conditional
operators in the program code, which should be avoided in
GPU programs.</p>
      <p>We also discuss two possible memory layouts of data
points. The points set can be stored as a 2D data matrix. The
question is how to place the coordinates of one point. The
first layout (denoted below as a flat layout) places the point
coordinates in rows. This layout allows us to compute the
distances between points faster since in this case we are able
to use the vector load and store instructions. The second
layout (denoted below as a transposed layout) places the
coordinates of points in columns of the data matrix. This
allows the neighboring threads to read the neighboring
memory cells when accessing the data. This facilitates
memory caching and allows the memory controller to merge
many small memory access requests to one (memory
coalescing).</p>
    </sec>
    <sec id="sec-4">
      <title>V. EXPERIMENTAL RESULTS</title>
      <p>Two implementation approaches and two memory
layouts give 4 implementations:
1.
2.
3.
4.</p>
      <p>a standard approach with a flat layout;
a modified approach with a flat layout;
a standard approach with a transposed layout;
a modified approach with a transposed layout;</p>
      <p>Proposed implementations were tested using a dataset
with random points with coordinates from the range [0, 255].
We measured the average execution time for various thread
block sizes and datasets sizes. The time of the data transfer
from RAM to GPU was not accounted, only the kernel time
was measured.</p>
      <p>We compared the experimental results with the results of
CPU implementation. This implementation was created
using an OpenMP as a parallel framework and was compiled
with the AVX cycle vectorization allowed. We measured
execution time for both single-threaded and 16-threaded
versions of this realization.</p>
      <p>The experiments
configuration:
were
run
on
the
following



</p>
    </sec>
    <sec id="sec-5">
      <title>CPU: AMD Ryzen 7 3700X;</title>
    </sec>
    <sec id="sec-6">
      <title>GPU: AMD Radeon RX Vega 56;</title>
      <p>RAM: 8 GB DDR4-3200;</p>
    </sec>
    <sec id="sec-7">
      <title>OS: Ubuntu 18.04 LTS. The experimental results are shown in Fig. 1 and Fig.2. The best results along with used parameters are shown in Table I. The comparison of CPU and GPU results can be</title>
      <p>Number
of Points
found in Table II. The comparison of CPU and GPU final
error values is shown in Table III.</p>
      <p>Let us analyze the results. It is clear that performance
improvement grows along with the task size. The most
effective implementation is implementation 2 (a modified
approach with a flat memory layout). In our case, the ability
to compute distances faster was more important than
advanced caching and memory coalescing. The data given by
the profiler shows that the main performance limiting factor
is the HBM memory performance.
operations adds an additional load to the memory system.
This partially explains why the thread block size of 16
threads was the best. Since threads of one thread block are
executed in groups of 64 threads on the AMD GPU, the
thread block of only 16 threads causes only 25% occupancy
but also reduces the number of simultaneous memory
requests. The results from GPUs with different memory
types, such as GDDR5/6, probably will be different.</p>
    </sec>
    <sec id="sec-8">
      <title>VI. CONCLUSION</title>
      <p>In this paper, we have discussed different approaches to
implement the dimensionality reduction method based on
gradient descent for GPUs. Several experiments were taken
using an AMD Radeon Vega 56 GPU. The experimental
results show approximately 6 times performance
improvement in comparison to the multithreaded version
executed on the 8-core CPU, and almost 60 times
improvement over single-threaded implementation.</p>
      <p>Future work will be devoted to the comparison of the
proposed implementations using NVIDIA and AMD GPUs.</p>
    </sec>
    <sec id="sec-9">
      <title>ACKNOWLEDGMENT</title>
      <p>The work was partly funded by RFBR according to the
research project 18-07-01312-a in parts of «2. Method» - «3.
Experiments» and by the Russian Federation Ministry of
Science and Higher Education within a state contract with
the «Crystallography and Photonics» Research Center of the
RAS in parts «1. Introduction» and «4. Conclusion».</p>
      <p>The HBM (High Bandwidth Memory) features the very
wide data bus along with relatively low clocks. Since in our
case threads access memory cells located relatively far from
each other, the caching is ineffective, and the memory
requests often cause delays in execution. The use of atomic</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>E.A.</given-names>
            <surname>Dmitriev</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.V.</given-names>
            <surname>Myasnikov</surname>
          </string-name>
          , “
          <article-title>Comparative study of description algorithms for complex-valued gradient fields of digital images using linear dimensionality reduction methods</article-title>
          ,” Computer Optics, vol.
          <volume>42</volume>
          , no.
          <issue>5</issue>
          , pp.
          <fpage>822</fpage>
          -
          <lpage>828</lpage>
          ,
          <year>2018</year>
          . DOI:
          <volume>10</volume>
          .18287/
          <fpage>2412</fpage>
          -6179- 2018-42-5-
          <fpage>822</fpage>
          -828.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>M.V.</given-names>
            <surname>Gashnikov</surname>
          </string-name>
          , “
          <article-title>Optimization of the multidimensional signal interpolator in a lower dimensional space</article-title>
          ,”
          <source>Computer Optics</source>
          , vol.
          <volume>43</volume>
          , no.
          <issue>4</issue>
          , pp.
          <fpage>653</fpage>
          -
          <lpage>660</lpage>
          ,
          <year>2019</year>
          . DOI:
          <volume>10</volume>
          .18287/
          <fpage>2412</fpage>
          -6179-2019-43-4-
          <fpage>653</fpage>
          - 660.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>E.V.</given-names>
            <surname>Myasnikov</surname>
          </string-name>
          , “
          <article-title>The study of dimensionality reduction methods in the task of browsing of digital image collections,” Computer Optics</article-title>
          , vol.
          <volume>32</volume>
          , no.
          <issue>3</issue>
          , pp.
          <fpage>296</fpage>
          -
          <lpage>301</lpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>E.</given-names>
            <surname>Myasnikov</surname>
          </string-name>
          , “
          <article-title>Evaluation of nonlinear dimensionality reduction techniques for classification of hyperspectral images</article-title>
          ,
          <source>” CEUR Workshop Proceedings</source>
          , vol.
          <volume>2268</volume>
          , pp.
          <fpage>147</fpage>
          -
          <lpage>154</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>P.</given-names>
            <surname>Demartines</surname>
          </string-name>
          and
          <string-name>
            <given-names>J.</given-names>
            <surname>Herault</surname>
          </string-name>
          , “
          <article-title>Curvilinear Component Analysis: a SelfOrganizing Neural Network for Nonlinear Mapping of Data Sets,”</article-title>
          <source>IEEE Trans. Neural Networks</source>
          , vol.
          <volume>7</volume>
          , pp.
          <fpage>148</fpage>
          -
          <lpage>154</lpage>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>A.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Lendasse</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Donckers</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Verleysen</surname>
          </string-name>
          . “Robust Nonlinear Projection Method,
          <source>” Proc. ESANN</source>
          , Bruges: DFactopublic, pp.
          <fpage>13</fpage>
          -
          <lpage>20</lpage>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>J.W.</given-names>
            <surname>Sammon</surname>
          </string-name>
          Jr,
          <article-title>“A Nonlinear Mapping for Data Structure Analysis,”</article-title>
          <source>IEEE Trans. on Computers</source>
          , vol. C-
          <volume>18</volume>
          , no.
          <issue>5</issue>
          , pp.
          <fpage>401</fpage>
          -
          <lpage>409</lpage>
          ,
          <year>1969</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>M.</given-names>
            <surname>Andrecut</surname>
          </string-name>
          , “
          <article-title>Parallel GPU Implementation of Iterative PCA Algorithms,”</article-title>
          <string-name>
            <given-names>J.</given-names>
            <surname>Comp</surname>
          </string-name>
          . Biol., vol.
          <volume>16</volume>
          , pp.
          <fpage>1593</fpage>
          -
          <lpage>1599</lpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Yanshan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Zeng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Ren</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Shi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Yin</surname>
          </string-name>
          and
          <string-name>
            <given-names>Q.</given-names>
            <surname>Xu</surname>
          </string-name>
          , “
          <article-title>GPU-based Parallel Group ICA for functional magnetic resonance data,” Computer methods and programs in biomedicine</article-title>
          , vol.
          <volume>119</volume>
          , no.
          <issue>1</issue>
          , pp
          <fpage>9</fpage>
          -
          <lpage>16</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Sun</surname>
          </string-name>
          , “
          <article-title>Evaluating Performance Tradeoffs on the Radeon Open Compute Platform</article-title>
          ,” ISPASS, pp.
          <fpage>209</fpage>
          -
          <lpage>2018</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>