Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions bin/run_miniQMC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ export AOMP_USE_CCACHE=0
# Control how many OpenMP threads are used by MiniQMCPack
: "${MQMC_OMP_NUM_THREADS:=32}"

if [ -z "$AOMP_GPU" ]; then
echo "Error: Set AOMP_GPU to the target GPU architecture (e.g., gfx90a)"
exit 1
fi

export PATH=$AOMP/bin:$PATH
#export PATH=/home/janplehr/rocm/trunk/bin:$PATH

# We export all these paths, so they will be picked-up in the CMake command.
# For libraries that AOMP provides (hsa-runtime, hip, comgr, device-libs), use AOMP.
Expand All @@ -43,17 +47,23 @@ export rocsolver_DIR=${ROCM}/lib/cmake/rocsolver/
: "${MQMC_BUILD_PREFIX:=$AOMP_REPOS_TEST/miniqmc_build}"
# Set the default build directory name
: "${MQMC_BUILD_DIR:=${MQMC_BUILD_PREFIX}/build_aomp_clang}"
# Path to the miniqmc source directory
: "${MQMC_SOURCE_DIR:=$AOMP_REPOS_TEST/miniqmc_src}"
# how many threads should be used for building miniqmc
: "${MQMC_NUM_BUILD_PROCS:=32}"
# We pin the version by default, so we have only AOMP as moving target
: "${MQMC_GIT_TAG:=9d9d7d3}"

# Path to the miniqmc source directory
: "${MQMC_SOURCE_DIR:=$AOMP_REPOS_TEST/miniqmc_src}"

if [ ! -d "$MQMC_SOURCE_DIR" ]; then
git clone https://github.com/QMCPACK/miniqmc.git "$MQMC_SOURCE_DIR"
git checkout "${MQMC_GIT_TAG}"
git clone https://github.com/ye-luo/miniqmc.git "$MQMC_SOURCE_DIR"
pushd "$MQMC_SOURCE_DIR" || exit
git checkout OMP_offload
popd || exit
else
pushd "$MQMC_SOURCE_DIR" || exit
git pull
popd || exit
fi

rm -rf "${MQMC_BUILD_DIR}"
Expand All @@ -63,8 +73,8 @@ rm -rf "${MQMC_BUILD_DIR}"
cmake -B "${MQMC_BUILD_DIR}" -S "${MQMC_SOURCE_DIR}" \
-DCMAKE_PREFIX_PATH="${AOMP}/lib/cmake;${ROCM}/lib/cmake" \
-DCMAKE_CXX_COMPILER=clang++ \
-DENABLE_OFFLOAD=ON \
-DQMC_ENABLE_ROCM=ON \
-DQMC_GPU="openmp" \
-DQMC_GPU_ARCHS="${AOMP_GPU}" \
-DCMAKE_CXX_FLAGS='-fopenmp-assume-no-nested-parallelism -DCUDART_VERSION=10000 -DcudaMemoryTypeManaged=hipMemoryTypeManaged ' \
-DAMDGPU_DISABLE_HOST_DEVMEM=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON
Expand All @@ -81,13 +91,26 @@ echo "Running Tests"
# Ensure AOMP runtime libraries are found before /opt/rocm libraries to avoid ABI mismatches
export LD_LIBRARY_PATH="${AOMP}/lib:${AOMP}/lib/llvm/lib:${LD_LIBRARY_PATH}"

echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo_batched_reduction -n 10"
OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/check_spo_batched_reduction -n 10
# We intentionally continue running even if some binaries are missing.
if [ ! -f "${MQMC_BUILD_DIR}/bin/check_spo_batched_reduction" ]; then
echo "Error: check_spo_batched_reduction binary not found in ${MQMC_BUILD_DIR}/bin"
else
echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo_batched_reduction -n 10"
OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/check_spo_batched_reduction -n 10
fi

echo ""
echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/miniqmc"
OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/miniqmc -v
if [ ! -f "${MQMC_BUILD_DIR}/bin/miniqmc" ]; then
echo "Error: miniqmc binary not found in ${MQMC_BUILD_DIR}/bin"
else
echo ""
echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/miniqmc"
OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/miniqmc -v
fi

echo ""
echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo -n 10"
OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/check_spo -n 10 -v
if [ ! -f "${MQMC_BUILD_DIR}/bin/check_spo" ]; then
echo "Error: check_spo binary not found in ${MQMC_BUILD_DIR}/bin"
else
echo ""
echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo -n 10"
OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/check_spo -n 10 -v
fi
84 changes: 0 additions & 84 deletions test/fortran-map-tests/UMT-reproducer-6.f90

