mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-09-05 04:40:19 -05:00
Allow usage of non-gpu devices with OpenCL.
This is needed to use the CPU backend of PoCL http://portablecl.org/ which seems handy for debugging.
This commit is contained in:
@@ -89,10 +89,8 @@ openclSolverBackend<block_size>::openclSolverBackend(int verbosity_, int maxit_,
|
|||||||
out.clear();
|
out.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[platformID])(), 0};
|
platforms[platformID].getDevices(CL_DEVICE_TYPE_ALL, &devices);
|
||||||
context.reset(new cl::Context(CL_DEVICE_TYPE_GPU, properties));
|
|
||||||
|
|
||||||
devices = context->getInfo<CL_CONTEXT_DEVICES>();
|
|
||||||
if (devices.size() == 0){
|
if (devices.size() == 0){
|
||||||
OPM_THROW(std::logic_error, "Error openclSolver is selected but no OpenCL devices are found");
|
OPM_THROW(std::logic_error, "Error openclSolver is selected but no OpenCL devices are found");
|
||||||
}
|
}
|
||||||
@@ -168,8 +166,15 @@ openclSolverBackend<block_size>::openclSolverBackend(int verbosity_, int maxit_,
|
|||||||
out.clear();
|
out.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
cl::Event event;
|
// removed all unused devices
|
||||||
queue.reset(new cl::CommandQueue(*context, devices[deviceID], 0, &err));
|
if (deviceID != 0)
|
||||||
|
{
|
||||||
|
devices[0] = devices[deviceID];
|
||||||
|
}
|
||||||
|
devices.resize(1);
|
||||||
|
|
||||||
|
context = std::make_shared<cl::Context>(devices[0]);
|
||||||
|
queue.reset(new cl::CommandQueue(*context, devices[0], 0, &err));
|
||||||
|
|
||||||
} catch (const cl::Error& error) {
|
} catch (const cl::Error& error) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
|||||||
Reference in New Issue
Block a user