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

Toggle Float/Long flags in OSQPgen #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/osqp/codegen/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def codegen(work, target_dir, python_ext_name, project_type, compile_python_ext,
'linsys_solver': work['linsys_solver'],
'scaling': work['scaling'],
'embedded_flag': embedded,
'float_flag': float_flag,
'long_flag': long_flag,
'python_ext_name': python_ext_name}

# Add cmake args
Expand Down
4 changes: 2 additions & 2 deletions src/osqp/codegen/files_to_generate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ endif()
message(STATUS "Profiling is ${PROFILING}")

# Use floats instead of integers
option (DFLOAT "Use float numbers instead of doubles" OFF)
option (DFLOAT "Use float numbers instead of doubles" FLOAT_FLAG)
message(STATUS "Floats are ${DFLOAT}")

# Use long integers for indexing
option (DLONG "Use long integers (64bit) for indexing" ON)
option (DLONG "Use long integers (64bit) for indexing" LONG_FLAG)
if (NOT (CMAKE_SIZEOF_VOID_P EQUAL 8))
message(STATUS "Disabling long integers (64bit) on 32bit machine")
set(DLONG OFF)
Expand Down
8 changes: 8 additions & 0 deletions src/osqp/codegen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,17 @@ def render_setuppy(variables, output):
"""

embedded_flag = variables['embedded_flag']
float_flag = variables['float_flag']
long_flag = variables['long_flag']
python_ext_name = variables['python_ext_name']

f = open(os.path.join(files_to_generate_path, 'setup.py'))
filedata = f.read()
f.close()

filedata = filedata.replace("EMBEDDED_FLAG", str(embedded_flag))
filedata = filedata.replace("FLOAT_FLAG", str(float_flag))
filedata = filedata.replace("LONG_FLAG", str(long_flag))
filedata = filedata.replace("PYTHON_EXT_NAME", str(python_ext_name))

f = open(output, 'w')
Expand All @@ -495,12 +499,16 @@ def render_cmakelists(variables, output):
"""

embedded_flag = variables['embedded_flag']
float_flag = variables['float_flag']
long_flag = variables['long_flag']

f = open(os.path.join(files_to_generate_path, 'CMakeLists.txt'))
filedata = f.read()
f.close()

filedata = filedata.replace("EMBEDDED_FLAG", str(embedded_flag))
filedata = filedata.replace("FLOAT_FLAG", str(float_flag))
filedata = filedata.replace("LONG_FLAG", str(long_flag))

f = open(output, 'w')
f.write(filedata)
Expand Down