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

Difference between work vector size in generated header and c files #3697

Open
andreasbell opened this issue May 16, 2024 · 1 comment
Open

Comments

@andreasbell
Copy link

For the generated code there is a discrepancy between the work vector size (sz_w) between the .h file and .c file.

Example:

a = ca.SX.sym("a", 1)
fun = ca.Function("fun", [a], [a*a])
fun.generate("fun.c", {"with_header":True})

For the generated .c file we get the correct work vector size

CASADI_SYMBOL_EXPORT int fun_work(casadi_int *sz_arg, casadi_int* sz_res, casadi_int *sz_iw, casadi_int *sz_w) {
  if (sz_arg) *sz_arg = 1;
  if (sz_res) *sz_res = 1;
  if (sz_iw) *sz_iw = 0;
  if (sz_w) *sz_w = 0;
  return 0;
}

However for the .h file we get

#define fun_SZ_W 1

NOTE: When using the code generation option {"avoid_stack": True} we get the same work vector size for both the .c and .h file.

@jaeandersson
Copy link
Member

Too be clear, the risk here is that you allocate slightly too much memory (work vector size 1 instead of 0 which is what is needed).

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

No branches or pull requests

2 participants