[libc-commits] [PATCH] D149517: [libc] Enable running libc unit tests on AMDGPU

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Apr 29 07:36:20 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: sivachandra, lntue, michaelrj, jdoerfert, tianshilei1992, JonChesterfield.
Herald added subscribers: libc-commits, kosarev, ecnelises, tschuett, tpr, dstuttard, yaxunl, kzhuravl.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.
Herald added a subscriber: wdng.

The previous patches added the necessary support for global constructors
used to register tests. This patch enables the AMDGPU target to build
and run the unit tests on the GPU. Currently this only tests the `ctype`
tests, but adding more should be straightforward from here on.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149517

Files:
  libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
  libc/cmake/modules/LLVMLibCTestRules.cmake
  libc/test/CMakeLists.txt
  libc/test/src/CMakeLists.txt


Index: libc/test/src/CMakeLists.txt
===================================================================
--- libc/test/src/CMakeLists.txt
+++ libc/test/src/CMakeLists.txt
@@ -7,6 +7,11 @@
     ${ARGN}
   )
 
+  # Math tests and MPFR are not supported on the GPU so we simply exit.
+  if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+    return()
+  endif()
+
   if(MATH_UNITTEST_NEED_MPFR)
     if(NOT LIBC_TESTS_CAN_USE_MPFR)
       message("WARNING: Math test ${name} will be skipped as MPFR library is not available.")
Index: libc/test/CMakeLists.txt
===================================================================
--- libc/test/CMakeLists.txt
+++ libc/test/CMakeLists.txt
@@ -22,7 +22,7 @@
   return()
 endif()
 
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
+if(NOT LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
   add_subdirectory(src)
   add_subdirectory(utils)
 endif()
Index: libc/cmake/modules/LLVMLibCTestRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCTestRules.cmake
+++ libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -71,7 +71,7 @@
 #      LINK_LIBRARIES <list of linking libraries for this target>
 #    )
 function(create_libc_unittest fq_target_name)
-  if(NOT LLVM_INCLUDE_TESTS)
+  if(NOT LLVM_INCLUDE_TESTS OR NOT LIBC_ENABLE_UNITTESTS)
     return()
   endif()
 
Index: libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
+++ libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
@@ -5,10 +5,6 @@
 # Initialize ALL_CPU_FEATURES as empty list.
 set(ALL_CPU_FEATURES "")
 
-if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
-  return()
-endif()
-
 if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
   set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX AVX2 AVX512F AVX512BW FMA)
   set(LIBC_COMPILE_OPTIONS_NATIVE -march=native)
@@ -48,6 +44,10 @@
   set(${output_var} ${tmp} PARENT_SCOPE)
 endfunction()
 
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  return()
+endif()
+
 set(AVAILABLE_CPU_FEATURES "")
 if(LIBC_CROSSBUILD)
   # If we are doing a cross build, we will just assume that all CPU features


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149517.518164.patch
Type: text/x-patch
Size: 2135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230429/822ab62f/attachment-0001.bin>


More information about the libc-commits mailing list