Skip to content

Commit

Permalink
[iss-257]
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 4ad169d
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Tue Aug 27 12:23:39 2024 -0300

    Fix quantizer macros.

commit 91013b4
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Tue Aug 27 11:17:20 2024 -0300

    Remove x output setting.

commit e5d6599
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Tue Aug 27 10:52:10 2024 -0300

    Fix mliqss headers.

commit 7746349
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Tue Aug 27 10:51:42 2024 -0300

    Fix compilation warnings.

commit 41f743e
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Tue Aug 27 10:05:37 2024 -0300

    Updated QSS methods headers.

commit cadf6da
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Mon Aug 26 16:33:36 2024 -0300

    Update quantizer methods inteface.

commit 27aa2c4
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Mon Aug 26 16:29:46 2024 -0300

    Added quantizer interface macros to qss quantizer module.
  • Loading branch information
joaquinffernandez committed Aug 27, 2024
1 parent bfd0786 commit 1777b45
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 63 deletions.
46 changes: 17 additions & 29 deletions src/engine/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,28 @@

#pragma once

#define QSS_MODULE_INIT(module, args...) \
if (sim_data->params->lps > 0) { \
module##_PAR_init(args); \
} else { \
module##_init(args); \
}

#define TYPE_DEF(type) \
typedef struct type##_ *type; \
typedef const struct type##_ *const_##type;

#ifdef QSS_PARALLEL

#define QSS_FUNC_DECL(module, name) module##_##PAR_##name

#define QSS_FUNC_INVK(module, name) module##_##PAR_##name

#define QSS_ASSIGN_QUANTIZER_OPS(module) \
quantizer->state->qMap = simData->lp->qMap; \
quantizer->ops->recomputeNextTimes = module##_##PAR_recomputeNextTimes; \
quantizer->ops->recomputeNextTime = module##_##PAR_recomputeNextTime; \
quantizer->ops->nextTime = module##_##PAR_nextTime; \
quantizer->ops->updateQuantizedState = module##_##PAR_updateQuantizedState;

#define QSS_PARALLEL_EXP(exp) exp

#define QSS_PARALLEL_IF(map) if (map > NOT_ASSIGNED) {
#define QSS_PARALLEL_IF_END }

#else

#define QSS_FUNC_DECL(module, name) module##_##name
Expand All @@ -42,30 +49,11 @@

#define QSS_PARALLEL_EXP(exp)

#define QSS_ASSIGN_QUANTIZER_OPS(module) \
quantizer->ops->recomputeNextTimes = module##_##recomputeNextTimes; \
quantizer->ops->recomputeNextTime = module##_##recomputeNextTime; \
quantizer->ops->nextTime = module##_##nextTime; \
quantizer->ops->updateQuantizedState = module##_##updateQuantizedState;
#define QSS_PARALLEL_IF(map)

#endif
#define QSS_PARALLEL_IF_END

#define QSS_DECLARE_QUANTIZER_INTERFACE(module) \
extern void module##_##init(QA_quantizer quantizer, QSS_data simData, QSS_time simTime); \
extern void module##_##recomputeNextTimes(QA_quantizer quantizer, int vars, int *inf, double t, double *nTime, double *x, double *lqu, \
double *q) __attribute__((hot)); \
extern void module##_##recomputeNextTime(QA_quantizer quantizer, int var, double t, double *nTime, double *x, double *lqu, double *q) \
__attribute__((hot)); \
extern void module##_##nextTime(QA_quantizer quantizer, int var, double t, double *nTime, double *x, double *lqu) __attribute__((hot)); \
extern void module##_##updateQuantizedState(QA_quantizer quantizer, int i, double *q, double *x, double *lqu) __attribute__((hot)); \
extern void module##_##PAR_init(QA_quantizer quantizer, QSS_data simData, QSS_time simTime); \
extern void module##_##PAR_recomputeNextTimes(QA_quantizer quantizer, int vars, int *inf, double t, double *nTime, double *x, \
double *lqu, double *q) __attribute__((hot)); \
extern void module##_##PAR_recomputeNextTime(QA_quantizer quantizer, int var, double t, double *nTime, double *x, double *lqu, \
double *q) __attribute__((hot)); \
extern void module##_##PAR_nextTime(QA_quantizer quantizer, int var, double t, double *nTime, double *x, double *lqu) \
__attribute__((hot)); \
extern void module##_##PAR_updateQuantizedState(QA_quantizer quantizer, int i, double *q, double *x, double *lqu) __attribute__((hot));
#endif

