Modify

Opened 7 years ago

Closed 7 years ago

#544 closed enhancement (duplicate)

Enable optimisation in Fortran array index calculations

Reported by: Erik Schnetter Owned by: Peter Diener
Priority: major Milestone:
Component: Cactus Version:
Keywords: Cc: diener@…

Description

In Fortran, Cactus passes all grid functions as arguments to routines,
and the size of the grid functions are declared in
DECLARE_CCTK_ARGUMENTS. In these declarations, Cactus assumes that the
size of each grid variable group can be different, and the compiler
thus does not see that all grid functions have (locally) the same
array shape. The compiler can thus not simplify array index
calculations. This is probably only relevant in short loops accessing
grid functions from multiple groups (GRHydro?).

The attached patch passes three additional integer arguments
(cctk_lsh[123]) which contain the shape of grid functions, and uses
these to declare grid functions.

This patch is quite old, but was never applied. It comes from a time
when g77 didn't support declaring array shapes via an integer array
(since this is not allowed in Fortran 77). If this is now possible,
one could use the array cctk_lsh instead of passing three extra
integer arguments.

Attachments (1)

lsh123.patch (4.8 KB) - added by Erik Schnetter 7 years ago.

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by Erik Schnetter

Attachment: lsh123.patch added

comment:1 Changed 7 years ago by Erik Schnetter

Status: newreview

comment:2 Changed 7 years ago by Frank Löffler

If I understood correctly, this patch would change the declaration not only for Fortran 90, but also for Fortran 77 code. Wouldn't that break Fortran 77 code when a compiler follows the standard strictly?

comment:3 Changed 7 years ago by Erik Schnetter

No, this patch uses a mechanism that follows the Fortran 77 standard, apart from the usual ways in which one violates this standard anyway (using implicit none, line lengths, number of continuation lines, etc.)

Apart from this: I would be very surprised if we found a true Fortran 77 compiler these days that isn't just a Fortran 90 compiler (Fortran is backward compatible, apart from really murky corners that we don't touch anyway). In fact, we could probably remove support for Fortran 77 from Cactus without anybody noticing. (By default, Cactus overwrites all Fortran 77 settings with Fortran 90 settings, since this ensures that the Fortran 77 and Fortran 90 compilers are compatible -- if one uses the Fortran 90 compiler to build Fortran 77 code, this will be ensured...)

comment:4 Changed 7 years ago by Ian Hinder

I'm not really familiar with either Fortran or the flesh files that this patch touches. Frank, should the patch be committed?

comment:5 Changed 7 years ago by Frank Löffler

Cc: diener@… added
Owner: set to Peter Diener
Status: reviewassigned

I looked over the patch, and it seems to be ok, but didn't test it. However, Fortran and me are usually not getting along well, so I will ask Peter to provide input.

comment:6 Changed 7 years ago by Peter Diener

I applied the patch and used it to compile WaveToyF77 and WaveToyFree90. As far as I can see the patch is not complete. It does pass in cctk_lsh1, cctk_lsh2 and cctk_lsh3, but these are not used when declaring the grid functions later on. The grid functions are still declared the same was as before applying the patch, with distinct integers for each grid function.

comment:7 Changed 7 years ago by Erik Schnetter

Resolution: duplicate
Status: assignedclosed

I just committed #235, which includes this patch.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Diener.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.