-
Notifications
You must be signed in to change notification settings - Fork 1
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
API: synchonisation iode-dos 6.70 api -> iode 7.0 api #373
Conversation
@jmpplan please note that both unittests
failed. See Github Actions results here Both unittests seems linked to the C++ API. So I guess some of your changes broken the C++ API in some manner. Please compile the C++ API and the associated tests on your PC to solve the problem. |
I have noticed I broke the Please execute the following lines in a terminal: > git fetch --all
> git pull --rebase origin master
> git push --force |
I've modified test1.c to correct the simulation errors found by GH, but Now, if we want to compile with |
Why ? It is compiling on both my PC (MSVC 1935 -> I've installed Visual Studio 2022 some months ago) and on GH (still running on Windows 2019 with MSVC < 1929). On GH, two tests failed (from folder
Concerning SimulationTest.Simulation, please change the line 90 of the file EXPECT_DOUBLE_EQ(round(Variables.get_var("XNATY", "2000Y1") * 10e5) / 10e5, 0.800703); Concerning SimulationTest.SimulateSCC, the logs on GH Actions say: Running main() from D:\a\iode\iode\out\build\windows-debug\_deps\googletest-src\googletest\src\gtest_main.cc
Note: Google Test filter = SimulationTest.SimulateSCC
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from SimulationTest
[ RUN ] SimulationTest.SimulateSCC
Loading D:\a\iode\iode\out\build\windows-debug\tests\data\fun.eqs
274 objects loaded
Loading D:\a\iode\iode\out\build\windows-debug\tests\data\fun.scl
161 objects loaded
Loading D:\a\iode\iode\out\build\windows-debug\tests\data\fun.var
394 objects loaded
Pseudo-linking equations ....
Calculating SCC...
Calculating SCC... 0 ms -> #PRE 31 - #INTER 204 - #POST 39
Reordering interdependent block...
Reordering interdependent block... 0 ms
Linking equations ....
unknown file: error: SEH exception with code 0xc0000005 thrown in the test body.
[ FAILED ] SimulationTest.SimulateSCC (12 ms)
[----------] 1 test from SimulationTest (12 ms total) I don't know the reason of the |
Mmm... could you run the unittest |
I mean if we want to remove the flag
Done. But I had to change it also in test_c_api (with a slightly different value). I don't understand where these differences are coming from ??? I should add a new issue.
In previous version we already had similar errors. The problem came from the modification of static strings (like "" passed as parameter and modified inside the function). To solve that problem, we can either add the
Or add the keyword |
Good idea. As I understand it, you didn't expect to have those differences given the changes you made in the C API code. |
That would be the cleanest way. But that could be an important work... |
I already tried it before but for a mysterious reason, it does not compile: for example:
As you can see, CMake adds the parameter
|
char empty_string[1] ;
...
call to Fn(""...)
replaced by Fn(empty_string...) If it is not too much work, you could try this. |
Exactly. Worrying. |
In this case, that could be because me/GH and you are not using the same version of CMake. I don't know. |
- removed unnecessary comments and commented lines - some comments translated into En to avoid accents - extended comments for simulations variables - added new sim variables declarations: KSIM_CPUS, KSIM_CPU_SCC, KSIM_POSXK_REV and KSIM_CPU_SORT
- declarations of new functions for Cython implementation: - IodeModelCalcSCC(int nbtris, char* pre_listname, char* inter_listname, char* post_listname, char *eqs_list) - int IodeModelSimulateSCC(char *per_from, char *per_to, char *pre_eqlist, char *inter_eqlist, char* post_eqlist, double eps, double relax, int maxit, int init_values, int debug, double newton_eps, int newton_maxit, int newton_debug) - double IodeModelSimNorm(char* period) - int IodeModelSimNIter(char* period) - int IodeModelSimCpu(char* period))
- L_link1_endos(): for exogenous vars, cl->lnames[i].pos = -1 instead of KNB(dbe). Needed for the new model reordering algo
- T_insert_line(): description of parameter 'where' modified
- B_CreateVarFromVecOfInts(): if the variable cannot be created (bad name...), an error message is provided
- B_FileImportCmt() and B_FileImportVar(): in call to IMP_RuleImport(), "" replaced by a local empty string to avoid crash in SCR_strip()
- RP_silent(char* arg): implements $silent - RP_beep(): added char* parameter - RP_warning(): return 0 always
- new functions: - RPF_IodeVersion(): new fn to retrieve the running version of IODE - RPF_SimMaxit, RPF_SimEps, RPF_SimRelax, RPF_SimSortNbPasses, RPF_SimSortAlgo, RPF_SimInitValues, RPF_SimNorm: new function to retrieve info about simulation parameters - RPF_SimNIter, RPF_SimCpu, RPF_SimCpuSCC, RPF_SimCpuSort: data from last simulation - RPF_SimNormReal(), RPF_SimNIterInt() and RPF_SimCpuInt() to be shared bw report fns AND in python fns
- added command $silent - added functions: - simsortnbpasses - simsortalgo - siminitvalues - simnorm - simniter - simcpu - simcpuscc - simcpusort - version
- IodeInit(): does not read the SW_SEG_SIZE param in iode.ini anymore when the swap engine is already initialized (to enable the new -seg parameter of iodecmd). - IodeModelCalcSCC() and IodeModelSimulateSCC(): new fns to implement in python the alternative simulation function model_calc_scc() and model_simulate_scc() based on pre-calculated lists - IodeModelSimNorm(char* period), int IodeModelSimNIter(char* period), int IodeModelSimCpu(char* period): new functions to retrieve simulations results / parameters
- new vector KSIM_POSXK_REV[] containing the reverse of KSIM_POSXK[] to accelerate the process of retrieving the position of an equation in the model (for NEMESIS, reduces the SCC by a factor 300!) - KE_findpath(): assignation of KSIM_POSXK_REV[i] when KSIM_POSXK is modified api/simulation/k_sim_main.c: - new vector KSIM_POSXK_REV containing the reverse position of the equations - new vector KSIM_CPUS containing the CPU time for each simulated period - K_simul(): - initialize KSIM_POSXK_REV - alloc KSIM_NORMS, KSIM_NITERS and KSIM_CPUS - calc KSIM_POSXK_REV in the link loop - Fixed #330: in exchange endo-exo, if one of the vars does not exist, a message is provided and the function returns (and IODE does not crash anymore). - calc and store KSIM_CPUS[t] for each period - K_simul_free(): frees KSIM_POSXK_REV - K_simul_1(): - initialize KSIM_CPUS[t] - added CPU in the iteration messages - K_simul(): fixed #1. In exchange endo-exo, if one of the vars does not exist, a message is provided (and IODE does not crash anymore). api/k_sim_order.c: - new globals KSIM_CPU_SCC and KSIM_CPU_SORT - KE_order(): - the message "sorting equations" is split in 2 steps: "Calculating SCC..." and "Reordering interdependent block...". The CPU is provided for each separated step and saved in KSIM_CPU_SORT and KSIM_CPU_SCC - KE_poseq(): - use of KSIM_POSXK_REV containing the reverse position of the equations to (radically) accelerate the function - if posendo < 0 (ex in KE_ModelCalcSCC()), return(-1) - KE_tri(): save the elapsed time (not really CPU) in KSIM_CPU_SORT api/k_sim_scc.c: - KE_ModelCalcSCC(): new variable KSIM_POSXK_REV to store reverse positions of endogenous variables
- typedef LSTACK: misplaced closing comment */
api/iodebase.h: - declarations of new report functions: - int RP_silent(char* arg); - U_ch *RPF_IodeVersion(U_ch** args); - U_ch* RPF_SimSortNbPasses(); - U_ch* RPF_SimSortAlgo(); - U_ch* RPF_SimInitValues(); - IODE_REAL RPF_SimNormReal(U_ch** args); - int RPF_SimNIterInt(U_ch** args); - int RPF_SimCpuInt(U_ch** args); - U_ch* RPF_SimCpu(U_ch** args); - U_ch* RPF_SimCpuSCC(); - U_ch* RPF_SimCpuSort(); - signature of T_view_tbl() reset - declaration of T_view_tbl_super reset - added in comments pro memory the temporarily changed signature of T_view_tbl to T_view_tbl(char* name, char *smpl, char** vars_names) - idem for T_view_tbl_super() - added declaration of W_printfReplEsc(char* fmt, ...)
- signature of T_view_tbl() reset to its original value (+ in comment the signature used in IODE-QT) - definition of T_view_tbl_super reset to original values api/report/undoc/b_view.c - B_ViewPrintVar(): reset to iode-dos version - B_ViewPrintTbl_1(): idem
- SimulationTest : XNATY expected value 0.80071 replaced by 0.800703
From the logs of the last tests, one can see that the OS as been updated as well as the version MSVC -> 1935. unknown file: error: SEH exception with code 0xc0000005 thrown in the test body. I probably made an error when compiling on my PC. I don't know. The error is most probably as you said due to a constant string passed to a C function which modified it. |
I will again make a checkout pf your branch |
And as in GH Actions, the test |
@jmpplan for(i = 0; i < smpl->s_nb; i++, t++) {
if(rc = K_simul_1(t)) goto fin;
} The |
One step next: KSIM_CPUS[t] = 0; returns the error |
- KSIM_CPUS allocated in K_simul_SCC_init() - KSIM_CPUS freed in K_simul_SCC_init()
OK. Super. Tests are working! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As requested, I would like you to check the C++ Simulation class and add TODO comments (or recommendations in the code) when necessary.
- Simulation::model_calculate_SCC(): reference to IodeModelCalcSCC() added - Simulation::model_simulate_SCC(): ref to IodeModelSimulateSCC() added + TODO cpp_api/compute/simulation.h: - added some TODOs (implementation of a fns similar to IodeModelSimNorm, ...)
- added two separated sections for VS 2019 and VS 2022 (to comment or uncomment): - cmake_minimum_required 3.20 vs 3.24 - CMAKE_CXX_STANDARD vs add_compile_options("/std:c++latest")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for merge
…de_model_simulate_exchange() function -> returned value changed due to changes in the C API pushed in the PR #373
…de_model_simulate_exchange() function -> returned value changed due to changes in the C API pushed in the PR #373
-> reset arguments to (TBL* tbl, char* smpl, char* name) fix #387
-> reset arguments to (TBL* tbl, char* smpl, char* name) fix #387
Synchonisation iode-dos 6.70 api -> iode 7.0 api
Reports functions
$silent
@version()
$msg
: bug fixed@functions
related to simulations:Endo-Exo bug fixed
In a simulation, when an exchange endo-exo is required, if one of the vars does not exist,
an error message is now provided. In the previous versions, IODE crashed if that was the case.
-> Fix #330
Simulation algorithm
The method for decomposing models into strongly connex components has been revised and greatly improved
for large models.
FileImportVar and FileImportCmt
-> Fix #292.