summaryrefslogtreecommitdiffstats
path: root/Tests/ISPC/TryCompile
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-07-16 19:18:55 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-08-28 15:21:31 (GMT)
commit34cc6acc81758e29f8c88607c21ab11d8807f87c (patch)
tree38effcd493f057f6148f4d8f58262dfb27afaa24 /Tests/ISPC/TryCompile
parent419d70d49000e10c36d9615574ff03513f2edf0d (diff)
downloadCMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.zip
CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.tar.gz
CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.tar.bz2
Add ISPC compiler support to CMake
Diffstat (limited to 'Tests/ISPC/TryCompile')
-rw-r--r--Tests/ISPC/TryCompile/CMakeLists.txt16
-rw-r--r--Tests/ISPC/TryCompile/main.cxx19
-rw-r--r--Tests/ISPC/TryCompile/simple.ispc12
3 files changed, 47 insertions, 0 deletions
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;
+ }
+}