Skip to content

Commit

Permalink
[libc] Enable missing memory tests on the GPU (#68111)
Browse files Browse the repository at this point in the history
Summary:
There were a few tests that weren't enabled on the GPU. This is because
the logic caused them to be skipped as we don't use CPU featured on the
host. This also disables the logic making multiple versions of the
memory functions.
  • Loading branch information
jhuber6 authored Oct 6, 2023
1 parent 22f81b4 commit 4cb6c1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 0 additions & 4 deletions libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ list(SORT ALL_CPU_FEATURES)
# <list of cpu features>
# )
function(cpu_supports output_var features)
if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
unset(${output_var} PARENT_SCOPE)
return()
endif()
_intersection(var "${LIBC_CPU_FEATURES}" "${features}")
if("${var}" STREQUAL "${features}")
set(${output_var} TRUE PARENT_SCOPE)
Expand Down
12 changes: 12 additions & 0 deletions libc/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512BW)
add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_bcmp(bcmp)
elseif(LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_bcmp(bcmp)
else()
add_bcmp(bcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_bcmp(bcmp)
Expand Down Expand Up @@ -525,6 +527,8 @@ if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
add_bzero(bzero_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
add_bzero(bzero_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_bzero(bzero)
elseif(LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_bzero(bzero)
else()
add_bzero(bzero_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_bzero(bzero)
Expand Down Expand Up @@ -555,6 +559,8 @@ if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
add_memcmp(memcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_memcmp(memcmp)
elseif(LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_memcmp(memcmp)
else()
add_memcmp(memcmp_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_memcmp(memcmp)
Expand Down Expand Up @@ -589,6 +595,8 @@ elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
MLLVM_COMPILE_OPTIONS "-tail-merge-threshold=0")
add_memcpy(memcpy MLLVM_COMPILE_OPTIONS "-tail-merge-threshold=0")
elseif(LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_memcpy(memcpy)
else()
add_memcpy(memcpy_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_memcpy(memcpy)
Expand Down Expand Up @@ -621,6 +629,8 @@ elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
add_memmove(memmove_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
MLLVM_COMPILE_OPTIONS "-tail-merge-threshold=0")
add_memmove(memmove MLLVM_COMPILE_OPTIONS "-tail-merge-threshold=0")
elseif(LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_memmove(memmove)
else()
add_memmove(memmove_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_memmove(memmove)
Expand Down Expand Up @@ -653,6 +663,8 @@ elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
add_memset(memset_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
MLLVM_COMPILE_OPTIONS "-tail-merge-threshold=0")
add_memset(memset MLLVM_COMPILE_OPTIONS "-tail-merge-threshold=0")
elseif(LIBC_TARGET_ARCHITECTURE_IS_GPU)
add_memset(memset)
else()
add_memset(memset_opt_host COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
add_memset(memset)
Expand Down
5 changes: 4 additions & 1 deletion libc/test/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,11 @@ function(add_libc_multi_impl_test name)
get_target_property(required_cpu_features ${fq_config_name} REQUIRE_CPU_FEATURES)
cpu_supports(can_run "${required_cpu_features}")
if(can_run)
string(FIND ${fq_config_name} "." last_dot_loc REVERSE)
math(EXPR name_loc "${last_dot_loc} + 1")
string(SUBSTRING ${fq_config_name} ${name_loc} -1 target_name)
add_libc_test(
${fq_config_name}_test
${target_name}_test
SUITE
libc-string-tests
COMPILE_OPTIONS
Expand Down

0 comments on commit 4cb6c1c

Please sign in to comment.