[Openmp-commits] [llvm] [openmp] [WIP] Offload standalone (PR #88957)

via Openmp-commits openmp-commits at lists.llvm.org
Tue Apr 16 15:56:14 PDT 2024


================
@@ -190,33 +206,95 @@ if (LIBOMPTARGET_USE_LTO)
   list(APPEND offload_link_flags ${CMAKE_CXX_COMPILE_OPTIONS_IPO})
 endif()
 
+# Set LIBOMP_HAVE_OMPT_SUPPORT and LIBOMP_HAVE_VERSION_SCRIPT_FLAG using common offload/openmp cmake module.
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../openmp/runtime/cmake")
+include(OffloadOpenmpCommon)
+
 # OMPT support for libomptarget
 # Follow host OMPT support and check if host support has been requested.
 # LIBOMP_HAVE_OMPT_SUPPORT indicates whether host OMPT support has been implemented.
 # LIBOMP_OMPT_SUPPORT indicates whether host OMPT support has been requested (default is ON).
 # LIBOMPTARGET_OMPT_SUPPORT indicates whether target OMPT support has been requested (default is ON).
 set(OMPT_TARGET_DEFAULT FALSE)
-if ((LIBOMP_HAVE_OMPT_SUPPORT) AND (LIBOMP_OMPT_SUPPORT) AND (NOT WIN32))
+if ((LIBOMP_HAVE_OMPT_SUPPORT) AND (NOT WIN32))
   set (OMPT_TARGET_DEFAULT TRUE)
 endif()
 set(LIBOMPTARGET_OMPT_SUPPORT ${OMPT_TARGET_DEFAULT} CACHE BOOL "OMPT-target-support?")
-if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT))
+if (LIBOMPTARGET_OMPT_SUPPORT)
   add_definitions(-DOMPT_SUPPORT=1)
   message(STATUS "OMPT target enabled")
 else()
   set(LIBOMPTARGET_OMPT_SUPPORT FALSE)
   message(STATUS "OMPT target disabled")
 endif()
 
+include_directories(include)
+
+macro(pythonize_bool var)
+  if (${var})
+    set(${var} True)
+  else()
+    set(${var} False)
+  endif()
+endmacro()
+
 pythonize_bool(LIBOMPTARGET_OMPT_SUPPORT)
 
 set(LIBOMPTARGET_GPU_LIBC_SUPPORT ${LLVM_LIBC_GPU_BUILD} CACHE BOOL
     "Libomptarget support for the GPU libc")
 pythonize_bool(LIBOMPTARGET_GPU_LIBC_SUPPORT)
 
 set(LIBOMPTARGET_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
-message(STATUS "OpenMP tools dir in libomptarget: ${LIBOMP_OMP_TOOLS_INCLUDE_DIR}")
-include_directories(${LIBOMP_OMP_TOOLS_INCLUDE_DIR})
+
+find_path (
+  LIBOMP_OMP_TOOLS_INCLUDE_DIR
+  NAMES
+    omp-tools.h
+  PATHS
+    ${CMAKE_BINARY_DIR}/openmp/runtime/src
+    ${CMAKE_BINARY_DIR}/runtime/src
+  )
+
+if(OPENMP_STANDALONE_BUILD)
+  find_library (
+    LIBOMP_STANDALONE
+    NAMES
+      omp
+    HINTS
+      ${CMAKE_BINARY_DIR}/../openmp/runtime/src
+      ${CMAKE_BINARY_DIR}/../../openmp/runtime/src
+      ${LLVM_SRC}/../openmp/runtime/src
+    REQUIRED
+  )
+endif()
+include_directories(${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMP_OMP_TOOLS_INCLUDE_DIR})
+
+# Various LLVM_TOOLS are needed to build libomptarget
----------------
estewart08 wrote:

Yeah this code below should not be necessary.

https://github.com/llvm/llvm-project/pull/88957


More information about the Openmp-commits mailing list