Skip to content

Need to set OMEGA_ARCH when building as part of E3SM #508

Description

@andrewdnolan

In order to build with GPU support, we need to set the OMEGA_ARCH CMake variable when building as part of E3SM.

There's a TODO comment about this (Line 530) in OmegaBuild.cmake:

# set build-control-variables for e3sm build
macro(setup_e3sm_build)
set(OMEGA_BUILD_TYPE ${E3SM_DEFAULT_BUILD_TYPE})
set(OMEGA_CXX_COMPILER ${CMAKE_CXX_COMPILER})
#TODO: set OMEGA_ARCH according to E3SM variables
set(OMEGA_ARCH "")
set(OMEGA_BUILD_MODE "E3SM")
message(STATUS "OMEGA_CXX_COMPILER = ${OMEGA_CXX_COMPILER}")
endmacro()

When trying to build within e3sm using the craycray-mphipcc compiler on frontier, I would get build errors without adding:

diff --git a/components/omega/OmegaBuild.cmake b/components/omega/OmegaBuild.cmake
index 1474b3e898..db60b98384 100644
--- a/components/omega/OmegaBuild.cmake
+++ b/components/omega/OmegaBuild.cmake
@@ -527,8 +527,25 @@ macro(setup_e3sm_build)
 
   set(OMEGA_CXX_COMPILER ${CMAKE_CXX_COMPILER})
 
-  #TODO: set OMEGA_ARCH according to E3SM variables
-  set(OMEGA_ARCH "")
+  if(NOT DEFINED OMEGA_ARCH OR "${OMEGA_ARCH}" STREQUAL "")
+    if(USE_CUDA)
+      set(OMEGA_ARCH "CUDA")
+
+    elseif(USE_HIP)
+      set(OMEGA_ARCH "HIP")
+
+    elseif(USE_SYCL)
+      set(OMEGA_ARCH "SYCL")
+
+    elseif(compile_threaded)
+      set(OMEGA_ARCH "OPENMP")
+
+    else()
+      set(OMEGA_ARCH "SERIAL")
+
+    endif()
+  endif()
+
   set(OMEGA_BUILD_MODE "E3SM")
 
   message(STATUS "OMEGA_CXX_COMPILER = ${OMEGA_CXX_COMPILER}")
@@ -647,6 +664,10 @@ macro(update_variables)
 
   elseif("${OMEGA_ARCH}" STREQUAL "HIP")
     option(Kokkos_ENABLE_HIP "" ON)
+    # Frontier's MI250X GPUs use the gfx90a/VEGA90A architecture.
+    if("${AMDGPU_TARGETS}" MATCHES "gfx90a" OR "${MACH}" STREQUAL "frontier")
+      option(Kokkos_ARCH_VEGA90A "" ON)
+    endif()
     set(OMEGA_TARGET_DEVICE TRUE)
 
   elseif("${OMEGA_ARCH}" STREQUAL "SYCL")

From looking at eamxx (and EKAT) looks like they have machine specific files cmake files for exactly these variables.

Metadata

Metadata

Assignees

Labels

CMakeCMake-related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions