KADATH
magma_interface.cpp
1 /*
2  Copyright 2020 sauliac
3 
4  This file is part of Kadath.
5 
6  Kadath is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Kadath is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Kadath. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "magma_interface.hpp"
21 
22 namespace Kadath{
23 
24 #ifdef ENABLE_GPU_USE
25 
26  Magma_array::Magma_array(const Array<double> &source) : Base(source.get_nbr()),dim{static_cast<magma_int_t>(source.get_nbr())}
27  {
28  for(std::size_t i{0};i<this->size();i++)
29  {
30  std::size_t const k{i};
31  (*this)[k] = source.get_data()[k];
32  }
33  }
34 
35  Magma_array & Magma_array::operator=(const Array<double> &source)
36  {
37  assert(this->size()==source.get_nbr());
38  for(std::size_t i{0};i<this->size();i++)
39  {
40  std::size_t const k{i};
41  (*this)[k] = source.get_data()[k];
42  }
43  return *this;
44  }
45 
46  Magma_array & Magma_matrix::solve(Kadath::Magma_array &second_member)
47  {
48  pivot.reset(new std::vector<magma_int_t,Magma_allocator<magma_int_t>>(order));
49  magma_int_t info;
50  //std::cout << "callgin magma : magma_dgesv(order=" << order << ",nrhs=1,data=" << this->data() << ",lda=" << lda << ",pivot=" << pivot->data() << ",b=" << second_member.data() << "ldb=" << second_member.get_dim() << ",info)" << std::endl;
51  TESTING_CHECK(magma_dgesv( order, 1, this->data(), lda, pivot->data(), second_member.data(), second_member.get_dim(), &info ));
52  return second_member;
53  }
54 
55 
56 #endif
57 }