there's something incorrect with the setup of the preconditioner and solver I think. I keep getting compile errors. I tried to follow this example (http://viennacl.sourceforge.net/viennacl-examples-iterative.html) but I can't get it right
Note: This is my base implementation to get the interface right, it's supposed to compute the case on the CPU using OpenMP. GPU computing will be the next step.
It's hard to tell without the error message. Can you please provide the first couple of compiler error lines? Did you include the relevant headers (cf. example)?
Also note that when using ublas, there is no benefit from OpenMP, as ublas doesn't use OpenMP for its operations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here are the relevant compiler error lines, others are warnings about old-style-type-cast:
...
vclPCG.C: In member function ‘virtual Foam::solverPerformance Foam::vclPCG::solve(Foam::scalarField&, const scalarField&, Foam::direction) const’:
vclPCG.C:167:31: error: invalid use of non-static member function
ldu2vcl(matrix, vcl_matrix); // load external matrix into vcl_matrix
^
vclPCG.C:177:64: error: no matching function for call to ‘viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >::ilut_precond()’
viennacl::compressed_matrix<ScalarType> > vcl_ilut_t;
^
In file included from vclPCG.C:32:0:
viennacl/linalg/detail/ilu/ilut.hpp:415:3: note: candidate: viennacl::linalg::ilut_precond<viennacl::compressed_matrix<T, AlignmentV=""> >::ilut_precond(const MatrixType&, const viennacl::linalg::ilut_tag&) [with NumericT = double; unsigned int AlignmentV = 1u; viennacl::linalg::ilut_precond<viennacl::compressed_matrix<T, AlignmentV=""> >::MatrixType = viennacl::compressed_matrix<double>]
ilut_precond(MatrixType const & mat, ilut_tag const & tag)
^
viennacl/linalg/detail/ilu/ilut.hpp:415:3: note: candidate expects 2 arguments, 0 provided
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate: viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >::ilut_precond(const viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >&)
class ilut_precond< viennacl::compressed_matrix<NumericT, AlignmentV=""> >
^
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate expects 1 argument, 0 provided
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate: viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >::ilut_precond(viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >&&)
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate expects 1 argument, 0 provided
vclPCG.C:179:16: error: expected ‘;’ before ‘vcl_ilut’
vcl_ilut_t vcl_ilut(vcl_matrix, ilut_conf);
^
vclPCG.C:179:47: warning: statement has no effect [-Wunused-value]
vcl_ilut_t vcl_ilut(vcl_matrix, ilut_conf);
^
vclPCG.C:185:23: error: ‘vcl_ilut’ was not declared in this scope
vcl_ilut);
^
vclPCG.C:187:55: warning: use of old-style cast [-Wold-style-cast]
solverPerf.finalResidual() = (ScalarType)cg.error();
^
vclPCG.C:188:53: warning: use of old-style cast [-Wold-style-cast]
solverPerf.nIterations() = (ScalarType)cg.iters();
^
/opt/openfoam5/wmake/rules/General/transform:25: die Regel für Ziel „Make/linux64GccDPInt32Opt/vclPCG.o“ scheiterte
make: *** [Make/linux64GccDPInt32Opt/vclPCG.o] Fehler 1
The main program code is:
#define VIENNACL_WITH_OPENMP // enables execution on multiple CPU cores via OpenMP backend#include"vclPCG.H"// ViennaCL#include"viennacl/vector.hpp"#include"viennacl/linalg/detail/ilu/ilut.hpp"#include"viennacl/linalg/cg.hpp"#include"viennacl/compressed_matrix.hpp"typedefdoubleScalarType;// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //namespaceFoam{defineTypeNameAndDebug(vclPCG,0);lduMatrix::solver::addsymMatrixConstructorToTable<vclPCG>addvclPCGSymMatrixConstructorToTable_;}// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //Foam::vclPCG::vclPCG(constword&fieldName,constlduMatrix&matrix,constFieldField<Field,scalar>&interfaceBouCoeffs,constFieldField<Field,scalar>&interfaceIntCoeffs,constlduInterfaceFieldPtrsList&interfaces,constdictionary&solverControls):lduMatrix::solver(fieldName,matrix,interfaceBouCoeffs,interfaceIntCoeffs,interfaces,solverControls){}// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * ////// Convert matrix from LDU format to original format, storing only nonzero values//voidldu2org(constFoam::lduMatrix&matrix,uint*rows,// row and column indexes must be unsigned int for OpenMP and CUDA and cl_uint for OpenCLuint*cols,// column ScalarType*vals// values ){intk=0;// Index to fill lower triagonal part, diagonal part and upper triagonal part successively into one array// // Fill original format matrix arrays with nonzero values//// Fill original format matrix with lower trianglefor(inti=0;i<matrix.lower().size();i++){rows[k]=matrix.lduAddr().upperAddr()[i];cols[k]=matrix.lduAddr().lowerAddr()[i];vals[k]=matrix.lower()[i];k++;}// Fill original format matrix with diagonalfor(inti=0;i<matrix.diag().size();i++){rows[k]=matrix.lduAddr().upperAddr()[i];cols[k]=matrix.lduAddr().lowerAddr()[i];vals[k]=matrix.diag()[i];k++;}// Fill original format matrix with upper trianglefor(inti=0;i<matrix.upper().size();i++){rows[k]=matrix.lduAddr().lowerAddr()[i];cols[k]=matrix.lduAddr().upperAddr()[i];vals[k]=matrix.upper()[i];k++;}}voidldu2vcl(constFoam::lduMatrix&matrix,viennacl::compressed_matrix<ScalarType>&vcl_matrix){uintnnz=matrix.lower().size()+matrix.upper().size()+matrix.diag().size();// number of nonzero values (nnz)// Allocate memory for original sparse matrix uint*rows=(uint*)calloc(nnz,sizeof(uint));// rowsuint*cols=(uint*)calloc(nnz,sizeof(uint));// columnsScalarType*vals=(ScalarType*)calloc(nnz,sizeof(ScalarType));// valuesldu2org(matrix,rows,cols,vals);// row, column, value is the default order when adding values to an vcl_matrix// Fill the compressed vcl_matrixfor(uinti=0;i<nnz;i++){vcl_matrix(rows[i],cols[i])=vals[i];}// Free and release memory of for original sparse matrixfree(rows);free(cols);free(vals);//colloc() }Foam::solverPerformanceFoam::vclPCG::solve(scalarField&psi,constscalarField&source,constdirectioncmpt)const{// --- Setup class containing solver performance datasolverPerformancesolverPerf(lduMatrix::preconditioner::getName(controlDict_)+typeName,fieldName_);//// Solve case using ViennaCL //uintn=psi.size();viennacl::compressed_matrix<ScalarType>vcl_matrix;// create matrixldu2vcl(matrix,vcl_matrix);// load external matrix into vcl_matrixviennacl::vector<ScalarType>vcl_psi(n);// xviennacl::vector<ScalarType>vcl_source(n);// rhs// Set solver tolerance and maximum iterationsviennacl::linalg::cg_tagcg(tolerance_,maxIter_);// Set preconditionerviennacl::linalg::ilut_precond<viennacl::compressed_matrix<ScalarType>>vcl_ilut_t;vcl_ilut_tvcl_ilut(vcl_matrix,ilut_conf);// Solve the linear systemvcl_psi=solve(vcl_matrix,//using viennacl objects on GPUvcl_source,viennacl::linalg::cg_tag(),vcl_ilut);solverPerf.finalResidual()=(ScalarType)cg.error();solverPerf.nIterations()=(ScalarType)cg.iters();returnsolverPerf;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you, that helped and at the moment there's one error left:
clPCG_solve.C:47:37: error: ‘ilut_conf’ was not declared in this scope
vcl_ilut_t vcl_ilut(vcl_matrix, ilut_conf);
What's the correct syntax for that?.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
there's something incorrect with the setup of the preconditioner and solver I think. I keep getting compile errors. I tried to follow this example (http://viennacl.sourceforge.net/viennacl-examples-iterative.html) but I can't get it right
Note: This is my base implementation to get the interface right, it's supposed to compute the case on the CPU using OpenMP. GPU computing will be the next step.
What's wrong here?
T.
It's hard to tell without the error message. Can you please provide the first couple of compiler error lines? Did you include the relevant headers (cf. example)?
Also note that when using ublas, there is no benefit from OpenMP, as ublas doesn't use OpenMP for its operations.
Then I'm mislead.
Which configuration offers OpenMP support on the CPU? Is there an example?
Here are the relevant compiler error lines, others are warnings about old-style-type-cast:
...
vclPCG.C: In member function ‘virtual Foam::solverPerformance Foam::vclPCG::solve(Foam::scalarField&, const scalarField&, Foam::direction) const’:
vclPCG.C:167:31: error: invalid use of non-static member function
ldu2vcl(matrix, vcl_matrix); // load external matrix into vcl_matrix
^
vclPCG.C:177:64: error: no matching function for call to ‘viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >::ilut_precond()’
viennacl::compressed_matrix<ScalarType> > vcl_ilut_t;
^
In file included from vclPCG.C:32:0:
viennacl/linalg/detail/ilu/ilut.hpp:415:3: note: candidate: viennacl::linalg::ilut_precond<viennacl::compressed_matrix<T, AlignmentV=""> >::ilut_precond(const MatrixType&, const viennacl::linalg::ilut_tag&) [with NumericT = double; unsigned int AlignmentV = 1u; viennacl::linalg::ilut_precond<viennacl::compressed_matrix<T, AlignmentV=""> >::MatrixType = viennacl::compressed_matrix<double>]
ilut_precond(MatrixType const & mat, ilut_tag const & tag)
^
viennacl/linalg/detail/ilu/ilut.hpp:415:3: note: candidate expects 2 arguments, 0 provided
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate: viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >::ilut_precond(const viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >&)
class ilut_precond< viennacl::compressed_matrix<NumericT, AlignmentV=""> >
^
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate expects 1 argument, 0 provided
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate: viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >::ilut_precond(viennacl::linalg::ilut_precond<viennacl::compressed_matrix<double> >&&)
viennacl/linalg/detail/ilu/ilut.hpp:410:7: note: candidate expects 1 argument, 0 provided
vclPCG.C:179:16: error: expected ‘;’ before ‘vcl_ilut’
vcl_ilut_t vcl_ilut(vcl_matrix, ilut_conf);
^
vclPCG.C:179:47: warning: statement has no effect [-Wunused-value]
vcl_ilut_t vcl_ilut(vcl_matrix, ilut_conf);
^
vclPCG.C:185:23: error: ‘vcl_ilut’ was not declared in this scope
vcl_ilut);
^
vclPCG.C:187:55: warning: use of old-style cast [-Wold-style-cast]
solverPerf.finalResidual() = (ScalarType)cg.error();
^
vclPCG.C:188:53: warning: use of old-style cast [-Wold-style-cast]
solverPerf.nIterations() = (ScalarType)cg.iters();
^
/opt/openfoam5/wmake/rules/General/transform:25: die Regel für Ziel „Make/linux64GccDPInt32Opt/vclPCG.o“ scheiterte
make: *** [Make/linux64GccDPInt32Opt/vclPCG.o] Fehler 1
The main program code is:
Thanks! So in line 177 you are missing a typedef:
The first error in line 167 might be a problem with function visibility, but I'm not entirely sure.
You need to declare the configuration tag. That is, either replace
ilut_conf
withviennacl::linalg::ilut_tag()
or declarebefore line 47.