Skip to content

Commit ba2c3c7

Browse files
atmyersEZonidpgrote
authored
CI: Upgrade HIP Workflows, Fix New Bug (#5707)
- [x] Update HIP CI workflow to run on Ubuntu 24.04 - [x] Add HIP version to CLI, default 6.3.2 - [x] Fix bug caused by using `std::optional` on device --------- Co-authored-by: Edoardo Zoni <ezoni@lbl.gov> Co-authored-by: David Grote <grote1@llnl.gov>
1 parent 716d7cb commit ba2c3c7

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

.github/workflows/dependencies/hip.sh

+13-12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ sudo apt-key add rocm.gpg.key
2828

2929
source /etc/os-release # set UBUNTU_CODENAME: focal or jammy or ...
3030

31-
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${1-latest} ${UBUNTU_CODENAME} main" \
31+
VERSION=${1-6.3.2}
32+
33+
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${VERSION} ${UBUNTU_CODENAME} main" \
3234
| sudo tee /etc/apt/sources.list.d/rocm.list
3335
echo 'export PATH=/opt/rocm/llvm/bin:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin:$PATH' \
3436
| sudo tee -a /etc/profile.d/rocm.sh
@@ -50,12 +52,16 @@ sudo apt-get install -y --no-install-recommends \
5052
libzstd-dev \
5153
ninja-build \
5254
openmpi-bin \
53-
rocm-dev \
54-
rocfft-dev \
55-
rocprim-dev \
56-
rocsparse-dev \
57-
rocrand-dev \
58-
hiprand-dev
55+
rocm-dev${VERSION} \
56+
roctracer-dev${VERSION} \
57+
rocprofiler-dev${VERSION} \
58+
rocrand-dev${VERSION} \
59+
rocfft-dev${VERSION} \
60+
rocprim-dev${VERSION} \
61+
rocsparse-dev${VERSION}
62+
63+
# hiprand-dev is a new package that does not exist in old versions
64+
sudo apt-get install -y --no-install-recommends hiprand-dev${VERSION} || true
5965

6066
# ccache
6167
$(dirname "$0")/ccache.sh
@@ -69,11 +75,6 @@ which clang++
6975
export CXX=$(which clang++)
7076
export CC=$(which clang)
7177

72-
# "mpic++ --showme" forgets open-pal in Ubuntu 20.04 + OpenMPI 4.0.3
73-
# https://bugs.launchpad.net/ubuntu/+source/openmpi/+bug/1941786
74-
# https://github.com/open-mpi/ompi/issues/9317
75-
export LDFLAGS="-lopen-pal"
76-
7778
# cmake-easyinstall
7879
#
7980
sudo curl -L -o /usr/local/bin/cmake-easyinstall https://raw.githubusercontent.com/ax3l/cmake-easyinstall/main/cmake-easyinstall

.github/workflows/hip.yml

+4-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
jobs:
1717
build_hip_3d_sp:
1818
name: HIP 3D SP
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-24.04
2020
env:
2121
CXXFLAGS: "-Werror -Wno-deprecated-declarations -Wno-error=pass-failed"
2222
CMAKE_GENERATOR: Ninja
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v4
2626
- name: install dependencies
2727
shell: bash
28-
run: .github/workflows/dependencies/hip.sh
28+
run: .github/workflows/dependencies/hip.sh 6.3.2
2929
- name: CCache Cache
3030
uses: actions/cache@v4
3131
with:
@@ -48,11 +48,6 @@ jobs:
4848
export CXX=$(which clang++)
4949
export CC=$(which clang)
5050
51-
# "mpic++ --showme" forgets open-pal in Ubuntu 20.04 + OpenMPI 4.0.3
52-
# https://bugs.launchpad.net/ubuntu/+source/openmpi/+bug/1941786
53-
# https://github.com/open-mpi/ompi/issues/9317
54-
export LDFLAGS="-lopen-pal"
55-
5651
cmake -S . -B build_sp \
5752
-DCMAKE_VERBOSE_MAKEFILE=ON \
5853
-DAMReX_AMD_ARCH=gfx900 \
@@ -75,7 +70,7 @@ jobs:
7570
7671
build_hip_2d_dp:
7772
name: HIP 2D DP
78-
runs-on: ubuntu-20.04
73+
runs-on: ubuntu-24.04
7974
env:
8075
CXXFLAGS: "-Werror -Wno-deprecated-declarations -Wno-error=pass-failed"
8176
CMAKE_GENERATOR: Ninja
@@ -84,7 +79,7 @@ jobs:
8479
- uses: actions/checkout@v4
8580
- name: install dependencies
8681
shell: bash
87-
run: .github/workflows/dependencies/hip.sh
82+
run: .github/workflows/dependencies/hip.sh 6.3.2
8883
- name: CCache Cache
8984
uses: actions/cache@v4
9085
with:
@@ -107,11 +102,6 @@ jobs:
107102
export CXX=$(which clang++)
108103
export CC=$(which clang)
109104
110-
# "mpic++ --showme" forgets open-pal in Ubuntu 20.04 + OpenMPI 4.0.3
111-
# https://bugs.launchpad.net/ubuntu/+source/openmpi/+bug/1941786
112-
# https://github.com/open-mpi/ompi/issues/9317
113-
export LDFLAGS="-lopen-pal"
114-
115105
cmake -S . -B build_2d \
116106
-DCMAKE_VERBOSE_MAKEFILE=ON \
117107
-DAMReX_AMD_ARCH=gfx900 \

Source/AcceleratorLattice/LatticeElementFinder.H

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ struct LatticeElementFinderDevice
114114
AcceleratorLattice const& accelerator_lattice,
115115
LatticeElementFinder const & h_finder);
116116

