accessors.hh
Go to the documentation of this file.
1#pragma once
2
4
5#include <complex>
6
7namespace batchlas::sycl_gemm {
8
9template <typename T>
10inline T maybe_conj(const T& value, bool conjugate) {
11 static_cast<void>(conjugate);
12 return value;
13}
14
15template <typename T>
16inline std::complex<T> maybe_conj(const std::complex<T>& value, bool conjugate) {
17 return conjugate ? std::conj(value) : value;
18}
19
20template <typename T>
21inline T operand_value(const T* ptr,
22 int ld,
23 int batch_offset,
24 int row,
25 int col,
26 Transpose trans) {
27 const bool transpose = trans != Transpose::NoTrans;
28 const bool conjugate = trans == Transpose::ConjTrans;
29 const int source_row = transpose ? col : row;
30 const int source_col = transpose ? row : col;
31 return maybe_conj(ptr[batch_offset + source_col * ld + source_row], conjugate);
32}
33
34template <typename T, Transpose Op>
36 static T load(const T* ptr, int ld, int batch_offset, int row, int col) {
37 return operand_value(ptr, ld, batch_offset, row, col, Op);
38 }
39};
40
41} // namespace batchlas::sycl_gemm
Transpose
The operator op() applied to an operand: op(A) = A, A^T or A^H.
Definition enums.hh:171
@ NoTrans
op(A) = A.
Definition enums.hh:172
@ ConjTrans
op(A) = A^H (the same as Trans for real scalars).
Definition enums.hh:174
Event transpose(Queue &ctx, const MatrixView< T, MF > &A, const MatrixView< T, MF > &B)
Batched plain transpose (no conjugation).
T maybe_conj(const T &value, bool conjugate)
Definition accessors.hh:10
T operand_value(const T *ptr, int ld, int batch_offset, int row, int col, Transpose trans)
Definition accessors.hh:21
static T load(const T *ptr, int ld, int batch_offset, int row, int col)
Definition accessors.hh:36