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

Rename AMD GPU architectures #6266

Merged
merged 2 commits into from
Aug 9, 2023
Merged

Rename AMD GPU architectures #6266

merged 2 commits into from
Aug 9, 2023

Conversation

Rombur
Copy link
Member

@Rombur Rombur commented Jul 6, 2023

This is a proposal to rename the AMD architectures in Kokkos. Currently to enable an AMD GPU we need to use names like Kokkos_ARCH_VEGA90A, i.e. VEGA + the GFX flag or NAVI + the GFX flag. This works pretty well for the NAVI cards but it's terrible for the VEGA cards. The code name Vega corresponds to the MI50/60 cards. The code name for MI100 is Arcturus and the code name for the MI200 series is Aldebaran. Every year the Vega name becomes more and more obsolete, so we need a new name. At first, I was thinking about using MI50, MI100, etc. The problem is that an MI50 and an MI60 are identical from our point of view. There is a similar issue with the MI200 series. CMake also has support for AMD GPU and they simply use GFX90A. We could mimic what they are doing and use Kokkos_ARCH_GFX90A. I don't find it obvious that we are compiling for an AMD gpu. Instead, inspired by what we are doing for Intel, I propose that we use Kokkos_ARCH_AMD_GFX90A. This makes it clear that we are using an AMD GPU and the GFX flag matches what we are giving to the compiler. I also propose to drop our VEGA and NAVI macros that were rarely used and instead introduce an AMD_GPU macro similar to what we do for Intel. Users can keep using the current names but new GPU will only support the new naming conventions.

This PR is a draft until we agree on the new naming convention.

Still missing in the PR: setting Kokkos_ARCH_AMD_GFX90A should define both KOKKOS_ARCH_AMD_GFX90A and KOKKOS_ARCH_VEGA90A and vice versa.

cc: @arghdos

Copy link
Contributor

@skyreflectedinmirrors skyreflectedinmirrors left a comment

Choose a reason for hiding this comment

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

I agree with the change, and I think the arch name works well (and is more descriptive than what we currently have)

Makefile.kokkos Outdated
@@ -13,7 +13,7 @@ KOKKOS_DEVICES ?= "Threads"
# NVIDIA: Kepler,Kepler30,Kepler32,Kepler35,Kepler37,Maxwell,Maxwell50,Maxwell52,Maxwell53,Pascal60,Pascal61,Volta70,Volta72,Turing75,Ampere80,Ampere86,Ada89,Hopper90
# ARM: ARMv80,ARMv81,ARMv8-ThunderX,ARMv8-TX2,A64FX
# IBM: BGQ,Power7,Power8,Power9
# AMD-GPUS: Vega906,Vega908,Vega90A,Navi1030
# AMD-GPUS: Gfx906,Gfx908,Gfx90A,Gfx1030
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for these to not be fully capitalized? I guess the rest in the list here aren't, but AFAICT this is the only case where they're not.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, I'll change this.

@ldh4
Copy link
Contributor

ldh4 commented Jul 12, 2023

Will this change break any existing build scripts if a user had manually specified a kokkos arch (i.e. -DKokkos_ARCH_VEGA906) in their cmake scripts?

@Rombur
Copy link
Member Author

Rombur commented Jul 12, 2023

No this will be backward compatible once I fix the export of the macros.

@nmm0
Copy link
Contributor

nmm0 commented Jul 12, 2023

Per the meeting, this will need the docs updated. @dalg24 suggested to put a * next to the old names, and have code names/easily searchable values

@Rombur Rombur force-pushed the renaming_vega branch 3 times, most recently from 3fa8a0b to ce1d065 Compare July 14, 2023 15:39
Comment on lines +1078 to 1103
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX906), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX906")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx906
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_VEGA908), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA908")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA")
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX908), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX908")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx908
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_VEGA90A), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA90A")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA")
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX90A), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX90A")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx90a
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_NAVI1030), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_NAVI1030")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_NAVI")
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX1030), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX1030")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx1030
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_NAVI1100), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_NAVI1100")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_NAVI")
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX1100), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX1100")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx1100
endif
Copy link
Contributor

Choose a reason for hiding this comment

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

This means we don't set the old macros anymore when using Makefiles but we do for CMake? Shouldn't we be consistent?

Copy link
Member Author

Choose a reason for hiding this comment

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

One more reason to switch to cmake

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Do you plan any replacement for the VEGA and NAVI macros (regroup family of similar architectures)

#cmakedefine KOKKOS_ARCH_AMD_GFX90A
#cmakedefine KOKKOS_ARCH_AMD_GFX1030
#cmakedefine KOKKOS_ARCH_AMD_GFX1100
#cmakedefine KOKKOS_ARCH_AMD_GPU
Copy link
Member

Choose a reason for hiding this comment

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

