Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28517 Discussions

Performance issue with COMINITIALIZE

netphilou31
New Contributor II
671 Views

Hi,
I recently faced an issue using COMINITIALIZE/COMUNINITIALIZE too many times.

I have a dll which exports calculation routines which possibly need to call external procedures through COM interfaces. At the beginning and end of each subroutine I have a COMINITIALIZE and COMUNINITIALIZE calls (note that there is only one way to leave these subroutines, and this is done after the COMUNINITIALIZE call). These calls are in fact not necessary since COM is already initialized by the calling process and the pointers to the necessary COM objects are passed as arguments.

Anyway, to this day I did not notice any performance issue, but I found that when these routines are called intensively (more than hundred thousand times) the calculation time rises in a huge and redhibitory way, even if absolutely no COM calls are performed. To give you an example, with my test case, without the COMINITIALIZE/COMUNINITIALIZE calls the calculation time is around 1 minute whereas it is more than 1 hour with these calls (no other changes than commenting the calls).

I did not look in that direction first since some performance tests with another IDE (Delphi), gave me an overall time of about 46 ms when calling 100 000 times the CoInitialize / CoUninitialize routines. Unfortunately, these interfaces are not provided with Intel Fortran which seems to do more things behind the scenes.

Any Idea of what is going wrong?

Regards,

Phil.

0 Kudos
4 Replies
andrew_4619
Honored Contributor II
654 Views

I had a look at this because I use COM from intel also but not in an "intensive" way like you describe.  I agree that the SDK tools have a number of flags and settings and the intel doc is silent on this and than than zero status return there seems no way to know if it is initialised or not. I think some notes in the intel topic would help, e.g. what thread option is used etc.

Other than this I can't help with the problem it is one for Intel to respond to.

0 Kudos
netphilou31
New Contributor II
642 Views

Hi,
Thanks for giving me some ideas. I will wait for any additional comments.
I finally removed all the COMINITIALIZE/COMUNINITIALIZE with success to solve the issue.
What was strange is that I started running some calculations before leaving the office one day, I recorded the calculation time the morning after it was around 1 h, then even I don't remember exactly what I did or changed but suddenly the calculation time dropped down to a normal figures and then went back to 1 h. I guess here is something relating to the OS (memory cache?) but I don't know what!
Regards,
phil.

0 Kudos
Ron_Green
Moderator
590 Views

well the Fortran side is just a thin wrapper to OleInitialize().  So I don't think the problem is Fortran related.   Here's the call

 

extern void COMINITIALIZE(HRESULT* status)
{
    *status = OleInitialize(NULL);
}

extern void COMUNINITIALIZE()
{
    OleUninitialize();
}

 

0 Kudos
netphilou31
New Contributor II
494 Views

Hello Ron,

Thank you for your comment.

Could the problem be related to the OS? Windows 10 20H2 (19042.867 and later) and Windows 11 (any version) or to the compiler version (2021.4.0 and above) or to something else behind the call to OleInitialize()?

Regards,

Phil.

0 Kudos
Reply