|
| 1 | +dnl |
| 2 | +dnl Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved. |
| 3 | +dnl $COPYRIGHT$ |
| 4 | +dnl |
| 5 | +dnl Additional copyrights may follow |
| 6 | +dnl |
| 7 | +dnl $HEADER$ |
| 8 | +dnl |
| 9 | + |
| 10 | + |
| 11 | +# OMPI_CHECK_ROCM(prefix, [action-if-found], [action-if-not-found]) |
| 12 | +# -------------------------------------------------------- |
| 13 | +# check if ROCM support can be found. sets prefix_{CPPFLAGS, |
| 14 | +# LDFLAGS, LIBS} as needed and runs action-if-found if there is |
| 15 | +# support, otherwise executes action-if-not-found |
| 16 | + |
| 17 | + |
| 18 | +# |
| 19 | +# Check for ROCm support |
| 20 | +# |
| 21 | +AC_DEFUN([OPAL_CHECK_ROCM],[ |
| 22 | +
|
| 23 | + OPAL_VAR_SCOPE_PUSH([opal_check_rocm_happy rocm_save_CPPFLAGS rocm_save_LDFLAGS rocm_CPPFLAGS rocm_LDFLAGS]) |
| 24 | +
|
| 25 | + rocm_save_CPPFLAGS="$CPPFLAGS" |
| 26 | + rocm_save_LDFLAGS="$LDFLAGS" |
| 27 | + |
| 28 | + # Get some configuration information |
| 29 | + AC_ARG_WITH([rocm], |
| 30 | + [AS_HELP_STRING([--with-rocm(=DIR)], |
| 31 | + [Build ROCm support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])]) |
| 32 | +
|
| 33 | +
|
| 34 | + AS_IF([ test -n "$with_rocm" && test "$with_rocm" = "yes" ], |
| 35 | + [ with_rocm="/opt/rocm"] ) |
| 36 | +
|
| 37 | + rocm_CPPFLAGS="-D__HIP_PLATFORM_AMD__" |
| 38 | + rocm_LDFLAGS="-L${with_rocm}/lib/hip" |
| 39 | +
|
| 40 | + AS_IF([ test -n "$with_rocm" && test "$with_rocm" != "no" ], |
| 41 | + [ OPAL_APPEND([CPPFLAGS], [$rocm_CPPFLAGS]) |
| 42 | + OPAL_APPEND([LDFLAGS], [$rocm_LDFLAGS]) ]) |
| 43 | +
|
| 44 | + OAC_CHECK_PACKAGE([rocm], |
| 45 | + [$1], |
| 46 | + [hip/hip_runtime.h], |
| 47 | + [amdhip64], |
| 48 | + [hipFree], |
| 49 | + [opal_check_rocm_happy="yes"], |
| 50 | + [opal_check_rocm_happy="no"]) |
| 51 | +
|
| 52 | + LDFLAGS="$rocm_save_LDFLAGS" |
| 53 | + OPAL_APPEND([CPPFLAGS], [${$1_CPPFLAGS}] ) |
| 54 | + |
| 55 | + AS_IF([ test "$opal_check_rocm_happy" = "no" ], |
| 56 | + [ CPPFLAGS="$rocm_save_CPPFLAGS"]) |
| 57 | +
|
| 58 | + AS_IF([ test "$opal_check_rocm_happy" = "yes" ], |
| 59 | + [ AC_DEFINE_UNQUOTED([OPAL_ROCM_SUPPORT], [1], [Enable ROCm support]) |
| 60 | + ROCM_SUPPORT=1 ], |
| 61 | + [ AC_DEFINE_UNQUOTED([OPAL_ROCM_SUPPORT], [0], [Disable ROCm support]) |
| 62 | + ROCM_SUPPORT=0 ]) |
| 63 | +
|
| 64 | + AS_IF([ test "$opal_check_rocm_happy" = "yes" ], |
| 65 | + [$2], |
| 66 | + [AS_IF([test -n "$with_rocm" && test "$with_rocm" != "no"], |
| 67 | + [AC_MSG_ERROR([ROCm support requested but not found. Aborting])]) |
| 68 | + $3]) |
| 69 | +
|
| 70 | + AM_CONDITIONAL([OPAL_rocm_support], [test "$opal_check_rocm_happy" = "yes"]) |
| 71 | + OPAL_VAR_SCOPE_POP |
| 72 | +]) |
| 73 | + |
| 74 | +AC_DEFUN([OPAL_CHECK_ROCM_AFTER_OPAL_DL],[ |
| 75 | + # We cannot have ROCm support without OPAL DL support. Error out |
| 76 | + # if the user wants Rocm but we do not have OPAL DL support. |
| 77 | + AS_IF([test $OPAL_HAVE_DL_SUPPORT -eq 0 && test "$opal_check_rocm_happy" = "yes"], |
| 78 | + [AC_MSG_WARN([--with-rocm was specified, but dlopen support is disabled.]) |
| 79 | + AC_MSG_WARN([You must reconfigure Open MPI with dlopen ("dl") support.]) |
| 80 | + AC_MSG_ERROR([Cannot continue.])]) |
| 81 | +
|
| 82 | +]) |
0 commit comments