Skip to content

Commit

Permalink
Added quantizer interface macros to qss quantizer module.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinffernandez committed Aug 26, 2024
1 parent 62796da commit 27aa2c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 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
25 changes: 25 additions & 0 deletions src/engine/qss/qss_quantizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@
#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) 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 27aa2c4

Please sign in to comment.