File: opal_check_rocm.m4

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (72 lines) | stat: -rw-r--r-- 2,427 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
dnl
dnl Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl


# OMPI_CHECK_ROCM(prefix, [action-if-found], [action-if-not-found])
# --------------------------------------------------------
# check if ROCM support can be found.  sets prefix_{CPPFLAGS,
# LDFLAGS, LIBS} as needed and runs action-if-found if there is
# support, otherwise executes action-if-not-found


#
# Check for ROCm  support
#
AC_DEFUN([OPAL_CHECK_ROCM],[

     OPAL_VAR_SCOPE_PUSH([opal_check_rocm_happy rocm_save_CPPFLAGS rocm_save_LDFLAGS rocm_save_LIBS rocm_CPPFLAGS rocm_LDFLAGS rocm_LIBS])

     rocm_save_CPPFLAGS="$CPPFLAGS"
     rocm_save_LDFLAGS="$LDFLAGS"
     rocm_save_LIBS="$LIBS"

     # Get some configuration information
     AC_ARG_WITH([rocm],
        [AS_HELP_STRING([--with-rocm(=DIR)],
        [Build ROCm support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])])


     AS_IF([ test -n "$with_rocm" && test "$with_rocm" = "yes" ],
           [ with_rocm="/opt/rocm"] )

     rocm_CPPFLAGS="-D__HIP_PLATFORM_AMD__"
     rocm_LDFLAGS="-L${with_rocm}/lib/"

     AS_IF([ test -n "$with_rocm" && test "$with_rocm" != "no" ],
           [ OPAL_APPEND([CPPFLAGS], [$rocm_CPPFLAGS])
	     OPAL_APPEND([LDFLAGS], [$rocm_LDFLAGS]) ])

     OAC_CHECK_PACKAGE([rocm],
                       [$1],
                       [hip/hip_runtime.h],
                       [amdhip64],
		       [hipFree],
                       [opal_check_rocm_happy="yes"],
                       [opal_check_rocm_happy="no"])

     LDFLAGS="$rocm_save_LDFLAGS"
     LIBS="$rocm_save_LIBS"
     CPPFLAGS="$rocm_save_CPPFLAGS"

     AS_IF([ test "$opal_check_rocm_happy" = "yes" ],
           [ OPAL_APPEND([$1_CPPFLAGS], [$rocm_CPPFLAGS])
	     AC_DEFINE_UNQUOTED([OPAL_ROCM_SUPPORT], [1], [Enable ROCm support])
             ROCM_SUPPORT=1 ],
           [ AC_DEFINE_UNQUOTED([OPAL_ROCM_SUPPORT], [0], [Disable ROCm support])
             ROCM_SUPPORT=0 ])

     AS_IF([ test "$opal_check_rocm_happy" = "yes" ],
            [$2],
            [AS_IF([test -n "$with_rocm" && test "$with_rocm" != "no"],
                   [AC_MSG_ERROR([ROCm support requested but not found.  Aborting])])
            $3])

     AM_CONDITIONAL([OPAL_rocm_support], [test "$opal_check_rocm_happy" = "yes"])
     OPAL_VAR_SCOPE_POP
])