[PATCH] D114247: OpenMP: Correctly query location for amdgpu-arch

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 19 07:39:15 PST 2021


arsenm created this revision.
arsenm added reviewers: gregrodgers, JonChesterfield, jdoerfert, pdhaliwal, tianshilei1992, protze.joachim.
Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, mgorny, nhaehnle, jvesely, kzhuravl.
arsenm requested review of this revision.
Herald added subscribers: sstefan1, wdng.

This was trying to figure out the build path for amdgpu-arch, and
making assumptions about where it is which were not working on my
system. Whether a standalone build or not, we should have a proper
imported target to get the location from.


https://reviews.llvm.org/D114247

Files:
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt


Index: openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -98,27 +98,20 @@
   ${LDFLAGS_UNDEFINED}
   )
 
-if (LLVM_BINARY_DIR)
-  # for in-tree build using LLVM_ENABLE_RUNTIMES
-  set(AMDGPU_ARCH_TOOL "${LLVM_BINARY_DIR}/bin/amdgpu-arch")
-elseif (OPENMP_LLVM_TOOLS_DIR)
-  set(AMDGPU_ARCH_TOOL "${OPENMP_LLVM_TOOLS_DIR}/amdgpu-arch")
-else()
-  set(AMDGPU_ARCH_TOOL "amdgpu-arch")
-endif()
-
 # in case of amdgcn, skip running tests if amdgpu-arch was not built or fails
-if (NOT EXISTS "${AMDGPU_ARCH_TOOL}")
+if (NOT TARGET amdgpu-arch)
   libomptarget_say("Not generating amdgcn test targets as amdgpu-arch is not found")
   return()
 endif()
 
-execute_process(COMMAND "${AMDGPU_ARCH_TOOL}" RESULT_VARIABLE amdgpu_arch_result
-  OUTPUT_VARIABLE amdgpu_arch_output)
+get_property(AMDGPU_ARCH_COMMAND TARGET amdgpu-arch PROPERTY LOCATION)
+
+execute_process(COMMAND ${AMDGPU_ARCH_COMMAND} RESULT_VARIABLE amdgpu_arch_result
+                                               OUTPUT_VARIABLE amdgpu_arch_output)
 if (${amdgpu_arch_result})
   libomptarget_say("Not generating amdgcn test targets as amdgpu-arch exited with ${amdgpu_arch_result}")
-  return()
+else()
+  # Report to the parent scope that we are building a plugin for amdgpu
+  set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa" PARENT_SCOPE)
 endif()
 
-# Report to the parent scope that we are building a plugin for amdgpu
-set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa" PARENT_SCOPE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114247.388500.patch
Type: text/x-patch
Size: 1698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/1e5b7fff/attachment.bin>


More information about the llvm-commits mailing list