Skip to content

Commit

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

commit 2dd87fb
Author: joaquin.f.fernandez <[email protected]>
Date:   Fri Jan 3 13:43:12 2025 -0300

    Misc updated docs.

commit e981a21
Author: joaquin.f.fernandez <[email protected]>
Date:   Fri Jan 3 13:42:51 2025 -0300

    Generate partition stats afile and abort if requested.

commit 751c4d9
Author: joaquin.f.fernandez <[email protected]>
Date:   Fri Jan 3 13:42:19 2025 -0300

    Added settings to qss data structure.

commit 22088a4
Author: joaquin.f.fernandez <[email protected]>
Date:   Fri Jan 3 13:41:44 2025 -0300

    Added partition only settings to run models.
  • Loading branch information
joaquinffernandez committed Jan 3, 2025
1 parent 23c7f58 commit 12507c5
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 51 deletions.
4 changes: 4 additions & 0 deletions src/engine/common/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ SET_settings SET_Settings(char *fname)
p->CVODE_max_order = 0;
p->BDFMaxStep = 0;
p->x_output = 0;
p->partition_only = 0;
if (config_lookup_float(cf, "minstep", &dres)) {
if (dres == 0) {
p->minstep = MIN_STEP;
Expand Down Expand Up @@ -284,6 +285,9 @@ SET_settings SET_Settings(char *fname)
if (config_lookup_int(cf, "XOutput", &ires)) {
p->x_output = ires;
}
if (config_lookup_int(cf, "partitionOnly", &ires)) {
p->partition_only = ires;
}
config_destroy(cf);
return p;
}
Expand Down
1 change: 1 addition & 0 deletions src/engine/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct SET_settings_ {
SD_partitionerOptions partitionerOptions;
int BDFPart;
int x_output;
int partition_only;
};

SET_settings SET_Settings(char *fname);
Expand Down
23 changes: 21 additions & 2 deletions src/engine/qss/parallel/qss_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,28 @@ void PRT_createPartitions(PRT_partition partition, QSS_data data, char *name)
return;
}
char fileName[256];
char partition_stats_file_name[256];
char graphType[64] = "static";
grp_t nparts = (data->params->lps == 0 ? 64 : data->params->lps);
grp_t nvtxs = data->states + data->events;
FILE *file;
grp_t *xadj = NULL, *adjncy = NULL, *vwgt = NULL, *ewgt = NULL;
grp_t i, edges;
SD_PartitionMethod pm = data->params->pm;
struct timespec *init_time = checkedMalloc(sizeof(struct timespec));
struct timespec *end_time = checkedMalloc(sizeof(struct timespec));
sprintf(partition_stats_file_name, "%s-%ld-%ld-partition-stats.log", name, nvtxs, nparts);
FILE *partition_time_stats = fopen(partition_stats_file_name, "w");
getTime(init_time);
if (GRP_createGraph(name, data, &xadj, &adjncy, &edges, &vwgt, &ewgt, 0, NULL) == GRP_ReadError) {
fprintf(stderr, "Could not read generated graph files.");
abort();
}
getTime(end_time);
subTime(end_time, init_time);
fprintf(partition_time_stats, "Graph generation time: %g ms\n", getTimeValue(end_time));

