8000 MATLAB/python: Default value for `ext_fun_compile_flag` from environment variable by sandmaennchen · Pull Request #1312 · acados/acados · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MATLAB/python: Default value for ext_fun_compile_flag from environment variable #1312

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

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion interfaces/acados_matlab_octave/AcadosOcpOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@
obj.store_iterates = false;
obj.eval_residual_at_max_iter = [];

obj.ext_fun_compile_flags = '-O2';
% check whether flags are provided by environment variable
env_var = getenv("ACADOS_EXT_FUN_COMPILE_FLAGS");
if isempty(env_var)
obj.ext_fun_compile_flags = '-O2';
else
obj.ext_fun_compile_flags = env_var;
end

obj.model_external_shared_lib_dir = [];
obj.model_external_shared_lib_name = [];
obj.custom_update_filename = '';
Expand Down
8 changes: 7 additions & 1 deletion interfaces/acados_matlab_octave/AcadosSimOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@
obj.sens_hess = false;
obj.output_z = true;
obj.jac_reuse = 0;
obj.ext_fun_compile_flags = '-O2';
% check whether flags are provided by environment variable
env_var = getenv("ACADOS_EXT_FUN_COMPILE_FLAGS");
if isempty(env_var)
obj.ext_fun_compile_flags = '-O2';
else
obj.ext_fun_compile_flags = env_var;
end
obj.num_threads_in_batch_solve = 1;
obj.compile_interface = []; % corresponds to automatic detection, possible values: true, false, []
end
Expand Down
9 changes: 8 additions & 1 deletion interfaces/acados_matlab_octave/acados_ocp_opts.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@
obj.opts_struct.exact_hess_cost = 1;
obj.opts_struct.exact_hess_constr = 1;
obj.opts_struct.fixed_hess = 0;
obj.opts_struct.ext_fun_compile_flags = '-O2';

% check whether flags are provided by environment variable
env_var = getenv("ACADOS_EXT_FUN_COMPILE_FLAGS");
if isempty(env_var)
obj.opts_struct.ext_fun_compile_flags = '-O2';
else
obj.opts_struct.ext_fun_compile_flags = env_var;
end

obj.opts_struct.output_dir = fullfile(pwd, 'build');
obj.opts_struct.json_file = 'acados_ocp_nlp.json';
Expand Down
8 changes: 7 additions & 1 deletion interfaces/acados_matlab_octave/acados_sim_opts.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@
obj.opts_struct.jac_reuse = 'false';
obj.opts_struct.gnsf_detect_struct = 'true';
obj.opts_struct.output_dir = fullfile(pwd, 'build');
obj.opts_struct.ext_fun_compile_flags = '-O2';
% check whether flags are provided by environment variable
env_var = getenv("ACADOS_EXT_FUN_COMPILE_FLAGS");
if isempty(env_var)
obj.opts_struct.ext_fun_compile_flags = '-O2';
else
obj.opts_struct.ext_fun_compile_flags = env_var;
end
obj.opts_struct.parameter_values = [];
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# POSSIBILITY OF SUCH DAMAGE.;
#

import numpy as np
import os
from .utils import check_if_nparray_and_flatten


Expand Down Expand Up @@ -115,7 +115,9 @@ def __init__(self):
self.__log_primal_step_norm: bool = False
self.__store_iterates: bool = False
# TODO: move those out? they are more about generation than about the acados OCP solver.
self.__ext_fun_compile_flags = '-O2'

env = os.environ
self.__ext_fun_compile_flags = '-O2' if 'ACADOS_EXT_FUN_COMPILE_FLAGS' not in env else env['ACADOS_EXT_FUN_COMPILE_FLAGS']
self.__model_external_shared_lib_dir = None
self.__model_external_shared_lib_name = None
self.__custom_update_filename = ''
Expand All @@ -136,7 +138,7 @@ def qp_solver(self):
def ext_fun_compile_flags(self):
"""
String with compiler flags for external function compilation.
Default: '-O2'.
Default: '-O2' if environment variable ACADOS_EXT_FUN_COMPILE_FLAGS is not set, else ACADOS_EXT_FUN_COMPILE_FLAGS is used as default.
"""
return self.__ext_fun_compile_flags

Expand Down
5 changes: 3 additions & 2 deletions interfaces/acados_template/acados_template/acados_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self):
self.__sens_hess = False
self.__output_z = True
self.__sim_method_jac_reuse = 0
self.__ext_fun_compile_flags = '-O2'
env = os.environ
self.__ext_fun_compile_flags = '-O2' if 'ACADOS_EXT_FUN_COMPILE_FLAGS' not in env else env['ACADOS_EXT_FUN_COMPILE_FLAGS']
self.__num_threads_in_batch_solve: int = 1

@property
Expand Down Expand Up @@ -136,7 +137,7 @@ def collocation_type(self):
def ext_fun_compile_flags(self):
"""
String with compiler flags for external function compilation.
Default: '-O2'.
Default: '-O2' if environment variable ACADOS_EXT_FUN_COMPILE_FLAGS is not set, else ACADOS_EXT_FUN_COMPILE_FLAGS is used as default.
"""
return self.__ext_fun_compile_flags

Expand Down
Loading
0