2

The following implied Do-loop produces a bad performance at compile time

haarWPhi2D = reshape([((((((2**(-j/2))*haarWaveletPhi((2**j)*(m*dx)-k))* &
 ((2**(-j/2))*haarWaveletPhi((2**j)*(n*dt)-l)), &
  m = -grid_size, grid_size), k = -grid_size, grid_size), &
   n = 0, num_time_steps), l = 0, num_time_steps)], shape(haarWPhi2D))

I don't understand why the compilation is extremely slow and depending of the value of the finals may even never finish the compilation. For example with some of them at 100.

I'm not an expert but I expect in any case the performance to be affected at run time not at compile time.

Compiler version: GCC version 9.3.0
 Compiler options: -mtune=generic -march=x86-64 -fpre-include=/usr/include/finclude/math-vector-fortran.h

--Update--

This is a simple case that can be used to prove the problem

program main

    implicit none
        integer :: m, n
        integer :: k = 0
        integer :: l = 0
        integer, parameter :: num_time_steps = 100
        integer, parameter :: grid_size = 100
        real :: haarWPhi2D(-grid_size:grid_size, -grid_size:grid_size, 0:num_time_steps, 0:num_time_steps)
        haarWPhi2D = reshape([((((1, &
            m = -grid_size, grid_size), k = -grid_size, grid_size), &
                n = 0, num_time_steps), l = 0, num_time_steps)], shape(haarWPhi2D))

end program main
user38747
  • 29
  • 2
  • Your type declarations look incorrect. – steve Jan 25 '21 at 07:26
  • Why do people think everything needs to be done in 1 line? – Ian Bush Jan 25 '21 at 07:39
  • Sometimes implied loops do not optimise as well as explicit loops. trying to do the math into a secondary array independent of the RESHAPE might be worth a try? – Holmz Jan 25 '21 at 08:03
  • The type declarations can't be incorrect because as I said for lower values of the finals the compilation succeeded. My question is related to the fact that the compile-time is being affected and the run-time doesn't. Once is compiled the computations are extremely fast. – user38747 Jan 25 '21 at 12:54
  • You missed the point. You have not provided sufficient information that would allow someone to investigate the issue. In particular, I wrote pieces of gfortran that expand array constructors and do simplification (i.e., constant folding). Good luck. – steve Jan 25 '21 at 16:04

0 Answers0