Permalink
Browse files

working on parallelize multiple shooting with openmp

  • Loading branch information...
giaf committed Jul 19, 2018
1 parent 26b2bbd commit 106ad5c7e1c2c991f03b897d1239148145edc2e8
View
@@ -57,6 +57,9 @@ QORE_PATH = $(EXT_PATH)/qore
# QPDUNES path
QPDUNES_PATH = $(EXT_PATH)/qpdunes
# parallelize using openmp
ACADOS_WITH_OPENMP = 0
# include QPOASES
ACADOS_WITH_QPOASES = 1
@@ -88,6 +91,9 @@ CFLAGS += -O2 -fPIC
# debugging flags
CFLAGS += #-g -Wall -pedantic -Wfloat-equal #-pg
ifeq ($(ACADOS_WITH_OPENMP), 1)
CFLAGS += -DACADOS_WITH_OPENMP -fopenmp
endif
ifeq ($(ACADOS_WITH_QPOASES), 1)
CFLAGS += -DACADOS_WITH_QPOASES
endif
@@ -24,6 +24,9 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(ACADOS_WITH_OPENMP)
#include <omp.h>
#endif
// blasfeo
#include "blasfeo/include/blasfeo_d_aux.h"
@@ -166,7 +169,8 @@ void ocp_nlp_sqp_opts_initialize_default(void *config_, void *dims_, void *opts_
opts->min_res_d = 1e-8;
opts->min_res_m = 1e-8;
opts->reuse_workspace = 1;
opts->reuse_workspace = 0;
opts->num_threads = 2;
// submodules opts
@@ -402,6 +406,10 @@ int ocp_nlp_sqp_workspace_calculate_size(void *config_, void *dims_, void *opts_
size += sizeof(ocp_nlp_sqp_work);
#if defined(ACADOS_WITH_OPENMP)
assert(opts->reuse_workspace==0 && ACADOS_WITH_OPENMP);
#endif
if (opts->reuse_workspace)
{
@@ -653,6 +661,11 @@ static void linearize_update_qp_matrices(void *config_, ocp_nlp_dims *dims, ocp_
/* stage-wise multiple shooting lagrangian evaluation */
#if defined(ACADOS_WITH_OPENMP)
// set number of threads
omp_set_num_threads(opts->num_threads);
#pragma omp parallel for
#endif
for (i = 0; i < N; i++)
{
// cost
@@ -47,6 +47,7 @@ typedef struct
double min_res_m;
int maxIter;
int reuse_workspace;
int num_threads;
} ocp_nlp_sqp_opts;
//
@@ -24,6 +24,9 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(ACADOS_WITH_OPENMP)
#include <omp.h>
#endif
// blasfeo
#include "blasfeo/include/blasfeo_d_aux.h"
@@ -162,7 +165,8 @@ void ocp_nlp_sqp_rti_opts_initialize_default(void *config_, void *dims_, void *o
// opts->compute_dual_sol = 1;
opts->reuse_workspace = 1;
opts->reuse_workspace = 0;
opts->num_threads = 2;
// submodules opts
@@ -398,6 +402,10 @@ int ocp_nlp_sqp_rti_workspace_calculate_size(void *config_, void *dims_, void *o
size += sizeof(ocp_nlp_sqp_rti_work);
#if defined(ACADOS_WITH_OPENMP)
assert(opts->reuse_workspace==0 && ACADOS_WITH_OPENMP);
#endif
if (opts->reuse_workspace)
{
@@ -650,6 +658,11 @@ static void linearize_update_qp_matrices(void *config_, ocp_nlp_dims *dims, ocp_
/* stage-wise multiple shooting lagrangian evaluation */
#if defined(ACADOS_WITH_OPENMP)
// set number of threads
omp_set_num_threads(opts->num_threads);
#pragma omp parallel for
#endif
for (i = 0; i < N; i++)
{
// cost
@@ -43,6 +43,7 @@ typedef struct
void **constraints; // constraints_opts
int compute_dual_sol;
int reuse_workspace;
int num_threads;
} ocp_nlp_sqp_rti_opts;
//
View
@@ -35,6 +35,9 @@ endif
LIBS += -lblasfeo -lm -lblas -llapack
ifeq ($(ACADOS_WITH_OPENMP), 1)
LIBS += -fopenmp
endif
# Comment this out to enable using gprof

0 comments on commit 106ad5c

Please sign in to comment.