Clarified parameter help print and chosen OpenCL platform and device

This commit is contained in:
T.D. (Tongdong) Qiu
2020-07-07 14:26:02 +02:00
parent ab49f60eca
commit 0b20762e59
2 changed files with 34 additions and 14 deletions

View File

@@ -233,9 +233,9 @@ namespace Opm
EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse Amg Setup"); EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse Amg Setup");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfiguration, "Configuration of solver valid is: ilu0 (default), cpr_quasiimpes, cpr_trueimpes or file (specified in LinearSolverConfigurationJsonFile) "); EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfiguration, "Configuration of solver valid is: ilu0 (default), cpr_quasiimpes, cpr_trueimpes or file (specified in LinearSolverConfigurationJsonFile) ");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfigurationJsonFile, "Filename of JSON configuration for flexible linear solver system."); EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfigurationJsonFile, "Filename of JSON configuration for flexible linear solver system.");
EWOMS_REGISTER_PARAM(TypeTag, std::string, GpuMode, "Use GPU cusparseSolver or openclSolver as the linear solver"); EWOMS_REGISTER_PARAM(TypeTag, std::string, GpuMode, "Use GPU cusparseSolver or openclSolver as the linear solver, usage: '--gpu-mode=[none|cusparse|opencl]'");
EWOMS_REGISTER_PARAM(TypeTag, int, BdaDeviceId, "Choose device ID for cusparseSolver or openclSolver, too high value could lead to errors"); EWOMS_REGISTER_PARAM(TypeTag, int, BdaDeviceId, "Choose device ID for cusparseSolver or openclSolver, use 'nvidia-smi' or 'clinfo' to determine valid IDs");
EWOMS_REGISTER_PARAM(TypeTag, int, OpenclPlatformId, "Choose platform ID for openclSolver, too high value could lead to errors"); EWOMS_REGISTER_PARAM(TypeTag, int, OpenclPlatformId, "Choose platform ID for openclSolver, use 'clinfo' to determine valid platform IDs");
} }
FlowLinearSolverParameters() { reset(); } FlowLinearSolverParameters() { reset(); }

View File

