Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent definition of explicit constants in BLAS calls + warnings removal(explicit type conversion in gpnorm, format W=>D+7, unused statement function) #44

Merged
merged 6 commits into from
Nov 30, 2023

Conversation

piotrows
Copy link
Contributor

Aiming at the larger changes incoming with the CP/DP PR, this PR performs some tidy-up:

  • in the DP and SP BLAS calls, ensures that explicit constant values are passed with JPRD and JPRM, respectively (instead of JPRB)
    and removes compiler warnings through
  • commenting out unused statement function in tpm_pol
  • modifying write format in sugaw and benchmark that ensures W=>D+7
  • adding explicit, matching REAL type cast to JPRB in gpnorm invocation of max/min (this is due to the fact that one of the two arguments in max/min function is hard coded JPRD)
    Code tested on ATOS with gcc,intel,nvhpc and on the WSL workstation with gcc,intel,nvhpc, as well as clang/gfortran on Mac ARM. I've noticed that some tests are failing under Intel 2024 on WSL Ubuntu workstation.

@FussyDuck
Copy link

FussyDuck commented Nov 17, 2023

CLA assistant check
All committers have signed the CLA.

DA(KKN,KKM)=SQRT( (REAL(2*KKN+1,JPRD)*REAL(KKN-KKM,JPRD)&
&*REAL(KKN+KKM,JPRD))&
&/ REAL(2*KKN-1,JPRD) )
!DA(KKN,KKM)=SQRT( (REAL(2*KKN+1,JPRD)*REAL(KKN-KKM,JPRD)&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we just delete this? You're right, it doesn't seem to be used at all.

Copy link
Contributor Author

@piotrows piotrows Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we wait for a second opinion or should I give it a go ?

Copy link
Collaborator

@samhatfield samhatfield Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always nervous about modifying code that is almost as old as I am. Let's see what @marsdeno thinks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely looks pretty safe to me to be deleted!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@samhatfield
Copy link
Collaborator

Apart from my comment above, this looks ready for merging.

@samhatfield
Copy link
Collaborator

Some CI suites are failing but that looks like another problem...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to say on changes from JPRB to JPRM/JPRD, but while you're there, would it make sense to look at other precision-related things in this file? Things I see looking at file are

  • calls to REAL() conversion routine with JPRB kind request, when we know whether it should be JPRM or JPRD (for ex. l.890)
  • calls to NINT(xx,JPRB) look rather strange to me, shouldn't that be e.g. JPIB?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NINT(xx, JPRB) does not make sense to me, especially since assigned values (at least following are of integer(kind=JPIM) (always 32bit integer).

INTEGER(KIND=JPIM)  :: M_ORDER     =0 ! M of original matrix
INTEGER(KIND=JPIM)  :: N_ORDER     =0 ! N of original matrix
INTEGER(KIND=JPIM)  :: N_CMAX      =0 ! Max number of columns in each submatrix at level 0
INTEGER(KIND=JPIM)  :: N_LEVELS    =0 ! Max level in dyadic hierarchy
INTEGER(KIND=JPIM)  :: IBETALEN_MAX=0 ! Max workspace for one level of interim results "beta"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The REAL() call on line 890 seems to be correct because ZVECOUT is JPRB.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for NINT, it seems to do the following currently:

1. Round real number to nearest integer, returning a real number.
2. Implicit type conversion to integer.
3. Assign to integer.

when indeed it could be shortened to:

1. Round real number to nearest integer, returning an integer.
2. Assign to integer.

Presumably replacing the JPRB with JPIB will fix this, as Olivier suggests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we leave it all for a separate PR, or we extend this one ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well unless I misunderstand @marsdeno's point about REAL() conversions, the only thing outstanding is the NINT calls. If you could change those to use JPIM with one more commit on this PR, I think we're ready for merging!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The REAL() call on line 890 seems to be correct because ZVECOUT is JPRB.

My comment here was rather that we know from the code that in this particular instance, JPRB is in fact single precision.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well unless I misunderstand @marsdeno's point about REAL() conversions, the only thing outstanding is the NINT calls. If you could change those to use JPIM with one more commit on this PR, I think we're ready for merging!

The REAL() thing is not very important, I think, but it is similar in nature to the original point being addressed, regarding replacing JPRB by JPRM/JPRD in places where we know what it is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now. It's because on this line we are inside an IF branch which is only entered when LLDOUBLE = .FALSE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samhatfield @marsdeno this two issues are now corrected. We still have a type incompatibility in BLAS calls, e.g.
Users/napz/Codes/ectrans-typefix/src/trans/internal/ledir_mod.F90:170:53:

141 | CALL DGEMM('T','N',ILA,KIFC,KDGLU,1.0_JPRD,S%FA(KMLOC)%RPNMA,KDGLU,&
| 2
......
170 | CALL DGEMM('T','N',ILA,KIFC,KDGLU,1.0_JPRD,ZRPNMA,KDGLU,&
| 1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/REAL(4)).
If I understood correctly, @marsdeno you are already correcting it elsewhere, so we leave it alone for now.

@wdeconinck
Copy link
Collaborator

I like all new changes since my last review except the last commit 629a65f

The types of ZBETA and ZVEC_OUT are declared with JPRB

REAL(KIND=JPRB),ALLOCATABLE :: ZBETA(:,:,:)

Even if not executed due to if (.NOT. LLDOUBLE) it is counterintuitive to have that different from the declaration.
and compiler will create conversion instructions.

@samhatfield
Copy link
Collaborator

I have no strong feelings on this one way or the other...

@marsdeno
Copy link
Collaborator

I like all new changes since my last review except the last commit 629a65f

The types of ZBETA and ZVEC_OUT are declared with JPRB

REAL(KIND=JPRB),ALLOCATABLE :: ZBETA(:,:,:)

Even if not executed due to if (.NOT. LLDOUBLE) it is counterintuitive to have that different from the declaration. and compiler will create conversion instructions.

Fair enough, I can see your point about counterintuitive, although I'm not sure about the situation with conversion instructions actually being any different.

@wdeconinck
Copy link
Collaborator

wdeconinck commented Nov 27, 2023

I have no strong feelings on this one way or the other...

Me neither really. Can stay as is in the PR if Olivier likes it.

@piotrows
Copy link
Contributor Author

piotrows commented Nov 27, 2023

I like all new changes since my last review except the last commit 629a65f

The types of ZBETA and ZVEC_OUT are declared with JPRB

REAL(KIND=JPRB),ALLOCATABLE :: ZBETA(:,:,:)

Even if not executed due to if (.NOT. LLDOUBLE) it is counterintuitive to have that different from the declaration. and compiler will create conversion instructions.

Hmm, if I understand correctly, the conversion instructions would be generated in the inactive path only, and with the current (explicit: JPRM or JPRD) form the code seems better readable to me. @marsdeno @samhatfield ?
Edit: too late ;)
The only drawback I see is that perhaps the instruction cache may be negatively influenced if spurious conversion is actually generated. But this seems negligible.

@piotrows
Copy link
Contributor Author

@wdeconinck @marsdeno @samhatfield just to make clear, I expect one of you to mercifully merge it if its ready.

@samhatfield
Copy link
Collaborator

@wdeconinck could I be given rights to merge pull requests?

@wdeconinck wdeconinck merged commit f83ba32 into develop Nov 30, 2023
21 checks passed
@wdeconinck
Copy link
Collaborator

Thanks @piotrows for this cleanup!

@wdeconinck wdeconinck deleted the napz-blascalls-constantype-fix branch November 30, 2023 08:53
@marsdeno
Copy link
Collaborator

marsdeno commented Nov 30, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants