Only initialize VexCL once

This commit is contained in:
Tong Dong Qiu 2021-07-09 15:39:35 +02:00
parent b0749ce7d4
commit 0ee6b58fb0
2 changed files with 10 additions and 2 deletions

View File

@ -267,8 +267,12 @@ void amgclSolverBackend<block_size>::solve_system(double *b, BdaResult &res) {
std::tie(iters, error) = solve(B, X);
} else if (backend_type == Amgcl_backend_type::vexcl) {
#if HAVE_VEXCL
vex::Context ctx(vex::Filter::Env && vex::Filter::Count(1));
std::cout << ctx << std::endl;
static vex::Context ctx(vex::Filter::Env && vex::Filter::Count(1));
std::call_once(vexcl_initialize, [&](){
std::ostringstream out;
out << "Using VexCL on " << ctx << std::endl;
OpmLog::info(out.str());
});
if constexpr(block_size == 1){
auto A = std::tie(N, A_rows, A_cols, A_vals);

View File

@ -90,6 +90,10 @@ private:
void solve_cuda(double *b);
#endif
#if HAVE_VEXCL
std::once_flag vexcl_initialize;
#endif
/// Initialize GPU and allocate memory
/// \param[in] N number of nonzeroes, divide by dim*dim to get number of blocks
/// \param[in] nnz number of nonzeroes, divide by dim*dim to get number of blocks