#define QSS_INT_FUNC_DECL(ret_type, module, name, args...) \
extern ret_type module##_##name(args); \
Expand Down
7 changes: 2 additions & 5 deletions src/engine/common/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ SET_settings SET_Settings(char *fname)
int option;
double dres;
const char *sol;
const char *bdf;
cf = &cfg;
config_init(cf);
if (!config_read_file(cf, fname)) {
Expand Down Expand Up @@ -223,10 +222,8 @@ SET_settings SET_Settings(char *fname)
if (config_lookup_int(cf, "bdf", &ires)) {
p->BDFPart = ires;
}
if (config_lookup_int(cf, "BDFPartitionDepth", &ires)) {
if (ires > 0) {
p->BDFPartitionDepth = ires;
}
if (config_lookup_int(cf, "BDFPartitionDepth", &ires) && ires > 0) {
p->BDFPartitionDepth = ires;
}
if (config_lookup_float(cf, "BDFMaxStep", &dres)) {
p->BDFMaxStep = dres;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/qss/methods/cqss.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include <math.h>
#include <stdlib.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(CQSS, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/cqss.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
6 changes: 3 additions & 3 deletions src/engine/qss/methods/liqss.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <math.h>
#include <stdlib.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(LIQSS, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down Expand Up @@ -110,10 +110,10 @@ void QSS_FUNC_DECL(LIQSS, nextTime)(QA_quantizer quantizer, int var, double t, d
void QSS_FUNC_DECL(LIQSS, updateQuantizedState)(QA_quantizer quantizer, int var, double *q, double *x, double *lqu)
{
int cf0 = var * 2, cf1 = cf0 + 1;
double dx;
double dx = 0;
double *u = quantizer->state->u0;
double *a = quantizer->state->a;
double dq;
double dq = 0;
quantizer->state->qAux[var] = q[cf0];
quantizer->state->oldDx[var] = x[cf1];
quantizer->state->lt[var] = *(quantizer->state->simTime);
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/liqss.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
4 changes: 3 additions & 1 deletion src/engine/qss/methods/liqss2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <qss/methods/liqss2.h>

#include <math.h>
#include <stdlib.h>

#include <common/data.h>
#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(LIQSS2, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/liqss2.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
1 change: 1 addition & 0 deletions src/engine/qss/methods/liqss3.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <stdlib.h>

#include <common/data.h>
#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/liqss3.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
7 changes: 5 additions & 2 deletions src/engine/qss/methods/liqss_bdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
******************************************************************************/

#include <common/utils.h>
#include <math.h>
#include <qss/methods/liqss_bdf.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <common/macros.h>
#include <common/utils.h>

void QSS_FUNC_DECL(LIQSS_BDF, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
int i;
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/liqss_bdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
6 changes: 4 additions & 2 deletions src/engine/qss/methods/mliqss.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <qss/methods/mliqss.h>

#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/methods/mliqss.h>

#define TOL 2

Expand Down Expand Up @@ -93,7 +96,6 @@ void QSS_FUNC_DECL(mLIQSS, recomputeNextTime)(QA_quantizer quantizer, int i, dou
bool state_step = quantizer->state->lSimTime->type == ST_State;
double diff_Q;
bool *sim_step = quantizer->state->sim_step;
int *flag2 = quantizer->state->flag2;

if (t > 0 && state_step) {
diff_Q = q[2 * ifr_state] - quantizer->state->qAux[ifr_state];
Expand Down
4 changes: 3 additions & 1 deletion src/engine/qss/methods/mliqss2.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
******************************************************************************/

#include <qss/methods/mliqss2.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <qss/methods/mliqss2.h>
#include <common/macros.h>
#include <common/utils.h>

void QSS_FUNC_DECL(mLIQSS2, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
Expand Down
3 changes: 1 addition & 2 deletions src/engine/qss/methods/mliqss3.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
#include <stdlib.h>

#include <common/data.h>
#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

#define EPS 1e-40

Expand Down
3 changes: 1 addition & 2 deletions src/engine/qss/methods/qss.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

#include <math.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(QSS, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/qss.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
3 changes: 1 addition & 2 deletions src/engine/qss/methods/qss2.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

#include <math.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(QSS2, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/qss2.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
3 changes: 1 addition & 2 deletions src/engine/qss/methods/qss3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

#include <math.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(QSS3, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/qss3.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
3 changes: 1 addition & 2 deletions src/engine/qss/methods/qss4.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

#include <math.h>

#include <common/macros.h>
#include <common/utils.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

void QSS_FUNC_DECL(QSS4, init)(QA_quantizer quantizer, QSS_data simData, QSS_time simTime)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/qss/methods/qss4.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <common/macros.h>
#include <qss/qss_data.h>
#include <qss/qss_quantizer.h>

Expand Down
27 changes: 27 additions & 0 deletions src/engine/qss/qss_quantizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@
#include <qss/qss_data.h>
#include <qss/qss_bdf.h>

#define QSS_DEFINE_QUANTIZER_OPS(module) \
quantizer->ops->recomputeNextTimes = module##_recomputeNextTimes; \
quantizer->ops->recomputeNextTime = module##_recomputeNextTime; \
quantizer->ops->nextTime = module##_nextTime; \
quantizer->ops->updateQuantizedState = module##_updateQuantizedState;

#ifdef QSS_PARALLEL
#define QSS_ASSIGN_QUANTIZER_OPS(module) \
quantizer->state->qMap = simData->lp->qMap; \
QSS_DEFINE_QUANTIZER_OPS(module##_PAR)
#else
#define QSS_ASSIGN_QUANTIZER_OPS(module) QSS_DEFINE_QUANTIZER_OPS(module)
#endif

#define QSS_DEFINE_QUANTIZER_INTERFACE(module) \
extern void module##_init(QA_quantizer quantizer, QSS_data simData, QSS_time simTime); \
extern void module##_recomputeNextTimes(QA_quantizer quantizer, int vars, int *inf, double t, double *nTime, double *x, double *lqu, \
double *q) __attribute__((hot)); \
extern void module##_recomputeNextTime(QA_quantizer quantizer, int var, double t, double *nTime, double *x, double *lqu, double *q) \
__attribute__((hot)); \
extern void module##_nextTime(QA_quantizer quantizer, int var, double t, double *nTime, double *x, double *lqu) __attribute__((hot)); \
extern void module##_updateQuantizedState(QA_quantizer quantizer, int i, double *q, double *x, double *lqu) __attribute__((hot));

#define QSS_DECLARE_QUANTIZER_INTERFACE(module) \
QSS_DEFINE_QUANTIZER_INTERFACE(module) \
QSS_DEFINE_QUANTIZER_INTERFACE(module##_PAR)

typedef struct QA_quantizerOps_ *QA_quantizerOps;
typedef struct QA_quantizerState_ *QA_quantizerState;
typedef struct QA_quantizer_ *QA_quantizer;
Expand Down

0 comments on commit 1777b45

Please sign in to comment.