[libc-commits] [libc] b20a385 - [libc] Do not run tests on vendor implemented math

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Thu Aug 17 15:23:03 PDT 2023


Author: Joseph Huber
Date: 2023-08-17T17:22:55-05:00
New Revision: b20a385422d8714257cda7fba7b52ac09fb30b2d

URL: https://github.com/llvm/llvm-project/commit/b20a385422d8714257cda7fba7b52ac09fb30b2d
DIFF: https://github.com/llvm/llvm-project/commit/b20a385422d8714257cda7fba7b52ac09fb30b2d.diff

LOG: [libc] Do not run tests on vendor implemented math

We currently remap vendor implementations of math functions to provide a
temporarily functional `libm.a` for the GPU. However, we should not run
tests on any files that depend on these vendor implementations as they
are not under our control and are not always present.

The goal in the future is to remove the need for this by replacing all
the vendor functionality, but for now this is a workaround.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D158213

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCLibraryRules.cmake
    libc/cmake/modules/LLVMLibCObjectRules.cmake
    libc/cmake/modules/LLVMLibCTestRules.cmake
    libc/src/math/CMakeLists.txt
    libc/src/math/gpu/CMakeLists.txt
    libc/src/math/gpu/vendor/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
index 70b2babfb84ccf..3fe93e0e00b89d 100644
--- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake
+++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
@@ -75,7 +75,9 @@ function(add_entrypoint_library target_name)
   set(all_deps "")
   foreach(dep IN LISTS fq_deps_list)
     get_target_property(dep_type ${dep} "TARGET_TYPE")
-    if(NOT ((${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE}) OR (${dep_type} STREQUAL ${ENTRYPOINT_EXT_TARGET_TYPE})))
+    if(NOT ((${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE}) OR
+            (${dep_type} STREQUAL ${ENTRYPOINT_EXT_TARGET_TYPE}) OR
+            (${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})))
       message(FATAL_ERROR "Dependency '${dep}' of 'add_entrypoint_collection' is "
                           "not an 'add_entrypoint_object' or 'add_entrypoint_external' target.")
     endif()

diff  --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 49d7b94c43fbef..1742bd92f3fcd7 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -492,6 +492,7 @@ function(add_object_library target_name)
 endfunction(add_object_library)
 
 set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
+set(ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE "ENTRYPOINT_OBJ_VENDOR")
 
 # A rule for entrypoint object targets.
 # Usage:
@@ -509,12 +510,20 @@ set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
 function(create_entrypoint_object fq_target_name)
   cmake_parse_arguments(
     "ADD_ENTRYPOINT_OBJ"
-    "ALIAS;REDIRECTED" # Optional argument
+    "ALIAS;REDIRECTED;VENDOR" # Optional argument
     "NAME;CXX_STANDARD" # Single value arguments
     "SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;FLAGS"  # Multi value arguments
     ${ARGN}
   )
 
+  set(entrypoint_target_type ${ENTRYPOINT_OBJ_TARGET_TYPE})
+  if(${ADD_ENTRYPOINT_OBJ_VENDOR})
+    # TODO: We currently rely on external definitions of certain math functions
+    # provided by GPU vendors like AMD or Nvidia. We need to mark these so we
+    # don't end up running tests on these. In the future all of these should be
+    # implemented and this can be removed.
+    set(entrypoint_target_type ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})
+  endif()
   list(FIND TARGET_ENTRYPOINT_NAME_LIST ${ADD_ENTRYPOINT_OBJ_NAME} entrypoint_name_index)
   if(${entrypoint_name_index} EQUAL -1)
     add_custom_target(${fq_target_name})
@@ -522,7 +531,7 @@ function(create_entrypoint_object fq_target_name)
       ${fq_target_name}
       PROPERTIES
         "ENTRYPOINT_NAME" ${ADD_ENTRYPOINT_OBJ_NAME}
-        "TARGET_TYPE" ${ENTRYPOINT_OBJ_TARGET_TYPE}
+        "TARGET_TYPE" ${entrypoint_target_type}
         "OBJECT_FILE" ""
         "OBJECT_FILE_RAW" ""
         "DEPS" ""
@@ -556,7 +565,8 @@ function(create_entrypoint_object fq_target_name)
     endif()
 
     get_target_property(obj_type ${fq_dep_name} "TARGET_TYPE")
-    if((NOT obj_type) OR (NOT (${obj_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE})))
+    if((NOT obj_type) OR (NOT (${obj_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE} OR
+                               ${obj_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})))
       message(FATAL_ERROR "The aliasee of an entrypoint alias should be an entrypoint.")
     endif()
 
@@ -568,7 +578,7 @@ function(create_entrypoint_object fq_target_name)
       ${fq_target_name}
       PROPERTIES
         ENTRYPOINT_NAME ${ADD_ENTRYPOINT_OBJ_NAME}
-        TARGET_TYPE ${ENTRYPOINT_OBJ_TARGET_TYPE}
+        TARGET_TYPE ${entrypoint_target_type}
         IS_ALIAS "YES"
         OBJECT_FILE ""
         OBJECT_FILE_RAW ""

diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 59c2ac99c7b66f..ee1ac7ff819e15 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -43,6 +43,10 @@ function(get_object_files_for_test result skipped_entrypoints_list)
       if(object_file_raw)
         list(APPEND object_files ${object_file_raw})
       endif()
+    elseif(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE})
+      # We skip tests for all externally implemented entrypoints.
+      list(APPEND skipped_list ${dep})
+      continue()
     endif()
 
     get_target_property(indirect_deps ${dep} "DEPS")

diff  --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 5054fd76bcb838..74ee2acb90287a 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -27,6 +27,7 @@ function(add_math_entrypoint_object name)
       ALIAS
       DEPENDS
         .${LIBC_TARGET_ARCHITECTURE}.vendor.${name}
+      VENDOR
     )
     return()
   endif()

diff  --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt
index 37e9329eb5ac16..a23f660261571b 100644
--- a/libc/src/math/gpu/CMakeLists.txt
+++ b/libc/src/math/gpu/CMakeLists.txt
@@ -431,4 +431,4 @@ add_math_entrypoint_gpu_object(
     ../truncf.h
   COMPILE_OPTIONS
     -O2
-)
\ No newline at end of file
+)

diff  --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt
index 9a9d538d3dde04..a528641a3501b6 100644
--- a/libc/src/math/gpu/vendor/CMakeLists.txt
+++ b/libc/src/math/gpu/vendor/CMakeLists.txt
@@ -467,4 +467,4 @@ add_entrypoint_object(
   COMPILE_OPTIONS
     ${bitcode_link_flags}
     -O2
-)
\ No newline at end of file
+)


        


More information about the libc-commits mailing list