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

Speed issues related to Equivalence use in concert with IVF/C++

bmchenry
New Contributor II
404 Views

I have a third party developing a C++ program which will be calling some of my IVF programs.

In order to facilitate the exchange of information, what is proposed is to share a memory space so when my DLL updates the shared space then it is immediately available to the C++ program AND the data is stored between calls to the DLL. (the specific details of this situation havent been worked out yet, I am just preparing my code in anticipation)

One issue/question I have is:

Does using Equivalence statements have any significant penalties/issues?

For economy of coding, I propose using Equivalence statements in modules to permit passing of arrays rather than the individual variables.

For example, lets say my IVF has all letters of the alphabet A-Z used in code.

In the module, I create an array
Real, Dimension(24) :: Alphabet

And then use equivalence to store the alphabet

Equivalence (Alphabet(1), A)

Equivalence (Alphabet(2), B)

Equivalence (Alphabet(24), Z)

Now we simply set up the 'shared storage' for Alphabet bymy passingeither a pointer to Alphabet, the array or however we ultimately decide to accomplish the task. The use of simple arrays reduces significantly the setup for exchange of information.

Does anyone see possible issues which may occur?

There are a hundred or so common blocks (from back in mainframe days) which were movedto modules (years ago) and now the question is how best to share the data in the modules with C++?

They are all standard real, logical & integer variables and so no C++/IVF related character/complex/etc issues.

The reason for the array, etc is most of the variables will only be used by IVF so no need to pass them all by name but we want the storage to remain static between calls to IVF.

Thanks for any assistance.

Brian

0 Kudos
1 Reply
Steven_L_Intel1
Employee
404 Views
Look at the sample DLL_Shared_Data for an illustration of how to structure this. EQUIVALENCE may cost you some optimizations but itself doesn't slow things down. I would gently discourage you from using EQUIVALENCE, but if it makes sense for your application, ok. I recommend using module variables rather than COMMON.

One important tip - the shared variable(s) must be data-initialized (at least in part) to some non-zero value to make sure they get placed in the correct image section.
0 Kudos
Reply