|
3 | 3 | # See LICENSE.TXT |
4 | 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
5 | 5 |
|
| 6 | +if(NOT "${AMD_ARCH}" STREQUAL "" AND "${UR_CONFORMANCE_AMD_ARCH}" STREQUAL "") |
| 7 | + message(WARNING "Passing the HIP target architecture with AMD_ARCH is deprecated. " |
| 8 | + "Please use UR_CONFORMANCE_AMD_ARCH instead.") |
| 9 | +else() |
| 10 | + set(AMD_ARCH "${UR_CONFORMANCE_AMD_ARCH}") |
| 11 | +endif() |
| 12 | + |
| 13 | +if("${AMD_ARCH}" STREQUAL "" AND "${TARGET_TRIPLES}" MATCHES "amd") |
| 14 | + find_package(RocmAgentEnumerator) |
| 15 | + if(NOT ROCM_AGENT_ENUMERATOR_FOUND) |
| 16 | + message(FATAL_ERROR |
| 17 | + "rocm_agent_enumerator could not be found so detecting target " |
| 18 | + "HIP device has failed. Set target device with UR_CONFORMANCE_AMD_ARCH " |
| 19 | + "or ensure rocm_agent_enumerator is available on the PATH.") |
| 20 | + endif() |
| 21 | + execute_process(COMMAND ${ROCM_AGENT_ENUMERATOR} OUTPUT_VARIABLE ROCM_AGENTS) |
| 22 | + string(REGEX MATCHALL "[A-Za-z0-9]+" ROCM_AGENT_LIST "${ROCM_AGENTS}") |
| 23 | + # rocm_agent_enumerator will return gfx000 to represent non-amd-gpu devices, |
| 24 | + # we should skip over these |
| 25 | + list(GET ROCM_AGENT_LIST 0 FIRST_ROCM_AGENT) |
| 26 | + if("${FIRST_ROCM_AGENT}" STREQUAL "gfx000") |
| 27 | + list(POP_FRONT ROCM_AGENT_LIST) |
| 28 | + endif() |
| 29 | + list(LENGTH ROCM_AGENT_LIST NUM_ROCM_AGENTS) |
| 30 | + if(${NUM_ROCM_AGENTS} EQUAL 0) |
| 31 | + message(FATAL_ERROR |
| 32 | + "No target HIP devices detected with rocm_agent_enumerator, " |
| 33 | + "specify a target with the UR_CONFORMANCE_AMD_ARCH variable.") |
| 34 | + elseif(${NUM_ROCM_AGENTS} GREATER 1) |
| 35 | + message(FATAL_ERROR |
| 36 | + "Multiple possible target HIP devices found: ${ROCM_AGENT_LIST} " |
| 37 | + "please specify which target to use by setting UR_CONFORMANCE_AMD_ARCH.") |
| 38 | + endif() |
| 39 | + list(GET ROCM_AGENT_LIST 0 AMD_ARCH) |
| 40 | +endif() |
| 41 | + |
6 | 42 | macro(add_device_binary SOURCE_FILE) |
7 | 43 | get_filename_component(KERNEL_NAME ${SOURCE_FILE} NAME_WE) |
8 | 44 | set(DEVICE_BINARY_DIR "${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/${KERNEL_NAME}") |
|
0 commit comments