@@ -275,9 +275,9 @@ void openclSolverBackend<block_size>::gpu_pbicgstab(WellContributions& wellContr
// apply wellContributions // apply wellContributions
if (wellContribs.getNumWells() > 0) { if (wellContribs.getNumWells() > 0) {
t_well.start(); t_well.start();
wellContribs.apply(d_s, d_t); wellContribs.apply(d_s, d_t);
t_well.stop(); t_well.stop();
} }
t_rest.start(); t_rest.start();
@@ -345,7 +345,7 @@ void openclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doub
if (platforms.size() == 0) { if (platforms.size() == 0) {
OPM_THROW(std::logic_error, "Error openclSolver is selected but no OpenCL platforms are found"); OPM_THROW(std::logic_error, "Error openclSolver is selected but no OpenCL platforms are found");
} }
out << "Found " << platforms.size() << " OpenCL platforms" << "\n\n"; out << "Found " << platforms.size() << " OpenCL platforms" << "\n";
if (verbosity >= 1) { if (verbosity >= 1) {
std::string platform_info; std::string platform_info;
@@ -368,6 +368,16 @@ void openclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doub
if (platforms.size() <= platformID) { if (platforms.size() <= platformID) {
OPM_THROW(std::logic_error, "Error chosen too high OpenCL platform ID"); OPM_THROW(std::logic_error, "Error chosen too high OpenCL platform ID");
} else {
std::string platform_info;
out << "Chosen:\n";
platforms[platformID].getInfo(CL_PLATFORM_NAME, &platform_info);
out << "Platform name : " << platform_info << "\n";
platforms[platformID].getInfo(CL_PLATFORM_VERSION, &platform_info);
out << "Platform version : " << platform_info << "\n";
OpmLog::info(out.str());
out.str("");
out.clear();
} }
cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[platformID])(), 0}; cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[platformID])(), 0};
@@ -377,7 +387,7 @@ void openclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doub
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");
} }
out << "Found " << devices.size() << " OpenCL devices" << "\n\n"; out << "Found " << devices.size() << " OpenCL devices" << "\n";
if (verbosity >= 1) { if (verbosity >= 1) {
for (unsigned int i = 0; i < devices.size(); ++i) { for (unsigned int i = 0; i < devices.size(); ++i) {
@@ -393,8 +403,6 @@ void openclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doub
out << "CL_DRIVER_VERSION : " << device_info << "\n"; out << "CL_DRIVER_VERSION : " << device_info << "\n";
devices[i].getInfo(CL_DEVICE_BUILT_IN_KERNELS, &device_info); devices[i].getInfo(CL_DEVICE_BUILT_IN_KERNELS, &device_info);
out << "CL_DEVICE_BUILT_IN_KERNELS: " << device_info << "\n"; out << "CL_DEVICE_BUILT_IN_KERNELS: " << device_info << "\n";
devices[i].getInfo(CL_DEVICE_VERSION, &device_info);
out << "CL_DEVICE_VERSION : " << device_info << "\n";
devices[i].getInfo(CL_DEVICE_PROFILE, &device_info); devices[i].getInfo(CL_DEVICE_PROFILE, &device_info);
out << "CL_DEVICE_PROFILE : " << device_info << "\n"; out << "CL_DEVICE_PROFILE : " << device_info << "\n";
devices[i].getInfo(CL_DEVICE_OPENCL_C_VERSION, &device_info); devices[i].getInfo(CL_DEVICE_OPENCL_C_VERSION, &device_info);
@@ -434,9 +442,21 @@ void openclSolverBackend<block_size>::initialize(int N_, int nnz_, int dim, doub
} }
} }
OpmLog::info(out.str()); OpmLog::info(out.str());
out.str("");
out.clear();
if (devices.size() <= deviceID){ if (devices.size() <= deviceID){
OPM_THROW(std::logic_error, "Error chosen too high OpenCL device ID"); OPM_THROW(std::logic_error, "Error chosen too high OpenCL device ID");
} else {
std::string device_info;
out << "Chosen:\n";
devices[deviceID].getInfo(CL_DEVICE_NAME, &device_info);
out << "CL_DEVICE_NAME : " << device_info << "\n";
devices[deviceID].getInfo(CL_DEVICE_VERSION, &device_info);
out << "CL_DEVICE_VERSION : " << device_info << "\n";
OpmLog::info(out.str());
out.str("");
out.clear();
} }
cl::Program::Sources source(1, std::make_pair(axpy_s, strlen(axpy_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(axpy_s, strlen(axpy_s))); // what does this '1' mean? cl::Program::Sources is of type 'std::vector<std::pair<const char*, long unsigned int> >'
@@ -522,7 +542,7 @@ void openclSolverBackend<block_size>::finalize() {
template <unsigned int block_size> template <unsigned int block_size>
void openclSolverBackend<block_size>::copy_system_to_gpu() { void openclSolverBackend<block_size>::copy_system_to_gpu() {
Timer t; Timer t;
cl::Event event; cl::Event event;
#if COPY_ROW_BY_ROW #if COPY_ROW_BY_ROW
@@ -554,7 +574,7 @@ void openclSolverBackend<block_size>::copy_system_to_gpu() {
// don't copy rowpointers and colindices, they stay the same // don't copy rowpointers and colindices, they stay the same
template <unsigned int block_size> template <unsigned int block_size>
void openclSolverBackend<block_size>::update_system_on_gpu() { void openclSolverBackend<block_size>::update_system_on_gpu() {
Timer t; Timer t;
cl::Event event; cl::Event event;
#if COPY_ROW_BY_ROW #if COPY_ROW_BY_ROW
@@ -583,7 +603,7 @@ void openclSolverBackend<block_size>::update_system_on_gpu() {
template <unsigned int block_size> template <unsigned int block_size>
bool openclSolverBackend<block_size>::analyse_matrix() { bool openclSolverBackend<block_size>::analyse_matrix() {
Timer t; Timer t;
bool success = prec->init(mat.get()); bool success = prec->init(mat.get());
int work_group_size = 32; int work_group_size = 32;
@@ -625,7 +645,7 @@ void openclSolverBackend<block_size>::update_system(double *vals, double *b) {
template <unsigned int block_size> template <unsigned int block_size>
bool openclSolverBackend<block_size>::create_preconditioner() { bool openclSolverBackend<block_size>::create_preconditioner() {
Timer t; Timer t;
bool result = prec->create_preconditioner(mat.get()); bool result = prec->create_preconditioner(mat.get());
@@ -658,7 +678,7 @@ void openclSolverBackend<block_size>::solve_system(WellContributions& wellContri
// caller must be sure that x is a valid array // caller must be sure that x is a valid array
template <unsigned int block_size> template <unsigned int block_size>
void openclSolverBackend<block_size>::get_result(double *x) { void openclSolverBackend<block_size>::get_result(double *x) {
Timer t; Timer t;
queue->enqueueReadBuffer(d_x, CL_TRUE, 0, sizeof(double) * N, rb); queue->enqueueReadBuffer(d_x, CL_TRUE, 0, sizeof(double) * N, rb);
reorderBlockedVectorByPattern<block_size>(mat->Nb, rb, toOrder, x); reorderBlockedVectorByPattern<block_size>(mat->Nb, rb, toOrder, x);