This file was deleted.

110 changes: 110 additions & 0 deletions test/fortran-map-tests/initialized-common-block-mapping.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
! Copyright © Advanced Micro Devices, Inc., or its affiliates.
!
! SPDX-License-Identifier: MIT

! Common blocks can have a special "edge-case" where they are initialized
! common blocks, which basically just means we give them some values on
! initialize. This, however, means the LLVM-IR for a common block is actually
! generated differently, the common block goes from a byte array into a typed
! tuple, so we need to be sure this still lowers and handles fine.

block data init_blocks
implicit none

integer :: var_a
real :: var_b(5)
common /cblock_a/ var_a, var_b

integer :: var_c
real :: var_d(5)
common /cblock_b/ var_c, var_d

data var_a / 100 /
data var_b / 1.0, 2.0, 3.0, 4.0, 5.0 /

data var_c / 200 /
data var_d / 10.0, 20.0, 30.0, 40.0, 50.0 /

end block data

program prog_a
implicit none

integer :: var_a
real :: var_b(5)
common /cblock_a/ var_a, var_b
!$omp declare target link(/cblock_a/)

integer :: var_c
real :: var_d(5)
common /cblock_b/ var_c, var_d

integer :: i

print *, "=== Initial values (before target region) ==="
print *, ""
print *, "cblock_a (with declare target link):"
print *, " var_a =", var_a
print *, " var_b =", var_b
print *, ""
print *, "cblock_b (without declare target):"
print *, " var_c =", var_c
print *, " var_d =", var_d
print *, ""

!$omp target map(tofrom: /cblock_a/, /cblock_b/)
var_a = var_a + 1000
do i = 1, 5
var_b(i) = var_b(i) * 2.0
end do

var_c = var_c + 2000
do i = 1, 5
var_d(i) = var_d(i) * 3.0
end do
!$omp end target

print *, "=== Final values (after target region) ==="
print *, ""
print *, "cblock_a (with declare target link):"
print *, " var_a =", var_a
print *, " var_b =", var_b
print *, ""
print *, "cblock_b (without declare target):"
print *, " var_c =", var_c
print *, " var_d =", var_d
print *, ""

print *, "=== Validating results ==="

if (var_a /= 1100) then
print *, "FAILED: var_a expected 1100, got", var_a
print *, "======= FORTRAN Test Failed! ======="
stop 1
end if

if (var_b(1) /= 2.0 .or. var_b(2) /= 4.0 .or. &
var_b(3) /= 6.0 .or. var_b(4) /= 8.0 .or. &
var_b(5) /= 10.0) then
print *, "FAILED: var_b expected [2.0, 4.0, 6.0, 8.0, 10.0], got", var_b
print *, "======= FORTRAN Test Failed! ======="
stop 1
end if

if (var_c /= 2200) then
print *, "FAILED: var_c expected 2200, got", var_c
print *, "======= FORTRAN Test Failed! ======="
stop 1
end if

if (var_d(1) /= 30.0 .or. var_d(2) /= 60.0 .or. &
var_d(3) /= 90.0 .or. var_d(4) /= 120.0 .or. &
var_d(5) /= 150.0) then
print *, "FAILED: var_d expected [30.0, 60.0, 90.0, 120.0, 150.0], got", var_d
print *, "======= FORTRAN Test Failed! ======="
stop 1
end if

print *, "======= FORTRAN Test Passed! ======="

end program prog_a
44 changes: 44 additions & 0 deletions test/fortran-map-tests/size-zero-presence-check.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
! Copyright © Advanced Micro Devices, Inc., or its affiliates.
!
! SPDX-License-Identifier: MIT

program prog_a
implicit none
integer :: var_a
integer :: var_b
real, allocatable :: var_c(:)
integer :: var_d

var_a = 10
var_b = 9

! Make it size 0, the main purpose of this test is to make sure
! the presence check on a size 0 array returns true and lets us
! pass to the end of the program.
allocate(var_c(var_a:var_b))

do var_d = var_a, var_b
var_c(var_d) = real(var_d)
end do

!$omp target enter data map(to: var_c)

!$omp target teams distribute parallel do map(present,alloc: var_c)
do var_d = var_a, var_b
var_c(var_d) = var_c(var_d) * 2.0
end do
!$omp end target teams distribute parallel do

!$omp target exit data map(from: var_c)

do var_d = var_a, var_b
if (var_c(var_d) /= real(var_d) * 2.0) then
print *, "======= FORTRAN Test Failed! ======="
stop 1
end if
end do

deallocate(var_c)

print*, "======= FORTRAN Test Passed! ======="
end program
Loading
Loading