This is an archive of the discontinued LLVM Phabricator instance.

[flang] CUDA Fortran - part 2/5: symbols & scopes
ClosedPublic

Authored by klausler on May 8 2023, 5:02 PM.

Details

Summary

Add representations of CUDA Fortran data and subprogram attributes
to the symbol table and scopes of semantics. Set them in name
resolution, and emit them to module files.

Depends on https://reviews.llvm.org/D150159.

Diff Detail

Event Timeline

klausler created this revision.May 8 2023, 5:02 PM
Herald added a project: Restricted Project. · View Herald Transcript
klausler requested review of this revision.May 8 2023, 5:02 PM
klausler updated this revision to Diff 520536.May 8 2023, 5:14 PM

Remove redundantly added tests.

This revision is now accepted and ready to land.May 9 2023, 9:41 AM
wangzpgi added inline comments.May 9 2023, 11:31 AM
flang/lib/Semantics/resolve-names.cpp
3526

Can launch_bounds take third argument of max cluster rank for Hopper?

3551

Can cluster_dim take variable argument such as "cluster_dim(x,y,z)", where x, y, and z are integer variables?

wangzpgi added inline comments.May 9 2023, 1:12 PM
flang/include/flang/Semantics/symbol.h
152

misspelling: LANCH_BOUNDS -> LAUNCH_BOUNDS

klausler added inline comments.May 9 2023, 2:37 PM
flang/lib/Semantics/resolve-names.cpp
3526

Not according to https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#cfref-new-subs-func-attr which has "The form used in CUDA Fortran is:

attributes(global) launch_bounds(maxTPB, minBPM) subroutine sub(...)

where maxTPB is the maxThreadsPerBlock, the maximum number of threads per block with which the application will ever launch, and minBPM is the desired minimum number of resident blocks per multiprocessor. Both values must be numeric constants." in 3.1.2.

3551

No, not according to https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#cfref-new-subs-func-attr , which has "Beginning with the 23.3 release, support for thread block clusters is enabled for Hopper (cc90) and later targets. To specify the dimensions of the cluster, use the cluster_dims syntax and specify each x, y, and z dimension. Values must be numeric constants." in 3.1.3.

klausler marked an inline comment as done.May 9 2023, 3:04 PM
klausler updated this revision to Diff 520836.May 9 2023, 3:09 PM

Fix misspelling in comment.

klausler updated this revision to Diff 520837.May 9 2023, 3:12 PM

Generate diff against part 1 rather than main (oops).

wangzpgi added inline comments.May 9 2023, 3:32 PM
flang/lib/Semantics/resolve-names.cpp
3551

It mentioned at the end of 3.1.2: "Also, as part of the Hopper support, the launch_bounds syntax has been extended to accept a third argument, an upper bound on the cluster size."

klausler added inline comments.May 9 2023, 3:37 PM
flang/lib/Semantics/resolve-names.cpp
3551

That's for LAUNCH_BOUNDS(), not CLUSTER_DIMS().

klausler updated this revision to Diff 520850.May 9 2023, 3:51 PM

Allow third parameter to LAUNCH_BOUNDS().

klausler updated this revision to Diff 520851.May 9 2023, 3:52 PM

Upload correct diff (sorry).

wangzpgi added inline comments.May 9 2023, 4:42 PM
flang/lib/Semantics/resolve-names.cpp
3551

Yes, allowing third argument was for launch_bounds, not cluster_dims, I commented at the wrong place. Not quite sure how this Phabricator review works.

For cluster_dims as well as launch_bounds, Brent has requested to take maybe const expressions. He would like to use module parameters, for global routines that are in that module. Neither Michael nor I implemented that in nvfortran.

Is there checks for CUDA Version that some features are allowed for certain CUDA Version?

Is there checks for CUDA Version that some features are allowed for certain CUDA Version?

Not yet.

flang/lib/Semantics/resolve-names.cpp
3551

That's what I implemented -- any expression that can be folded to a constant value at compilation time will work. They don't have to integer literals.

wangzpgi added inline comments.May 12 2023, 9:29 AM
flang/lib/Semantics/resolve-names.cpp
3551

Great. Thanks.

klausler updated this revision to Diff 523552.May 18 2023, 2:07 PM

Rebase to current head.

klausler updated this revision to Diff 526741.May 30 2023, 12:37 PM

Rebasing to current head in preparation for merging.

This revision was automatically updated to reflect the committed changes.