Doxygen 1.15.0
Toolkit for Adaptive Stochastic Modeling and Non-Intrusive ApproximatioN: Tasmanian v8.2
Loading...
Searching...
No Matches
tsgGpuWrappers.hpp
1/*
2 * Copyright (c) 2017, Miroslav Stoyanov
3 *
4 * This file is part of
5 * Toolkit for Adaptive Stochastic Modeling And Non-Intrusive ApproximatioN: TASMANIAN
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
12 * and the following disclaimer in the documentation and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
20 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * UT-BATTELLE, LLC AND THE UNITED STATES GOVERNMENT MAKE NO REPRESENTATIONS AND DISCLAIM ALL WARRANTIES, BOTH EXPRESSED AND IMPLIED.
25 * THERE ARE NO EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE ANY PATENT,
26 * COPYRIGHT, TRADEMARK, OR OTHER PROPRIETARY RIGHTS, OR THAT THE SOFTWARE WILL ACCOMPLISH THE INTENDED RESULTS OR THAT THE SOFTWARE OR ITS USE WILL NOT RESULT IN INJURY OR DAMAGE.
27 * THE USER ASSUMES RESPONSIBILITY FOR ALL LIABILITIES, PENALTIES, FINES, CLAIMS, CAUSES OF ACTION, AND COSTS AND EXPENSES, CAUSED BY, RESULTING FROM OR ARISING OUT OF,
28 * IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
29 */
30
31#ifndef __TASMANIAN_GPU_WRAPPERS_HPP
32#define __TASMANIAN_GPU_WRAPPERS_HPP
33
45
46#include "tsgAcceleratedDataStructures.hpp"
47
48namespace TasGrid{
49namespace TasGpu{
50
59template<typename scalar_type>
60void solveLSmultiGPU(AccelerationContext const *acceleration, int n, int m, scalar_type A[], int nrhs, scalar_type B[]);
61
65template<typename scalar_type>
66void solveLSmultiOOC(AccelerationContext const *acceleration, int n, int m, scalar_type A[], int nrhs, scalar_type B[]);
67
69template<typename scalar_type>
70void solveLSmulti(AccelerationContext const *acceleration, int n, int m, scalar_type A[], int nrhs, scalar_type B[]){
71 GpuVector<scalar_type> gpuA(acceleration, m, n, A);
72 GpuVector<scalar_type> gpuB(acceleration, nrhs, n, B);
73 solveLSmultiGPU(acceleration, n, m, gpuA.data(), nrhs, gpuB.data());
74 gpuB.unload(acceleration, B);
75}
76
78void factorizePLU(AccelerationContext const *acceleration, int n, double A[], int_gpu_lapack ipiv[]);
80void solvePLU(AccelerationContext const *acceleration, char trans, int n, double const A[], int_gpu_lapack const ipiv[], double b[]);
82void solvePLU(AccelerationContext const *acceleration, char trans, int n, double const A[], int_gpu_lapack const ipiv[], int nrhs, double B[]);
83
92template<typename scalar_type>
93void denseMultiply(AccelerationContext const *acceleration, int M, int N, int K,
94 typename GpuVector<scalar_type>::value_type alpha, GpuVector<scalar_type> const &A,
95 GpuVector<scalar_type> const &B, typename GpuVector<scalar_type>::value_type beta, scalar_type C[]);
96
98template<typename scalar_type>
99void denseMultiplyMixed(AccelerationContext const *acceleration, int M, int N, int K, typename GpuVector<scalar_type>::value_type alpha,
100 GpuVector<scalar_type> const &A, scalar_type const B[],
101 typename GpuVector<scalar_type>::value_type beta, scalar_type C[]){
102 GpuVector<scalar_type> gpuB(acceleration, K, N, B), gpuC(acceleration, M, N);
103 denseMultiply(acceleration, M, N, K, alpha, A, gpuB, beta, gpuC.data());
104 gpuC.unload(acceleration, C);
105}
106
113template<typename scalar_type>
114void sparseMultiply(AccelerationContext const *acceleration, int M, int N, int K, typename GpuVector<scalar_type>::value_type alpha,
115 const GpuVector<scalar_type> &A, const GpuVector<int> &pntr, const GpuVector<int> &indx,
116 const GpuVector<scalar_type> &vals, scalar_type C[]);
117
119template<typename T>
120void sparseMultiplyMixed(AccelerationContext const *acceleration, int M, int N, int K, typename GpuVector<T>::value_type alpha, const GpuVector<T> &A,
121 const std::vector<int> &pntr, const std::vector<int> &indx, const std::vector<T> &vals, T C[]){
122 GpuVector<int> gpu_pntr(acceleration, pntr), gpu_indx(acceleration, indx);
123 GpuVector<T> gpu_vals(acceleration, vals), gpu_c(acceleration, M, N);
124 sparseMultiply(acceleration, M, N, K, alpha, A, gpu_pntr, gpu_indx, gpu_vals, gpu_c.data());
125 gpu_c.unload(acceleration, C);
126}
127
128}
129}
130
131#endif
Encapsulates the Tasmanian Sparse Grid module.
Definition TasmanianSparseGrid.hpp:68