-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbatch_trsm.cc
161 lines (148 loc) · 6.05 KB
/
batch_trsm.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Copyright (c) 2017-2023, University of Tennessee. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
// This program is free software: you can redistribute it and/or modify it under
// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
#include "blas/batch_common.hh"
#include "blas.hh"
#include <limits>
namespace blas {
//==============================================================================
namespace impl {
//------------------------------------------------------------------------------
/// CPU, variable-size batched version.
/// Mid-level templated wrapper checks and converts arguments,
/// then makes individual routine calls in parallel.
/// @ingroup trsm_internal
///
template <typename scalar_t>
void trsm(
blas::Layout layout,
std::vector<blas::Side> const& side,
std::vector<blas::Uplo> const& uplo,
std::vector<blas::Op> const& trans,
std::vector<blas::Diag> const& diag,
std::vector<int64_t> const& m,
std::vector<int64_t> const& n,
std::vector<scalar_t > const& alpha,
std::vector<scalar_t*> const& Aarray, std::vector<int64_t> const& lda,
std::vector<scalar_t*> const& Barray, std::vector<int64_t> const& ldb,
size_t batch_size,
std::vector<int64_t>& info )
{
blas_error_if( batch_size < 0 );
blas_error_if( info.size() != 0
&& info.size() != 1
&& info.size() != batch_size );
if (info.size() > 0) {
// perform error checking
blas::batch::trsm_check(
layout, side, uplo, trans, diag, m, n,
alpha, Aarray, lda, Barray, ldb, batch_size, info );
}
#pragma omp parallel for schedule( dynamic )
for (size_t i = 0; i < batch_size; ++i) {
blas::Side side_ = blas::batch::extract( side, i );
blas::Uplo uplo_ = blas::batch::extract( uplo, i );
blas::Op trans_ = blas::batch::extract( trans, i );
blas::Diag diag_ = blas::batch::extract( diag, i );
int64_t m_ = blas::batch::extract( m, i );
int64_t n_ = blas::batch::extract( n, i );
int64_t lda_ = blas::batch::extract( lda, i );
int64_t ldb_ = blas::batch::extract( ldb, i );
scalar_t alpha_ = blas::batch::extract( alpha, i );
scalar_t* A_ = blas::batch::extract( Aarray, i );
scalar_t* B_ = blas::batch::extract( Barray, i );
blas::trsm( layout, side_, uplo_, trans_, diag_, m_, n_,
alpha_, A_, lda_, B_, ldb_ );
}
}
} // namespace impl
//==============================================================================
// High-level overloaded wrappers call mid-level templated wrapper.
namespace batch {
//------------------------------------------------------------------------------
/// CPU, variable-size batched, float version.
/// @ingroup trsm
void trsm(
blas::Layout layout,
std::vector<blas::Side> const& side,
std::vector<blas::Uplo> const& uplo,
std::vector<blas::Op> const& trans,
std::vector<blas::Diag> const& diag,
std::vector<int64_t> const& m,
std::vector<int64_t> const& n,
std::vector<float > const& alpha,
std::vector<float*> const& Aarray, std::vector<int64_t> const& lda,
std::vector<float*> const& Barray, std::vector<int64_t> const& ldb,
size_t batch_size,
std::vector<int64_t>& info )
{
impl::trsm( layout, side, uplo, trans, diag, m, n,
alpha, Aarray, lda, Barray, ldb,
batch_size, info );
}
//------------------------------------------------------------------------------
/// CPU, variable-size batched, double version.
/// @ingroup trsm
void trsm(
blas::Layout layout,
std::vector<blas::Side> const& side,
std::vector<blas::Uplo> const& uplo,
std::vector<blas::Op> const& trans,
std::vector<blas::Diag> const& diag,
std::vector<int64_t> const& m,
std::vector<int64_t> const& n,
std::vector<double > const& alpha,
std::vector<double*> const& Aarray, std::vector<int64_t> const& lda,
std::vector<double*> const& Barray, std::vector<int64_t> const& ldb,
size_t batch_size,
std::vector<int64_t>& info )
{
impl::trsm( layout, side, uplo, trans, diag, m, n,
alpha, Aarray, lda, Barray, ldb,
batch_size, info );
}
//------------------------------------------------------------------------------
/// CPU, variable-size batched, complex<float> version.
/// @ingroup trsm
void trsm(
blas::Layout layout,
std::vector<blas::Side> const& side,
std::vector<blas::Uplo> const& uplo,
std::vector<blas::Op> const& trans,
std::vector<blas::Diag> const& diag,
std::vector<int64_t> const& m,
std::vector<int64_t> const& n,
std::vector< std::complex<float> > const& alpha,
std::vector< std::complex<float>* > const& Aarray, std::vector<int64_t> const& lda,
std::vector< std::complex<float>* > const& Barray, std::vector<int64_t> const& ldb,
size_t batch_size,
std::vector<int64_t>& info )
{
impl::trsm( layout, side, uplo, trans, diag, m, n,
alpha, Aarray, lda, Barray, ldb,
batch_size, info );
}
//------------------------------------------------------------------------------
/// CPU, variable-size batched, complex<double> version.
/// @ingroup trsm
void trsm(
blas::Layout layout,
std::vector<blas::Side> const& side,
std::vector<blas::Uplo> const& uplo,
std::vector<blas::Op> const& trans,
std::vector<blas::Diag> const& diag,
std::vector<int64_t> const& m,
std::vector<int64_t> const& n,
std::vector< std::complex<double> > const& alpha,
std::vector< std::complex<double>* > const& Aarray, std::vector<int64_t> const& lda,
std::vector< std::complex<double>* > const& Barray, std::vector<int64_t> const& ldb,
size_t batch_size,
std::vector<int64_t>& info )
{
impl::trsm( layout, side, uplo, trans, diag, m, n,
alpha, Aarray, lda, Barray, ldb,
batch_size, info );
}
} // namespace batch
} // namespace blas