Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Has anyone tested the efficiency of MERGE function?

Xj_Kong
Novice
375 Views
REAL::X(100,5)
INTEGER::IS,K
IS=merge(MINLOC(X(:,K)),MAXLOC(X(:,-K)),K>0)

! its equivalent is

IF(K>0)THEN
   IS=MINLOC(X(:,K))
ELSEIF(K<0)THEN
   IS=MAXLOC(X(:,-K))
END IF

! but it seems the later has better efficiency.

0 Kudos
1 Reply
TimP
Honored Contributor III
375 Views

Did you mean to set a DIM argument for minloc and maxloc? Until the code does what you intend, talking about efficiency seems pointless.

The strength of MERGE is not for cases as complicated as array operations.  Performance would depend on the expansion of minloc and maxloc and whether the compiler is able to optimize without making temporary arrays.  The size you quote is marginal on whether vectorization would be useful, and that depends (with recent released ifort) on whether you have set the old_maxminloc.  What do your optreports say?

0 Kudos
Reply