117+
/* Whether the class has been initialized */
118+
bool m_initialized = false;
119+
117120
/* Size and location of the index lookup table */
118121
amrex::Real m_zmin;
119122
amrex::Real m_dz;

Source/AcceleratorLattice/LatticeElementFinder.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ LatticeElementFinderDevice::InitLatticeElementFinderDevice (WarpXParIter const&
9292
LatticeElementFinder const & h_finder)
9393
{
9494

95+
m_initialized = true;
96+
9597
auto& warpx = WarpX::GetInstance();
9698

9799
int const lev = a_pti.GetLevel();

Source/Particles/Gather/GetExternalFields.H

+5-8
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <AMReX_Parser.H>
1616
#include <AMReX_REAL.H>
1717

18-
#include <optional>
19-
2018

2119
/** \brief Functor class that assigns external
2220
* field values (E and B) to particles.
@@ -56,10 +54,10 @@ struct GetExternalEBField
5654
const amrex::ParticleReal* AMREX_RESTRICT m_uy = nullptr;
5755
const amrex::ParticleReal* AMREX_RESTRICT m_uz = nullptr;
5856

59-
std::optional<LatticeElementFinderDevice> d_lattice_element_finder;
57+
LatticeElementFinderDevice d_lattice_element_finder;
6058

6159
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
62-
bool isNoOp () const { return (m_Etype == None && m_Btype == None && !d_lattice_element_finder.has_value()); }
60+
bool isNoOp () const { return (m_Etype == None && m_Btype == None && !d_lattice_element_finder.m_initialized); }
6361

6462
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
6563
void operator () (long i,
@@ -72,10 +70,9 @@ struct GetExternalEBField
7270
{
7371
using namespace amrex::literals;
7472

75-
if (d_lattice_element_finder) {
76-
// Note that the "*" is needed since d_lattice_element_finder is optional
77-
(*d_lattice_element_finder)(i, field_Ex, field_Ey, field_Ez,
78-
field_Bx, field_By, field_Bz);
73+
if (d_lattice_element_finder.m_initialized) {
74+
d_lattice_element_finder(i, field_Ex, field_Ey, field_Ez,
75+
field_Bx, field_By, field_Bz);
7976
}
8077

8178
if (m_Etype == None && m_Btype == None) { return; }

0 commit comments

Comments
 (0)