Skip to content
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

Performance update #22

Open
wants to merge 84 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ef19637
Fix whitespaces
Vaan5 Oct 22, 2021
0666de9
Add capacity to ObjectContainer
klausschuch Nov 13, 2021
b15a6e8
Use ObjectContainerResize in ObjectContainerPushBack
klausschuch Nov 13, 2021
6cf1173
Use size within ObjectContainer directly
klausschuch Nov 13, 2021
ef60f7b
Add ObjectList
klausschuch Nov 13, 2021
03a2379
Use ObjectList instead of ObjectContainer
klausschuch Nov 13, 2021
5ebc0bd
Use size variable
klausschuch Nov 13, 2021
6cd90eb
Cache ConnectionInfo type
klausschuch Nov 13, 2021
8b5cc36
Adapt coding style
klausschuch Nov 13, 2021
a80e917
Remove size check in ObjectList/Container Resize
klausschuch Nov 15, 2021
1433851
Fix TypeConversionConvertBoolDouble
klausschuch Nov 18, 2021
9acf45b
time: Add mcx_time_to_micro_s function
klausschuch Nov 23, 2021
7ea9280
Add calcStart/EndWallClockTime to rt factor results
klausschuch Nov 23, 2021
34c8bee
rtFactor: Use a more consistent naming
klausschuch Nov 23, 2021
e121150
Add ComponentBeforeDoSteps()
klausschuch Nov 24, 2021
fc70701
Use rtGlobalSimStart as reference for rtCalcStart and rtCalcEnd
klausschuch Nov 24, 2021
48c2dbb
component: Restructue ComponentSetupRTFactor
klausschuch Nov 25, 2021
dd5da10
component: Reuse rtData->rtTotalSum_s
klausschuch Nov 25, 2021
0cac58a
Set rtData.rtCompStart in ComponentBeforeDoSteps()
klausschuch Nov 24, 2021
4c34594
Component post do-step hook
Vaan5 Nov 29, 2021
11052c6
Do not get FMU values in Fmu2DoStep()
klausschuch Nov 15, 2021
5839809
Add retrieval of observables to components (+submodels)
klausschuch Nov 16, 2021
129f788
Rename Monitoring to Observable
klausschuch Nov 17, 2021
53eeda6
Add STORE_MICRO store level
klausschuch Oct 2, 2021
f0f3b71
Databus: Track connected inputs
klausschuch Nov 15, 2021
a1e57a2
Update connected inputs
klausschuch Nov 15, 2021
4d00f15
Add function to trigger only connected inputs
klausschuch Nov 15, 2021
5653e8c
Trigger only connected inputs in steptypes
klausschuch Nov 15, 2021
0dc4ac7
Component: Remove redundant ComponentUpdateOutChannels() call
klausschuch Dec 15, 2021
ca44ee0
Move DatabusUpdateInConnected() call to ModelConnectionsDone()
klausschuch Jan 11, 2022
dde5cc1
Model: Improve error handling in ModelConnectionsDone
klausschuch Jan 11, 2022
4fa9c4f
Expose a getter to values of constants
Vaan5 Dec 23, 2021
67467e4
Add explicit conversion functions
Vaan5 Dec 23, 2021
5153411
Preprocess connections to constant elements
Vaan5 Dec 23, 2021
6973a60
ChannelInUpdate: Trigger conversion only if channel is connected
Vaan5 Dec 23, 2021
d2c46a8
Apply range/linear conversions immediately when setting a default value
Vaan5 Dec 23, 2021
eac058b
Avoid using magic values
Vaan5 Jan 13, 2022
48e2282
Group object creation and failure check
Vaan5 Jan 13, 2022
83445f5
Remove obsolete comment
klausschuch Jan 22, 2022
a8b0321
Avoid cache misses during coupling step mode switches
Vaan5 Jan 20, 2022
9e6c479
Avoid cache misses during synch mode switches
Vaan5 Jan 27, 2022
bee00ab
Make IntFilter buffer size configurable
Vaan5 Jan 26, 2022
f93c77e
Calculate required size of the IntFilter buffer
Vaan5 Jan 26, 2022
557c71d
Add buffer limit and 'safety zone'
Vaan5 Jan 26, 2022
6f89ec7
Change log levels
Vaan5 Jan 28, 2022
24d9626
fmu2: Filter out connected inputs
Vaan5 Feb 1, 2022
98be115
Do not set unconnected variables in every DoStep
Vaan5 Feb 1, 2022
eba29f2
component: Add SyncStart/EndWallClockTime timing results
klausschuch Dec 16, 2021
381c2d7
component: Measure additional times
klausschuch Jan 31, 2022
639c44a
Do not use uninitialized rtGlobalSimStart
klausschuch Feb 1, 2022
e5da00e
Extract common code into a function
Vaan5 Feb 4, 2022
15f5444
Enable profiling times with a development flag
Vaan5 Feb 4, 2022
b0680ad
Restructure timings
Vaan5 Feb 8, 2022
69f1e8e
Avoid premature simulation end in case of only NeverFinishing components
Vaan5 Mar 4, 2022
a63defc
Ignore FLUSH_STORE in case of parallel
Vaan5 Mar 7, 2022
7ea746b
Change time format in log file header
Vaan5 Mar 7, 2022
cae9ce6
Fix const warnings regarding ChannelValue
klausschuch Jan 24, 2022
1630ee5
Convert path to a normalized absolute path prior to _waccess call
Vaan5 Mar 16, 2022
118cb96
Implement a memory filter
Vaan5 Feb 15, 2022
be4a159
Forward correct argument to CompPostDoUpdateState
Vaan5 Feb 15, 2022
0224c67
Use the MemoryFilter when possible
Vaan5 Feb 15, 2022
e291799
Add a switch to disable the MemoryFilter on demand
Vaan5 Feb 21, 2022
89d3a9c
Check for cycles when determining the buffer size
Vaan5 Feb 21, 2022
51d02a2
Use >= to check for buffer overflow
Vaan5 Mar 22, 2022
1c95704
Use SIZE_MAX instead of MEM_FILTER_IDX_FLAG
Vaan5 Mar 22, 2022
a7631c1
Print user's input as a string instead of the converted int value
Vaan5 Mar 22, 2022
80aa0c3
Fix compiler warnings
Vaan5 Mar 22, 2022
254d521
Define a Vector of pure C objects
Vaan5 Feb 24, 2022
2702ae2
Inline ConnectionInfo into the Connection
Vaan5 Feb 25, 2022
a84098a
Remove ConnectionData
Vaan5 Feb 23, 2022
836e97d
Vector: Add SetAt method
Vaan5 Feb 28, 2022
563936e
Vector: Hide Resize and expose a Reserve method
Vaan5 Mar 2, 2022
edd73e6
Inline ChannelInfo into the Channel
Vaan5 Feb 28, 2022
8dc290f
Drop ChannelData
Vaan5 Mar 2, 2022
5448247
Inline Channel::GetInfo
Vaan5 Mar 2, 2022
27a29e0
Vector optimizations
Vaan5 Mar 22, 2022
b5c256b
Remove unused variables
Vaan5 Mar 22, 2022
f8bb70f
Move variables closer to the place where they are used
Vaan5 Mar 22, 2022
5854fa6
Simplify ResultStorage
klausschuch Mar 9, 2024
1ef31f4
Check that the Databus channels were set before trying to update thei…
klausschuch Mar 9, 2024
bdb8500
Define a ContainsComponent method
Vaan5 Apr 6, 2022
35259ba
Submodel utility to properly check container-like components
Vaan5 Apr 6, 2022
0727977
Make sure ComponentStorage->Finished is called for comp_solver compon…
Vaan5 Apr 6, 2022
e08d0dd
common_fmu2: Add Fmi2TypeToString() function
klausschuch Sep 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions libs/util/src/win/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,25 @@ const char * mcx_os_get_errno_descr(int errnum) {

int mcx_os_path_exists(const char * path) {
int ret;
wchar_t * wPath = mcx_string_to_widechar(path);
char * absoluteNormalizedPath = NULL;
wchar_t * wPath = NULL;

absoluteNormalizedPath = mcx_os_path_normalize(path);
if (path && !absoluteNormalizedPath) {
mcx_log(LOG_ERROR, "Util: Could not convert path '%s' to a normalized absolute path", path);
return 0;
}

wPath = mcx_string_to_widechar(absoluteNormalizedPath);

if (absoluteNormalizedPath) {
mcx_free(absoluteNormalizedPath);
}

ret = (_waccess(wPath, 0) != -1);
mcx_free(wPath);
if (wPath) {
mcx_free(wPath);
}

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CentralParts.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ typedef enum DecoupleTypeDef {
DECOUPLE_ALWAYS = 0x4
} DecoupleType;

// Note: the enum values are mandatory because the enum is used in integer context
typedef enum PolyOrderTypeDef {
POLY_CONSTANT = 0
, POLY_LINEAR = 1
Expand Down Expand Up @@ -150,6 +149,7 @@ typedef enum StoreLevel {
STORE_NONE = 1,
STORE_SYNCHRONIZATION = 2,
STORE_COUPLING = 3,
STORE_MICRO = 4,
} StoreLevel;

typedef enum {
Expand Down
4 changes: 3 additions & 1 deletion src/components/ComponentTypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ OBJECT_CLASS(ComponentType, Object);
/*****************************************************************************/
/* ComponentTypeConstant */
/*****************************************************************************/
const char * const compConstantTypeString = "CONSTANT";

static const char * ComponentTypeConstantToString(ComponentType * type) {
return "CONSTANT";
return compConstantTypeString;
}

static void ComponentTypeConstantDestructor(ComponentTypeConstant * type) {
Expand Down
1 change: 1 addition & 0 deletions src/components/ComponentTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ComponentType {
};


extern const char * const compConstantTypeString;
extern const ObjectClass _ComponentTypeConstant;
typedef struct ComponentTypeConstant {
ComponentType _;
Expand Down
47 changes: 40 additions & 7 deletions src/components/comp_constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
#endif /* __cplusplus */


typedef struct CompConstant {
Component _;

ChannelValue ** values;
} CompConstant;

static McxStatus Read(Component * comp, ComponentInput * input, const struct Config * const config) {
CompConstant * compConstant = (CompConstant *)comp;
ConstantInput * constantInput = (ConstantInput *)input;
Expand Down Expand Up @@ -62,6 +56,43 @@
return RETURN_OK;
}

static ChannelValue * GetValue(CompConstant * compConstant, size_t idx) {
Component * comp = (Component *) (compConstant);
Databus * db = comp->GetDatabus(comp);
size_t numVecOut = DatabusGetOutVectorChannelsNum(db);
size_t i = 0;
size_t sum = 0;
ChannelValue * value = NULL;
VectorChannelInfo * vInfo = NULL;
size_t numCh = 0;
size_t startIdx = 0;
size_t endIdx = 0;

for (i = 0; i < numVecOut; i++) {
vInfo = DatabusGetOutVectorChannelInfo(db, i);
startIdx = vInfo->GetStartIndex(vInfo);
endIdx = vInfo->GetEndIndex(vInfo);
numCh = endIdx - startIdx + 1;

sum += numCh;
if (sum > idx) {
break;
}
}

if (i >= numVecOut) {
ComponentLog(comp, LOG_ERROR, "GetValue: Invalid index (%d) provided", idx);

Check failure

Code scanning / CodeQL

Wrong type of arguments to formatting function High

This format specifier for type 'int' does not match the argument type 'unsigned long'.
return NULL;
}

value = compConstant->values[i];
if (!vInfo->IsScalar(vInfo)) {
value += idx - (sum - numCh);
}

return value;
}

static McxStatus Setup(Component * comp) {
CompConstant * constComp = (CompConstant *)comp;
McxStatus retVal = RETURN_OK;
Expand Down Expand Up @@ -118,13 +149,15 @@
static Component * CompConstantCreate(Component * comp) {
CompConstant * self = (CompConstant *)comp;

// map to local funciotns
// map to local functions
comp->Read = Read;
comp->Setup = Setup;
comp->Initialize = Initialize;

comp->GetFinishState = CompConstantGetFinishState;

// local functions
self->GetValue = GetValue;
// local values
self->values = NULL;

Expand Down
15 changes: 15 additions & 0 deletions src/components/comp_constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,28 @@
#define MCX_COMPONENTS_COMP_CONSTANT_H

#include "core/Component.h"
#include "core/channels/ChannelValue.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


typedef struct CompConstant CompConstant;

extern const struct ObjectClass _CompConstant;

typedef ChannelValue * (*fCompConstantGetValue)(CompConstant * compConstant, size_t idx);

struct CompConstant {
Component _;

fCompConstantGetValue GetValue;

ChannelValue ** values;
};


#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif /* __cplusplus */
Expand Down
Loading
Loading