diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/ISPC/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/ISPC/Defines/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/ISPC/Defines/main.cxx | 15 | ||||
-rw-r--r-- | Tests/ISPC/Defines/simple.ispc | 15 | ||||
-rw-r--r-- | Tests/ISPC/ObjectLibrary/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/ISPC/ObjectLibrary/main.cxx | 15 | ||||
-rw-r--r-- | Tests/ISPC/ObjectLibrary/simple.ispc | 12 | ||||
-rw-r--r-- | Tests/ISPC/ResponseAndDefine/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/ISPC/ResponseAndDefine/main.cxx | 15 | ||||
-rw-r--r-- | Tests/ISPC/ResponseAndDefine/simple.ispc | 16 | ||||
-rw-r--r-- | Tests/ISPC/StaticLibrary/CMakeLists.txt | 12 | ||||
-rw-r--r-- | Tests/ISPC/StaticLibrary/main.cxx | 15 | ||||
-rw-r--r-- | Tests/ISPC/StaticLibrary/simple.ispc | 12 | ||||
-rw-r--r-- | Tests/ISPC/TryCompile/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/ISPC/TryCompile/main.cxx | 19 | ||||
-rw-r--r-- | Tests/ISPC/TryCompile/simple.ispc | 12 |
17 files changed, 241 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4a774dd..0daf4ae 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1479,6 +1479,10 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_subdirectory(CudaOnly) endif() + if(CMake_TEST_ISPC) + add_subdirectory(ISPC) + endif() + if(CMake_TEST_FindGTest) add_subdirectory(FindGTest) add_subdirectory(GoogleTest) diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt new file mode 100644 index 0000000..c8d58fd --- /dev/null +++ b/Tests/ISPC/CMakeLists.txt @@ -0,0 +1,14 @@ + + +macro (add_ispc_test_macro name) + add_test_macro("${name}" ${ARGN}) + set_property(TEST "${name}" APPEND + PROPERTY LABELS "ISPC") +endmacro () + +# set (ISPC_IA_TARGETS "sse2-i32x4,sse4-i32x4,avx1-i32x8,avx2-i32x8,avx512knl-i32x16,avx512skx-i32x16") + +add_ispc_test_macro(ISPC.Defines ISPCDefines) +add_ispc_test_macro(ISPC.ObjectLibrary ISPCObjectLibrary) +add_ispc_test_macro(ISPC.StaticLibrary ISPCStaticLibrary) +add_ispc_test_macro(ISPC.TryCompile ISPCTryCompile) diff --git a/Tests/ISPC/Defines/CMakeLists.txt b/Tests/ISPC/Defines/CMakeLists.txt new file mode 100644 index 0000000..2c9f4c3 --- /dev/null +++ b/Tests/ISPC/Defines/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.18) +project(ISPCDefines CXX ISPC) + +set(CMAKE_ISPC_FLAGS -DM_PI=3.1415926535f [==[-DSTRUCT_DEFINE=struct{uniform int a]==]) + +add_executable(ISPCResponseFile + main.cxx + simple.ispc + ) +set_target_properties(ISPCResponseFile PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(ISPCResponseFile PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/Tests/ISPC/Defines/main.cxx b/Tests/ISPC/Defines/main.cxx new file mode 100644 index 0000000..a6b91a6 --- /dev/null +++ b/Tests/ISPC/Defines/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple_ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/Defines/simple.ispc b/Tests/ISPC/Defines/simple.ispc new file mode 100644 index 0000000..d8d6465 --- /dev/null +++ b/Tests/ISPC/Defines/simple.ispc @@ -0,0 +1,15 @@ + +//textual error if STRUCT_DEFINE not set +STRUCT_DEFINE;}; + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ObjectLibrary/CMakeLists.txt b/Tests/ISPC/ObjectLibrary/CMakeLists.txt new file mode 100644 index 0000000..edfbdd8 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCObjectLibrary CXX ISPC) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) + +add_library(ispc_objects OBJECT simple.ispc) + +target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4;--arch=x86-64>") +target_include_directories(ispc_objects INTERFACE "${CMAKE_CURRENT_BINARY_DIR}") +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_executable(ISPCObjectLibrary main.cxx) +target_link_libraries(ISPCObjectLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx new file mode 100644 index 0000000..a6b91a6 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple_ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ObjectLibrary/simple.ispc b/Tests/ISPC/ObjectLibrary/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ResponseAndDefine/CMakeLists.txt b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt new file mode 100644 index 0000000..0dc5320 --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt @@ -0,0 +1,24 @@ + +project(ispc_spaces_in_path) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) + +# Make sure we can handle an arg file with tricky defines including spaces in -I include +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/path with spaces/simple_include.h" +" + typedef float FLOAT_TYPE; +" +) + +add_executable(SpacesInPath main.cxx simple.ispc) +set_target_properties(SpacesInPath PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(SpacesInPath PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +target_compile_options(SpacesInPath PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4;--arch=x86-64>") + +target_compile_definitions(SpacesInPath PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:STRUCT_DEFINE=\"struct{uniform int a;varying int b;\";M_PI=3.1415926535f>") +target_include_directories(SpacesInPath PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:\"fake path with spaces\">"" + "$<$<COMPILE_LANGUAGE:ISPC>:\"path with spaces\">") diff --git a/Tests/ISPC/ResponseAndDefine/main.cxx b/Tests/ISPC/ResponseAndDefine/main.cxx new file mode 100644 index 0000000..a6b91a6 --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple_ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ResponseAndDefine/simple.ispc b/Tests/ISPC/ResponseAndDefine/simple.ispc new file mode 100644 index 0000000..3f32c37 --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/simple.ispc @@ -0,0 +1,16 @@ + +STRUCT_DEFINE}; + +#include "simple_include.h" + +export void simple(uniform FLOAT_TYPE vin[], uniform FLOAT_TYPE vout[], + uniform int count) { + foreach (index = 0 ... count) { + FLOAT_TYPE v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/StaticLibrary/CMakeLists.txt b/Tests/ISPC/StaticLibrary/CMakeLists.txt new file mode 100644 index 0000000..b057544 --- /dev/null +++ b/Tests/ISPC/StaticLibrary/CMakeLists.txt @@ -0,0 +1,12 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCStaticLibrary CXX ISPC) + +add_library(ispc_objects STATIC simple.ispc) + +target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4;--arch=x86-64>") +target_include_directories(ispc_objects INTERFACE "${CMAKE_CURRENT_BINARY_DIR}") +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_executable(ISPCStaticLibrary main.cxx) +target_link_libraries(ISPCStaticLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx new file mode 100644 index 0000000..a6b91a6 --- /dev/null +++ b/Tests/ISPC/StaticLibrary/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple_ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/StaticLibrary/simple.ispc b/Tests/ISPC/StaticLibrary/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/StaticLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/TryCompile/CMakeLists.txt b/Tests/ISPC/TryCompile/CMakeLists.txt new file mode 100644 index 0000000..742f511 --- /dev/null +++ b/Tests/ISPC/TryCompile/CMakeLists.txt @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCTryCompile ISPC CXX) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + +#Verify we can use try_compile with ISPC +try_compile(result "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/simple.ispc" + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/result.o") + +add_executable(ISPCTryCompile main.cxx ) +target_link_libraries(ISPCTryCompile "${CMAKE_CURRENT_BINARY_DIR}/result.o") diff --git a/Tests/ISPC/TryCompile/main.cxx b/Tests/ISPC/TryCompile/main.cxx new file mode 100644 index 0000000..c8d1ed6 --- /dev/null +++ b/Tests/ISPC/TryCompile/main.cxx @@ -0,0 +1,19 @@ +#include <stdio.h> + +namespace ispc { +extern "C" { +void simple(float*, float*, int); +} +} + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/TryCompile/simple.ispc b/Tests/ISPC/TryCompile/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/TryCompile/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} |