getTime(init_time);
if (nvtxs > nparts) {
switch (pm) {
case SD_Metis: {
Expand All @@ -444,6 +455,7 @@ void PRT_createPartitions(PRT_partition partition, QSS_data data, char *name)
options[METIS_OPTION_CONTIG] = 1;
options[METIS_OPTION_PTYPE] = METIS_PTYPE_KWAY;
options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_VOL;
options[METIS_OPTION_RTYPE] = METIS_RTYPE_FM;
options[METIS_OPTION_SEED] = 1;
PRT_setMetisOptions(options, data);
METIS_PartGraphKway(&nvtxs, &ncon, xadj, adjncy, vwgt, NULL, ewgt, &nparts, NULL, NULL, options, &edgecut, partition->values);
Expand Down Expand Up @@ -508,8 +520,8 @@ void PRT_createPartitions(PRT_partition partition, QSS_data data, char *name)
SCOTCH_Graph *graph_sc = SCOTCH_graphAlloc();
SCOTCH_Strat *strat = SCOTCH_stratAlloc();
SCOTCH_stratInit(strat);
PRT_setScotchOptions(strat, data);
if (SCOTCH_graphBuild(graph_sc, 0, n, x, x + 1, vw, NULL, e, xa, ew) != 0) {
SCOTCH_stratGraphMapBuild(strat, SCOTCH_STRATDEFAULT, data->params->lps, 0.05);
if (SCOTCH_graphBuild(graph_sc, 0, n, x, NULL, vw, NULL, e, xa, ew) != 0) {
printf("Error: Scotch Graph Build\n");
}
if (SCOTCH_graphPart(graph_sc, np, strat, val) != 0) {
Expand Down Expand Up @@ -540,6 +552,10 @@ void PRT_createPartitions(PRT_partition partition, QSS_data data, char *name)
break;
}
}
getTime(end_time);
subTime(end_time, init_time);
fprintf(partition_time_stats, "Partition time: %g ms\n", getTimeValue(end_time));
fclose(partition_time_stats);
switch (pm) {
case SD_Metis:
sprintf(fileName, "%s-Metis-%s-%ld.partition", name, graphType, nparts);
Expand Down Expand Up @@ -571,6 +587,9 @@ void PRT_createPartitions(PRT_partition partition, QSS_data data, char *name)
if (ewgt != NULL) {
free(ewgt);
}
if (data->settings->partition_only > 0) {
abort();
}
}

PRT_partition PRT_Partition(QSS_data data, char *name)
Expand Down
4 changes: 3 additions & 1 deletion src/engine/qss/qss_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ QSS_data QSS_Data(int states, int discretes, int events, int inputs, int algs, i
QSS_setReinitBuffer(TRUE);
}
p->jac_matrices = SD_JacMatrices(state_eqs, states, alg_eqs, algs);
freeSettings(settings);
p->settings = settings;
return p;
}

Expand Down Expand Up @@ -619,6 +619,7 @@ QSS_data QSS_copyData(QSS_data data)
p->it = data->it;
p->ft = data->ft;
p->maxRHS = data->maxRHS;
p->settings = data->settings;
if (discretes) {
p->d = (double *)malloc(discretes * sizeof(double));
for (i = 0; i < discretes; i++) {
Expand Down Expand Up @@ -878,6 +879,7 @@ void QSS_freeData(QSS_data data)
}
SD_freeEventData(data->event, data->events);
SD_freeParameters(data->params);
freeSettings(data->settings);
free(data);
}

Expand Down
2 changes: 2 additions & 0 deletions src/engine/qss/qss_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

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

#define QSS_REINIT_BUFFER 10000
Expand Down Expand Up @@ -230,6 +231,7 @@ struct QSS_data_ {
SD_parameters params;
QSS_LP_data lp;
SD_jacMatrices jac_matrices;
SET_settings settings;
};

QSS_data QSS_Data(int states, int discretes, int events, int inputs, int algs, int state_eqs, int alg_eqs, string name);
Expand Down
45 changes: 1 addition & 44 deletions src/engine/qss/qss_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,24 @@
******************************************************************************/

#ifndef QSS_FILE_H_
#define QSS_FILE_H_
#pragma once

#include <common/data.h>
#include <qss/qss_data.h>
#include <qss/qss_log.h>

/**
*
* @param
* @param
* @param
*/
void F_write(LG_log log, int i, double time, double value);

/**
*
* @param
* @param
* @param
*/
void F_writeLine(LG_log log, int, double, double*);

/**
*
*/
void F_toFile(LG_log log);

/**
*
* @param simData
* @param simOutput
*/
void F_init(LG_log log, QSS_data simData, SD_output simOutput);

/**
*
* @param
* @param
* @param
*/
void F_PAR_write(LG_log log, int i, double time, double value);

/**
*
* @param
* @param
* @param
*/
void F_PAR_writeLine(LG_log log, int, double, double*);

/**
*
*/
void F_PAR_toFile(LG_log log);

/**
*
* @param simData
* @param simOutput
*/
void F_PAR_init(LG_log log, QSS_data simData, SD_output simOutput);

#endif /* QSS_FILE_H_ */
8 changes: 4 additions & 4 deletions src/engine/qss/qss_quantizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ struct QA_quantizerState_ {
* The above type defines a struct that contains function pointers for various operations related to
* quantization.
*
* @var QA_quantizerState_:: {QA_recomputeNextTimesFn} recomputeNextTimes - A function pointer that takes no arguments
* @var QA_quantizerState_::{QA_recomputeNextTimesFn} recomputeNextTimes - A function pointer that takes no arguments
* and returns no value. It is used to recompute the next times for the quantizer.
* @var QA_quantizerState_:: {QA_recomputeNextTimeFn} recomputeNextTime - A function that takes in a quantized state
* @var QA_quantizerState_::{QA_recomputeNextTimeFn} recomputeNextTime - A function that takes in a quantized state
* and returns the next time at which the state should be recomputed.
* @var QA_quantizerState_:: {QA_nextTimeFn} nextTime - The nextTime property is a function that calculates the next
* @var QA_quantizerState_::{QA_nextTimeFn} nextTime - The nextTime property is a function that calculates the next
* time step for the quantizer.
* @var QA_quantizerState_:: {QA_updateQuantizedStateFn} updateQuantizedState - The updateQuantizedState property is a
* @var QA_quantizerState_::{QA_updateQuantizedStateFn} updateQuantizedState - The updateQuantizedState property is a
* function that is responsible for updating the quantized state of the QA_quantizerOps_ struct.
*/
struct QA_quantizerOps_ {
Expand Down

0 comments on commit 12507c5

Please sign in to comment.