Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onemkl linear solver doesn't have a default difference quotient jacobian? #182

Open
ciropom opened this issue Jul 29, 2022 · 5 comments
Open

Comments

@ciropom
Copy link

ciropom commented Jul 29, 2022

Hello again,
I finally was able to compile link and execute my model with the onemkl dense linear solver.
The problem now is that at initialization time I get this error

[CVLS ERROR]  cvLsInitialize
  No Jacobian constructor available for SUNMatrix type


[CVODE ERROR]  cvInitialSetup
  The linear solver's init routine failed.

I'm using the following initialization code:

    /* Create dense SUNMatrix for use in linear solves */
    A = SUNMatrix_OneMklDense(y_len, y_len, SUNMEMTYPE_DEVICE, memhelper, &s->qspccQueue, s->sunctx);
	if (check_flag((void *)A, "SUNMatrix_OneMklDense", 0)) return s;
    s->matrix = A; /* save for deallocation */
	// Create the SUNLinearSolver object for use by CVode
    LS = SUNLinSol_OneMklDense(s->y, A, s->sunctx);
    if (check_flag((void *)LS, "SUNLinSol_OneMklDense", 0)) return s;
	s->flag = CVodeSetLinearSolver(s->cvode_mem, LS, A);
    if(check_flag(&s->flag, "CVodeSetLinearSolver", 1)) return s;    

It looks like onemkldense solver doesn't have a default difference-quotient jacobian, like the standard dense/band/lapack solvers.
Is this true? Users are forced to provide a Jacobian through CVodeSetJacFn to use this solver?

As always thank you very much for your help.

@gardner48
Copy link
Member

Yes, that's correct. A user-supplied Jacobian function is currently required when using the oneMKL interface. This function may compute the analytic Jacobian or an approximation to it e.g., using difference-quotients.

@ciropom
Copy link
Author

ciropom commented Jul 29, 2022

Why there is not any pre-packaged difference-quotient jacobian as it is for the standard dense solver?

@balos1
Copy link
Member

balos1 commented Jul 29, 2022

Why there is not any pre-packaged difference-quotient jacobian as it is for the standard dense solver?

The implementation of the difference-quotients routine in CVODE currently is specific to the standard dense and banded matrices. Generalizing it to support other matrices is something that I think would be nice, but we don't currently have any plans to do so.

@ciropom
Copy link
Author

ciropom commented Aug 1, 2022

Thank you for the explanation. This is blocking in my scenario, where I'm translating automatically from MATLAB to C and simulating with sundials by using QSPcc

Can you give me some hints on how to implement a difference-quotient jacobian for the MKL matrix?
Thanks

@drreynolds
Copy link
Collaborator

@ciropom: you will need to emulate the code from cvLsDenseDQJac (here), but ensuring that each of the operations use device-resident vector data, and that these operations fill device-resident data within the MKL matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants