diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-07-16 19:18:55 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2020-08-28 15:21:31 (GMT) |
commit | 34cc6acc81758e29f8c88607c21ab11d8807f87c (patch) | |
tree | 38effcd493f057f6148f4d8f58262dfb27afaa24 /Tests/ISPC/ResponseAndDefine | |
parent | 419d70d49000e10c36d9615574ff03513f2edf0d (diff) | |
download | CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.zip CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.tar.gz CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.tar.bz2 |
Add ISPC compiler support to CMake
Diffstat (limited to 'Tests/ISPC/ResponseAndDefine')
-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 |
3 files changed, 55 insertions, 0 deletions
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; + } +} |