15void runOnTilePool(
void* context, std::ptrdiff_t count,
16 void (*item)(
void*, std::ptrdiff_t),
void* item_context)
18 const int threads = *
static_cast<const int*
>(context);
20 item(item_context,
static_cast<std::ptrdiff_t
>(i));
28 return threads > 1 ? runOnTilePool :
nullptr;
30 [[nodiscard]]
void* context() noexcept
39constexpr int kAlgoBlock = 32;
45bool parallelPays(
double flops)
51double& solveWallSeconds()
53 static double seconds = 0.0;
56double& factorWallSeconds()
58 static double seconds = 0.0;
63void addWall(
double& total,
double seconds)
65 std::atomic_ref<double>(total).fetch_add(seconds,
66 std::memory_order_relaxed);
70 thread_local int depth = 0;
73std::int64_t nowNanoseconds()
75 return std::chrono::duration_cast<std::chrono::nanoseconds>(
76 std::chrono::steady_clock::now().time_since_epoch())
94 return solveWallSeconds();
99 solveWallSeconds() = 0.0;
104 if (seconds > 0.0) addWall(solveWallSeconds(), seconds);
109 return factorWallSeconds();
114 factorWallSeconds() = 0.0;
119 return parallelPays(flops);
123 : kind_(kind), outermost_(wallDepth()++ == 0), start_ns_(nowNanoseconds())
130 if (!outermost_)
return;
131 const double seconds =
132 1e-9 *
static_cast<double>(nowNanoseconds() - start_ns_);
133 addWall(kind_ ==
Kind::Factor ? factorWallSeconds() : solveWallSeconds(),
139 if (n < 0 || (n > 0 && (lower ==
nullptr || lda < n)))
return false;
147 double* rhs, std::int64_t ldb, std::int64_t n,
150 if (n <= 0 || cols <= 0 || lower ==
nullptr || rhs ==
nullptr)
return;
154 cols, team.run(), team.context());
158 bool lower_factor,
double* rhs, std::int64_t n)
160 if (n <= 0 || lower ==
nullptr || rhs ==
nullptr)
return;
166 std::int64_t ldc, std::int64_t n)
168 if (n <= 0 || b ==
nullptr || c ==
nullptr)
return;
KernelWall(Kind kind) noexcept
void runWith(int threads, long count, F &&fn)
run() with an explicit thread count in place of the configured one.
static TilePool & instance()
void(*)(void *context, std::ptrdiff_t count, void(*item)(void *, std::ptrdiff_t), void *item_context) ParallelItems
void solveLeftGeneral(const double *factor, std::ptrdiff_t factor_stride, bool lower_factor, double *rhs, std::ptrdiff_t rhs_stride, std::ptrdiff_t order, std::ptrdiff_t columns, ParallelItems run, void *run_context)
void solveVectorGeneral(const double *factor, std::ptrdiff_t factor_stride, bool lower_factor, double *rhs, std::ptrdiff_t order)
void assignTransposeGram(const double *b, std::ptrdiff_t b_stride, double *c, std::ptrdiff_t c_stride, std::ptrdiff_t order, ParallelItems run, void *run_context)
bool factorLowerGeneral(double *matrix, std::ptrdiff_t stride, std::ptrdiff_t order, ParallelItems run, void *run_context)
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
void teamFactorWallReset()
void teamSolveLowerVector(const double *lower, std::int64_t lda, bool lower_factor, double *rhs, std::int64_t n)
void teamSolveLower(const double *lower, std::int64_t lda, bool lower_factor, double *rhs, std::int64_t ldb, std::int64_t n, std::int64_t cols)
double teamFactorWallSeconds()
void teamSymmetricGram(const double *b, std::int64_t ldb, double *c, std::int64_t ldc, std::int64_t n)
double teamSolveWallSeconds()
bool teamParallelPays(double flops)
bool teamPanelBitsIndependent()
void teamSolveWallReset()
bool teamCholeskyLower(double *lower, std::int64_t lda, std::int64_t n)
int configuredLinalgThreads() noexcept
Requested dense numerical budget, independent of nested BLAS controls.
void teamAddSolveWall(double seconds)
std::int64_t teamPanelWidth()