Issue with acados solver fail on the QNX platform

Hello!
I constructed a MPC model using python and then utilized acados_template to generate theC-generation code. The model operateds flawlessly on linux platform. Subsequently i attempted to run the identical code on the QNX platform, here are modifications made to the Cmakelists in acados:

set(HPIPM_TARGET "GENERIC" CACHE STRING "HPIPM Target architecture")
set(BLASFEO_TARGET "GENERIC" CACHE STRING "Manually set BLASFEO target")

The cmake command executes successfully and generates libraries in ARM aarch64 format. Then i replace the previous x64 libraries with these newly generated ones and the cross-compiled runs successfully.

-- Target: BLASFEO is GENERIC, HPIPM is GENERIC
-- Linear algebra: HIGH_PERFORMANCE
-- Octave MEX (OFF)
-- System name:version QNX:
-- Build type is Debug
-- OpenMP parallelization is OFF

However, when i attempt to execute the identical code within the qnx system, output of the solver is exceptional:

  1. The value of nlp_dims->N turns out to be a large number such as 546296 or -3103240, seems like a potential memory leak issue. The code snippet involved is as follows:
ocp_nlp_dims* nlp_dims = lmop_mpc_model_acados_get_nlp_dims(lmop_ocp_capsule_);
std::cout << "nlp_dims->N " << nlp_dims->N << std::endl;
  1. The solver status returns 0, indicating a seemingly successful execution. But when i use the ocp_nlp_out_get function to read the solver output, the values obtained are not consistent with the results generated when running the same code on the Linux platform. The relevant code is shown below:
  double xtraj[NX * 1000];
  for (int ii = 0; ii < nlp_dims->N; ii++) {
    ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "x", &xtraj[ii * NX]);
  }

First I referred to the following resource and was able to obtain the correct value of nlp_dims->N:

However, after rectifying the nlp_dims->N, the solver gets stuck during the following process:

solver_info_.status = lmop_mpc_model_acados_solve(lmop_ocp_capsule_);

Within the acados library, the relevant function in ocp_nlp_interface.c is as follows:

int ocp_nlp_solve(ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out)
{
    return solver->config->evaluate(solver->config, solver->dims, nlp_in, nlp_out,
                                    solver->opts, solver->mem, solver->work);
}

My question is, did I miss some parameters or set them incorrectly when generating the aarch64 libraries? Or is there an issue with memory alignment in acados when it runs on different platforms?

Thanks for your advice.

Gavin

1 Like

Hi Gavin,

However, after rectifying the nlp_dims->N, the solver gets stuck during the following process:

what do you mean with rectifying here?
Do you just reset the value to whatever it should read?

If this value is indeed overwritten, it is very likely that also other parts of the memory get corrupted.
It is not surprising that resetting nlp_dims->N does not solve the issue.
Could you check with valgrind if there are any issues?

Are your QNX system using 32-bit system?
In this case you cannot use aarch64 libraries.

Also what do you mean by

and the cross-compiled runs successfully.

Best,
Jonathan

Hi FreyJo, much thanks for your reply.

  1. I didn’t just change the value of nlp_dims->N. I adopted the method mentioned in the following resource and after that i was able to obtain the correct value of nlp_dims->N.
    Vxworks 32bit system, PPC, Diab Compiler, Embedded application problems - #6 by Yutao
assign_and_advance_double(mem->hpipm_workspace->stat_m*(1+opts->hpipm_opts->stat_max), &mem->hpipm_workspace->stat, &c_ptr);
  1. The processor architecture of my QNX platform is ARMv8 and it uses aarch64 structure
  2. Cross-compiled means that I successfully compiled the program using the AArch64 libraries.
    Sorry for the unclear points in my description. I’d really appreciate it if you have any better solutions or advice. I’ll first try to use the Valgrind you mentioned to locate the issue.