22#ifndef MADNESS_TENSOR_MTXMQ_H__INCLUDED
23#define MADNESS_TENSOR_MTXMQ_H__INCLUDED
33#if !defined(MADNESS_RESTRICT)
34# if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
35# define MADNESS_RESTRICT __restrict__
37# define MADNESS_RESTRICT
43namespace mTxmq_detail {
57 template <
typename T>
struct Scratch { std::vector<T>
buf; };
61 static ::madness::detail::thread_specific<Scratch<T>>
pool;
68 if (s.buf.size() <
need) s.buf.resize(
need);
82template <
typename aT,
typename bT,
typename cT>
92 if (
dimi <= 0 || dimj <= 0)
return;
94 for (
long i = 0; i <
dimi * dimj; ++i)
c[i] =
cT(0);
97 for (
long i = 0; i <
dimi; ++i,
c += dimj, ++
a) {
98 for (
long j = 0; j < dimj; ++j)
c[j] =
cT(0);
102 for (
long j = 0; j < dimj; ++j) {
139 const std::complex<double>*
a,
140 const std::complex<double>*
b,
146 const std::complex<float>*
a,
147 const std::complex<float>*
b,
156 const std::complex<T>*
a,
159 if (
ldb == -1)
ldb = dimj;
161 if (
dimi <= 0 || dimj <= 0)
return;
170 T*
Ra = mTxmq_detail::scratch<T>(
static_cast<std::size_t
>(2 *
a_sz + 2 *
c_sz));
175 const T*
a_raw =
reinterpret_cast<const T*
>(
a);
176 for (
long i = 0; i <
a_sz; ++i) {
184 T*
c_raw =
reinterpret_cast<T*
>(
c);
185 for (
long i = 0; i <
c_sz; ++i) {
201template <
typename aT,
typename bT,
typename cT>
Definition thread_specific.h:82
#define MADNESS_RESTRICT
Definition mTxmq.h:37
Macros and tools pertaining to the configuration of MADNESS.
Defines madness::MadnessException for exception handling.
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
constexpr long MAX_DIMI
Definition mTxmq.h:44
::madness::detail::thread_specific< Scratch< T > > & scratch_pool()
Definition mTxmq.h:60
T * scratch(std::size_t need)
Definition mTxmq.h:66
constexpr long MAX_DIMJ
Definition mTxmq.h:45
constexpr long MAX_DIMK
Definition mTxmq.h:46
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
void print_mtxmq_profile()
Print call profile and shape statistics for mTxmq (automatically called at exit)
Definition mTxmq.cc:546
void mTxmq_init()
Definition mTxmq.cc:548
void mTxmq_scratch_clear()
Free every thread's mTxmq scratch buffers. Call only at a quiescent point.
Definition mTxmq.h:75
void mTxmq_reference(long dimi, long dimj, long dimk, cT *MADNESS_RESTRICT c, const aT *a, const bT *b, long ldb=-1)
Reference implementation for verification / fallback.
Definition mTxmq.h:83
void reset_mtxmq_profile()
Reset profiling statistics counters.
Definition mTxmq.cc:547
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
void mTxmq(long dimi, long dimj, long dimk, double *MADNESS_RESTRICT c, const double *a, const double *b, long ldb)
Explicit template specializations for homogeneous types (implemented in mTxmq.cc)
Definition mTxmq.cc:551
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
static const long k
Definition rk.cc:44
std::vector< T > buf
Definition mTxmq.h:57
Reclaimable thread-specific storage (a thread_local you can free).