mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-09-05 04:40:19 -05:00
Added error checking and std::call_once
This commit is contained in:
@@ -487,9 +487,13 @@ void FGPILU::decomposition(
|
|||||||
const int block_size = 3;
|
const int block_size = 3;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (initialized == false) {
|
// just put everything in the capture list
|
||||||
|
std::call_once(initialize_flag, [&](){
|
||||||
cl::Program::Sources source(1, std::make_pair(fgpilu_sweep_s, strlen(fgpilu_sweep_s))); // what does this '1' mean? cl::Program::Sources is of type 'std::vector<std::pair<const char*, long unsigned int> >'
|
cl::Program::Sources source(1, std::make_pair(fgpilu_sweep_s, strlen(fgpilu_sweep_s))); // what does this '1' mean? cl::Program::Sources is of type 'std::vector<std::pair<const char*, long unsigned int> >'
|
||||||
cl::Program program = cl::Program(*context, source, &err);
|
cl::Program program = cl::Program(*context, source, &err);
|
||||||
|
if (err != CL_SUCCESS) {
|
||||||
|
OPM_THROW(std::logic_error, "FGPILU OpenCL could not create Program");
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<cl::Device> devices = context->getInfo<CL_CONTEXT_DEVICES>();
|
std::vector<cl::Device> devices = context->getInfo<CL_CONTEXT_DEVICES>();
|
||||||
program.build(devices);
|
program.build(devices);
|
||||||
@@ -499,6 +503,9 @@ void FGPILU::decomposition(
|
|||||||
cl::Buffer&, cl::Buffer&, cl::Buffer&,
|
cl::Buffer&, cl::Buffer&, cl::Buffer&,
|
||||||
cl::Buffer&, cl::Buffer&,
|
cl::Buffer&, cl::Buffer&,
|
||||||
const int, cl::LocalSpaceArg, cl::LocalSpaceArg>(cl::Kernel(program, "fgpilu_sweep", &err)));
|
const int, cl::LocalSpaceArg, cl::LocalSpaceArg>(cl::Kernel(program, "fgpilu_sweep", &err)));
|
||||||
|
if (err != CL_SUCCESS) {
|
||||||
|
OPM_THROW(std::logic_error, "FGPILU OpenCL could not create Kernel");
|
||||||
|
}
|
||||||
|
|
||||||
// allocate GPU memory
|
// allocate GPU memory
|
||||||
d_Ut_vals = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(double) * Ut_nnzbs * block_size * block_size);
|
d_Ut_vals = cl::Buffer(*context, CL_MEM_READ_WRITE, sizeof(double) * Ut_nnzbs * block_size * block_size);
|
||||||
@@ -530,9 +537,7 @@ void FGPILU::decomposition(
|
|||||||
out << "FGPILU PARALLEL: " << PARALLEL;
|
out << "FGPILU PARALLEL: " << PARALLEL;
|
||||||
OpmLog::info(out.str());
|
OpmLog::info(out.str());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// copy to GPU
|
// copy to GPU
|
||||||
|
|||||||
@@ -21,8 +21,9 @@
|
|||||||
#define FGPILU_HEADER_INCLUDED
|
#define FGPILU_HEADER_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <opm/simulators/linalg/bda/opencl.hpp>
|
#include <mutex>
|
||||||
|
|
||||||
|
#include <opm/simulators/linalg/bda/opencl.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace bda
|
namespace bda
|
||||||
@@ -43,6 +44,7 @@ namespace bda
|
|||||||
|
|
||||||
cl::Event event;
|
cl::Event event;
|
||||||
cl_int err;
|
cl_int err;
|
||||||
|
std::once_flag initialize_flag;
|
||||||
|
|
||||||
std::unique_ptr<cl::make_kernel<cl::Buffer&, cl::Buffer&, cl::Buffer&,
|
std::unique_ptr<cl::make_kernel<cl::Buffer&, cl::Buffer&, cl::Buffer&,
|
||||||
cl::Buffer&, cl::Buffer&, cl::Buffer&,
|
cl::Buffer&, cl::Buffer&, cl::Buffer&,
|
||||||
@@ -50,8 +52,6 @@ namespace bda
|
|||||||
cl::Buffer&, cl::Buffer&,
|
cl::Buffer&, cl::Buffer&,
|
||||||
const int, cl::LocalSpaceArg, cl::LocalSpaceArg> > fgpilu_sweep_k;
|
const int, cl::LocalSpaceArg, cl::LocalSpaceArg> > fgpilu_sweep_k;
|
||||||
|
|
||||||
bool initialized = false;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Executes the FGPILU sweeps
|
/// Executes the FGPILU sweeps
|
||||||
/// also copies data from CPU to GPU and GPU to CPU
|
/// also copies data from CPU to GPU and GPU to CPU
|
||||||
|
|||||||
Reference in New Issue
Block a user