From 3a9b8ef0477a41e0146d7ab82f761fdc57f8b351 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 9 May 2023 14:05:32 -0400 Subject: Tests: Teach ISPC tests to run on macOS arm64 host --- Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt | 11 ++++++++--- Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt | 6 +++++- Tests/ISPC/Defines/CMakeLists.txt | 7 ++++++- Tests/ISPC/DynamicLibrary/CMakeLists.txt | 9 +++++++-- Tests/ISPC/ObjectGenex/CMakeLists.txt | 11 ++++++++--- Tests/ISPC/ObjectLibrary/CMakeLists.txt | 6 +++++- Tests/ISPC/ResponseAndDefine/CMakeLists.txt | 12 +++++++----- Tests/ISPC/StaticLibrary/CMakeLists.txt | 10 +++++++--- Tests/ISPC/SystemIncludes/CMakeLists.txt | 11 +++++++---- Tests/RunCMake/CMakeLists.txt | 1 + .../install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake | 6 +++++- Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake | 6 +++++- 12 files changed, 71 insertions(+), 25 deletions(-) (limited to 'Tests') diff --git a/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt b/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt index 9a255a0b82..a09f638e05 100644 --- a/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt +++ b/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt @@ -11,10 +11,15 @@ add_library(ispc_objects1 STATIC extra.ispc extra.cxx) add_library(ispc_objects2 STATIC simple.ispc) set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") - set_target_properties(ispc_objects2 PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4") + +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set_property(TARGET ispc_objects1 PROPERTY ISPC_INSTRUCTION_SETS "neon-i32x4") + set_property(TARGET ispc_objects2 PROPERTY ISPC_INSTRUCTION_SETS "neon-i32x4") +else() + set_property(TARGET ispc_objects1 PROPERTY ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") + set_property(TARGET ispc_objects2 PROPERTY ISPC_INSTRUCTION_SETS "sse2-i32x4") +endif() target_link_libraries(ispc_objects2 PRIVATE ispc_objects1) diff --git a/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt index d20f88e915..4cf5ca1cd7 100644 --- a/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt +++ b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt @@ -6,7 +6,11 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_ISPC_FLAGS "--arch=x86") endif() -set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set(CMAKE_ISPC_INSTRUCTION_SETS "neon-i32x4") +else() + set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") +endif() set(CMAKE_ISPC_HEADER_SUFFIX ".ispc.h") diff --git a/Tests/ISPC/Defines/CMakeLists.txt b/Tests/ISPC/Defines/CMakeLists.txt index 764580458e..2b99469683 100644 --- a/Tests/ISPC/Defines/CMakeLists.txt +++ b/Tests/ISPC/Defines/CMakeLists.txt @@ -1,7 +1,12 @@ cmake_minimum_required(VERSION 3.18) project(ISPCDefines CXX ISPC) -set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4;avx512knl-i32x16;avx512skx-i32x8") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set(CMAKE_ISPC_INSTRUCTION_SETS "neon-i32x4") +else() + set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4;avx512knl-i32x16;avx512skx-i32x8") +endif() + set(CMAKE_ISPC_FLAGS -DM_PI=3.1415926535f) add_compile_definitions([==[STRUCT_DEFINE=struct{uniform int a]==]) diff --git a/Tests/ISPC/DynamicLibrary/CMakeLists.txt b/Tests/ISPC/DynamicLibrary/CMakeLists.txt index 4655090314..516cdc1d8b 100644 --- a/Tests/ISPC/DynamicLibrary/CMakeLists.txt +++ b/Tests/ISPC/DynamicLibrary/CMakeLists.txt @@ -13,8 +13,13 @@ target_sources(ispc_objects2 PRIVATE simple.cxx) set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") -set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set_property(TARGET ispc_objects1 PROPERTY ISPC_INSTRUCTION_SETS "neon-i32x4") + set_property(TARGET ispc_objects2 PROPERTY ISPC_INSTRUCTION_SETS "neon-i32x4") +else() + set_property(TARGET ispc_objects1 PROPERTY ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") + set_property(TARGET ispc_objects2 PROPERTY ISPC_INSTRUCTION_SETS "sse2-i32x4") +endif() target_link_libraries(ispc_objects2 PUBLIC ispc_objects1) diff --git a/Tests/ISPC/ObjectGenex/CMakeLists.txt b/Tests/ISPC/ObjectGenex/CMakeLists.txt index bc0cbf6fca..5e64004344 100644 --- a/Tests/ISPC/ObjectGenex/CMakeLists.txt +++ b/Tests/ISPC/ObjectGenex/CMakeLists.txt @@ -1,7 +1,14 @@ cmake_minimum_required(VERSION 3.18) project(ISPCObjectGenex CXX ISPC) -set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4;avx512knl-i32x16;avx512skx-i32x8") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set(CMAKE_ISPC_INSTRUCTION_SETS "neon-i32x4") + set(numberOfTargets 1) +else() + set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4;avx512knl-i32x16;avx512skx-i32x8") + list(LENGTH CMAKE_ISPC_INSTRUCTION_SETS numberOfTargets) + math(EXPR numberOfTargets "${numberOfTargets}+1") +endif() add_library(ispc_objects OBJECT simple.ispc @@ -35,8 +42,6 @@ static std::string obj_paths = "$"; add_executable(ISPCObjectGenex main.cxx) add_dependencies(ISPCObjectGenex ispc_objects) -list(LENGTH CMAKE_ISPC_INSTRUCTION_SETS numberOfTargets) -math(EXPR numberOfTargets "${numberOfTargets}+1") target_compile_definitions(ISPCObjectGenex PRIVATE "ExpectedISPCObjects=${numberOfTargets}" "CONFIG_TYPE=gen_$>" diff --git a/Tests/ISPC/ObjectLibrary/CMakeLists.txt b/Tests/ISPC/ObjectLibrary/CMakeLists.txt index a4c81a9f51..60ce920e50 100644 --- a/Tests/ISPC/ObjectLibrary/CMakeLists.txt +++ b/Tests/ISPC/ObjectLibrary/CMakeLists.txt @@ -11,8 +11,12 @@ endif() add_library(ispc_objects OBJECT simple.ispc subdir/extra.ispc) set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(ispc_objects PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set_property(TARGET ispc_objects PROPERTY ISPC_INSTRUCTION_SETS "neon-i32x4") +else() + set_property(TARGET ispc_objects PROPERTY ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") +endif() add_executable(ISPCObjectLibrary main.cxx extra.cxx) target_link_libraries(ISPCObjectLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/ResponseAndDefine/CMakeLists.txt b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt index 7539209936..d29cb2aa80 100644 --- a/Tests/ISPC/ResponseAndDefine/CMakeLists.txt +++ b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt @@ -14,13 +14,15 @@ add_executable(ISPCResponseAndDefine main.cxx simple.ispc) set_target_properties(ISPCResponseAndDefine PROPERTIES POSITION_INDEPENDENT_CODE ON) target_include_directories(ISPCResponseAndDefine PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") -target_compile_options(ISPCResponseAndDefine PRIVATE "$<$:--target=sse2-i32x4>") -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - target_compile_options(ISPCResponseAndDefine PRIVATE "$<$:--arch=x86>") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + target_compile_options(ISPCResponseAndDefine PRIVATE "$<$:--target=neon-i32x4>") +else() + target_compile_options(ISPCResponseAndDefine PRIVATE "$<$:--target=sse2-i32x4>") + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ISPCResponseAndDefine PRIVATE "$<$:--arch=x86>") + endif() endif() - - target_compile_definitions(ISPCResponseAndDefine PRIVATE "$<$:STRUCT_DEFINE=struct{uniform int a>;M_PI=3.14159f") target_include_directories(ISPCResponseAndDefine PRIVATE diff --git a/Tests/ISPC/StaticLibrary/CMakeLists.txt b/Tests/ISPC/StaticLibrary/CMakeLists.txt index ebe59609b5..76f78e5f55 100644 --- a/Tests/ISPC/StaticLibrary/CMakeLists.txt +++ b/Tests/ISPC/StaticLibrary/CMakeLists.txt @@ -4,9 +4,13 @@ project(ISPCStaticLibrary CXX ISPC) add_library(ispc_objects STATIC simple.ispc) -target_compile_options(ispc_objects PRIVATE "$<$:--target=sse2-i32x4>") -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - target_compile_options(ispc_objects PRIVATE "$<$:--arch=x86>") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + target_compile_options(ispc_objects PRIVATE "$<$:--target=neon-i32x4>") +else() + target_compile_options(ispc_objects PRIVATE "$<$:--target=sse2-i32x4>") + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ispc_objects PRIVATE "$<$:--arch=x86>") + endif() endif() set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/Tests/ISPC/SystemIncludes/CMakeLists.txt b/Tests/ISPC/SystemIncludes/CMakeLists.txt index d94e75e8ce..3b4c28962a 100644 --- a/Tests/ISPC/SystemIncludes/CMakeLists.txt +++ b/Tests/ISPC/SystemIncludes/CMakeLists.txt @@ -7,8 +7,11 @@ set_target_properties(ISPCSystemIncludes PROPERTIES POSITION_INDEPENDENT_CODE ON set_target_properties(ISPCSystemIncludes PROPERTIES ISPC_HEADER_SUFFIX ".ispc.h") target_include_directories(ISPCSystemIncludes SYSTEM PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") - -target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--target=sse2-i32x4>") -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--arch=x86>") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--target=neon-i32x4>") +else() + target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--target=sse2-i32x4>") + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ISPCSystemIncludes PRIVATE "$<$:--arch=x86>") + endif() endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index ae7bdeb88b..cea8cff731 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -791,6 +791,7 @@ endif() add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DCMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN=${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR} -DCMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG=${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG} -DCMAKE_EXECUTABLE_FORMAT=${CMAKE_EXECUTABLE_FORMAT} -DCMake_TEST_ISPC=${CMake_TEST_ISPC} diff --git a/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake index 8750a76850..2d4ce66037 100644 --- a/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake +++ b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake @@ -1,6 +1,10 @@ set(objs obj1 obj2) -set(targets sse2 sse4 avx avx2) +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set(targets "") +else() + set(targets sse2 sse4 avx avx2) +endif() foreach(o IN LISTS objs) set(item "objs/${o}\\.ispc\\.(o|obj)") check_installed("${item}") diff --git a/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake index ad542ed828..91ed4588dd 100644 --- a/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake +++ b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake @@ -1,4 +1,8 @@ enable_language(ISPC) add_library(objs OBJECT obj1.ispc obj2.ispc) -set_target_properties(objs PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4") +if("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + set_property(TARGET objs PROPERTY ISPC_INSTRUCTION_SETS "neon-i32x4") +else() + set_property(TARGET objs PROPERTY ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4") +endif() install(FILES $ DESTINATION objs) -- cgit v1.2.1