The NVIDIA equivalent macro is an impl only (KOKKOS_IMPL_ARCH_NVIDIA_GPU)
while we have KOKKOS_ARCH_INTEL_GPU.
Please confirm you don't want it to be KOKKOS_IMPL_ARCH_AMD_GPU and if so explain why in a few words.

Copy link
Member

Choose a reason for hiding this comment

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

not sure that there is a good consistent value to be set for AMD which actually implies growing capability?

Copy link
Member Author

Choose a reason for hiding this comment

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

Please confirm you don't want it to be KOKKOS_IMPL_ARCH_AMD_GPU and if so explain why in a few words.

My idea was to have a macro for user to do sanity check or to use in their code if they want to do something special on AMD GPU.

not sure that there is a good consistent value to be set for AMD which actually implies growing capability?

No, I don't think so.

Copy link
Contributor

Choose a reason for hiding this comment

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

The gfxarch ID does at least indicate a card's capabilities as according to the compiler: https://llvm.org/docs/AMDGPUUsage.html#processors, though I agree that it won't necessarily align to 'growing capabilities'.

Edit: note that most of these are things a user code does not have to care about, with the large exception of Wave32 vs Wave64

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add // deprecated on the old macros

@Rombur
Copy link
Member Author

Rombur commented Jul 17, 2023

Do you plan any replacement for the VEGA and NAVI macros ?

No I don't. Right now, the difference between VEGA and NAVI is that VEGA is using a wave front of 64 and NAVI use 32. However on some NAVI architectures, you can switch the wavefront to use 64. The current division VEGA/NAVI does not make sense and I don't feel confident introducing a new 32/64 wavefront macro, since we don't have any NAVI hardware to test the different configurations.

@skyreflectedinmirrors
Copy link
Contributor

Do you plan any replacement for the VEGA and NAVI macros ?

No I don't. Right now, the difference between VEGA and NAVI is that VEGA is using a wave front of 64 and NAVI use 32. However on some NAVI architectures, you can switch the wavefront to use 64. The current division VEGA/NAVI does not make sense and I don't feel confident introducing a new 32/64 wavefront macro, since we don't have any NAVI hardware to test the different configurations.

I'm also a bit dubious of Wave64 support on Navi. Yes, it's supposed to work, but...

Copy link
Member

Choose a reason for hiding this comment

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

@stanmoore1 make sure you see this

We might need to be more cautious with that change.
Although I tend to agree with Bruno's sentiment https://github.com/kokkos/kokkos/pull/6266/files#r1263934282 but we need to protect downstream users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the note. Maintaining backwards compatibility for Makefiles would be nice, or at least put it into a deprecation cycle.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the note. Maintaining backwards compatibility for Makefiles would be nice, or at least put it into a deprecation cycle.

The HIP old architecture names or the whole makefiles shenanigans?

Copy link
Member

Choose a reason for hiding this comment

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

Clarification, what changes is not the configuration keyword, these we will continue to honor.
In the current form of the PR we would not define the KOKKOS_ARCH_VEGA* macros which Bruno actually looked for in LAMMPS and they are not used.

Sorry about the confusion.

KOKKOS_INTERNAL_USE_ARCH_VEGA908 := $(call kokkos_has_string,$(KOKKOS_ARCH),Vega908)
KOKKOS_INTERNAL_USE_ARCH_VEGA90A := $(call kokkos_has_string,$(KOKKOS_ARCH),Vega90A)
KOKKOS_INTERNAL_USE_ARCH_NAVI1030 := $(call kokkos_has_string,$(KOKKOS_ARCH),Navi1030)
KOKKOS_INTERNAL_USE_ARCH_AMD_GFX906 := $(or $(call kokkos_has_string,$(KOKKOS_ARCH),VEGA906),$(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX906))
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to change the case? Vega906 -> VEGA906

Copy link
Member

Choose a reason for hiding this comment

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

This needs fixing though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change it back but it makes no difference because kokkos_has_string converts the lower case to upper case.

@Rombur
Copy link
Member Author

Rombur commented Jul 24, 2023

There is a problem with the architecture auto-detection. I am working on fixing the issue.

@Rombur
Copy link
Member Author

Rombur commented Jul 24, 2023

It should be good now. I just had to move function to a different place. I also updated the OpenACC and OpenMPTarget backends to use the new macros.

@Rombur
Copy link
Member Author

Rombur commented Aug 2, 2023

Can we get this merged? I think @arghdos is waiting on this to be merged before creating a PR for MI300

@crtrott crtrott merged commit 7e91f11 into kokkos:develop Aug 9, 2023
26 of 28 checks passed
@Rombur Rombur mentioned this pull request Jul 21, 2023
@Rombur Rombur deleted the renaming_vega branch September 7, 2023 15:51
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.

None yet

8 participants